aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorMarek Vasut <marex@denx.de>2019-02-07 00:55:26 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2019-02-07 01:17:46 -0500
commit201f3c803544c052aa1bab9e562e0ada4aefe03d (patch)
tree2da7a2a8795b0e78ef7e622783aa7aaac9bddbbc /drivers/input
parent63083fd582b9eb46a67fff6d4077a931d986d066 (diff)
Input: ili210x - add reset GPIO support
The touchscreen can have a reset GPIO connected to it, add support for such an arrangement. Signed-off-by: Marek Vasut <marex@denx.de> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/ili210x.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/ili210x.c b/drivers/input/touchscreen/ili210x.c
index 788f4140e302..f8b20d302384 100644
--- a/drivers/input/touchscreen/ili210x.c
+++ b/drivers/input/touchscreen/ili210x.c
@@ -6,6 +6,7 @@
6#include <linux/input/mt.h> 6#include <linux/input/mt.h>
7#include <linux/delay.h> 7#include <linux/delay.h>
8#include <linux/workqueue.h> 8#include <linux/workqueue.h>
9#include <linux/gpio/consumer.h>
9 10
10#define MAX_TOUCHES 2 11#define MAX_TOUCHES 2
11#define DEFAULT_POLL_PERIOD 20 12#define DEFAULT_POLL_PERIOD 20
@@ -45,6 +46,7 @@ struct ili210x {
45 struct input_dev *input; 46 struct input_dev *input;
46 unsigned int poll_period; 47 unsigned int poll_period;
47 struct delayed_work dwork; 48 struct delayed_work dwork;
49 struct gpio_desc *reset_gpio;
48}; 50};
49 51
50static int ili210x_read_reg(struct i2c_client *client, u8 reg, void *buf, 52static int ili210x_read_reg(struct i2c_client *client, u8 reg, void *buf,
@@ -168,11 +170,19 @@ static const struct attribute_group ili210x_attr_group = {
168 .attrs = ili210x_attributes, 170 .attrs = ili210x_attributes,
169}; 171};
170 172
173static void ili210x_power_down(void *data)
174{
175 struct gpio_desc *reset_gpio = data;
176
177 gpiod_set_value_cansleep(reset_gpio, 1);
178}
179
171static int ili210x_i2c_probe(struct i2c_client *client, 180static int ili210x_i2c_probe(struct i2c_client *client,
172 const struct i2c_device_id *id) 181 const struct i2c_device_id *id)
173{ 182{
174 struct device *dev = &client->dev; 183 struct device *dev = &client->dev;
175 struct ili210x *priv; 184 struct ili210x *priv;
185 struct gpio_desc *reset_gpio;
176 struct input_dev *input; 186 struct input_dev *input;
177 struct panel_info panel; 187 struct panel_info panel;
178 struct firmware_version firmware; 188 struct firmware_version firmware;
@@ -186,6 +196,21 @@ static int ili210x_i2c_probe(struct i2c_client *client,
186 return -EINVAL; 196 return -EINVAL;
187 } 197 }
188 198
199 reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
200 if (IS_ERR(reset_gpio))
201 return PTR_ERR(reset_gpio);
202
203 if (reset_gpio) {
204 error = devm_add_action_or_reset(dev, ili210x_power_down,
205 reset_gpio);
206 if (error)
207 return error;
208
209 usleep_range(50, 100);
210 gpiod_set_value_cansleep(reset_gpio, 0);
211 msleep(100);
212 }
213
189 /* Get firmware version */ 214 /* Get firmware version */
190 error = ili210x_read_reg(client, REG_FIRMWARE_VERSION, 215 error = ili210x_read_reg(client, REG_FIRMWARE_VERSION,
191 &firmware, sizeof(firmware)); 216 &firmware, sizeof(firmware));
@@ -218,6 +243,7 @@ static int ili210x_i2c_probe(struct i2c_client *client,
218 priv->input = input; 243 priv->input = input;
219 priv->poll_period = DEFAULT_POLL_PERIOD; 244 priv->poll_period = DEFAULT_POLL_PERIOD;
220 INIT_DELAYED_WORK(&priv->dwork, ili210x_work); 245 INIT_DELAYED_WORK(&priv->dwork, ili210x_work);
246 priv->reset_gpio = reset_gpio;
221 247
222 /* Setup input device */ 248 /* Setup input device */
223 input->name = "ILI210x Touchscreen"; 249 input->name = "ILI210x Touchscreen";