From 8f137c6c471813f34b84ed4cdb6d24fe65171ea6 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Tue, 25 Jul 2017 14:11:34 -0700 Subject: Input: atmel_mxt_ts - add support for reset line 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 Signed-off-by: Sebastian Reichel Signed-off-by: Dmitry Torokhov (cherry picked from commit f657b00df22e231da217ca0162a75db452475e8f) Signed-off-by: Dominik Sliwa Acked-by: Marcel Ziswiler --- drivers/input/touchscreen/atmel_mxt_ts.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'drivers') diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index ef944319036a..1899cc5daab4 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -2942,6 +2943,8 @@ static const struct mxt_platform_data *mxt_parse_dt(struct i2c_client *client) if (!pdata) return ERR_PTR(-ENOMEM); + pdata->gpio_reset = of_get_named_gpio(np, "reset-gpios", 0); + if (of_find_property(np, "linux,gpio-keymap", &proplen)) { pdata->t19_num_keys = proplen / sizeof(u32); @@ -3141,6 +3144,20 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) init_completion(&data->reset_completion); init_completion(&data->crc_completion); + if (pdata->gpio_reset >= 0) { + error = devm_gpio_request_one(&client->dev, pdata->gpio_reset, + GPIOF_OUT_INIT_LOW, "atmel-mxt-ts reset"); + } else { + dev_err(&client->dev, "No reset gpio defined\n"); + return -ENOENT; + } + + + if (error) { + 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, @@ -3150,6 +3167,16 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) return error; } + data->in_bootloader = true; + msleep(MXT_RESET_TIME); + reinit_completion(&data->bl_completion); + __gpio_set_value(pdata->gpio_reset, 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); -- cgit v1.2.3