summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Reichel <sebastian.reichel@collabora.co.uk>2017-07-25 14:11:34 -0700
committerMarcel Ziswiler <marcel.ziswiler@toradex.com>2018-11-29 10:32:09 +0100
commit8f137c6c471813f34b84ed4cdb6d24fe65171ea6 (patch)
tree3dee7f36eea8244a75cfc12c951ca00786a237c5
parent646f667f8ed09b18cedb14f043d542dbba99ec74 (diff)
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 <robh@kernel.org> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> (cherry picked from commit f657b00df22e231da217ca0162a75db452475e8f) Signed-off-by: Dominik Sliwa <dominik.sliwa@toradex.com> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
-rw-r--r--Documentation/devicetree/bindings/input/atmel,maxtouch.txt34
-rw-r--r--drivers/input/touchscreen/atmel_mxt_ts.c27
-rw-r--r--include/linux/platform_data/atmel_mxt_ts.h1
3 files changed, 62 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/input/atmel,maxtouch.txt b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt
new file mode 100644
index 000000000000..23e3abc3fdef
--- /dev/null
+++ b/Documentation/devicetree/bindings/input/atmel,maxtouch.txt
@@ -0,0 +1,34 @@
+Atmel maXTouch touchscreen/touchpad
+
+Required properties:
+- compatible:
+ atmel,maxtouch
+
+- reg: The I2C address of the device
+
+- interrupts: The sink for the touchpad's IRQ output
+ See ../interrupt-controller/interrupts.txt
+
+Optional properties for main touchpad device:
+
+- linux,gpio-keymap: When enabled, the SPT_GPIOPWN_T19 object sends messages
+ on GPIO bit changes. An array of up to 8 entries can be provided
+ indicating the Linux keycode mapped to each bit of the status byte,
+ starting at the LSB. Linux keycodes are defined in
+ <dt-bindings/input/input.h>.
+
+ Note: the numbering of the GPIOs and the bit they start at varies between
+ maXTouch devices. You must either refer to the documentation, or
+ 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 {
+ compatible = "atmel,maxtouch";
+ reg = <0x4b>;
+ interrupt-parent = <&gpio>;
+ interrupts = <TEGRA_GPIO(W, 3) IRQ_TYPE_LEVEL_LOW>;
+ };
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 <linux/delay.h>
#include <linux/firmware.h>
#include <linux/i2c.h>
+#include <linux/of_gpio.h>
#include <linux/platform_data/atmel_mxt_ts.h>
#include <linux/input/mt.h>
#include <linux/interrupt.h>
@@ -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);
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 */