Skip to content

Commit

Permalink
Input: atmel_mxt_ts - add support for reset line
Browse files Browse the repository at this point in the history
Provide support for controlling reset pin. If this is not driven
correctly the device will be held in reset and will not respond.

Acked-by: Rob Herring <[email protected]>
Signed-off-by: Sebastian Reichel <[email protected]>
Signed-off-by: Dmitry Torokhov <[email protected]>
  • Loading branch information
sre authored and dtor committed Aug 21, 2017
1 parent 8cc8446 commit f657b00
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Documentation/devicetree/bindings/input/atmel,maxtouch.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Optional properties for main touchpad device:
experiment to determine which bit corresponds to which input. Use
KEY_RESERVED for unused padding values.

- reset-gpios: GPIO specifier for the touchscreen's reset pin (active low)

Example:

touch@4b {
Expand Down
22 changes: 22 additions & 0 deletions drivers/input/touchscreen/atmel_mxt_ts.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/interrupt.h>
#include <linux/of.h>
#include <linux/slab.h>
#include <linux/gpio/consumer.h>
#include <asm/unaligned.h>
#include <media/v4l2-device.h>
#include <media/v4l2-ioctl.h>
Expand Down Expand Up @@ -300,6 +301,7 @@ struct mxt_data {
u8 multitouch;
struct t7_config t7_cfg;
struct mxt_dbg dbg;
struct gpio_desc *reset_gpio;

/* Cached parameters from object table */
u16 T5_address;
Expand Down Expand Up @@ -3133,6 +3135,14 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
init_completion(&data->reset_completion);
init_completion(&data->crc_completion);

data->reset_gpio = devm_gpiod_get_optional(&client->dev,
"reset", GPIOD_OUT_LOW);
if (IS_ERR(data->reset_gpio)) {
error = PTR_ERR(data->reset_gpio);
dev_err(&client->dev, "Failed to get reset gpio: %d\n", error);
return error;
}

error = devm_request_threaded_irq(&client->dev, client->irq,
NULL, mxt_interrupt,
pdata->irqflags | IRQF_ONESHOT,
Expand All @@ -3142,6 +3152,18 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
return error;
}

if (data->reset_gpio) {
data->in_bootloader = true;
msleep(MXT_RESET_TIME);
reinit_completion(&data->bl_completion);
gpiod_set_value(data->reset_gpio, 1);
error = mxt_wait_for_completion(data, &data->bl_completion,
MXT_RESET_TIMEOUT);
if (error)
return error;
data->in_bootloader = false;
}

disable_irq(client->irq);

error = mxt_initialize(data);
Expand Down

0 comments on commit f657b00

Please sign in to comment.