0b99d4bf9e98a12c1d7d4a27d614e09bf0e22e59
[openwrt/staging/ynezz.git] /
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
5 configured.
6
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
9 configured.
10
11 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
12 ---
13 drivers/input/touchscreen/edt-ft5x06.c | 51 +++++++++++++++++++++-----
14 1 file changed, 41 insertions(+), 10 deletions(-)
15
16 --- a/drivers/input/touchscreen/edt-ft5x06.c
17 +++ b/drivers/input/touchscreen/edt-ft5x06.c
18 @@ -69,6 +69,8 @@
19 #define EDT_RAW_DATA_RETRIES 100
20 #define EDT_RAW_DATA_DELAY 1000 /* usec */
21
22 +#define POLL_INTERVAL_MS 17 /* 17ms = 60fps */
23 +
24 enum edt_pmode {
25 EDT_PMODE_NOT_SUPPORTED,
26 EDT_PMODE_HIBERNATE,
27 @@ -126,6 +128,9 @@ struct edt_ft5x06_ts_data {
28
29 struct edt_reg_addr reg_addr;
30 enum edt_ver version;
31 +
32 + struct timer_list timer;
33 + struct work_struct work_i2c_poll;
34 };
35
36 struct edt_i2c_chip_data {
37 @@ -275,6 +280,22 @@ out:
38 return IRQ_HANDLED;
39 }
40
41 +static void edt_ft5x06_ts_irq_poll_timer(struct timer_list *t)
42 +{
43 + struct edt_ft5x06_ts_data *tsdata = from_timer(tsdata, t, timer);
44 +
45 + schedule_work(&tsdata->work_i2c_poll);
46 + mod_timer(&tsdata->timer, jiffies + msecs_to_jiffies(POLL_INTERVAL_MS));
47 +}
48 +
49 +static void edt_ft5x06_ts_work_i2c_poll(struct work_struct *work)
50 +{
51 + struct edt_ft5x06_ts_data *tsdata = container_of(work,
52 + struct edt_ft5x06_ts_data, work_i2c_poll);
53 +
54 + edt_ft5x06_ts_isr(0, tsdata);
55 +}
56 +
57 static int edt_ft5x06_register_write(struct edt_ft5x06_ts_data *tsdata,
58 u8 addr, u8 value)
59 {
60 @@ -1221,17 +1242,27 @@ static int edt_ft5x06_ts_probe(struct i2
61
62 i2c_set_clientdata(client, tsdata);
63
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;
68 -
69 - error = devm_request_threaded_irq(&client->dev, client->irq,
70 - NULL, edt_ft5x06_ts_isr, irq_flags,
71 - client->name, tsdata);
72 - if (error) {
73 - dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
74 - return error;
75 + if (client->irq) {
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;
80 +
81 + error = devm_request_threaded_irq(&client->dev, client->irq,
82 + NULL, edt_ft5x06_ts_isr,
83 + irq_flags, client->name,
84 + tsdata);
85 + if (error) {
86 + dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
87 + return error;
88 + }
89 + } else {
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);
96 }
97
98 error = devm_device_add_group(&client->dev, &edt_ft5x06_attr_group);