aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBastian Hecht <hechtb@gmail.com>2013-04-15 12:31:00 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2013-04-15 13:00:44 -0400
commite6a90810559cc3755a5b1629d1fd0b914462f98c (patch)
tree1c72c3dca2b9807cc94593687c49423d8beaf077
parent95b24d22135549ac8352d719a052002838bb9f80 (diff)
Input: st1232 - add reset pin handling
We add the possibility to hand over a GPIO number for the reset pin. This way we can remove existing board code that takes care of it and group this information properly in the platform data or in the device tree configuration. Signed-off-by: Bastian Hecht <hechtb+renesas@gmail.com> Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--Documentation/devicetree/bindings/input/touchscreen/sitronix-st1232.txt24
-rw-r--r--drivers/input/touchscreen/st1232.c47
-rw-r--r--include/linux/platform_data/st1232_pdata.h13
3 files changed, 80 insertions, 4 deletions
diff --git a/Documentation/devicetree/bindings/input/touchscreen/sitronix-st1232.txt b/Documentation/devicetree/bindings/input/touchscreen/sitronix-st1232.txt
new file mode 100644
index 000000000000..64ad48b824a2
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/touchscreen/sitronix-st1232.txt
@@ -0,0 +1,24 @@
1* Sitronix st1232 touchscreen controller
2
3Required properties:
4- compatible: must be "sitronix,st1232"
5- reg: I2C address of the chip
6- interrupts: interrupt to which the chip is connected
7
8Optional properties:
9- gpios: a phandle to the reset GPIO
10
11Example:
12
13 i2c@00000000 {
14 /* ... */
15
16 touchscreen@55 {
17 compatible = "sitronix,st1232";
18 reg = <0x55>;
19 interrupts = <2 0>;
20 gpios = <&gpio1 166 0>;
21 };
22
23 /* ... */
24 };
diff --git a/drivers/input/touchscreen/st1232.c b/drivers/input/touchscreen/st1232.c
index 75d8eb5ee609..1740a2496371 100644
--- a/drivers/input/touchscreen/st1232.c
+++ b/drivers/input/touchscreen/st1232.c
@@ -19,13 +19,16 @@
19 */ 19 */
20 20
21#include <linux/delay.h> 21#include <linux/delay.h>
22#include <linux/gpio.h>
22#include <linux/i2c.h> 23#include <linux/i2c.h>
23#include <linux/input.h> 24#include <linux/input.h>
24#include <linux/interrupt.h> 25#include <linux/interrupt.h>
25#include <linux/module.h> 26#include <linux/module.h>
27#include <linux/of_gpio.h>
26#include <linux/pm_qos.h> 28#include <linux/pm_qos.h>
27#include <linux/slab.h> 29#include <linux/slab.h>
28#include <linux/types.h> 30#include <linux/types.h>
31#include <linux/platform_data/st1232_pdata.h>
29 32
30#define ST1232_TS_NAME "st1232-ts" 33#define ST1232_TS_NAME "st1232-ts"
31 34
@@ -48,6 +51,7 @@ struct st1232_ts_data {
48 struct input_dev *input_dev; 51 struct input_dev *input_dev;
49 struct st1232_ts_finger finger[MAX_FINGERS]; 52 struct st1232_ts_finger finger[MAX_FINGERS];
50 struct dev_pm_qos_request low_latency_req; 53 struct dev_pm_qos_request low_latency_req;
54 int reset_gpio;
51}; 55};
52 56
53static int st1232_ts_read_data(struct st1232_ts_data *ts) 57static int st1232_ts_read_data(struct st1232_ts_data *ts)
@@ -139,10 +143,17 @@ end:
139 return IRQ_HANDLED; 143 return IRQ_HANDLED;
140} 144}
141 145
146static void st1232_ts_power(struct st1232_ts_data *ts, bool poweron)
147{
148 if (gpio_is_valid(ts->reset_gpio))
149 gpio_direction_output(ts->reset_gpio, poweron);
150}
151
142static int st1232_ts_probe(struct i2c_client *client, 152static int st1232_ts_probe(struct i2c_client *client,
143 const struct i2c_device_id *id) 153 const struct i2c_device_id *id)
144{ 154{
145 struct st1232_ts_data *ts; 155 struct st1232_ts_data *ts;
156 struct st1232_pdata *pdata = client->dev.platform_data;
146 struct input_dev *input_dev; 157 struct input_dev *input_dev;
147 int error; 158 int error;
148 159
@@ -167,6 +178,25 @@ static int st1232_ts_probe(struct i2c_client *client,
167 ts->client = client; 178 ts->client = client;
168 ts->input_dev = input_dev; 179 ts->input_dev = input_dev;
169 180
181 if (pdata)
182 ts->reset_gpio = pdata->reset_gpio;
183 else if (client->dev.of_node)
184 ts->reset_gpio = of_get_gpio(client->dev.of_node, 0);
185 else
186 ts->reset_gpio = -ENODEV;
187
188 if (gpio_is_valid(ts->reset_gpio)) {
189 error = devm_gpio_request(&client->dev, ts->reset_gpio, NULL);
190 if (error) {
191 dev_err(&client->dev,
192 "Unable to request GPIO pin %d.\n",
193 ts->reset_gpio);
194 return error;
195 }
196 }
197
198 st1232_ts_power(ts, true);
199
170 input_dev->name = "st1232-touchscreen"; 200 input_dev->name = "st1232-touchscreen";
171 input_dev->id.bustype = BUS_I2C; 201 input_dev->id.bustype = BUS_I2C;
172 input_dev->dev.parent = &client->dev; 202 input_dev->dev.parent = &client->dev;
@@ -203,7 +233,10 @@ static int st1232_ts_probe(struct i2c_client *client,
203 233
204static int st1232_ts_remove(struct i2c_client *client) 234static int st1232_ts_remove(struct i2c_client *client)
205{ 235{
236 struct st1232_ts_data *ts = i2c_get_clientdata(client);
237
206 device_init_wakeup(&client->dev, 0); 238 device_init_wakeup(&client->dev, 0);
239 st1232_ts_power(ts, false);
207 240
208 return 0; 241 return 0;
209} 242}
@@ -212,11 +245,14 @@ static int st1232_ts_remove(struct i2c_client *client)
212static int st1232_ts_suspend(struct device *dev) 245static int st1232_ts_suspend(struct device *dev)
213{ 246{
214 struct i2c_client *client = to_i2c_client(dev); 247 struct i2c_client *client = to_i2c_client(dev);
248 struct st1232_ts_data *ts = i2c_get_clientdata(client);
215 249
216 if (device_may_wakeup(&client->dev)) 250 if (device_may_wakeup(&client->dev)) {
217 enable_irq_wake(client->irq); 251 enable_irq_wake(client->irq);
218 else 252 } else {
219 disable_irq(client->irq); 253 disable_irq(client->irq);
254 st1232_ts_power(ts, false);
255 }
220 256
221 return 0; 257 return 0;
222} 258}
@@ -224,11 +260,14 @@ static int st1232_ts_suspend(struct device *dev)
224static int st1232_ts_resume(struct device *dev) 260static int st1232_ts_resume(struct device *dev)
225{ 261{
226 struct i2c_client *client = to_i2c_client(dev); 262 struct i2c_client *client = to_i2c_client(dev);
263 struct st1232_ts_data *ts = i2c_get_clientdata(client);
227 264
228 if (device_may_wakeup(&client->dev)) 265 if (device_may_wakeup(&client->dev)) {
229 disable_irq_wake(client->irq); 266 disable_irq_wake(client->irq);
230 else 267 } else {
268 st1232_ts_power(ts, true);
231 enable_irq(client->irq); 269 enable_irq(client->irq);
270 }
232 271
233 return 0; 272 return 0;
234} 273}
diff --git a/include/linux/platform_data/st1232_pdata.h b/include/linux/platform_data/st1232_pdata.h
new file mode 100644
index 000000000000..cac3e7b4c454
--- /dev/null
+++ b/include/linux/platform_data/st1232_pdata.h
@@ -0,0 +1,13 @@
1#ifndef _LINUX_ST1232_PDATA_H
2#define _LINUX_ST1232_PDATA_H
3
4/*
5 * Optional platform data
6 *
7 * Use this if you want the driver to drive the reset pin.
8 */
9struct st1232_pdata {
10 int reset_gpio;
11};
12
13#endif