14 #include <linux/module.h>
15 #include <linux/input.h>
23 #define TSI_PEN_DOWN_STATUS 0x40
27 struct input_dev *
dev;
36 static void da9052_ts_adc_toggle(
struct da9052_tsi *tsi,
bool on)
51 da9052_ts_adc_toggle(tsi,
true);
59 static void da9052_ts_read(
struct da9052_tsi *tsi)
90 x = ((x << 2) & 0x3fc) | (v & 0x3);
91 y = ((y << 2) & 0x3fc) | ((v & 0xc) >> 2);
92 z = ((z << 2) & 0x3fc) | ((v & 0x30) >> 4);
95 input_report_abs(input,
ABS_X, x);
96 input_report_abs(input,
ABS_Y, y);
101 static irqreturn_t da9052_ts_datardy_irq(
int irq,
void *data)
120 struct input_dev *input = tsi->
dev;
123 da9052_ts_adc_toggle(tsi,
false);
134 ret = da9052_reg_update(tsi->
da9052,
169 error = da9052_ts_configure_gpio(tsi->
da9052);
192 static int da9052_ts_input_open(
struct input_dev *input_dev)
194 struct da9052_tsi *tsi = input_get_drvdata(input_dev);
207 static void da9052_ts_input_close(
struct input_dev *input_dev)
209 struct da9052_tsi *tsi = input_get_drvdata(input_dev);
218 da9052_ts_adc_toggle(tsi,
false);
234 struct da9052 *da9052;
236 struct input_dev *input_dev;
247 if (irq_pendwn < 0 || irq_datardy < 0) {
248 dev_err(da9052->
dev,
"Unable to determine device interrupts\n");
253 input_dev = input_allocate_device();
254 if (!tsi || !input_dev) {
260 tsi->
dev = input_dev;
266 input_dev->id.version = 0x0101;
267 input_dev->id.vendor = 0x15B6;
268 input_dev->id.product = 0x9052;
269 input_dev->name =
"Dialog DA9052 TouchScreen Driver";
270 input_dev->dev.parent = &pdev->
dev;
271 input_dev->open = da9052_ts_input_open;
272 input_dev->close = da9052_ts_input_close;
278 input_set_abs_params(input_dev,
ABS_X, 0, 1023, 0, 0);
279 input_set_abs_params(input_dev,
ABS_Y, 0, 1023, 0, 0);
280 input_set_abs_params(input_dev,
ABS_PRESSURE, 0, 1023, 0, 0);
282 input_set_drvdata(input_dev, tsi);
288 da9052_ts_adc_toggle(tsi,
false);
291 NULL, da9052_ts_pendwn_irq,
296 "Failed to register PENDWN IRQ %d, error = %d\n",
302 NULL, da9052_ts_datardy_irq,
307 "Failed to register TSIRDY IRQ %d, error = %d\n",
309 goto err_free_pendwn_irq;
316 error = da9052_configure_tsi(tsi);
318 goto err_free_datardy_irq;
320 error = input_register_device(tsi->
dev);
322 goto err_free_datardy_irq;
324 platform_set_drvdata(pdev, tsi);
328 err_free_datardy_irq:
334 input_free_device(input_dev);
341 struct da9052_tsi *tsi = platform_get_drvdata(pdev);
348 input_unregister_device(tsi->
dev);
351 platform_set_drvdata(pdev,
NULL);
357 .probe = da9052_ts_probe,
360 .name =
"da9052-tsi",