/* * Switch to Y plate resistance mode. Set MY to ground, PY to * supply. Measure current. */ static inline unsigned int ucb1x00_ts_read_yres(struct ucb1x00_ts *ts) { ucb1x00_reg_write(ts->ucb, UCB_TS_CR, UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_POW | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); return ucb1x00_adc_read(ts->ucb, 0, ts->adcsync); }
/* * Switch to pressure mode, and read pressure. We don't need to wait * here, since both plates are being driven. */ static inline unsigned int ucb1x00_ts_read_pressure(struct ucb1x00_ts *ts) { if (machine_is_collie()) { ucb1x00_io_write(ts->ucb, COLLIE_TC35143_GPIO_TBL_CHK, 0); ucb1x00_reg_write(ts->ucb, UCB_TS_CR, UCB_TS_CR_TSPX_POW | UCB_TS_CR_TSMX_POW | UCB_TS_CR_MODE_POS | UCB_TS_CR_BIAS_ENA); udelay(55); return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_AD2, ts->adcsync); } else { ucb1x00_reg_write(ts->ucb, UCB_TS_CR, UCB_TS_CR_TSMX_POW | UCB_TS_CR_TSPX_POW | UCB_TS_CR_TSMY_GND | UCB_TS_CR_TSPY_GND | UCB_TS_CR_MODE_PRES | UCB_TS_CR_BIAS_ENA); return ucb1x00_adc_read(ts->ucb, UCB_ADC_INP_TSPY, ts->adcsync); } }
int collie_read_backup_battery(void) { int voltage; ucb1x00_adc_enable(ucb); ucb1x00_io_write(ucb, COLLIE_TC35143_GPIO_BBAT_ON, 0); voltage = ucb1x00_adc_read(ucb, UCB_ADC_INP_AD1, UCB_SYNC); ucb1x00_io_write(ucb, 0, COLLIE_TC35143_GPIO_BBAT_ON); ucb1x00_adc_disable(ucb); printk("Backup battery = %d(%d)\n", ADCtoPower(voltage), voltage); return ADCtoPower(voltage); }
int collie_read_temp(void) { int voltage; /* According to Sharp, temp must be > 973, main battery must be < 465, FIXME: sharpsl_pm.c has both conditions negated? FIXME: values are way out of range? */ ucb1x00_adc_enable(ucb); ucb1x00_io_write(ucb, COLLIE_TC35143_GPIO_TMP_ON, 0); /* >1010 = battery removed, 460 = 22C ?, higer = lower temp ? */ voltage = ucb1x00_adc_read(ucb, UCB_ADC_INP_AD0, UCB_SYNC); ucb1x00_io_write(ucb, 0, COLLIE_TC35143_GPIO_TMP_ON); ucb1x00_adc_disable(ucb); printk("Battery temp = %d\n", voltage); return voltage; }
static unsigned long collie_read_bat(struct collie_bat *bat) { unsigned long value = 0; if (bat->gpio_bat < 0 || bat->adc_bat < 0) return 0; mutex_lock(&bat_lock); gpio_set_value(bat->gpio_bat, 1); msleep(5); ucb1x00_adc_enable(ucb); value = ucb1x00_adc_read(ucb, bat->adc_bat, UCB_SYNC); ucb1x00_adc_disable(ucb); gpio_set_value(bat->gpio_bat, 0); mutex_unlock(&bat_lock); value = value * 1000000 / bat->adc_bat_divider; return value; }
int collie_read_main_battery(void) { int voltage, voltage_rev, voltage_volts; ucb1x00_adc_enable(ucb); ucb1x00_io_write(ucb, 0, COLLIE_TC35143_GPIO_BBAT_ON); ucb1x00_io_write(ucb, COLLIE_TC35143_GPIO_MBAT_ON, 0); mdelay(1); voltage = ucb1x00_adc_read(ucb, UCB_ADC_INP_AD1, UCB_SYNC); ucb1x00_io_write(ucb, 0, COLLIE_TC35143_GPIO_MBAT_ON); ucb1x00_adc_disable(ucb); voltage_rev = voltage + ((ad_revise * voltage) / 652); voltage_volts = ADCtoPower(voltage_rev); printk("Main battery = %d(%d)\n", voltage_volts, voltage); if (voltage != -1) return voltage_volts; else return voltage; }