* [PATCH v14 1/2] HID: cp2112: Add fwnode support
2026-05-20 16:13 [PATCH v14 0/2] Firmware Support for USB-HID Devices and CP2112 Danny Kaehn
@ 2026-05-20 16:13 ` Danny Kaehn
2026-06-01 19:18 ` Andy Shevchenko
` (2 more replies)
2026-05-20 16:13 ` [PATCH v14 2/2] HID: cp2112: Configure I2C bus speed from firmware Danny Kaehn
` (2 subsequent siblings)
3 siblings, 3 replies; 8+ messages in thread
From: Danny Kaehn @ 2026-05-20 16:13 UTC (permalink / raw)
To: Benjamin Tissoires, Andy Shevchenko, Danny Kaehn, Andi Shyti,
Conor Dooley
Cc: Jiri Kosina, linux-input, Dmitry Torokhov, Ethan Twardy,
linux-i2c, linux-kernel, Leo Huang, Arun D Patil, Willie Thai,
Ting-Kai Chen, Bartosz Golaszewski
Support describing the CP2112's I2C and GPIO interfaces in firmware.
Bindings between the firmware nodes and the functions of the device
are distinct between ACPI and DeviceTree.
For ACPI, the i2c_adapter will use the child with _ADR equal to Zero
and the gpio_chip will use the child with _ADR equal to One.
For DeviceTree, the i2c_adapter will use the child with name "i2c",
but the gpio_chip will share a firmware node with the CP2112.
Signed-off-by: Danny Kaehn <danny.kaehn@plexus.com>
---
drivers/hid/hid-cp2112.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
index 803b883ae875..e960fc988058 100644
--- a/drivers/hid/hid-cp2112.c
+++ b/drivers/hid/hid-cp2112.c
@@ -29,6 +29,18 @@
#include <linux/usb/ch9.h>
#include "hid-ids.h"
+/**
+ * enum cp2112_child_acpi_cell_addrs - Child ACPI addresses for CP2112 sub-functions
+ * Note that the enum values are explicitly defined, as this defines the interface
+ * between ACPI and Linux
+ * @CP2112_I2C_ADR: Address for I2C node
+ * @CP2112_GPIO_ADR: Address for GPIO node
+ */
+enum cp2112_child_acpi_cell_addrs {
+ CP2112_I2C_ADR = 0,
+ CP2112_GPIO_ADR = 1,
+};
+
#define CP2112_REPORT_MAX_LENGTH 64
#define CP2112_GPIO_CONFIG_LENGTH 5
#define CP2112_GPIO_GET_LENGTH 2
@@ -1208,7 +1220,10 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
struct cp2112_device *dev;
u8 buf[3];
struct cp2112_smbus_config_report config;
+ struct fwnode_handle *cp2112_fwnode;
+ struct fwnode_handle *child;
struct gpio_irq_chip *girq;
+ u32 addr;
int ret;
dev = devm_kzalloc(&hdev->dev, sizeof(*dev), GFP_KERNEL);
@@ -1226,6 +1241,28 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
return ret;
}
+ cp2112_fwnode = dev_fwnode(&hdev->dev);
+ if (is_acpi_device_node(cp2112_fwnode)) {
+ fwnode_for_each_child_node(cp2112_fwnode, child) {
+ ret = acpi_get_local_address(ACPI_HANDLE_FWNODE(child), &addr);
+ if (ret)
+ continue;
+
+ switch (addr) {
+ case CP2112_I2C_ADR:
+ device_set_node(&dev->adap.dev, child);
+ break;
+ case CP2112_GPIO_ADR:
+ dev->gc.fwnode = child;
+ break;
+ }
+ }
+ } else if (is_of_node(cp2112_fwnode)) {
+ child = fwnode_get_named_child_node(cp2112_fwnode, "i2c");
+ device_set_node(&dev->adap.dev, child);
+ fwnode_handle_put(child);
+ }
+
ret = hid_parse(hdev);
if (ret) {
hid_err(hdev, "parse failed\n");
--
2.25.1
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH v14 1/2] HID: cp2112: Add fwnode support
2026-05-20 16:13 ` [PATCH v14 1/2] HID: cp2112: Add fwnode support Danny Kaehn
@ 2026-06-01 19:18 ` Andy Shevchenko
2026-06-03 19:46 ` Jacky Huang
2026-06-04 12:45 ` Bartosz Golaszewski
2 siblings, 0 replies; 8+ messages in thread
From: Andy Shevchenko @ 2026-06-01 19:18 UTC (permalink / raw)
To: Danny Kaehn
Cc: Benjamin Tissoires, Andi Shyti, Conor Dooley, Jiri Kosina,
linux-input, Dmitry Torokhov, Ethan Twardy, linux-i2c,
linux-kernel, Leo Huang, Arun D Patil, Willie Thai,
Ting-Kai Chen, Bartosz Golaszewski
On Wed, May 20, 2026 at 11:13:06AM -0500, Danny Kaehn wrote:
> Support describing the CP2112's I2C and GPIO interfaces in firmware.
>
> Bindings between the firmware nodes and the functions of the device
> are distinct between ACPI and DeviceTree.
>
> For ACPI, the i2c_adapter will use the child with _ADR equal to Zero
> and the gpio_chip will use the child with _ADR equal to One.
>
> For DeviceTree, the i2c_adapter will use the child with name "i2c",
> but the gpio_chip will share a firmware node with the CP2112.
As we seems settled on the approaches in both cases, I think we are fine
to go
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v14 1/2] HID: cp2112: Add fwnode support
2026-05-20 16:13 ` [PATCH v14 1/2] HID: cp2112: Add fwnode support Danny Kaehn
2026-06-01 19:18 ` Andy Shevchenko
@ 2026-06-03 19:46 ` Jacky Huang
2026-06-04 12:45 ` Bartosz Golaszewski
2 siblings, 0 replies; 8+ messages in thread
From: Jacky Huang @ 2026-06-03 19:46 UTC (permalink / raw)
To: Danny Kaehn
Cc: Jacky Huang, Benjamin Tissoires, Andy Shevchenko, Andi Shyti,
Conor Dooley, Jiri Kosina, Dmitry Torokhov, Ethan Twardy,
Bartosz Golaszewski, Leo Huang, Arun D Patil, Willie Thai,
Ting-Kai Chen, linux-input, linux-i2c, linux-kernel
Hi Danny,
Thank you for all your work bringing this through so many revisions, and
I am glad to help by testing it.
I tested this on an AST2600-based OpenBMC platform (NVIDIA Vera Rubin)
that has several CP2112s. With this patch, a CP2112 whose device-tree
"i2c" subnode declares downstream I2C devices (PCA9555 expanders) has
them auto-instantiated by i2c-core: they appeared on the adapter's I2C
bus with their gpio-line-names. CP2112s with an empty "i2c" node
registered their adapters but instantiated no children, as expected.
Tested-by: Jacky Huang <jackyhuang@nvidia.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v14 1/2] HID: cp2112: Add fwnode support
2026-05-20 16:13 ` [PATCH v14 1/2] HID: cp2112: Add fwnode support Danny Kaehn
2026-06-01 19:18 ` Andy Shevchenko
2026-06-03 19:46 ` Jacky Huang
@ 2026-06-04 12:45 ` Bartosz Golaszewski
2 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-06-04 12:45 UTC (permalink / raw)
To: Danny Kaehn
Cc: Jiri Kosina, linux-input, Dmitry Torokhov, Ethan Twardy,
linux-i2c, linux-kernel, Leo Huang, Arun D Patil, Willie Thai,
Ting-Kai Chen, Bartosz Golaszewski, Benjamin Tissoires,
Andy Shevchenko, Andi Shyti, Conor Dooley
On Wed, 20 May 2026 18:13:06 +0200, Danny Kaehn <danny.kaehn@plexus.com> said:
> Support describing the CP2112's I2C and GPIO interfaces in firmware.
>
> Bindings between the firmware nodes and the functions of the device
> are distinct between ACPI and DeviceTree.
>
> For ACPI, the i2c_adapter will use the child with _ADR equal to Zero
> and the gpio_chip will use the child with _ADR equal to One.
>
> For DeviceTree, the i2c_adapter will use the child with name "i2c",
> but the gpio_chip will share a firmware node with the CP2112.
>
> Signed-off-by: Danny Kaehn <danny.kaehn@plexus.com>
> ---
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v14 2/2] HID: cp2112: Configure I2C bus speed from firmware
2026-05-20 16:13 [PATCH v14 0/2] Firmware Support for USB-HID Devices and CP2112 Danny Kaehn
2026-05-20 16:13 ` [PATCH v14 1/2] HID: cp2112: Add fwnode support Danny Kaehn
@ 2026-05-20 16:13 ` Danny Kaehn
2026-06-10 15:35 ` [PATCH v14 0/2] Firmware Support for USB-HID Devices and CP2112 Jiri Kosina
2026-11-05 9:01 ` Bartosz Golaszewski
3 siblings, 0 replies; 8+ messages in thread
From: Danny Kaehn @ 2026-05-20 16:13 UTC (permalink / raw)
To: Benjamin Tissoires, Andy Shevchenko, Danny Kaehn, Andi Shyti,
Conor Dooley
Cc: Jiri Kosina, linux-input, Dmitry Torokhov, Ethan Twardy,
linux-i2c, linux-kernel, Leo Huang, Arun D Patil, Willie Thai,
Ting-Kai Chen, Bartosz Golaszewski
Now that the I2C adapter on the CP2112 can have an associated firmware
node, set the bus speed based on firmware configuration
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Danny Kaehn <danny.kaehn@plexus.com>
---
drivers/hid/hid-cp2112.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/hid/hid-cp2112.c b/drivers/hid/hid-cp2112.c
index e960fc988058..04379db93571 100644
--- a/drivers/hid/hid-cp2112.c
+++ b/drivers/hid/hid-cp2112.c
@@ -1223,6 +1223,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
struct fwnode_handle *cp2112_fwnode;
struct fwnode_handle *child;
struct gpio_irq_chip *girq;
+ struct i2c_timings timings;
u32 addr;
int ret;
@@ -1308,6 +1309,9 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
goto err_power_normal;
}
+ i2c_parse_fw_timings(&dev->adap.dev, &timings, true);
+
+ config.clock_speed = cpu_to_be32(timings.bus_freq_hz);
config.retry_time = cpu_to_be16(1);
ret = cp2112_hid_output(hdev, (u8 *)&config, sizeof(config),
--
2.25.1
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v14 0/2] Firmware Support for USB-HID Devices and CP2112
2026-05-20 16:13 [PATCH v14 0/2] Firmware Support for USB-HID Devices and CP2112 Danny Kaehn
2026-05-20 16:13 ` [PATCH v14 1/2] HID: cp2112: Add fwnode support Danny Kaehn
2026-05-20 16:13 ` [PATCH v14 2/2] HID: cp2112: Configure I2C bus speed from firmware Danny Kaehn
@ 2026-06-10 15:35 ` Jiri Kosina
2026-11-05 9:01 ` Bartosz Golaszewski
3 siblings, 0 replies; 8+ messages in thread
From: Jiri Kosina @ 2026-06-10 15:35 UTC (permalink / raw)
To: Danny Kaehn
Cc: Benjamin Tissoires, Andy Shevchenko, Andi Shyti, Conor Dooley,
linux-input, Dmitry Torokhov, Ethan Twardy, linux-i2c,
linux-kernel, Leo Huang, Arun D Patil, Willie Thai,
Ting-Kai Chen, Bartosz Golaszewski
On Wed, 20 May 2026, Danny Kaehn wrote:
> This patchset allows USB-HID devices to have Firmware bindings through sharing
> the USB fwnode with the HID driver, and adds such a binding and driver
> implementation for the CP2112 USB to SMBus Bridge (which necessitated the
> USB-HID change). This change allows a CP2112 permanently attached in hardware to
> be described in DT and ACPI and interoperate with other drivers.
Applied to hid.git#for-7.2/cp2112, thanks.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v14 0/2] Firmware Support for USB-HID Devices and CP2112
2026-05-20 16:13 [PATCH v14 0/2] Firmware Support for USB-HID Devices and CP2112 Danny Kaehn
` (2 preceding siblings ...)
2026-06-10 15:35 ` [PATCH v14 0/2] Firmware Support for USB-HID Devices and CP2112 Jiri Kosina
@ 2026-11-05 9:01 ` Bartosz Golaszewski
3 siblings, 0 replies; 8+ messages in thread
From: Bartosz Golaszewski @ 2026-11-05 9:01 UTC (permalink / raw)
To: Danny Kaehn
Cc: Benjamin Tissoires, Andy Shevchenko, Andi Shyti, Conor Dooley,
Jiri Kosina, linux-input, Dmitry Torokhov, Ethan Twardy,
linux-i2c, linux-kernel, Leo Huang, Arun D Patil, Willie Thai,
Ting-Kai Chen
On Wed, May 20, 2026 at 11:13:05AM -0500, Danny Kaehn wrote:
> This patchset allows USB-HID devices to have Firmware bindings through sharing
> the USB fwnode with the HID driver, and adds such a binding and driver
> implementation for the CP2112 USB to SMBus Bridge (which necessitated the
> USB-HID change). This change allows a CP2112 permanently attached in hardware to
> be described in DT and ACPI and interoperate with other drivers.
>
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
^ permalink raw reply [flat|nested] 8+ messages in thread