]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/meta-ti-glsdk.git/blob - recipes-kernel/linux/linux-ti33x-psp-3.2/3.2.28/0030-Input-eeti_ts-pass-gpio-value-instead-of-IRQ.patch
linux-ti33x-psp 3.2: update to 3.2.28 and add motorcape support
[glsdk/meta-ti-glsdk.git] / recipes-kernel / linux / linux-ti33x-psp-3.2 / 3.2.28 / 0030-Input-eeti_ts-pass-gpio-value-instead-of-IRQ.patch
1 From 2cc9ed812de17dc47de5a66405766895cc02c729 Mon Sep 17 00:00:00 2001
2 From: Arnd Bergmann <arnd@arndb.de>
3 Date: Mon, 30 Apr 2012 16:21:37 +0000
4 Subject: [PATCH 30/38] Input: eeti_ts: pass gpio value instead of IRQ
6 commit 4eef6cbfcc03b294d9d334368a851b35b496ce53 upstream.
8 The EETI touchscreen asserts its IRQ line as soon as it has data in its
9 internal buffers. The line is automatically deasserted once all data has
10 been read via I2C. Hence, the driver has to monitor the GPIO line and
11 cannot simply rely on the interrupt handler reception.
13 In the current implementation of the driver, irq_to_gpio() is used to
14 determine the GPIO number from the i2c_client's IRQ value.
16 As irq_to_gpio() is not available on all platforms, this patch changes
17 this and makes the driver ignore the passed in IRQ. Instead, a GPIO is
18 added to the platform_data struct and gpio_to_irq is used to derive the
19 IRQ from that GPIO. If this fails, bail out. The driver is only able to
20 work in environments where the touchscreen GPIO can be mapped to an
21 IRQ.
23 Without this patch, building raumfeld_defconfig results in:
25 drivers/input/touchscreen/eeti_ts.c: In function 'eeti_ts_irq_active':
26 drivers/input/touchscreen/eeti_ts.c:65:2: error: implicit declaration of function 'irq_to_gpio' [-Werror=implicit-function-declaration]
28 Signed-off-by: Daniel Mack <zonque@gmail.com>
29 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
30 Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
31 Cc: Sven Neumann <s.neumann@raumfeld.com>
32 Cc: linux-input@vger.kernel.org
33 Cc: Haojian Zhuang <haojian.zhuang@gmail.com>
34 [bwh: Backported to 3.2: raumfeld_controller_i2c_board_info.irq was
35  initialised using gpio_to_irq(), but this doesn't seem to matter]
36 Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
37 ---
38  arch/arm/mach-pxa/raumfeld.c        |    2 +-
39  drivers/input/touchscreen/eeti_ts.c |   21 +++++++++++++--------
40  include/linux/input/eeti_ts.h       |    1 +
41  3 files changed, 15 insertions(+), 9 deletions(-)
43 diff --git a/arch/arm/mach-pxa/raumfeld.c b/arch/arm/mach-pxa/raumfeld.c
44 index f0c05f4..ae7786d 100644
45 --- a/arch/arm/mach-pxa/raumfeld.c
46 +++ b/arch/arm/mach-pxa/raumfeld.c
47 @@ -951,12 +951,12 @@ static struct i2c_board_info raumfeld_connector_i2c_board_info __initdata = {
48  
49  static struct eeti_ts_platform_data eeti_ts_pdata = {
50         .irq_active_high = 1,
51 +       .irq_gpio = GPIO_TOUCH_IRQ,
52  };
53  
54  static struct i2c_board_info raumfeld_controller_i2c_board_info __initdata = {
55         .type   = "eeti_ts",
56         .addr   = 0x0a,
57 -       .irq    = gpio_to_irq(GPIO_TOUCH_IRQ),
58         .platform_data = &eeti_ts_pdata,
59  };
60  
61 diff --git a/drivers/input/touchscreen/eeti_ts.c b/drivers/input/touchscreen/eeti_ts.c
62 index 7f8f538..4f938bb 100644
63 --- a/drivers/input/touchscreen/eeti_ts.c
64 +++ b/drivers/input/touchscreen/eeti_ts.c
65 @@ -48,7 +48,7 @@ struct eeti_ts_priv {
66         struct input_dev *input;
67         struct work_struct work;
68         struct mutex mutex;
69 -       int irq, irq_active_high;
70 +       int irq_gpio, irq, irq_active_high;
71  };
72  
73  #define EETI_TS_BITDEPTH       (11)
74 @@ -62,7 +62,7 @@ struct eeti_ts_priv {
75  
76  static inline int eeti_ts_irq_active(struct eeti_ts_priv *priv)
77  {
78 -       return gpio_get_value(irq_to_gpio(priv->irq)) == priv->irq_active_high;
79 +       return gpio_get_value(priv->irq_gpio) == priv->irq_active_high;
80  }
81  
82  static void eeti_ts_read(struct work_struct *work)
83 @@ -157,7 +157,7 @@ static void eeti_ts_close(struct input_dev *dev)
84  static int __devinit eeti_ts_probe(struct i2c_client *client,
85                                    const struct i2c_device_id *idp)
86  {
87 -       struct eeti_ts_platform_data *pdata;
88 +       struct eeti_ts_platform_data *pdata = client->dev.platform_data;
89         struct eeti_ts_priv *priv;
90         struct input_dev *input;
91         unsigned int irq_flags;
92 @@ -199,9 +199,12 @@ static int __devinit eeti_ts_probe(struct i2c_client *client,
93  
94         priv->client = client;
95         priv->input = input;
96 -       priv->irq = client->irq;
97 +       priv->irq_gpio = pdata->irq_gpio;
98 +       priv->irq = gpio_to_irq(pdata->irq_gpio);
99  
100 -       pdata = client->dev.platform_data;
101 +       err = gpio_request_one(pdata->irq_gpio, GPIOF_IN, client->name);
102 +       if (err < 0)
103 +               goto err1;
104  
105         if (pdata)
106                 priv->irq_active_high = pdata->irq_active_high;
107 @@ -215,13 +218,13 @@ static int __devinit eeti_ts_probe(struct i2c_client *client,
108  
109         err = input_register_device(input);
110         if (err)
111 -               goto err1;
112 +               goto err2;
113  
114         err = request_irq(priv->irq, eeti_ts_isr, irq_flags,
115                           client->name, priv);
116         if (err) {
117                 dev_err(&client->dev, "Unable to request touchscreen IRQ.\n");
118 -               goto err2;
119 +               goto err3;
120         }
121  
122         /*
123 @@ -233,9 +236,11 @@ static int __devinit eeti_ts_probe(struct i2c_client *client,
124         device_init_wakeup(&client->dev, 0);
125         return 0;
126  
127 -err2:
128 +err3:
129         input_unregister_device(input);
130         input = NULL; /* so we dont try to free it below */
131 +err2:
132 +       gpio_free(pdata->irq_gpio);
133  err1:
134         input_free_device(input);
135         kfree(priv);
136 diff --git a/include/linux/input/eeti_ts.h b/include/linux/input/eeti_ts.h
137 index f875b31..16625d7 100644
138 --- a/include/linux/input/eeti_ts.h
139 +++ b/include/linux/input/eeti_ts.h
140 @@ -2,6 +2,7 @@
141  #define LINUX_INPUT_EETI_TS_H
142  
143  struct eeti_ts_platform_data {
144 +       int irq_gpio;
145         unsigned int irq_active_high;
146  };
147  
148 -- 
149 1.7.7.6