Commit feedaacd authored by Linus Walleij's avatar Linus Walleij Committed by Dmitry Torokhov

Input: atmel_mxt_ts - fix up inverted RESET handler

This driver uses GPIO descriptors to drive the touchscreen RESET line. In
the existing device trees this has in conflict with intution been flagged
as GPIO_ACTIVE_HIGH and the driver then applies the reverse action by
driving the line low (setting to 0) to enter reset state and driving the
line high (setting to 1) to get out of reset state.

The correct way to handle active low GPIO lines is to provide the
GPIO_ACTIVE_LOW in the device tree (thus properly describing the hardware)
and letting the GPIO framework invert the assertion (driving high) to a
low level and vice versa.

This is considered a bug since the device trees are incorrectly
mis-specifying the line as active high.

Fix the driver and all device trees specifying a reset line.
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Reviewed-by: default avatarPhilippe Schenker <philippe.schenker@toradex.com>
Acked-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/20201104153032.1387747-1-linus.walleij@linaro.orgSigned-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 05909cd9
...@@ -589,7 +589,7 @@ &i2c2 { ...@@ -589,7 +589,7 @@ &i2c2 {
touchscreen@4b { touchscreen@4b {
compatible = "atmel,maxtouch"; compatible = "atmel,maxtouch";
reset-gpio = <&gpio5 19 GPIO_ACTIVE_HIGH>; reset-gpio = <&gpio5 19 GPIO_ACTIVE_LOW>;
reg = <0x4b>; reg = <0x4b>;
interrupt-parent = <&gpio5>; interrupt-parent = <&gpio5>;
interrupts = <4 IRQ_TYPE_LEVEL_LOW>; interrupts = <4 IRQ_TYPE_LEVEL_LOW>;
......
...@@ -143,7 +143,7 @@ touchscreen@4a { ...@@ -143,7 +143,7 @@ touchscreen@4a {
reg = <0x4a>; reg = <0x4a>;
interrupt-parent = <&gpio1>; interrupt-parent = <&gpio1>;
interrupts = <9 IRQ_TYPE_EDGE_FALLING>; /* SODIMM 28 */ interrupts = <9 IRQ_TYPE_EDGE_FALLING>; /* SODIMM 28 */
reset-gpios = <&gpio2 10 GPIO_ACTIVE_HIGH>; /* SODIMM 30 */ reset-gpios = <&gpio2 10 GPIO_ACTIVE_LOW>; /* SODIMM 30 */
status = "disabled"; status = "disabled";
}; };
......
...@@ -140,7 +140,7 @@ touchscreen@4a { ...@@ -140,7 +140,7 @@ touchscreen@4a {
reg = <0x4a>; reg = <0x4a>;
interrupt-parent = <&gpio6>; interrupt-parent = <&gpio6>;
interrupts = <10 IRQ_TYPE_EDGE_FALLING>; interrupts = <10 IRQ_TYPE_EDGE_FALLING>;
reset-gpios = <&gpio6 9 GPIO_ACTIVE_HIGH>; /* SODIMM 13 */ reset-gpios = <&gpio6 9 GPIO_ACTIVE_LOW>; /* SODIMM 13 */
status = "disabled"; status = "disabled";
}; };
......
...@@ -145,7 +145,7 @@ touchscreen@4a { ...@@ -145,7 +145,7 @@ touchscreen@4a {
reg = <0x4a>; reg = <0x4a>;
interrupt-parent = <&gpio6>; interrupt-parent = <&gpio6>;
interrupts = <10 IRQ_TYPE_EDGE_FALLING>; interrupts = <10 IRQ_TYPE_EDGE_FALLING>;
reset-gpios = <&gpio6 9 GPIO_ACTIVE_HIGH>; /* SODIMM 13 */ reset-gpios = <&gpio6 9 GPIO_ACTIVE_LOW>; /* SODIMM 13 */
status = "disabled"; status = "disabled";
}; };
......
...@@ -144,7 +144,7 @@ touchscreen@4a { ...@@ -144,7 +144,7 @@ touchscreen@4a {
reg = <0x4a>; reg = <0x4a>;
interrupt-parent = <&gpio6>; interrupt-parent = <&gpio6>;
interrupts = <10 IRQ_TYPE_EDGE_FALLING>; interrupts = <10 IRQ_TYPE_EDGE_FALLING>;
reset-gpios = <&gpio6 9 GPIO_ACTIVE_HIGH>; /* SODIMM 13 */ reset-gpios = <&gpio6 9 GPIO_ACTIVE_LOW>; /* SODIMM 13 */
status = "disabled"; status = "disabled";
}; };
......
...@@ -99,7 +99,7 @@ touchscreen@4a { ...@@ -99,7 +99,7 @@ touchscreen@4a {
reg = <0x4a>; reg = <0x4a>;
interrupt-parent = <&gpio2>; interrupt-parent = <&gpio2>;
interrupts = <15 IRQ_TYPE_EDGE_FALLING>; /* SODIMM 107 */ interrupts = <15 IRQ_TYPE_EDGE_FALLING>; /* SODIMM 107 */
reset-gpios = <&gpio2 28 GPIO_ACTIVE_HIGH>; /* SODIMM 106 */ reset-gpios = <&gpio2 28 GPIO_ACTIVE_LOW>; /* SODIMM 106 */
}; };
/* M41T0M6 real time clock on carrier board */ /* M41T0M6 real time clock on carrier board */
......
...@@ -124,7 +124,7 @@ touchscreen@4a { ...@@ -124,7 +124,7 @@ touchscreen@4a {
reg = <0x4a>; reg = <0x4a>;
interrupt-parent = <&gpio1>; interrupt-parent = <&gpio1>;
interrupts = <9 IRQ_TYPE_EDGE_FALLING>; /* SODIMM 28 */ interrupts = <9 IRQ_TYPE_EDGE_FALLING>; /* SODIMM 28 */
reset-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>; /* SODIMM 30 */ reset-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>; /* SODIMM 30 */
status = "disabled"; status = "disabled";
}; };
......
...@@ -428,7 +428,7 @@ touchscreen@4a { ...@@ -428,7 +428,7 @@ touchscreen@4a {
pinctrl-names = "default"; pinctrl-names = "default";
pinctrl-0 = <&touchscreen_pins>; pinctrl-0 = <&touchscreen_pins>;
reset-gpios = <&gpio6 13 GPIO_ACTIVE_HIGH>; /* gpio173 */ reset-gpios = <&gpio6 13 GPIO_ACTIVE_LOW>; /* gpio173 */
/* gpio_183 with sys_nirq2 pad as wakeup */ /* gpio_183 with sys_nirq2 pad as wakeup */
interrupts-extended = <&gpio6 23 IRQ_TYPE_LEVEL_LOW>, interrupts-extended = <&gpio6 23 IRQ_TYPE_LEVEL_LOW>,
......
...@@ -620,7 +620,7 @@ touchscreen@4a { ...@@ -620,7 +620,7 @@ touchscreen@4a {
interrupts = <5 IRQ_TYPE_EDGE_FALLING>; interrupts = <5 IRQ_TYPE_EDGE_FALLING>;
pinctrl-names = "default"; pinctrl-names = "default";
pinctrl-0 = <&ts_irq>; pinctrl-0 = <&ts_irq>;
reset-gpios = <&gpj1 3 GPIO_ACTIVE_HIGH>; reset-gpios = <&gpj1 3 GPIO_ACTIVE_LOW>;
}; };
}; };
......
...@@ -436,7 +436,7 @@ touchscreen@4c { ...@@ -436,7 +436,7 @@ touchscreen@4c {
interrupt-parent = <&gpio>; interrupt-parent = <&gpio>;
interrupts = <TEGRA_GPIO(V, 6) IRQ_TYPE_LEVEL_LOW>; interrupts = <TEGRA_GPIO(V, 6) IRQ_TYPE_LEVEL_LOW>;
reset-gpios = <&gpio TEGRA_GPIO(Q, 7) GPIO_ACTIVE_HIGH>; reset-gpios = <&gpio TEGRA_GPIO(Q, 7) GPIO_ACTIVE_LOW>;
avdd-supply = <&vdd_3v3_sys>; avdd-supply = <&vdd_3v3_sys>;
vdd-supply = <&vdd_3v3_sys>; vdd-supply = <&vdd_3v3_sys>;
......
...@@ -3134,8 +3134,9 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -3134,8 +3134,9 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
if (error) if (error)
return error; return error;
/* Request the RESET line as asserted so we go into reset */
data->reset_gpio = devm_gpiod_get_optional(&client->dev, data->reset_gpio = devm_gpiod_get_optional(&client->dev,
"reset", GPIOD_OUT_LOW); "reset", GPIOD_OUT_HIGH);
if (IS_ERR(data->reset_gpio)) { if (IS_ERR(data->reset_gpio)) {
error = PTR_ERR(data->reset_gpio); error = PTR_ERR(data->reset_gpio);
dev_err(&client->dev, "Failed to get reset gpio: %d\n", error); dev_err(&client->dev, "Failed to get reset gpio: %d\n", error);
...@@ -3153,8 +3154,9 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id) ...@@ -3153,8 +3154,9 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
disable_irq(client->irq); disable_irq(client->irq);
if (data->reset_gpio) { if (data->reset_gpio) {
/* Wait a while and then de-assert the RESET GPIO line */
msleep(MXT_RESET_GPIO_TIME); msleep(MXT_RESET_GPIO_TIME);
gpiod_set_value(data->reset_gpio, 1); gpiod_set_value(data->reset_gpio, 0);
msleep(MXT_RESET_INVALID_CHG); msleep(MXT_RESET_INVALID_CHG);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment