2022-09-20 04:53:42

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 1/4] ARM: dts: imx6qdl-sabre*: fix Egalax touchscreen properties

This patch fixes interrupt trigger (should be level low as that is what the
driver is always using), the GPIO that is the interrupt source that is also
used to wake up chip by driving the line low.

The proper polarity is be needed for converting the driver to gpiod API.

Signed-off-by: Dmitry Torokhov <[email protected]>
---
arch/arm/boot/dts/imx6qdl-sabreauto.dtsi | 4 ++--
arch/arm/boot/dts/imx6qdl-sabresd.dtsi | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
index 1368a4762037..1883350d004e 100644
--- a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
@@ -451,8 +451,8 @@ touchscreen@4 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_egalax_int>;
interrupt-parent = <&gpio2>;
- interrupts = <28 IRQ_TYPE_EDGE_FALLING>;
- wakeup-gpios = <&gpio2 28 GPIO_ACTIVE_HIGH>;
+ interrupts = <28 IRQ_TYPE_LEVEL_LOW>;
+ wakeup-gpios = <&gpio2 28 GPIO_ACTIVE_LOW>;
};
};

diff --git a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
index 37482a9023fc..09f4c2fa3ad6 100644
--- a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
+++ b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
@@ -311,8 +311,8 @@ touchscreen@4 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c2_egalax_int>;
interrupt-parent = <&gpio6>;
- interrupts = <8 IRQ_TYPE_EDGE_FALLING>;
- wakeup-gpios = <&gpio6 8 GPIO_ACTIVE_HIGH>;
+ interrupts = <8 IRQ_TYPE_LEVEL_LOW>;
+ wakeup-gpios = <&gpio6 8 GPIO_ACTIVE_LOW>;
};

ov5640: camera@3c {
@@ -450,8 +450,8 @@ egalax_ts@4 {
compatible = "eeti,egalax_ts";
reg = <0x04>;
interrupt-parent = <&gpio6>;
- interrupts = <7 2>;
- wakeup-gpios = <&gpio6 7 0>;
+ interrupts = <7 IRQ_TYPE_LEVEL_LOW>;
+ wakeup-gpios = <&gpio6 7 GPIO_ACTIVE_LOW>;
};

magnetometer@e {
--
2.37.3.968.ga6b4b080e4-goog


2022-09-20 04:55:06

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 3/4] Input: egalax_ts - switch to using gpiod API

This updates the driver to gpiod API, and removes yet another use of
of_get_named_gpio().

Signed-off-by: Dmitry Torokhov <[email protected]>
---
drivers/input/touchscreen/egalax_ts.c | 42 +++++++++++----------------
1 file changed, 17 insertions(+), 25 deletions(-)

diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
index 83ac8c128192..9e9b1c52720d 100644
--- a/drivers/input/touchscreen/egalax_ts.c
+++ b/drivers/input/touchscreen/egalax_ts.c
@@ -14,17 +14,17 @@
- auto idle mode support
*/

+#include <linux/err.h>
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/input.h>
#include <linux/irq.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
#include <linux/delay.h>
#include <linux/slab.h>
#include <linux/bitops.h>
#include <linux/input/mt.h>
-#include <linux/of_gpio.h>

/*
* Mouse Mode: some panel may configure the controller to mouse mode,
@@ -119,32 +119,26 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
/* wake up controller by an falling edge of interrupt gpio. */
static int egalax_wake_up_device(struct i2c_client *client)
{
- struct device_node *np = client->dev.of_node;
- int gpio;
+ struct gpio_desc *gpio;
int ret;

- if (!np)
- return -ENODEV;
-
- gpio = of_get_named_gpio(np, "wakeup-gpios", 0);
- if (!gpio_is_valid(gpio))
- return -ENODEV;
-
- ret = gpio_request(gpio, "egalax_irq");
- if (ret < 0) {
- dev_err(&client->dev,
- "request gpio failed, cannot wake up controller: %d\n",
- ret);
+ /* wake up controller via an falling edge on IRQ gpio. */
+ gpio = gpiod_get(&client->dev, "wakeup", GPIOD_OUT_HIGH);
+ ret = PTR_ERR_OR_ZERO(gpio);
+ if (ret) {
+ if (ret != -EPROBE_DEFER)
+ dev_err(&client->dev,
+ "failed to request wakeup gpio, cannot wake up controller: %d\n",
+ ret);
return ret;
}

- /* wake up controller via an falling edge on IRQ gpio. */
- gpio_direction_output(gpio, 0);
- gpio_set_value(gpio, 1);
+ /* release the line */
+ gpiod_set_value_cansleep(gpio, 0);

- /* controller should be waken up, return irq. */
- gpio_direction_input(gpio);
- gpio_free(gpio);
+ /* controller should be woken up, return irq. */
+ gpiod_direction_input(gpio);
+ gpiod_put(gpio);

return 0;
}
@@ -185,10 +179,8 @@ static int egalax_ts_probe(struct i2c_client *client,

/* controller may be in sleep, wake it up. */
error = egalax_wake_up_device(client);
- if (error) {
- dev_err(&client->dev, "Failed to wake up the controller\n");
+ if (error)
return error;
- }

error = egalax_firmware_version(client);
if (error < 0) {
--
2.37.3.968.ga6b4b080e4-goog

2022-09-20 05:22:53

by Dmitry Torokhov

[permalink] [raw]
Subject: [PATCH 4/4] Input: egalax_ts - do not hardcode interrupt trigger

Stop hard-coding interrupt trigger, instead rely on the platform code
to do the right thing, according to DT or ACPI data.

Signed-off-by: Dmitry Torokhov <[email protected]>
---
drivers/input/touchscreen/egalax_ts.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/input/touchscreen/egalax_ts.c b/drivers/input/touchscreen/egalax_ts.c
index 9e9b1c52720d..8333a512b605 100644
--- a/drivers/input/touchscreen/egalax_ts.c
+++ b/drivers/input/touchscreen/egalax_ts.c
@@ -203,10 +203,9 @@ static int egalax_ts_probe(struct i2c_client *client,
ABS_MT_POSITION_Y, 0, EGALAX_MAX_Y, 0, 0);
input_mt_init_slots(input_dev, MAX_SUPPORT_POINTS, 0);

- error = devm_request_threaded_irq(&client->dev, client->irq, NULL,
- egalax_ts_interrupt,
- IRQF_TRIGGER_LOW | IRQF_ONESHOT,
- "egalax_ts", ts);
+ error = devm_request_threaded_irq(&client->dev, client->irq,
+ NULL, egalax_ts_interrupt,
+ IRQF_ONESHOT, "egalax_ts", ts);
if (error < 0) {
dev_err(&client->dev, "Failed to register interrupt\n");
return error;
--
2.37.3.968.ga6b4b080e4-goog

2022-10-23 09:54:27

by Shawn Guo

[permalink] [raw]
Subject: Re: [PATCH 1/4] ARM: dts: imx6qdl-sabre*: fix Egalax touchscreen properties

On Mon, Sep 19, 2022 at 09:26:05PM -0700, Dmitry Torokhov wrote:
> This patch fixes interrupt trigger (should be level low as that is what the
> driver is always using), the GPIO that is the interrupt source that is also
> used to wake up chip by driving the line low.
>
> The proper polarity is be needed for converting the driver to gpiod API.
>
> Signed-off-by: Dmitry Torokhov <[email protected]>

Looks good to me. Let me know if you want me to pick it up. Otherwise,

Acked-by: Shawn Guo <[email protected]>

Shawn

> ---
> arch/arm/boot/dts/imx6qdl-sabreauto.dtsi | 4 ++--
> arch/arm/boot/dts/imx6qdl-sabresd.dtsi | 8 ++++----
> 2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
> index 1368a4762037..1883350d004e 100644
> --- a/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
> +++ b/arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
> @@ -451,8 +451,8 @@ touchscreen@4 {
> pinctrl-names = "default";
> pinctrl-0 = <&pinctrl_egalax_int>;
> interrupt-parent = <&gpio2>;
> - interrupts = <28 IRQ_TYPE_EDGE_FALLING>;
> - wakeup-gpios = <&gpio2 28 GPIO_ACTIVE_HIGH>;
> + interrupts = <28 IRQ_TYPE_LEVEL_LOW>;
> + wakeup-gpios = <&gpio2 28 GPIO_ACTIVE_LOW>;
> };
> };
>
> diff --git a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
> index 37482a9023fc..09f4c2fa3ad6 100644
> --- a/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
> +++ b/arch/arm/boot/dts/imx6qdl-sabresd.dtsi
> @@ -311,8 +311,8 @@ touchscreen@4 {
> pinctrl-names = "default";
> pinctrl-0 = <&pinctrl_i2c2_egalax_int>;
> interrupt-parent = <&gpio6>;
> - interrupts = <8 IRQ_TYPE_EDGE_FALLING>;
> - wakeup-gpios = <&gpio6 8 GPIO_ACTIVE_HIGH>;
> + interrupts = <8 IRQ_TYPE_LEVEL_LOW>;
> + wakeup-gpios = <&gpio6 8 GPIO_ACTIVE_LOW>;
> };
>
> ov5640: camera@3c {
> @@ -450,8 +450,8 @@ egalax_ts@4 {
> compatible = "eeti,egalax_ts";
> reg = <0x04>;
> interrupt-parent = <&gpio6>;
> - interrupts = <7 2>;
> - wakeup-gpios = <&gpio6 7 0>;
> + interrupts = <7 IRQ_TYPE_LEVEL_LOW>;
> + wakeup-gpios = <&gpio6 7 GPIO_ACTIVE_LOW>;
> };
>
> magnetometer@e {
> --
> 2.37.3.968.ga6b4b080e4-goog
>

2022-10-24 14:08:55

by Dmitry Torokhov

[permalink] [raw]
Subject: Re: [PATCH 1/4] ARM: dts: imx6qdl-sabre*: fix Egalax touchscreen properties

On Sun, Oct 23, 2022 at 05:30:16PM +0800, Shawn Guo wrote:
> On Mon, Sep 19, 2022 at 09:26:05PM -0700, Dmitry Torokhov wrote:
> > This patch fixes interrupt trigger (should be level low as that is what the
> > driver is always using), the GPIO that is the interrupt source that is also
> > used to wake up chip by driving the line low.
> >
> > The proper polarity is be needed for converting the driver to gpiod API.
> >
> > Signed-off-by: Dmitry Torokhov <[email protected]>
>
> Looks good to me. Let me know if you want me to pick it up. Otherwise,
>
> Acked-by: Shawn Guo <[email protected]>

Thank you, I merged it with the other 3 patches through my tree.

--
Dmitry