Ejemplo n.º 1
0
int mxt_get_sensor_vendor(void)
{
        int val = -1;
	struct twl6030_gpadc_request req;

	req.channels = (1 << GPADC_CHANNEL_TOUCH_VENDOR);
	req.method = TWL6032_GPADC_SW2;
	req.active = 0;
	req.func_cb = NULL;
	val = twl6030_gpadc_conversion(&req);
        if (val < 0) { /* failure */
                printk("Atmel touch sensor vendor get gpadc value failure %d\n", val);
        }
	else {
		val = req.rbuf[GPADC_CHANNEL_TOUCH_VENDOR];
                printk("Atmel touch sensor vendor get gpadc value %d\n", val);
                if (val < 515) return ATMEL_TOUCH_SENSOR_VENDOR_TPK; /* this value is for compatible with tate pre-EVT2.0 devices */
                else if (val < 550) return ATMEL_TOUCH_SENSOR_VENDOR_TPK;
                else if (val < 617) return ATMEL_TOUCH_SENSOR_VENDOR_WINTEK;
                else if (val < 678) return ATMEL_TOUCH_SENSOR_VENDOR_CMI;
                else if (val < 725) return ATMEL_TOUCH_SENSOR_VENDOR_HANNSTOUCH;
                else return -1;
        }

        return val;
}
Ejemplo n.º 2
0
int get_pcb_therm()
{
	struct twl6030_gpadc_request req;
	int ret;

	req.channels = (1 << PCB_THM_ADC_CHANNEL);
	req.method = TWL6030_GPADC_SW2;
	req.func_cb = NULL;
	ret = twl6030_gpadc_conversion(&req);

	return adc_to_temp_conversion(req.buf[PCB_THM_ADC_CHANNEL].code);
}
static int pcb_read_current_temp(struct pcb_temp_sensor *temp_sensor)
{
	int temp = 0;
	struct twl6030_gpadc_request req;
	int val;

	req.channels = (1 << TWL6030_GPADC_CHANNEL);
	req.method = TWL6030_GPADC_SW2;
	req.func_cb = NULL;
	val = twl6030_gpadc_conversion(&req);
	if (val < 0) {
		pr_err("%s:TWL6030_GPADC conversion is invalid %d\n",
			__func__, val);
		return -EINVAL;
	}
	temp = adc_to_temp_conversion(req.rbuf[TWL6030_GPADC_CHANNEL]);

	return temp;
}
Ejemplo n.º 4
0
/*
 * Return battery voltage
 * Or < 0 on failure.
 */
static int twl6030battery_voltage(void)
{
	struct twl6030_gpadc_request req;
	int temp, temp2;

	req.channels = (1 << 7) | (1 << 10);
	req.method = TWL6030_GPADC_SW1;
	req.active = 0;
	req.func_cb = NULL;
	twl6030_gpadc_conversion(&req);
	temp = (u16)req.rbuf[7] * 25/4; /* multiply by 6.25 to convert to mV */

	if (charger_source == 2)
		temp2 = (u16)req.rbuf[10];
		/* FIXME only for USB charging current*/

	return  temp;

}
Ejemplo n.º 5
0
/*
 * Return channel value
 * Or < 0 on failure.
 */
static int charger_get_gpadc_conversion(struct charger_info *di, int channel_no)
{
	struct twl6030_gpadc_request req;
	int temp = 0;
	int ret;

	req.channels = (1 << channel_no);
	req.method = TWL6030_GPADC_SW2;
	req.active = 0;
	req.func_cb = NULL;
	ret = twl6030_gpadc_conversion(&req);
	if (ret < 0)
		return ret;

	if (req.rbuf[channel_no] > 0)
		temp = req.rbuf[channel_no];

	return temp;
}