diff options
author | Dominik Sliwa <dominik.sliwa@toradex.com> | 2018-03-22 13:08:22 +0100 |
---|---|---|
committer | Max Krummenacher <max.krummenacher@toradex.com> | 2018-06-21 17:36:33 +0200 |
commit | c6f9bbccf346902d77628534a7d0491cbb77c16b (patch) | |
tree | 38912e8ebb44e6ae4d035b260157fa6c69e1884a | |
parent | 52657351d56eb8b655682daa57dd2139eba71be0 (diff) |
input: atmel_mxt_ts: support reset gpio line
Signed-off-by: Dominik Sliwa <dominik.sliwa@toradex.com>
Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
(cherry picked from commit 22a2065b9a3fa6ad458e3100b66c4acaa05f2466)
-rw-r--r-- | drivers/input/touchscreen/atmel_mxt_ts.c | 23 | ||||
-rw-r--r-- | include/linux/platform_data/atmel_mxt_ts.h | 1 |
2 files changed, 24 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/atmel_mxt_ts.c b/drivers/input/touchscreen/atmel_mxt_ts.c index 88dfe3008cf4..29ba8e1c45c8 100644 --- a/drivers/input/touchscreen/atmel_mxt_ts.c +++ b/drivers/input/touchscreen/atmel_mxt_ts.c @@ -26,6 +26,7 @@ #include <linux/input/mt.h> #include <linux/interrupt.h> #include <linux/of.h> +#include <linux/of_gpio.h> #include <linux/slab.h> #include <asm/unaligned.h> @@ -2428,6 +2429,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-gpio", 0); + if (of_find_property(np, "linux,gpio-keymap", &proplen)) { pdata->t19_num_keys = proplen / sizeof(u32); @@ -2646,6 +2649,21 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) goto err_free_mem; } + if (pdata->gpio_reset >= 0) { + error = gpio_request(pdata->gpio_reset, "atmel-mxt-ts-reset"); + if (error < 0 ) { + dev_err(&client->dev, "Failure %d requesting reset " + "gpio\n", error); + goto err_free_mem; + } + error = gpio_direction_output(pdata->gpio_reset, 1); + if (error < 0 ) { + dev_err(&client->dev, "Failure %d setting reset gpio" + "direction\n", error); + goto err_free_gpio; + } + } + disable_irq(client->irq); error = mxt_initialize(data); @@ -2666,6 +2684,9 @@ err_free_object: mxt_free_object_table(data); err_free_irq: free_irq(client->irq, data); +err_free_gpio: + if (pdata->gpio_reset >= 0) + gpio_free(pdata->gpio_reset); err_free_mem: kfree(data); return error; @@ -2677,6 +2698,8 @@ static int mxt_remove(struct i2c_client *client) sysfs_remove_group(&client->dev.kobj, &mxt_attr_group); free_irq(data->irq, data); + if (data->pdata->gpio_reset >= 0) + gpio_free(data->pdata->gpio_reset); mxt_free_input_device(data); mxt_free_object_table(data); kfree(data); diff --git a/include/linux/platform_data/atmel_mxt_ts.h b/include/linux/platform_data/atmel_mxt_ts.h index 695035a8d7fb..c59fc18118aa 100644 --- a/include/linux/platform_data/atmel_mxt_ts.h +++ b/include/linux/platform_data/atmel_mxt_ts.h @@ -26,6 +26,7 @@ struct mxt_platform_data { u8 t19_num_keys; const unsigned int *t19_keymap; enum mxt_suspend_mode suspend_mode; + int gpio_reset; }; #endif /* __LINUX_PLATFORM_DATA_ATMEL_MXT_TS_H */ |