Lines Matching refs:tsc
51 static int tps6507x_read_u8(struct tps6507x_ts *tsc, u8 reg, u8 *data) in tps6507x_read_u8() argument
53 return tsc->mfd->read_dev(tsc->mfd, reg, 1, data); in tps6507x_read_u8()
56 static int tps6507x_write_u8(struct tps6507x_ts *tsc, u8 reg, u8 data) in tps6507x_write_u8() argument
58 return tsc->mfd->write_dev(tsc->mfd, reg, 1, &data); in tps6507x_write_u8()
61 static s32 tps6507x_adc_conversion(struct tps6507x_ts *tsc, in tps6507x_adc_conversion() argument
70 ret = tps6507x_write_u8(tsc, TPS6507X_REG_TSCMODE, tsc_mode); in tps6507x_adc_conversion()
72 dev_err(tsc->dev, "TSC mode read failed\n"); in tps6507x_adc_conversion()
78 ret = tps6507x_write_u8(tsc, TPS6507X_REG_ADCONFIG, in tps6507x_adc_conversion()
81 dev_err(tsc->dev, "ADC config write failed\n"); in tps6507x_adc_conversion()
86 ret = tps6507x_read_u8(tsc, TPS6507X_REG_ADCONFIG, in tps6507x_adc_conversion()
89 dev_err(tsc->dev, "ADC config read failed\n"); in tps6507x_adc_conversion()
94 ret = tps6507x_read_u8(tsc, TPS6507X_REG_ADRESULT_2, &result); in tps6507x_adc_conversion()
96 dev_err(tsc->dev, "ADC result 2 read failed\n"); in tps6507x_adc_conversion()
102 ret = tps6507x_read_u8(tsc, TPS6507X_REG_ADRESULT_1, &result); in tps6507x_adc_conversion()
104 dev_err(tsc->dev, "ADC result 1 read failed\n"); in tps6507x_adc_conversion()
110 dev_dbg(tsc->dev, "TSC channel %d = 0x%X\n", tsc_mode, *value); in tps6507x_adc_conversion()
120 static s32 tps6507x_adc_standby(struct tps6507x_ts *tsc) in tps6507x_adc_standby() argument
126 ret = tps6507x_write_u8(tsc, TPS6507X_REG_ADCONFIG, in tps6507x_adc_standby()
131 ret = tps6507x_write_u8(tsc, TPS6507X_REG_TSCMODE, in tps6507x_adc_standby()
136 ret = tps6507x_read_u8(tsc, TPS6507X_REG_INT, &val); in tps6507x_adc_standby()
142 ret = tps6507x_read_u8(tsc, TPS6507X_REG_INT, &val); in tps6507x_adc_standby()
153 struct tps6507x_ts *tsc = poll_dev->private; in tps6507x_ts_poll() local
158 ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_PRESSURE, in tps6507x_ts_poll()
159 &tsc->tc.pressure); in tps6507x_ts_poll()
163 pendown = tsc->tc.pressure > tsc->min_pressure; in tps6507x_ts_poll()
165 if (unlikely(!pendown && tsc->pendown)) { in tps6507x_ts_poll()
166 dev_dbg(tsc->dev, "UP\n"); in tps6507x_ts_poll()
170 tsc->pendown = false; in tps6507x_ts_poll()
175 if (!tsc->pendown) { in tps6507x_ts_poll()
176 dev_dbg(tsc->dev, "DOWN\n"); in tps6507x_ts_poll()
179 dev_dbg(tsc->dev, "still down\n"); in tps6507x_ts_poll()
181 ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_X_POSITION, in tps6507x_ts_poll()
182 &tsc->tc.x); in tps6507x_ts_poll()
186 ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_Y_POSITION, in tps6507x_ts_poll()
187 &tsc->tc.y); in tps6507x_ts_poll()
191 input_report_abs(input_dev, ABS_X, tsc->tc.x); in tps6507x_ts_poll()
192 input_report_abs(input_dev, ABS_Y, tsc->tc.y); in tps6507x_ts_poll()
193 input_report_abs(input_dev, ABS_PRESSURE, tsc->tc.pressure); in tps6507x_ts_poll()
195 tsc->pendown = true; in tps6507x_ts_poll()
199 tps6507x_adc_standby(tsc); in tps6507x_ts_poll()
207 struct tps6507x_ts *tsc; in tps6507x_ts_probe() local
229 tsc = kzalloc(sizeof(struct tps6507x_ts), GFP_KERNEL); in tps6507x_ts_probe()
230 if (!tsc) { in tps6507x_ts_probe()
235 tsc->mfd = tps6507x_dev; in tps6507x_ts_probe()
236 tsc->dev = tps6507x_dev->dev; in tps6507x_ts_probe()
237 tsc->min_pressure = init_data ? in tps6507x_ts_probe()
240 snprintf(tsc->phys, sizeof(tsc->phys), in tps6507x_ts_probe()
241 "%s/input0", dev_name(tsc->dev)); in tps6507x_ts_probe()
245 dev_err(tsc->dev, "Failed to allocate polled input device.\n"); in tps6507x_ts_probe()
250 tsc->poll_dev = poll_dev; in tps6507x_ts_probe()
252 poll_dev->private = tsc; in tps6507x_ts_probe()
266 input_dev->phys = tsc->phys; in tps6507x_ts_probe()
267 input_dev->dev.parent = tsc->dev; in tps6507x_ts_probe()
275 error = tps6507x_adc_standby(tsc); in tps6507x_ts_probe()
283 platform_set_drvdata(pdev, tsc); in tps6507x_ts_probe()
290 kfree(tsc); in tps6507x_ts_probe()
296 struct tps6507x_ts *tsc = platform_get_drvdata(pdev); in tps6507x_ts_remove() local
297 struct input_polled_dev *poll_dev = tsc->poll_dev; in tps6507x_ts_remove()
302 kfree(tsc); in tps6507x_ts_remove()