* [PATCH v3 2/2] i2c: designware: fix probe ordering for AMD GPIO on Lenovo Yoga 7 14AGP11
2026-05-15 16:15 [PATCH v3 0/1] i2c: designware: fix probe ordering for AMD GPIO on Lenovo Yoga 7 14AGP11 Hardik Prakash
@ 2026-05-15 16:15 ` Hardik Prakash
2026-05-15 17:34 ` [PATCH v3 0/1] " Mario Limonciello
1 sibling, 0 replies; 3+ messages in thread
From: Hardik Prakash @ 2026-05-15 16:15 UTC (permalink / raw)
To: linux-i2c
Cc: linux-gpio, wsa, andriy.shevchenko, mario.limonciello, brgl,
basavaraj.natikar, linus.walleij, Hardik Prakash
On Lenovo Yoga 7 14AGP11 (83TD), the WACF2200 touchscreen fails with
lost arbitration errors on AMDI0010:02 at boot. The root cause is a
probe ordering issue: i2c_designware probes AMDI0010:02 before
pinctrl-amd has finished initialising, so the GPIO 157 interrupt
needed by the touchscreen is not yet enabled.
Add a DMI-matched deferral in dw_i2c_plat_probe() that uses
device_is_bound() under device_lock() to correctly wait until
pinctrl-amd's probe has fully completed. Use acpi_dev_get_first_match_dev()
for robust HID/UID-based GPIO controller lookup instead of string
name matching.
Signed-off-by: Hardik Prakash <hardikprakash.official@gmail.com>
Assisted-by: Claude:claude-sonnet-4-6
Assisted-by: GPT-Codex:gpt-5.2-codex
BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=221494
---
drivers/i2c/busses/i2c-designware-platdrv.c | 77 +++++++++++++++++++++
1 file changed, 77 insertions(+)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 3351c4a9ef118..3ffc3d757fbd1 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -8,6 +8,7 @@
* Copyright (C) 2007 MontaVista Software Inc.
* Copyright (C) 2009 Provigent Ltd.
*/
+#include <linux/acpi.h>
#include <linux/clk-provider.h>
#include <linux/clk.h>
#include <linux/delay.h>
@@ -86,6 +87,78 @@ static const struct dmi_system_id dw_i2c_hwmon_class_dmi[] = {
{ } /* terminate list */
};
+static const struct dmi_system_id dw_i2c_amd_gpio_defer_dmi[] = {
+ {
+ .ident = "Lenovo Yoga 7 14AGP11",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+ DMI_MATCH(DMI_PRODUCT_NAME, "83TD"),
+ DMI_MATCH(DMI_BOARD_NAME, "LNVNB161216"),
+ },
+ },
+ { } /* terminate list */
+};
+
+static bool dw_i2c_needs_amd_gpio_dep(struct device *device)
+{
+ struct acpi_device *adev;
+
+ if (!dmi_check_system(dw_i2c_amd_gpio_defer_dmi))
+ return false;
+
+ adev = ACPI_COMPANION(device);
+ if (!adev)
+ return false;
+
+ return acpi_dev_hid_uid_match(adev, "AMDI0010", "2");
+}
+
+static int dw_i2c_defer_for_amd_gpio(struct device *device)
+{
+ struct acpi_device *gpio_adev;
+ struct device *gpio_dev;
+
+ if (!dw_i2c_needs_amd_gpio_dep(device))
+ return 0;
+
+ /*
+ * Find the AMD GPIO controller by HID/UID and get its physical
+ * platform device. We need the platform device (not the ACPI device)
+ * because that is what gets bound by the amd_gpio driver.
+ */
+ gpio_adev = acpi_dev_get_first_match_dev("AMDI0030", "0", -1);
+ if (!gpio_adev)
+ return -EPROBE_DEFER;
+
+ gpio_dev = acpi_get_first_physical_node(gpio_adev);
+ acpi_dev_put(gpio_adev);
+ if (!gpio_dev)
+ return -EPROBE_DEFER;
+
+ /*
+ * Check that amd_gpio probe has fully completed, not just that the
+ * driver pointer is set. The driver pointer is assigned before probe
+ * finishes, so checking it would allow i2c_designware to probe before
+ * the GPIO IRQ quirk in amd_gpio_probe() has run.
+ */
+ device_lock(gpio_dev);
+ if (!device_is_bound(gpio_dev)) {
+ device_unlock(gpio_dev);
+ return -EPROBE_DEFER;
+ }
+ device_unlock(gpio_dev);
+
+ /*
+ * Create a device link so the driver core enforces probe/remove
+ * ordering between this I2C controller and the GPIO controller.
+ */
+ if (!device_link_add(device, gpio_dev, DL_FLAG_AUTOREMOVE_CONSUMER))
+ dev_warn(device, "failed to add device link to %s\n",
+ dev_name(gpio_dev));
+
+ return 0;
+}
+
static const struct i2c_dw_semaphore_callbacks i2c_dw_semaphore_cb_table[] = {
#ifdef CONFIG_I2C_DESIGNWARE_BAYTRAIL
{
@@ -138,6 +211,10 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
struct dw_i2c_dev *dev;
int irq, ret;
+ ret = dw_i2c_defer_for_amd_gpio(device);
+ if (ret)
+ return ret;
+
irq = platform_get_irq_optional(pdev, 0);
if (irq == -ENXIO)
flags |= ACCESS_POLLING;
--
2.54.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v3 0/1] i2c: designware: fix probe ordering for AMD GPIO on Lenovo Yoga 7 14AGP11
2026-05-15 16:15 [PATCH v3 0/1] i2c: designware: fix probe ordering for AMD GPIO on Lenovo Yoga 7 14AGP11 Hardik Prakash
2026-05-15 16:15 ` [PATCH v3 2/2] " Hardik Prakash
@ 2026-05-15 17:34 ` Mario Limonciello
1 sibling, 0 replies; 3+ messages in thread
From: Mario Limonciello @ 2026-05-15 17:34 UTC (permalink / raw)
To: Hardik Prakash, linux-i2c
Cc: linux-gpio, wsa, andriy.shevchenko, brgl, basavaraj.natikar,
linus.walleij
On 5/15/26 11:15, Hardik Prakash wrote:
> The Wacom WACF2200 touchscreen on the Lenovo Yoga 7 14AGP11 (83TD) is
> non-functional on Linux due to two bugs. Patch 1 (pinctrl-amd GPIO IRQ
> fix) has already been taken into Linus Walleij's tree. This v3 resend
> covers patch 2 only, addressing Andy Shevchenko's formatting feedback.
>
> Root cause: i2c_designware probes AMDI0010:02 before pinctrl-amd's
> probe completes, so GPIO 157 (WACF2200 GpioInt per ACPI _CRS) has its
> interrupt bits cleared when the first I2C transaction is attempted,
> causing lost arbitration errors. The udev rebind workaround (which
> works because pinctrl-amd has finished by userspace time) confirms
> probe ordering as the root cause.
>
> Note: the dual-master hypothesis raised by Mario Limonciello was
> investigated. TPNL's _DSM (UUID 3cdff6f7-4267-4555-ad05-b30a3d8938de)
> is a pure query method returning a constant HID descriptor address with
> no side effects, making firmware acting as secondary I2C master unlikely
> on this hardware. Awaiting Mario and Bart's technical verdict before
> any further approach changes.
>
> v3:
> - Patch 2 only (patch 1 already in Linus Walleij's tree)
> - Fix variable declaration style in dw_i2c_needs_amd_gpio_dep (Andy Shevchenko)
> - Add BugLink tag (Andy Shevchenko)
> - Add -v3 subject versioning (Andy Shevchenko)
> - CC AMD engineers (Andy Shevchenko)
>
> v2:
> - Replace custom HID/UID lookup with acpi_dev_get_first_match_dev() (Andy Shevchenko)
> - Use acpi_get_first_physical_node() for platform device lookup
> - Use device_is_bound() under device_lock() with explanatory comments
> - Fix dev_warn to use dev_name() instead of hardcoded suffix
> - Fix commit message (removed incorrect "existing" reference)
> - Add Assisted-by tags per coding-assistants.rst
>
> Kernel bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=221494
> Related: https://bugzilla.kernel.org/show_bug.cgi?id=221454
>
> Hardik Prakash (1):
> i2c: designware: fix probe ordering for AMD GPIO on Lenovo Yoga 7
> 14AGP11
>
> drivers/i2c/busses/i2c-designware-platdrv.c | 77 +++++++++++++++++++++
> 1 file changed, 77 insertions(+)
I have another idea. Why don't we just move pinctrl-amd to initialize
earlier? That should avoid the problem without more quirks I think.
Something like this:
╰─❯ git diff
diff --git a/drivers/pinctrl/pinctrl-amd.c b/drivers/pinctrl/pinctrl-amd.c
index e3128b0045d22..56a189082351b 100644
--- a/drivers/pinctrl/pinctrl-amd.c
+++ b/drivers/pinctrl/pinctrl-amd.c
@@ -1292,7 +1292,18 @@ static struct platform_driver amd_gpio_driver = {
.remove = amd_gpio_remove,
};
-module_platform_driver(amd_gpio_driver);
+static int __init amd_gpio_init(void)
+{
+ return platform_driver_register(&amd_gpio_driver);
+}
+subsys_initcall(amd_gpio_init);
+
+static void __exit amd_gpio_exit(void)
+{
+ platform_driver_unregister(&amd_gpio_driver);
+}
+module_exit(amd_gpio_exit);
MODULE_AUTHOR("Ken Xue <Ken.Xue@amd.com>, Jeff Wu <Jeff.Wu@amd.com>");
MODULE_DESCRIPTION("AMD GPIO pinctrl driver");
+MODULE_LICENSE("GPL");
^ permalink raw reply related [flat|nested] 3+ messages in thread