Skip to contentSkip to conversation

Input: goodix - Try to reset the controller if the i2c-test fails

PATCH New Hans de Goede 2 participants 3 messages Mar 11, 2020 – Mar 24, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Input: goodix - Try to reset the controller if the i2c-test fails

Hi,

Here is a small patch fixing the goodix touchscreen driver failing at probe due to what I consider a BIOS bug on Dmitry's Mastykin's tablet.

This patch applies on top of my earlier series starting with:
[PATCH v3 01/11] Input: goodix - Refactor IRQ pin GPIO accesses

Regards,

Hans

#1 lore raw

PATCH 1/1 Input: goodix - Try to reset the controller if the i2c-test fails

On some ACPI/x86 devices (where we use one of the ACPI IRQ pin access methods) the firmware is buggy, it does not properly reset the controller at boot, and we cannot communicate with it.

Normally on ACPI/x86 devices we do not want to reset the controller at probe time since in some cases this causes the controller to loose its configuration and this is loaded into it by the system's firmware. So on these systems we leave the reset_controller_at_probe flag unset, even though we have a access to both the IRQ and reset pins and thus could reset it.

In the case of the buggy firmware we have to reset the controller to actually be able to talk to it.

This commit adds a special case for this, if the goodix_i2c_test() fails, and we have not reset the controller yet; and we do have a way to reset the controller then retry the i2c-test after resetting the controller.

This fixes the driver failing at probe on ACPI/x86 systems with this firmware bug.

---
 drivers/input/touchscreen/goodix.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/input/touchscreen/goodix.c +7 -0
index 2f135ac9484e..816d6ade89a9 100644
@@ -1165,6 +1165,7 @@ static int goodix_ts_probe(struct i2c_client *client,
 	if (error)
 		return error;
 
+reset:
 	if (ts->reset_controller_at_probe) {
 		/* reset the controller */
 		error = goodix_reset(ts);
@@ -1176,6 +1177,12 @@ static int goodix_ts_probe(struct i2c_client *client,
 
 	error = goodix_i2c_test(client);
 	if (error) {
+		if (!ts->reset_controller_at_probe &&
+		    ts->irq_pin_access_method != IRQ_PIN_ACCESS_NONE) {
+			/* Retry after a controller reset */
+			ts->reset_controller_at_probe = true;
+			goto reset;
+		}
 		dev_err(&client->dev, "I2C communication failure: %d\n", error);
 		return error;
 	}
Signature · 1 line
2.25.1
maintainer Applied
#2 lore raw
Quoted 18 lines · Hans de Goede

On some ACPI/x86 devices (where we use one of the ACPI IRQ pin access methods) the firmware is buggy, it does not properly reset the controller at boot, and we cannot communicate with it.

Normally on ACPI/x86 devices we do not want to reset the controller at probe time since in some cases this causes the controller to loose its configuration and this is loaded into it by the system's firmware. So on these systems we leave the reset_controller_at_probe flag unset, even though we have a access to both the IRQ and reset pins and thus could reset it.

In the case of the buggy firmware we have to reset the controller to actually be able to talk to it.

This commit adds a special case for this, if the goodix_i2c_test() fails, and we have not reset the controller yet; and we do have a way to reset the controller then retry the i2c-test after resetting the controller.

Quoted 5 lines

This fixes the driver failing at probe on ACPI/x86 systems with this firmware bug.

Applied, thank you.

Quoted 32 lines
---
 drivers/input/touchscreen/goodix.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/input/touchscreen/goodix.c +7 -0
index 2f135ac9484e..816d6ade89a9 100644
@@ -1165,6 +1165,7 @@ static int goodix_ts_probe(struct i2c_client *client,
 	if (error)
 		return error;
 
+reset:
 	if (ts->reset_controller_at_probe) {
 		/* reset the controller */
 		error = goodix_reset(ts);
@@ -1176,6 +1177,12 @@ static int goodix_ts_probe(struct i2c_client *client,
 
 	error = goodix_i2c_test(client);
 	if (error) {
+		if (!ts->reset_controller_at_probe &&
+		    ts->irq_pin_access_method != IRQ_PIN_ACCESS_NONE) {
+			/* Retry after a controller reset */
+			ts->reset_controller_at_probe = true;
+			goto reset;
+		}
 		dev_err(&client->dev, "I2C communication failure: %d\n", error);
 		return error;
 	}
Signature · 1 line
2.25.1
Signature · 1 line
Dmitry