static int msm_bahama_setup_pcm_i2s(int mode)
{
	int fm_state = 0, bt_state = 0;
	int rc = 0;
	struct marimba config = { .mod_id =  SLAVE_ID_BAHAMA};

	fm_state = marimba_get_fm_status(&config);
	bt_state = marimba_get_bt_status(&config);

	switch (mode) {
	case BT_PCM_ON:
	case BT_PCM_OFF:
		if (!fm_state)
			rc = config_pcm(mode);
		break;
	case FM_I2S_ON:
		rc = config_i2s(mode);
		break;
	case FM_I2S_OFF:
		if (bt_state)
			rc = config_pcm(BT_PCM_ON);
		else
			rc = config_i2s(mode);
		break;
	default:
		rc = -EIO;
		pr_err("%s:Unsupported mode", __func__);
	}
	return rc;
}
Exemplo n.º 2
0
//Cellon modify start, Eagle.Yin, 2012/12/27 for debug WCN2243 code
static int bt_set_gpio(int on)
{
	int rc = 0;
	struct marimba config = { .mod_id =  SLAVE_ID_BAHAMA};

	pr_debug("%s: Setting SYS_RST_PIN(%d) to %d\n",
			__func__, gpio_bt_sys_rest_en, on);
	if (on) {
		rc = gpio_tlmm_config(GPIO_CFG(gpio_bt_sys_rest_en, 0,
				GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
				GPIO_CFG_2MA),
				GPIO_CFG_ENABLE);

		gpio_set_value(gpio_bt_sys_rest_en, 1);
		rc = gpio_direction_output(gpio_bt_sys_rest_en, 1);
		msleep(100);
//Cellon modify end, Eagle.Yin, 2012/12/27 for debug WCN2243 code
	} else {
		if (!marimba_get_fm_status(&config) &&
				!marimba_get_bt_status(&config)) {
			gpio_set_value_cansleep(gpio_bt_sys_rest_en, 0);
			rc = gpio_direction_input(gpio_bt_sys_rest_en);
			msleep(100);
		}
	}
	if (rc)
		pr_err("%s: BT sys_reset_en GPIO : Error", __func__);

	return rc;
}
Exemplo n.º 3
0
static int bt_set_gpio(int on)
{
	int rc = 0;
	struct marimba config = { .mod_id =  SLAVE_ID_BAHAMA};


	pr_debug("%s: Setting SYS_RST_PIN(%d) to %d\n",
			__func__, gpio_bt_sys_rest_en, on);
	if (on) {
		#if defined(CONFIG_QCT2243_V21) && defined(CONFIG_CPLD)
		cpld_gpio_write(gpio_bt_sys_rest_en, 1);
		#else
		if (machine_is_msm7627a_evb() || machine_is_msm8625_qrd7()) {
			rc = gpio_tlmm_config(GPIO_CFG(gpio_bt_sys_rest_en, 0,
					GPIO_CFG_OUTPUT, GPIO_CFG_NO_PULL,
					GPIO_CFG_2MA),
					GPIO_CFG_ENABLE);

			gpio_set_value(gpio_bt_sys_rest_en, 1);
		} else {
			rc = gpio_direction_output(gpio_bt_sys_rest_en, 1);
		}
		#endif
		msleep(100);
	} else {

		if (!marimba_get_fm_status(&config) &&
				!marimba_get_bt_status(&config)) {
			#if defined(CONFIG_QCT2243_V21) && defined(CONFIG_CPLD)
			cpld_gpio_write(gpio_bt_sys_rest_en, 0);
			#else
			if (machine_is_msm7627a_evb() ||
					 machine_is_msm8625_qrd7()) {
				gpio_set_value(gpio_bt_sys_rest_en, 0);
				rc = gpio_tlmm_config(GPIO_CFG(
					gpio_bt_sys_rest_en, 0,
					GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN,
					GPIO_CFG_2MA),
					GPIO_CFG_ENABLE);
			} else {
				gpio_set_value_cansleep(gpio_bt_sys_rest_en, 0);
				rc = gpio_direction_input(gpio_bt_sys_rest_en);
			}
			#endif
			msleep(100);
		}
	}
	if (rc)
		pr_err("%s: BT sys_reset_en GPIO : Error", __func__);

	return rc;
}
static int bt_set_gpio(int on)
{
	int rc = 0;
	struct marimba config = { .mod_id =  SLAVE_ID_BAHAMA};
printk("%s : [dm]  on=%d gpio_bt_sys_rest_en =%d  \n",__func__,on,gpio_bt_sys_rest_en);
	if (on) {
		rc = gpio_direction_output(gpio_bt_sys_rest_en, 1);
		msleep(100);
	} else {
		if (!marimba_get_fm_status(&config) &&
				!marimba_get_bt_status(&config)) {
			gpio_set_value_cansleep(gpio_bt_sys_rest_en, 0);
			rc = gpio_direction_input(gpio_bt_sys_rest_en);
			msleep(100);
		}
	}
	if (rc)
		pr_err("%s: BT sys_reset_en GPIO : Error", __func__);

	return rc;
}
static int bt_set_gpio(int on)
{
	int rc = 0;
	struct marimba config = { .mod_id =  SLAVE_ID_BAHAMA};

	if (on) {
		rc = gpio_direction_output(BT_SYS_REST_EN, 1);
		msleep(100);
	} else {
		if (!marimba_get_fm_status(&config) &&
				!marimba_get_bt_status(&config)) {
			gpio_set_value_cansleep(BT_SYS_REST_EN, 0);
			rc = gpio_direction_input(BT_SYS_REST_EN);
			msleep(100);
		}
	}
	if (rc)
		pr_err("%s: BT sys_reset_en GPIO : Error", __func__);

	return rc;
}
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;
}
static int bt_set_gpio(int on)
{
	int rc = 0;
	struct marimba config = { .mod_id =  SLAVE_ID_BAHAMA};

#if defined (CONFIG_ARIMA_BT_DBG_INFO)
	if (on)
	{
		printk(KERN_INFO "[BT_DBG] - bt_set_gpio(), on, %d \n", on);
	}
	else
	{
		printk(KERN_INFO "[BT_DBG] - bt_set_gpio(), off, %d \n", on);
	}
#endif

	if (on) {
		if (machine_is_msm7627a_evb() || machine_is_msm8625_qrd7()) {
		//+ murphy 2011.09.19
		#if 1  //re-configure GPIO setting in case AMSS part is not executed okay
		printk(KERN_INFO "[BT_DBG] - bt_set_gpio(), on = %d, if cond exec \n", on);

		rc = gpio_tlmm_config(GPIO_CFG(gpio_bt_sys_rest_en, 0, GPIO_CFG_OUTPUT, GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA),
		                      GPIO_CFG_ENABLE);
		if (rc < 0)
		{
			printk(KERN_INFO "[BT_DBG] - GPIO 12 enable fail \n");
		}
		else
		{
			printk(KERN_INFO "[BT_DBG] - GPIO 12 enable OK \n");
		}

		gpio_set_value(gpio_bt_sys_rest_en, 1);
		#endif
		//- murphy 2011.09.19
		} else {
			rc = gpio_direction_output(gpio_bt_sys_rest_en, 1);
		}
#if defined (CONFIG_ARIMA_BT_DBG_INFO)
		printk(KERN_INFO "[BT_DBG] - bt_set_gpio(), msleep(%d) \n", 150);
#endif

		msleep(150);  //murphy 2011.11.07
	} else {

		if (!marimba_get_fm_status(&config) &&
				!marimba_get_bt_status(&config)) {
			if (machine_is_msm7627a_evb() ||
					 machine_is_msm8625_qrd7()) {
				gpio_set_value(gpio_bt_sys_rest_en, 0);
				rc = gpio_tlmm_config(GPIO_CFG(
					gpio_bt_sys_rest_en, 0,
					GPIO_CFG_INPUT, GPIO_CFG_PULL_DOWN,
					GPIO_CFG_2MA),
					GPIO_CFG_ENABLE);
			} else {
				gpio_set_value_cansleep(gpio_bt_sys_rest_en, 0);
				rc = gpio_direction_input(gpio_bt_sys_rest_en);
			}
      //+ murphy 2012.08.14
      //Fixed for BT CTS failed case - test_enableDisable
      //restore back to original sleep time to avoid unvisitable side effect at 2012.10.22
			msleep(100);
			//msleep(75);
      //- murphy 2012.08.14
		}
	}
	if (rc)
		pr_err("%s: BT sys_reset_en GPIO : Error", __func__);

	return rc;
}