Lines Matching full:tsc
50 static int tps6507x_read_u8(struct tps6507x_ts *tsc, u8 reg, u8 *data) in tps6507x_read_u8() argument
52 return tsc->mfd->read_dev(tsc->mfd, reg, 1, data); in tps6507x_read_u8()
55 static int tps6507x_write_u8(struct tps6507x_ts *tsc, u8 reg, u8 data) in tps6507x_write_u8() argument
57 return tsc->mfd->write_dev(tsc->mfd, reg, 1, &data); in tps6507x_write_u8()
60 static s32 tps6507x_adc_conversion(struct tps6507x_ts *tsc, in tps6507x_adc_conversion() argument
69 ret = tps6507x_write_u8(tsc, TPS6507X_REG_TSCMODE, tsc_mode); in tps6507x_adc_conversion()
71 dev_err(tsc->dev, "TSC mode read failed\n"); in tps6507x_adc_conversion()
77 ret = tps6507x_write_u8(tsc, TPS6507X_REG_ADCONFIG, in tps6507x_adc_conversion()
80 dev_err(tsc->dev, "ADC config write failed\n"); in tps6507x_adc_conversion()
85 ret = tps6507x_read_u8(tsc, TPS6507X_REG_ADCONFIG, in tps6507x_adc_conversion()
88 dev_err(tsc->dev, "ADC config read failed\n"); in tps6507x_adc_conversion()
93 ret = tps6507x_read_u8(tsc, TPS6507X_REG_ADRESULT_2, &result); in tps6507x_adc_conversion()
95 dev_err(tsc->dev, "ADC result 2 read failed\n"); in tps6507x_adc_conversion()
101 ret = tps6507x_read_u8(tsc, TPS6507X_REG_ADRESULT_1, &result); in tps6507x_adc_conversion()
103 dev_err(tsc->dev, "ADC result 1 read failed\n"); in tps6507x_adc_conversion()
109 dev_dbg(tsc->dev, "TSC channel %d = 0x%X\n", tsc_mode, *value); in tps6507x_adc_conversion()
119 static s32 tps6507x_adc_standby(struct tps6507x_ts *tsc) in tps6507x_adc_standby() argument
125 ret = tps6507x_write_u8(tsc, TPS6507X_REG_ADCONFIG, in tps6507x_adc_standby()
130 ret = tps6507x_write_u8(tsc, TPS6507X_REG_TSCMODE, in tps6507x_adc_standby()
135 ret = tps6507x_read_u8(tsc, TPS6507X_REG_INT, &val); in tps6507x_adc_standby()
141 ret = tps6507x_read_u8(tsc, TPS6507X_REG_INT, &val); in tps6507x_adc_standby()
152 struct tps6507x_ts *tsc = input_get_drvdata(input_dev); in tps6507x_ts_poll() local
156 ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_PRESSURE, in tps6507x_ts_poll()
157 &tsc->tc.pressure); in tps6507x_ts_poll()
161 pendown = tsc->tc.pressure > tsc->min_pressure; in tps6507x_ts_poll()
163 if (unlikely(!pendown && tsc->pendown)) { in tps6507x_ts_poll()
164 dev_dbg(tsc->dev, "UP\n"); in tps6507x_ts_poll()
168 tsc->pendown = false; in tps6507x_ts_poll()
173 if (!tsc->pendown) { in tps6507x_ts_poll()
174 dev_dbg(tsc->dev, "DOWN\n"); in tps6507x_ts_poll()
177 dev_dbg(tsc->dev, "still down\n"); in tps6507x_ts_poll()
179 ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_X_POSITION, in tps6507x_ts_poll()
180 &tsc->tc.x); in tps6507x_ts_poll()
184 ret = tps6507x_adc_conversion(tsc, TPS6507X_TSCMODE_Y_POSITION, in tps6507x_ts_poll()
185 &tsc->tc.y); in tps6507x_ts_poll()
189 input_report_abs(input_dev, ABS_X, tsc->tc.x); in tps6507x_ts_poll()
190 input_report_abs(input_dev, ABS_Y, tsc->tc.y); in tps6507x_ts_poll()
191 input_report_abs(input_dev, ABS_PRESSURE, tsc->tc.pressure); in tps6507x_ts_poll()
193 tsc->pendown = true; in tps6507x_ts_poll()
197 tps6507x_adc_standby(tsc); in tps6507x_ts_poll()
205 struct tps6507x_ts *tsc; in tps6507x_ts_probe() local
226 tsc = devm_kzalloc(&pdev->dev, sizeof(struct tps6507x_ts), GFP_KERNEL); in tps6507x_ts_probe()
227 if (!tsc) { in tps6507x_ts_probe()
232 tsc->mfd = tps6507x_dev; in tps6507x_ts_probe()
233 tsc->dev = tps6507x_dev->dev; in tps6507x_ts_probe()
234 tsc->min_pressure = init_data ? in tps6507x_ts_probe()
237 snprintf(tsc->phys, sizeof(tsc->phys), in tps6507x_ts_probe()
238 "%s/input0", dev_name(tsc->dev)); in tps6507x_ts_probe()
242 dev_err(tsc->dev, "Failed to allocate polled input device.\n"); in tps6507x_ts_probe()
246 tsc->input = input_dev; in tps6507x_ts_probe()
247 input_set_drvdata(input_dev, tsc); in tps6507x_ts_probe()
255 input_dev->phys = tsc->phys; in tps6507x_ts_probe()
256 input_dev->dev.parent = tsc->dev; in tps6507x_ts_probe()
264 error = tps6507x_adc_standby(tsc); in tps6507x_ts_probe()