All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH regression fix 0/1] Input: goodix - Try not to touch the reset-pin on x86/ACPI devices
@ 2021-12-06  9:11 Hans de Goede
  2021-12-06  9:11 ` [PATCH regression fix 1/1] " Hans de Goede
  0 siblings, 1 reply; 3+ messages in thread
From: Hans de Goede @ 2021-12-06  9:11 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Hans de Goede, Bastien Nocera, linux-input

Hi Dmitry,

This patch fixes a regression in the goodix driver on some boards,
which was introduced in 5.7 (yes 5.7) unfortunately this did not
come to my attention until now, see:
https://bugzilla.kernel.org/show_bug.cgi?id=209061

If you can get this on its way to Linus for 5.16 that would be
great. Alternatively if you don't have time to prep a fixes pull-req
for this let me know and I can add it to my next pdx86 fixes pull-req.

Regards,

Hans


Hans de Goede (1):
  Input: goodix - Try not to touch the reset-pin on x86/ACPI devices

 drivers/input/touchscreen/goodix.c | 30 +++++++++++++++++++++++++-----
 drivers/input/touchscreen/goodix.h |  1 +
 2 files changed, 26 insertions(+), 5 deletions(-)

-- 
2.33.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH regression fix 1/1] Input: goodix - Try not to touch the reset-pin on x86/ACPI devices
  2021-12-06  9:11 [PATCH regression fix 0/1] Input: goodix - Try not to touch the reset-pin on x86/ACPI devices Hans de Goede
@ 2021-12-06  9:11 ` Hans de Goede
  2021-12-07  7:18   ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Hans de Goede @ 2021-12-06  9:11 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: Hans de Goede, Bastien Nocera, linux-input

Unless the controller is not responding at boot or after suspend/resume,
the driver never resets the controller on x86/ACPI platforms. The driver
still requesting the reset pin at probe() though in case it needs it.

Until now the driver has always requested the reset pin with GPIOD_IN
as type. The idea being to put the pin in high-impedance mode to save
power until the driver actually wants to issue a reset.

But this means that just requesting the pin can cause issues, since
requesting it in another mode then GPIOD_ASIS may cause the pinctrl
driver to touch the pin settings. We have already had issues before
due to a bug in the pinctrl-cherryview.c driver which has been fixed in
commit 921daeeca91b ("pinctrl: cherryview: Preserve
CHV_PADCTRL1_INVRXTX_TXDATA flag on GPIOs").

And now it turns out that requesting the reset-pin as GPIOD_IN also stops
the touchscreen from working on the GPD P2 max mini-laptop. The behavior
of putting the pin in high-impedance mode relies on there being some
external pull-up to keep it high and there seems to be no pull-up on the
GPD P2 max, causing things to break.

This commit fixes this by requesting the reset pin as is when using
the x86/ACPI code paths to lookup the GPIOs; and by not dropping it
back into input-mode in case the driver does end up issuing a reset
for error-recovery.

BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=209061
Fixes: a7d4b171660c ("Input: goodix - add support for getting IRQ + reset GPIOs on Cherry Trail devices")
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 drivers/input/touchscreen/goodix.c | 30 +++++++++++++++++++++++++-----
 drivers/input/touchscreen/goodix.h |  1 +
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/input/touchscreen/goodix.c b/drivers/input/touchscreen/goodix.c
index b5cc91788195..eaa659969097 100644
--- a/drivers/input/touchscreen/goodix.c
+++ b/drivers/input/touchscreen/goodix.c
@@ -650,10 +650,16 @@ int goodix_reset_no_int_sync(struct goodix_ts_data *ts)
 
 	usleep_range(6000, 10000);		/* T4: > 5ms */
 
-	/* end select I2C slave addr */
-	error = gpiod_direction_input(ts->gpiod_rst);
-	if (error)
-		goto error;
+	/*
+	 * Put the reset pin back in to input / high-impedance mode to save
+	 * power. Only do this in the non ACPI case since some ACPI boards
+	 * don't have a pull-up, so there the reset pin must stay active-high.
+	 */
+	if (ts->irq_pin_access_method == IRQ_PIN_ACCESS_GPIO) {
+		error = gpiod_direction_input(ts->gpiod_rst);
+		if (error)
+			goto error;
+	}
 
 	return 0;
 
@@ -787,6 +793,14 @@ static int goodix_add_acpi_gpio_mappings(struct goodix_ts_data *ts)
 		return -EINVAL;
 	}
 
+	/*
+	 * Normally we put the reset pin in input / high-impedance mode to save
+	 * power. But some x86/ACPI boards don't have a pull-up, so for the ACPI
+	 * case, leave the pin as is. This results in the pin not being touched
+	 * at all on x86/ACPI boards, except when needed for error-recover.
+	 */
+	ts->gpiod_rst_flags = GPIOD_ASIS;
+
 	return devm_acpi_dev_add_driver_gpios(dev, gpio_mapping);
 }
 #else
@@ -812,6 +826,12 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 		return -EINVAL;
 	dev = &ts->client->dev;
 
+	/*
+	 * By default we request the reset pin as input, leaving it in
+	 * high-impedance when not resetting the controller to save power.
+	 */
+	ts->gpiod_rst_flags = GPIOD_IN;
+
 	ts->avdd28 = devm_regulator_get(dev, "AVDD28");
 	if (IS_ERR(ts->avdd28)) {
 		error = PTR_ERR(ts->avdd28);
@@ -849,7 +869,7 @@ static int goodix_get_gpio_config(struct goodix_ts_data *ts)
 	ts->gpiod_int = gpiod;
 
 	/* Get the reset line GPIO pin number */
-	gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_RST_NAME, GPIOD_IN);
+	gpiod = devm_gpiod_get_optional(dev, GOODIX_GPIO_RST_NAME, ts->gpiod_rst_flags);
 	if (IS_ERR(gpiod)) {
 		error = PTR_ERR(gpiod);
 		if (error != -EPROBE_DEFER)
diff --git a/drivers/input/touchscreen/goodix.h b/drivers/input/touchscreen/goodix.h
index 62138f930d1a..02065d1c3263 100644
--- a/drivers/input/touchscreen/goodix.h
+++ b/drivers/input/touchscreen/goodix.h
@@ -87,6 +87,7 @@ struct goodix_ts_data {
 	struct gpio_desc *gpiod_rst;
 	int gpio_count;
 	int gpio_int_idx;
+	enum gpiod_flags gpiod_rst_flags;
 	char id[GOODIX_ID_MAX_LEN + 1];
 	char cfg_name[64];
 	u16 version;
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH regression fix 1/1] Input: goodix - Try not to touch the reset-pin on x86/ACPI devices
  2021-12-06  9:11 ` [PATCH regression fix 1/1] " Hans de Goede
@ 2021-12-07  7:18   ` Dmitry Torokhov
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2021-12-07  7:18 UTC (permalink / raw)
  To: Hans de Goede; +Cc: Bastien Nocera, linux-input

On Mon, Dec 06, 2021 at 10:11:16AM +0100, Hans de Goede wrote:
> Unless the controller is not responding at boot or after suspend/resume,
> the driver never resets the controller on x86/ACPI platforms. The driver
> still requesting the reset pin at probe() though in case it needs it.
> 
> Until now the driver has always requested the reset pin with GPIOD_IN
> as type. The idea being to put the pin in high-impedance mode to save
> power until the driver actually wants to issue a reset.
> 
> But this means that just requesting the pin can cause issues, since
> requesting it in another mode then GPIOD_ASIS may cause the pinctrl
> driver to touch the pin settings. We have already had issues before
> due to a bug in the pinctrl-cherryview.c driver which has been fixed in
> commit 921daeeca91b ("pinctrl: cherryview: Preserve
> CHV_PADCTRL1_INVRXTX_TXDATA flag on GPIOs").
> 
> And now it turns out that requesting the reset-pin as GPIOD_IN also stops
> the touchscreen from working on the GPD P2 max mini-laptop. The behavior
> of putting the pin in high-impedance mode relies on there being some
> external pull-up to keep it high and there seems to be no pull-up on the
> GPD P2 max, causing things to break.
> 
> This commit fixes this by requesting the reset pin as is when using
> the x86/ACPI code paths to lookup the GPIOs; and by not dropping it
> back into input-mode in case the driver does end up issuing a reset
> for error-recovery.
> 
> BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=209061
> Fixes: a7d4b171660c ("Input: goodix - add support for getting IRQ + reset GPIOs on Cherry Trail devices")
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

Applied, thank you.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-12-07  7:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06  9:11 [PATCH regression fix 0/1] Input: goodix - Try not to touch the reset-pin on x86/ACPI devices Hans de Goede
2021-12-06  9:11 ` [PATCH regression fix 1/1] " Hans de Goede
2021-12-07  7:18   ` Dmitry Torokhov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.