]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
Input: atmel_mxt_ts - fix up inverted RESET handler
authorLinus Walleij <linus.walleij@linaro.org>
Tue, 10 Nov 2020 02:00:06 +0000 (18:00 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 21 Aug 2022 13:15:32 +0000 (15:15 +0200)
[ Upstream commit feedaacdadfc332e1a6e436f3adfbc67e244db47 ]

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: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Philippe Schenker <philippe.schenker@toradex.com>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/20201104153032.1387747-1-linus.walleij@linaro.org
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/arm/boot/dts/imx53-ppd.dts
arch/arm/boot/dts/imx6dl-colibri-eval-v3.dts
arch/arm/boot/dts/imx6q-apalis-eval.dts
arch/arm/boot/dts/imx6q-apalis-ixora-v1.1.dts
arch/arm/boot/dts/imx6q-apalis-ixora.dts
arch/arm/boot/dts/imx7-colibri-aster.dtsi
arch/arm/boot/dts/imx7-colibri-eval-v3.dtsi
arch/arm/boot/dts/motorola-mapphone-common.dtsi
arch/arm/boot/dts/s5pv210-aries.dtsi
arch/arm/boot/dts/tegra20-acer-a500-picasso.dts
drivers/input/touchscreen/atmel_mxt_ts.c

index 6d9a5ede94aaf820a7ebc30545b1a74475c5bc65..006fbd7f543221e0dd0c9bc4df6373f26decf19e 100644 (file)
 
        touchscreen@4b {
                compatible = "atmel,maxtouch";
-               reset-gpio = <&gpio5 19 GPIO_ACTIVE_HIGH>;
+               reset-gpio = <&gpio5 19 GPIO_ACTIVE_LOW>;
                reg = <0x4b>;
                interrupt-parent = <&gpio5>;
                interrupts = <4 IRQ_TYPE_LEVEL_LOW>;
index 65359aece950dbe3f25ee82f2b0ac596780b344a..7da74e6f46d9b57eca6a20c8445a88efdf80976f 100644 (file)
                reg = <0x4a>;
                interrupt-parent = <&gpio1>;
                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";
        };
 
index fab83abb64660eef35b0a56dfaf1f9111c56f3a6..a0683b4aeca159d8d6b790b667ab21a914fe20bc 100644 (file)
                reg = <0x4a>;
                interrupt-parent = <&gpio6>;
                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";
        };
 
index 1614b1ae501d90a979fc9420c694aa7fc28d1229..86e84781cf5d85f5853565b6ac20e619ca0b755a 100644 (file)
                reg = <0x4a>;
                interrupt-parent = <&gpio6>;
                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";
        };
 
index fa9f98dd15ac65a483af32363501c8d8880b3120..62e72773e53b39721bbcc37c67b78813c5a2b933 100644 (file)
                reg = <0x4a>;
                interrupt-parent = <&gpio6>;
                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";
        };
 
index 9fa701bec2eca11a27545af3f427346cbc16a1af..139188eb9f409c76306c7b8e690b21668ea1de05 100644 (file)
@@ -99,7 +99,7 @@
                reg = <0x4a>;
                interrupt-parent = <&gpio2>;
                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 */
index 97601375f26407293c6f496943ce9ee8fba0647b..3caf450735d7ecd02b081bdebf28990ae502eb03 100644 (file)
                reg = <0x4a>;
                interrupt-parent = <&gpio1>;
                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";
        };
 
index d5ded4f794df48c698323ff440201b2b1037c364..5f8f77cfbe59f7b1a020d3d7b2eda2accb511942 100644 (file)
                pinctrl-names = "default";
                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 */
                interrupts-extended = <&gpio6 23 IRQ_TYPE_LEVEL_LOW>,
index 9005f0a23e8f2dfa104206dc0715fb89aca8914e..984bc8dc5e4bd91992baffb14beeb09231c1c2b4 100644 (file)
                interrupts = <5 IRQ_TYPE_EDGE_FALLING>;
                pinctrl-names = "default";
                pinctrl-0 = <&ts_irq>;
-               reset-gpios = <&gpj1 3 GPIO_ACTIVE_HIGH>;
+               reset-gpios = <&gpj1 3 GPIO_ACTIVE_LOW>;
        };
 };
 
index 5dbfb83c1b06bb9f701e0b3e308ef138787af20e..ce87e1ec10dcd8b524d345123b547fbb284ed046 100644 (file)
                        interrupt-parent = <&gpio>;
                        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>;
 
                        vdda-supply = <&vdd_3v3_sys>;
                        vdd-supply  = <&vdd_3v3_sys>;
index 8df402a1ed446cd518e7e14e649f9b0596dbc08c..3c152e934cb8829453612d2666c53de3e4140536 100644 (file)
@@ -3134,8 +3134,9 @@ static int mxt_probe(struct i2c_client *client, const struct i2c_device_id *id)
        if (error)
                return error;
 
+       /* Request the RESET line as asserted so we go into reset */
        data->reset_gpio = devm_gpiod_get_optional(&client->dev,
-                                                  "reset", GPIOD_OUT_LOW);
+                                                  "reset", GPIOD_OUT_HIGH);
        if (IS_ERR(data->reset_gpio)) {
                error = PTR_ERR(data->reset_gpio);
                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)
        disable_irq(client->irq);
 
        if (data->reset_gpio) {
+               /* Wait a while and then de-assert the RESET GPIO line */
                msleep(MXT_RESET_GPIO_TIME);
-               gpiod_set_value(data->reset_gpio, 1);
+               gpiod_set_value(data->reset_gpio, 0);
                msleep(MXT_RESET_INVALID_CHG);
        }