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>
This commit is contained in:
parent
63083fd582
commit
201f3c8035
@ -6,6 +6,7 @@
|
|||||||
#include <linux/input/mt.h>
|
#include <linux/input/mt.h>
|
||||||
#include <linux/delay.h>
|
#include <linux/delay.h>
|
||||||
#include <linux/workqueue.h>
|
#include <linux/workqueue.h>
|
||||||
|
#include <linux/gpio/consumer.h>
|
||||||
|
|
||||||
#define MAX_TOUCHES 2
|
#define MAX_TOUCHES 2
|
||||||
#define DEFAULT_POLL_PERIOD 20
|
#define DEFAULT_POLL_PERIOD 20
|
||||||
@ -45,6 +46,7 @@ struct ili210x {
|
|||||||
struct input_dev *input;
|
struct input_dev *input;
|
||||||
unsigned int poll_period;
|
unsigned int poll_period;
|
||||||
struct delayed_work dwork;
|
struct delayed_work dwork;
|
||||||
|
struct gpio_desc *reset_gpio;
|
||||||
};
|
};
|
||||||
|
|
||||||
static int ili210x_read_reg(struct i2c_client *client, u8 reg, void *buf,
|
static int ili210x_read_reg(struct i2c_client *client, u8 reg, void *buf,
|
||||||
@ -168,11 +170,19 @@ static const struct attribute_group ili210x_attr_group = {
|
|||||||
.attrs = ili210x_attributes,
|
.attrs = ili210x_attributes,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void ili210x_power_down(void *data)
|
||||||
|
{
|
||||||
|
struct gpio_desc *reset_gpio = data;
|
||||||
|
|
||||||
|
gpiod_set_value_cansleep(reset_gpio, 1);
|
||||||
|
}
|
||||||
|
|
||||||
static int ili210x_i2c_probe(struct i2c_client *client,
|
static int ili210x_i2c_probe(struct i2c_client *client,
|
||||||
const struct i2c_device_id *id)
|
const struct i2c_device_id *id)
|
||||||
{
|
{
|
||||||
struct device *dev = &client->dev;
|
struct device *dev = &client->dev;
|
||||||
struct ili210x *priv;
|
struct ili210x *priv;
|
||||||
|
struct gpio_desc *reset_gpio;
|
||||||
struct input_dev *input;
|
struct input_dev *input;
|
||||||
struct panel_info panel;
|
struct panel_info panel;
|
||||||
struct firmware_version firmware;
|
struct firmware_version firmware;
|
||||||
@ -186,6 +196,21 @@ static int ili210x_i2c_probe(struct i2c_client *client,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
|
||||||
|
if (IS_ERR(reset_gpio))
|
||||||
|
return PTR_ERR(reset_gpio);
|
||||||
|
|
||||||
|
if (reset_gpio) {
|
||||||
|
error = devm_add_action_or_reset(dev, ili210x_power_down,
|
||||||
|
reset_gpio);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
|
|
||||||
|
usleep_range(50, 100);
|
||||||
|
gpiod_set_value_cansleep(reset_gpio, 0);
|
||||||
|
msleep(100);
|
||||||
|
}
|
||||||
|
|
||||||
/* Get firmware version */
|
/* Get firmware version */
|
||||||
error = ili210x_read_reg(client, REG_FIRMWARE_VERSION,
|
error = ili210x_read_reg(client, REG_FIRMWARE_VERSION,
|
||||||
&firmware, sizeof(firmware));
|
&firmware, sizeof(firmware));
|
||||||
@ -218,6 +243,7 @@ static int ili210x_i2c_probe(struct i2c_client *client,
|
|||||||
priv->input = input;
|
priv->input = input;
|
||||||
priv->poll_period = DEFAULT_POLL_PERIOD;
|
priv->poll_period = DEFAULT_POLL_PERIOD;
|
||||||
INIT_DELAYED_WORK(&priv->dwork, ili210x_work);
|
INIT_DELAYED_WORK(&priv->dwork, ili210x_work);
|
||||||
|
priv->reset_gpio = reset_gpio;
|
||||||
|
|
||||||
/* Setup input device */
|
/* Setup input device */
|
||||||
input->name = "ILI210x Touchscreen";
|
input->name = "ILI210x Touchscreen";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user