/** * marimba_read_bahama_ver - Reads Bahama version. * @param marimba: marimba structure pointer passed by client * @returns result of the operation. */ int marimba_read_bahama_ver(struct marimba *marimba) { int rc; u8 bahama_version; rc = marimba_read_bit_mask(marimba, 0x00, &bahama_version, 1, 0x1F); if (rc < 0) return rc; switch (bahama_version) { case 0x08: /* varient of bahama v1 */ case 0x10: case 0x00: return BAHAMA_VER_1_0; case 0x09: /* variant of bahama v2 */ return BAHAMA_VER_2_0; default: return BAHAMA_VER_UNSUPPORTED; } }
/** * marimba_read_bahama_ver - Reads Bahama version. * @param marimba: marimba structure pointer passed by client * @returns result of the operation. */ int marimba_read_bahama_ver(struct marimba *marimba) { int rc; u8 bahama_version; rc = marimba_read_bit_mask(marimba, 0x00, &bahama_version, 1, 0x1F); if (rc < 0) return rc; pr_debug("%s: Bahama version: 0x%x\n", __func__, bahama_version); switch (bahama_version) { case 0x08: /* varient of bahama v1 */ case 0x10: case 0x00: return BAHAMA_VER_1_0; case 0x09: /* variant of bahama v2 */ case 0x0a: /* variant of bahama v2.1 */ /* Falling through because initialization */ /* and configuration for 2.0 and 2.1 are same */ return BAHAMA_VER_2_0; default: return BAHAMA_VER_UNSUPPORTED; } }
int marimba_read_bahama_ver(struct marimba *marimba) { int rc; u8 bahama_version; rc = marimba_read_bit_mask(marimba, 0x00, &bahama_version, 1, 0x1F); if (rc < 0) return rc; pr_debug("%s: Bahama version: 0x%x\n", __func__, bahama_version); switch (bahama_version) { case 0x08: /* */ case 0x10: case 0x00: return BAHAMA_VER_1_0; case 0x09: /* */ case 0x0a: /* */ /* */ /* */ return BAHAMA_VER_2_0; default: return BAHAMA_VER_UNSUPPORTED; } }
static int bahama_bt(int on) { int rc = 0; int i; struct marimba config = { .mod_id = SLAVE_ID_BAHAMA}; struct bahama_variant_register { const size_t size; const struct bahama_config_register *set; }; const struct bahama_config_register *p; u8 version; const struct bahama_config_register v10_bt_on[] = { { 0xE9, 0x00, 0xFF }, { 0xF4, 0x80, 0xFF }, { 0xE4, 0x00, 0xFF }, { 0xE5, 0x00, 0x0F }, #ifdef CONFIG_WLAN { 0xE6, 0x38, 0x7F }, { 0xE7, 0x06, 0xFF }, #endif { 0xE9, 0x21, 0xFF }, { 0x01, 0x0C, 0x1F }, { 0x01, 0x08, 0x1F }, }; const struct bahama_config_register v20_bt_on_fm_off[] = { { 0x11, 0x0C, 0xFF }, { 0x13, 0x01, 0xFF }, { 0xF4, 0x80, 0xFF }, { 0xF0, 0x00, 0xFF }, { 0xE9, 0x00, 0xFF }, #ifdef CONFIG_WLAN { 0x81, 0x00, 0x7F }, { 0x82, 0x00, 0xFF }, { 0xE6, 0x38, 0x7F }, { 0xE7, 0x06, 0xFF }, #endif { 0x8E, 0x15, 0xFF }, { 0x8F, 0x15, 0xFF }, { 0x90, 0x15, 0xFF }, { 0xE9, 0x21, 0xFF }, }; const struct bahama_config_register v20_bt_on_fm_on[] = { { 0x11, 0x0C, 0xFF }, { 0x13, 0x01, 0xFF }, { 0xF4, 0x86, 0xFF }, { 0xF0, 0x06, 0xFF }, { 0xE9, 0x00, 0xFF }, #ifdef CONFIG_WLAN { 0x81, 0x00, 0x7F }, { 0x82, 0x00, 0xFF }, { 0xE6, 0x38, 0x7F }, { 0xE7, 0x06, 0xFF }, #endif { 0xE9, 0x21, 0xFF }, }; const struct bahama_config_register v10_bt_off[] = { { 0xE9, 0x00, 0xFF }, }; const struct bahama_config_register v20_bt_off_fm_off[] = { { 0xF4, 0x84, 0xFF }, { 0xF0, 0x04, 0xFF }, { 0xE9, 0x00, 0xFF } }; const struct bahama_config_register v20_bt_off_fm_on[] = { { 0xF4, 0x86, 0xFF }, { 0xF0, 0x06, 0xFF }, { 0xE9, 0x00, 0xFF } }; const struct bahama_variant_register bt_bahama[2][3] = { { { ARRAY_SIZE(v10_bt_off), v10_bt_off }, { ARRAY_SIZE(v20_bt_off_fm_off), v20_bt_off_fm_off }, { ARRAY_SIZE(v20_bt_off_fm_on), v20_bt_off_fm_on } }, { { ARRAY_SIZE(v10_bt_on), v10_bt_on }, { ARRAY_SIZE(v20_bt_on_fm_off), v20_bt_on_fm_off }, { ARRAY_SIZE(v20_bt_on_fm_on), v20_bt_on_fm_on } } }; u8 offset = 0; /* index into bahama configs */ on = on ? 1 : 0; version = marimba_read_bahama_ver(&config); if ((int)version < 0 || version == BAHAMA_VER_UNSUPPORTED) { dev_err(&msm_bt_power_device.dev, "%s : Bahama " "version read Error, version = %d\n", __func__, version); return -EIO; } if (version == BAHAMA_VER_2_0) { if (marimba_get_fm_status(&config)) offset = 0x01; } p = bt_bahama[on][version + offset].set; dev_info(&msm_bt_power_device.dev, "%s: found version %d\n", __func__, version); for (i = 0; i < bt_bahama[on][version + offset].size; i++) { u8 value = (p+i)->value; rc = marimba_write_bit_mask(&config, (p+i)->reg, &value, sizeof((p+i)->value), (p+i)->mask); if (rc < 0) { dev_err(&msm_bt_power_device.dev, "%s: reg %x write failed: %d\n", __func__, (p+i)->reg, rc); return rc; } dev_dbg(&msm_bt_power_device.dev, "%s: reg 0x%02x write value 0x%02x mask 0x%02x\n", __func__, (p+i)->reg, value, (p+i)->mask); value = 0; rc = marimba_read_bit_mask(&config, (p+i)->reg, &value, sizeof((p+i)->value), (p+i)->mask); if (rc < 0) dev_err(&msm_bt_power_device.dev, "%s marimba_read_bit_mask- error", __func__); dev_dbg(&msm_bt_power_device.dev, "%s: reg 0x%02x read value 0x%02x mask 0x%02x\n", __func__, (p+i)->reg, value, (p+i)->mask); } /* Update BT Status */ if (on) marimba_set_bt_status(&config, true); else marimba_set_bt_status(&config, false); return rc; }
int timpani_read(struct marimba *marimba, u8 reg, u8 *value, unsigned num_bytes) { return marimba_read_bit_mask(marimba, reg, value, num_bytes, 0xff); }