mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "谢致邦 (XIE Zhibang)" <Yeking@Red54.com>
To: linux-input@vger.kernel.org, hansg@kernel.org, dmitry.torokhov@gmail.com
Cc: Yeking@red54.com, bentiss@kernel.org, dianders@chromium.org,
	jikos@kernel.org, linux-kernel@vger.kernel.org,
	superm1@kernel.org, "谢致邦 (XIE Zhibang)" <Yeking@Red54.com>,
	"Pin-yen Lin" <treapking@chromium.org>,
	"Xu Rao" <raoxu@uniontech.com>,
	"Kwok Kin Ming" <kenkinming2002@gmail.com>,
	"Dan Carpenter" <error27@gmail.com>
Subject: [PATCH 3/3] HID: i2c-hid-of: Fall back to ACPI _DSM when hid-descr-addr is missing
Date: Mon,  1 Jun 2026 17:37:22 +0000	[thread overview]
Message-ID: <tencent_589FE3DA1F7ED602D168E57BC2AC41FEEA09@qq.com> (raw)
In-Reply-To: <20260601173722.38151-1-Yeking@Red54.com>

Before commit b33752c30023 ("HID: i2c-hid: Reorganize so ACPI and OF are
separate modules"), the unified i2c-hid driver handled both PNP0C50 ACPI
devices and hid-over-i2c OF devices. After the split, devices with _HID
"PRP0001" and _DSD compatible "hid-over-i2c" are only probed by
i2c_hid_of, which requires "hid-descr-addr" in the _DSD. Some devices,
for example the Lenovo KaiTian N60d and Inspur CP300L3, provide the HID
descriptor address only through the _DSM method. Call the common
i2c_hid_core_acpi_get_descriptor() helper as a fallback, and set safe
post-power-on and post-reset-deassert delays.

Fixes: b33752c30023 ("HID: i2c-hid: Reorganize so ACPI and OF are separate modules")
Signed-off-by: 谢致邦 (XIE Zhibang) <Yeking@Red54.com>
---
 drivers/hid/i2c-hid/i2c-hid-of.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/hid/i2c-hid/i2c-hid-of.c b/drivers/hid/i2c-hid/i2c-hid-of.c
index 57379b77e977..e925e2d2cfe0 100644
--- a/drivers/hid/i2c-hid/i2c-hid-of.c
+++ b/drivers/hid/i2c-hid/i2c-hid-of.c
@@ -92,6 +92,36 @@ static int i2c_hid_of_probe(struct i2c_client *client)
 	ihid_of->ops.power_down = i2c_hid_of_power_down;
 
 	ret = device_property_read_u32(dev, "hid-descr-addr", &val);
+	if (ret) {
+		/*
+		 * Some devices, for example the Lenovo KaiTian N60d and Inspur
+		 * CP300L3, declare their I2C HID touchpad with _HID "PRP0001"
+		 * and _DSD compatible "hid-over-i2c" but lack the
+		 * "hid-descr-addr" property. Fall back to _DSM to obtain the
+		 * HID descriptor address.
+		 */
+		int dsm_ret = i2c_hid_core_acpi_get_descriptor(dev);
+
+		if (dsm_ret >= 0) {
+			dev_warn(dev,
+				 "hid-descr-addr NOT found, using _DSM fallback. Contact vendor for firmware update!\n");
+			val = dsm_ret;
+
+			/*
+			 * Firmware providing the descriptor address only
+			 * through _DSM may also lack "post-power-on-delay-ms"
+			 * or "post-reset-deassert-delay-ms", leaving the
+			 * driver without enough delay before the first HID
+			 * descriptor read. Set safe defaults to avoid reading
+			 * the descriptor before the device has finished its
+			 * internal power-on reset.
+			 */
+			ihid_of->post_power_delay_ms = 250;
+			ihid_of->post_reset_delay_ms = 250;
+
+			ret = 0;
+		}
+	}
 	if (ret) {
 		dev_err(dev, "HID register address not provided\n");
 		return -ENODEV;
-- 
2.54.0


  parent reply	other threads:[~2026-06-01 17:39 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-27 15:17 [PATCH] HID: i2c-hid-acpi: Add PRP0001 to match table and OF alias 谢致邦 (XIE Zhibang)
2026-05-27 15:44 ` Hans de Goede
2026-05-29 12:16   ` [PATCH] HID: i2c-hid-of: Fall back to ACPI _DSM when hid-descr-addr is missing 谢致邦 (XIE Zhibang)
2026-05-29 15:00     ` Hans de Goede
2026-05-29 19:36       ` Dmitry Torokhov
2026-06-01 17:37         ` [PATCH 0/3] HID: i2c-hid: Fix some PRP0001 touchpads probe after OF/ACPI split 谢致邦 (XIE Zhibang)
     [not found]         ` <20260601173722.38151-1-Yeking@Red54.com>
2026-06-01 17:37           ` [PATCH 1/3] HID: i2c-hid-acpi: Move blacklist check to probe() before devm_kzalloc() 谢致邦 (XIE Zhibang)
2026-06-01 17:37           ` [PATCH 2/3] HID: i2c-hid: Move common ACPI _DSM helper into core 谢致邦 (XIE Zhibang)
2026-06-01 17:37           ` 谢致邦 (XIE Zhibang) [this message]
2026-06-01 18:15         ` [PATCH v2 0/3] HID: i2c-hid: Fix some PRP0001 touchpads probe after OF/ACPI split 谢致邦 (XIE Zhibang)
     [not found]         ` <20260601181510.38705-1-Yeking@Red54.com>
2026-06-01 18:15           ` [PATCH v2 1/3] HID: i2c-hid-acpi: Move blacklist check to probe() before devm_kzalloc() 谢致邦 (XIE Zhibang)
2026-06-01 18:15           ` [PATCH v2 2/3] HID: i2c-hid: Move common ACPI _DSM helper into core 谢致邦 (XIE Zhibang)
2026-06-03  9:43             ` Benjamin Tissoires
2026-06-03 10:25               ` Hans de Goede
2026-06-03 11:59                 ` Benjamin Tissoires
2026-06-03 13:12                   ` Hans de Goede
2026-06-03 13:30                     ` Benjamin Tissoires
2026-06-04  4:23                       ` 谢致邦 (XIE Zhibang)
2026-06-05  1:29                         ` [PATCH] HID: i2c-hid: Refactor _DSM helper and add i2c-hid-acpi-prp0001 driver 谢致邦 (XIE Zhibang)
2026-06-01 18:15           ` [PATCH v2 3/3] HID: i2c-hid-of: Fall back to ACPI _DSM when hid-descr-addr is missing 谢致邦 (XIE Zhibang)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tencent_589FE3DA1F7ED602D168E57BC2AC41FEEA09@qq.com \
    --to=yeking@red54.com \
    --cc=bentiss@kernel.org \
    --cc=dianders@chromium.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=error27@gmail.com \
    --cc=hansg@kernel.org \
    --cc=jikos@kernel.org \
    --cc=kenkinming2002@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=raoxu@uniontech.com \
    --cc=superm1@kernel.org \
    --cc=treapking@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome