16 #include <linux/module.h>
18 #include <linux/slab.h>
19 #include <linux/input.h>
25 #define TSC_DEFAULT_POLL_PERIOD 30
26 #define TPS_DEFAULT_MIN_PRESSURE 0x30
27 #define MAX_10BIT ((1 << 10) - 1)
29 #define TPS6507X_ADCONFIG_CONVERT_TS (TPS6507X_ADCONFIG_AD_ENABLE | \
30 TPS6507X_ADCONFIG_START_CONVERSION | \
31 TPS6507X_ADCONFIG_INPUT_REAL_TSC)
32 #define TPS6507X_ADCONFIG_POWER_DOWN_TS (TPS6507X_ADCONFIG_INPUT_REAL_TSC)
61 err = tsc->
mfd->read_dev(tsc->
mfd, reg, 1, data);
71 return tsc->
mfd->write_dev(tsc->
mfd, reg, 1, &data);
94 dev_err(tsc->
dev,
"ADC config write failed\n");
102 dev_err(tsc->
dev,
"ADC config read failed\n");
109 dev_err(tsc->
dev,
"ADC result 2 read failed\n");
117 dev_err(tsc->
dev,
"ADC result 1 read failed\n");
123 dev_dbg(tsc->
dev,
"TSC channel %d = 0x%X\n", tsc_mode, *value);
168 struct input_dev *input_dev = tsc->
input_dev;
183 input_report_key(input_dev,
BTN_TOUCH, 0);
185 input_sync(input_dev);
193 input_report_key(input_dev,
BTN_TOUCH, 1);
207 input_report_abs(input_dev,
ABS_X, tsc->
tc.x);
208 input_report_abs(input_dev,
ABS_Y, tsc->
tc.y);
210 input_sync(input_dev);
231 ret = tps6507x_adc_standby(tsc);
240 struct input_dev *input_dev;
253 "Could not find tps6507x platform data\n");
266 dev_err(tps6507x_dev->
dev,
"failed to allocate driver data\n");
271 tps6507x_dev->
ts =
tsc;
272 tsc->
mfd = tps6507x_dev;
273 tsc->
dev = tps6507x_dev->
dev;
274 input_dev = input_allocate_device();
276 dev_err(tsc->
dev,
"Failed to allocate input device.\n");
288 input_dev->name =
"TPS6507x Touchscreen";
289 input_dev->id.bustype =
BUS_I2C;
290 input_dev->dev.parent = tsc->
dev;
293 "%s/input0", dev_name(tsc->
dev));
294 input_dev->phys = tsc->
phys;
296 dev_dbg(tsc->
dev,
"device: %s\n", input_dev->phys);
298 input_set_drvdata(input_dev, tsc);
308 input_dev->id.vendor = init_data->
vendor;
309 input_dev->id.product = init_data->
product;
310 input_dev->id.version = init_data->
version;
316 error = tps6507x_adc_standby(tsc);
320 error = input_register_device(input_dev);
334 platform_set_drvdata(pdev, tps6507x_dev);
340 input_free_device(input_dev);
350 struct tps6507x_dev *tps6507x_dev = platform_get_drvdata(pdev);
352 struct input_dev *input_dev = tsc->
input_dev;
356 input_unregister_device(input_dev);
366 .name =
"tps6507x-ts",
369 .probe = tps6507x_ts_probe,