static bool sec_bat_check_cable_result_callback(
				int cable_type)
{
	struct regulator *l14;
	current_cable_type = cable_type;

	if (current_cable_type == POWER_SUPPLY_TYPE_BATTERY)
	{
#if defined(CONFIG_MACH_MELIUS_CHN_CMCC) || defined(CONFIG_MACH_MELIUS_CHN_CTC) ||  defined(CONFIG_MACH_MELIUS_CHN_OPEN) ||  defined(CONFIG_MACH_MELIUS_ZH_LTE) ||defined(CONFIG_MACH_CRATER_CHN_CTC)
		if ( msm8930_get_board_rev()>=0xA )
			sec_battery_detect_switch(0);
#endif
		pr_info("%s set ldo off\n", __func__);
		l14 = regulator_get(NULL, "8917_l14");
		if(l14 > 0)
		{
			regulator_disable(l14);
		}
	}
	else
	{
		pr_info("%s set ldo on\n", __func__);
		l14 = regulator_get(NULL, "8917_l14");
		if(l14 > 0)
		{
			regulator_enable(l14);
		}
#if defined(CONFIG_MACH_MELIUS_CHN_CMCC) || defined(CONFIG_MACH_MELIUS_CHN_CTC) ||  defined(CONFIG_MACH_MELIUS_CHN_OPEN) ||  defined(CONFIG_MACH_MELIUS_ZH_LTE) ||defined(CONFIG_MACH_CRATER_CHN_CTC)
		if ( msm8930_get_board_rev()>=0xA )
			sec_battery_detect_switch(1);
#endif
	}
	return true;
}
void __init S5000_tsp_input_init(void)
{
	int ret;
	int touch_irq_gpio;
#ifdef CONFIG_LEDS_CLASS
	rmi4_platformdata.tkey_led_vdd_on = msm_tkey_led_vdd_on;
#endif

#if defined(CONFIG_MACH_MELIUS_CHN_CTC) || defined(CONFIG_MACH_CRATER_CHN_CTC)
	rmi4_platformdata.gpio = GPIO_TOUCH_IRQ_CTC_REV00;
	bus2_i2c_devices[0].irq = MSM_GPIO_TO_INT(GPIO_TOUCH_IRQ_CTC_REV00);
	touch_irq_gpio = GPIO_TOUCH_IRQ_CTC_REV00;
#else
#if	defined(CONFIG_MACH_MELIUS_EUR_LTE) \
	|| defined(CONFIG_MACH_MELIUS_EUR_OPEN) \
	|| defined(CONFIG_MACH_MELIUS_ATT) \
	|| defined(CONFIG_MACH_MELIUS_TMO) \
	|| defined(CONFIG_MACH_MELIUS_SKT) \
	|| defined(CONFIG_MACH_MELIUS_KTT) \
	|| defined(CONFIG_MACH_MELIUS_LGT) \
	|| defined(CONFIG_MACH_MELIUS_MTR)
	if(msm8930_get_board_rev() > 6) {
		rmi4_platformdata.gpio = GPIO_TOUCH_IRQ_MAIN_REV03;
		bus2_i2c_devices[0].irq = MSM_GPIO_TO_INT(GPIO_TOUCH_IRQ_MAIN_REV03);
		touch_irq_gpio = GPIO_TOUCH_IRQ_MAIN_REV03;
	} else if(msm8930_get_board_rev() > 1) {
#elif	defined(CONFIG_MACH_MELIUS_VZW) \
	|| defined(CONFIG_MACH_MELIUS_SPR)
	if(msm8930_get_board_rev() > 0) {
		rmi4_platformdata.gpio = GPIO_TOUCH_IRQ_MAIN_REV03;
		bus2_i2c_devices[0].irq = MSM_GPIO_TO_INT(GPIO_TOUCH_IRQ_MAIN_REV03);
		touch_irq_gpio = GPIO_TOUCH_IRQ_MAIN_REV03;
	} else {
#elif	defined(CONFIG_MACH_MELIUS_USC)
	if((msm8930_get_board_rev() > 0) && (msm8930_get_board_rev() != 5)) {
		rmi4_platformdata.gpio = GPIO_TOUCH_IRQ_MAIN_REV03;
		bus2_i2c_devices[0].irq = MSM_GPIO_TO_INT(GPIO_TOUCH_IRQ_MAIN_REV03);
		touch_irq_gpio = GPIO_TOUCH_IRQ_MAIN_REV03;
	} else {
#endif
		rmi4_platformdata.gpio = GPIO_TOUCH_IRQ_REV02;
		bus2_i2c_devices[0].irq = MSM_GPIO_TO_INT(GPIO_TOUCH_IRQ_REV02);
		touch_irq_gpio = GPIO_TOUCH_IRQ_REV02;
#if	defined(CONFIG_MACH_MELIUS_EUR_LTE) \
	|| defined(CONFIG_MACH_MELIUS_EUR_OPEN) \
	|| defined(CONFIG_MACH_MELIUS_ATT) \
	|| defined(CONFIG_MACH_MELIUS_TMO) \
	|| defined(CONFIG_MACH_MELIUS_SKT) \
	|| defined(CONFIG_MACH_MELIUS_KTT) \
	|| defined(CONFIG_MACH_MELIUS_LGT) \
	|| defined(CONFIG_MACH_MELIUS_MTR)
	} else {
		rmi4_platformdata.gpio = GPIO_TOUCH_IRQ;
		bus2_i2c_devices[0].irq = MSM_GPIO_TO_INT(GPIO_TOUCH_IRQ);
		touch_irq_gpio = GPIO_TOUCH_IRQ;
	}
#elif	defined(CONFIG_MACH_MELIUS_VZW) \
	|| defined(CONFIG_MACH_MELIUS_SPR) \
	|| defined(CONFIG_MACH_MELIUS_USC)
	}
#endif
#endif
		
	printk(KERN_DEBUG "[TSP]START %s\n", __func__);
	ret = gpio_request(touch_irq_gpio, "tsp_int");
	if (ret != 0) {
		printk(KERN_ERR"tsp int request failed, ret=%d", ret);
		goto err_int_gpio_request;
	}
	gpio_tlmm_config(GPIO_CFG(touch_irq_gpio, 0,
		GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), 1);
	gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_SDA, 1,
		GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), 1);
	gpio_tlmm_config(GPIO_CFG(GPIO_TOUCH_SCL, 1,
		GPIO_CFG_INPUT, GPIO_CFG_NO_PULL, GPIO_CFG_2MA), 1);

	i2c_register_board_info(MSM_8960_GSBI3_QUP_I2C_BUS_ID, bus2_i2c_devices,
			ARRAY_SIZE(bus2_i2c_devices));
	printk(KERN_DEBUG "[TSP]END %s\n", __func__);
	return ;

err_int_gpio_request:
	gpio_free(touch_irq_gpio);
}
static int sec_therm_get_adc_data(struct sec_therm_info *info)
{
	int rc = 0;
	int adc_max = 0;
	int adc_min = 0;
	int adc_total = 0;
	int i, adc_data;

#if defined (CONFIG_ARCH_MSM8226)

	struct qpnp_vadc_result results;

	for (i = 0; i < ADC_SAMPLING_CNT; i++) {

	rc = qpnp_vadc_read(therm_vadc_dev, P_MUX2_1_1, &results);

	if (rc) {
			pr_err("error reading AMUX %d, rc = %d\n", P_MUX2_1_1, rc);
			goto err;
	}

	adc_data = results.adc_code;
	//pr_err("########## reading P_MUX2_1_1 [rc = %d] [adc_code = %d]\n", rc, results.adc_code);
#else
	struct pm8xxx_adc_chan_result result;
#if defined (CONFIG_MACH_LT02)
	int system_rev = msm8930_get_board_rev();
#endif

	for (i = 0; i < ADC_SAMPLING_CNT; i++) {
#if defined (CONFIG_MACH_LT02)
		if (system_rev >= 2)
			rc = pm8xxx_adc_mpp_config_read(PM8XXX_AMUX_MPP_3,
						ADC_MPP_1_AMUX6, &result);
		else
			rc = pm8xxx_adc_mpp_config_read(PM8XXX_AMUX_MPP_4,
						ADC_MPP_1_AMUX6, &result);
#else
		rc = pm8xxx_adc_mpp_config_read(PM8XXX_AMUX_MPP_4,
						ADC_MPP_1_AMUX6, &result);
#endif
		if (rc) {
			pr_err("error reading mpp %d, rc = %d\n",
						PM8XXX_AMUX_MPP_4, rc);
			goto err;
		}
		adc_data = (int)result.measurement;
		pr_err("reading PM8XXX_AMUX_MPP_4 [rc = %d] [measurement = %lld]\n", rc,result.measurement);
#endif
		if (i != 0) {
			if (adc_data > adc_max)
				adc_max = adc_data;
			else if (adc_data < adc_min)
				adc_min = adc_data;
		} else {
			adc_max = adc_data;
			adc_min = adc_data;
		}

		adc_total += adc_data;
	}

	return (adc_total - adc_max - adc_min) / (ADC_SAMPLING_CNT - 2);

err:
	return rc;

}

static int convert_adc_to_temper(struct sec_therm_info *info, unsigned int adc)
{
	int low = 0;
	int high = 0;
	int mid = 0;
	int temp = 0;
	int temp2 = 0;

	if (!info->pdata->adc_table || !info->pdata->adc_arr_size) {
		/* using fake temp */
		return 300;
	}

	high = info->pdata->adc_arr_size - 1;

	if (info->pdata->adc_table[low].adc >= adc) {
		temp = info->pdata->adc_table[low].temperature;
		goto convert_adc_to_temp_goto;
	} else if (info->pdata->adc_table[high].adc <= adc) {
		temp = info->pdata->adc_table[high].temperature;
		goto convert_adc_to_temp_goto;
	}

	while (low <= high) {
		mid = (low + high) / 2;
		if (info->pdata->adc_table[mid].adc > adc) {
			high = mid - 1;
		} else if (info->pdata->adc_table[mid].adc < adc) {
			low = mid + 1;
		} else {
			temp = info->pdata->adc_table[mid].temperature;
			goto convert_adc_to_temp_goto;
		}
	}

	temp = info->pdata->adc_table[high].temperature;

	temp2 = (info->pdata->adc_table[low].temperature -
			info->pdata->adc_table[high].temperature) *
			(adc - info->pdata->adc_table[high].adc);

	temp += temp2 /
		(info->pdata->adc_table[low].adc -
			info->pdata->adc_table[high].adc);

convert_adc_to_temp_goto:

	return temp;
}