bcm27xx: switch to kernel v6.1
[openwrt/openwrt.git] / target / linux / bcm27xx / patches-5.15 / 950-0315-Input-edt-ft5x06-Poll-the-device-if-no-interrupt-is-.patch
1 From cd24e1ce67ea6e34d9ef0886858b8b5ac77bf847 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 @@ -72,6 +72,8 @@
19 #define EDT_DEFAULT_NUM_X 1024
20 #define EDT_DEFAULT_NUM_Y 1024
21
22 +#define POLL_INTERVAL_MS 17 /* 17ms = 60fps */
23 +
24 enum edt_pmode {
25 EDT_PMODE_NOT_SUPPORTED,
26 EDT_PMODE_HIBERNATE,
27 @@ -130,6 +132,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 @@ -279,6 +284,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 @@ -1234,17 +1255,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);