Lines Matching refs:tsc
51 static int tps6507x_read_u8(struct tps6507x_ts *tsc, u8 reg, u8 *data) in tps6507x_read_u8() argument
55 err = tsc->mfd->read_dev(tsc->mfd, reg, 1, data); in tps6507x_read_u8()
63 static int tps6507x_write_u8(struct tps6507x_ts *tsc, u8 reg, u8 data) in tps6507x_write_u8() argument
65 return tsc->mfd->write_dev(tsc->mfd, reg, 1, &data); in tps6507x_write_u8()
68 static s32 tps6507x_adc_conversion(struct tps6507x_ts *tsc, in tps6507x_adc_conversion() argument
77 ret = tps6507x_write_u8(tsc, TPS6507X_REG_TSCMODE, tsc_mode); in tps6507x_adc_conversion()
79 dev_err(tsc->dev, "TSC mode read failed\n"); in tps6507x_adc_conversion()
85 ret = tps6507x_write_u8(tsc, TPS6507X_REG_ADCONFIG, in tps6507x_adc_conversion()
88 dev_err(tsc->dev, "ADC config write failed\n"); in tps6507x_adc_conversion()
93 ret = tps6507x_read_u8(tsc, TPS6507X_REG_ADCONFIG, in tps6507x_adc_conversion()
96 dev_err(tsc->dev, "ADC config read failed\n"); in tps6507x_adc_conversion()
101 ret = tps6507x_read_u8(tsc, TPS6507X_REG_ADRESULT_2, &result); in tps6507x_adc_conversion()
103 dev_err(tsc->dev, "ADC result 2 read failed\n"); in tps6507x_adc_conversion()
109 ret = tps6507x_read_u8(tsc, TPS6507X_REG_ADRESULT_1, &result); in tps6507x_adc_conversion()
111 dev_err(tsc->dev, "ADC result 1 read failed\n"); in tps6507x_adc_conversion()
117 dev_dbg(tsc->dev, "TSC channel %d = 0x%X\n", tsc_mode, *value); in tps6507x_adc_conversion()
127 static s32 tps6507x_adc_standby(struct tps6507x_ts *tsc) in tps6507x_adc_standby() argument
133 ret = tps6507x_write_u8(tsc, TPS6507X_REG_ADCONFIG, in tps6507x_adc_standby()
138 ret = tps6507x_write_u8(tsc, TPS6507X_REG_TSCMODE, in tps6507x_adc_standby()
143 ret = tps6507x_read_u8(tsc, TPS6507X_REG_INT, &val); in tps6507x_adc_standby()
149 ret = tps6507x_read_u8(tsc, TPS6507X_REG_INT, &val); in tps6507x_adc_standby()
160 struct tps6507x_ts *tsc = poll_dev->private; in tps6507x_ts_poll() local
165 ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_PRESSURE, in tps6507x_ts_poll()
166 &tsc->tc.pressure); in tps6507x_ts_poll()
170 pendown = tsc->tc.pressure > tsc->min_pressure; in tps6507x_ts_poll()
172 if (unlikely(!pendown && tsc->pendown)) { in tps6507x_ts_poll()
173 dev_dbg(tsc->dev, "UP\n"); in tps6507x_ts_poll()
177 tsc->pendown = false; in tps6507x_ts_poll()
182 if (!tsc->pendown) { in tps6507x_ts_poll()
183 dev_dbg(tsc->dev, "DOWN\n"); in tps6507x_ts_poll()
186 dev_dbg(tsc->dev, "still down\n"); in tps6507x_ts_poll()
188 ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_X_POSITION, in tps6507x_ts_poll()
189 &tsc->tc.x); in tps6507x_ts_poll()
193 ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_Y_POSITION, in tps6507x_ts_poll()
194 &tsc->tc.y); in tps6507x_ts_poll()
198 input_report_abs(input_dev, ABS_X, tsc->tc.x); in tps6507x_ts_poll()
199 input_report_abs(input_dev, ABS_Y, tsc->tc.y); in tps6507x_ts_poll()
200 input_report_abs(input_dev, ABS_PRESSURE, tsc->tc.pressure); in tps6507x_ts_poll()
202 tsc->pendown = true; in tps6507x_ts_poll()
206 tps6507x_adc_standby(tsc); in tps6507x_ts_poll()
214 struct tps6507x_ts *tsc; in tps6507x_ts_probe() local
236 tsc = kzalloc(sizeof(struct tps6507x_ts), GFP_KERNEL); in tps6507x_ts_probe()
237 if (!tsc) { in tps6507x_ts_probe()
242 tsc->mfd = tps6507x_dev; in tps6507x_ts_probe()
243 tsc->dev = tps6507x_dev->dev; in tps6507x_ts_probe()
244 tsc->min_pressure = init_data ? in tps6507x_ts_probe()
247 snprintf(tsc->phys, sizeof(tsc->phys), in tps6507x_ts_probe()
248 "%s/input0", dev_name(tsc->dev)); in tps6507x_ts_probe()
252 dev_err(tsc->dev, "Failed to allocate polled input device.\n"); in tps6507x_ts_probe()
257 tsc->poll_dev = poll_dev; in tps6507x_ts_probe()
259 poll_dev->private = tsc; in tps6507x_ts_probe()
273 input_dev->phys = tsc->phys; in tps6507x_ts_probe()
274 input_dev->dev.parent = tsc->dev; in tps6507x_ts_probe()
282 error = tps6507x_adc_standby(tsc); in tps6507x_ts_probe()
290 platform_set_drvdata(pdev, tsc); in tps6507x_ts_probe()
297 kfree(tsc); in tps6507x_ts_probe()
303 struct tps6507x_ts *tsc = platform_get_drvdata(pdev); in tps6507x_ts_remove() local
304 struct input_polled_dev *poll_dev = tsc->poll_dev; in tps6507x_ts_remove()
309 kfree(tsc); in tps6507x_ts_remove()