1 From d7763e8128b7697f5521e08f097f455d20aab5be Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Fri, 6 Nov 2020 18:45:10 +0000
4 Subject: [PATCH] Input: edt-ft5x06: Poll the device if no interrupt is
7 Not all systems have the interrupt line wired up, so switch to
8 polling the touchscreen off a timer if no interrupt line is
11 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
13 drivers/input/touchscreen/edt-ft5x06.c | 51 +++++++++++++++++++++-----
14 1 file changed, 41 insertions(+), 10 deletions(-)
16 --- a/drivers/input/touchscreen/edt-ft5x06.c
17 +++ b/drivers/input/touchscreen/edt-ft5x06.c
19 #define EDT_RAW_DATA_RETRIES 100
20 #define EDT_RAW_DATA_DELAY 1000 /* usec */
22 +#define POLL_INTERVAL_MS 17 /* 17ms = 60fps */
25 EDT_PMODE_NOT_SUPPORTED,
27 @@ -126,6 +128,9 @@ struct edt_ft5x06_ts_data {
29 struct edt_reg_addr reg_addr;
32 + struct timer_list timer;
33 + struct work_struct work_i2c_poll;
36 struct edt_i2c_chip_data {
37 @@ -275,6 +280,22 @@ out:
41 +static void edt_ft5x06_ts_irq_poll_timer(struct timer_list *t)
43 + struct edt_ft5x06_ts_data *tsdata = from_timer(tsdata, t, timer);
45 + schedule_work(&tsdata->work_i2c_poll);
46 + mod_timer(&tsdata->timer, jiffies + msecs_to_jiffies(POLL_INTERVAL_MS));
49 +static void edt_ft5x06_ts_work_i2c_poll(struct work_struct *work)
51 + struct edt_ft5x06_ts_data *tsdata = container_of(work,
52 + struct edt_ft5x06_ts_data, work_i2c_poll);
54 + edt_ft5x06_ts_isr(0, tsdata);
57 static int edt_ft5x06_register_write(struct edt_ft5x06_ts_data *tsdata,
60 @@ -1221,17 +1242,27 @@ static int edt_ft5x06_ts_probe(struct i2
62 i2c_set_clientdata(client, tsdata);
64 - irq_flags = irq_get_trigger_type(client->irq);
65 - if (irq_flags == IRQF_TRIGGER_NONE)
66 - irq_flags = IRQF_TRIGGER_FALLING;
67 - irq_flags |= IRQF_ONESHOT;
69 - error = devm_request_threaded_irq(&client->dev, client->irq,
70 - NULL, edt_ft5x06_ts_isr, irq_flags,
71 - client->name, tsdata);
73 - dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
76 + irq_flags = irq_get_trigger_type(client->irq);
77 + if (irq_flags == IRQF_TRIGGER_NONE)
78 + irq_flags = IRQF_TRIGGER_FALLING;
79 + irq_flags |= IRQF_ONESHOT;
81 + error = devm_request_threaded_irq(&client->dev, client->irq,
82 + NULL, edt_ft5x06_ts_isr,
83 + irq_flags, client->name,
86 + dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
90 + INIT_WORK(&tsdata->work_i2c_poll,
91 + edt_ft5x06_ts_work_i2c_poll);
92 + timer_setup(&tsdata->timer, edt_ft5x06_ts_irq_poll_timer, 0);
93 + tsdata->timer.expires = jiffies +
94 + msecs_to_jiffies(POLL_INTERVAL_MS);
95 + add_timer(&tsdata->timer);
98 error = devm_device_add_group(&client->dev, &edt_ft5x06_attr_group);