DeviceTree Support for USB-HID Devices and CP2112
Subsystems (3)
cover DeviceTree Support for USB-HID Devices and CP2112
This patchset allows USB-HID devices to have DeviceTree bindings through sharing the USB of_node 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 interoperate with other drivers, and exposed the threaded interrupt bug fixed in patch 0003.
Plese correct if the assumption made that there is a 1:1 correlation between a USB device and its HID device is not always true. If so, patch 0002 would then need to be reworked.
Danny Kaehn (4):
dt-bindings: hid: Add CP2112 HID USB to SMBus Bridge Share USB device devicetree node with child HID device Fix CP2112 driver not registering GPIO IRQ chip as threaded CP2112 Devicetree Support
.../bindings/hid/silabs,cp2112.yaml | 82 +++++++++++++++++++ drivers/hid/hid-cp2112.c | 10 +++ drivers/hid/usbhid/hid-core.c | 2 + 3 files changed, 94 insertions(+) create mode 100644 Documentation/devicetree/bindings/hid/silabs,cp2112.yaml
Signature · 1 line
2.25.1
PATCH 1/4 dt-bindings: hid: Add CP2112 HID USB to SMBus Bridge
This is a USB HID device which includes an I2C controller and 8 GPIO pins.
The binding allows describing the chip's gpio and i2c controller in DT using the subnodes named "gpio" and "i2c", respectively. This is intended to be used in configurations where the CP2112 is permanently connected in hardware.
--- .../bindings/hid/silabs,cp2112.yaml | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 Documentation/devicetree/bindings/hid/silabs,cp2112.yaml
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +82 -0
@@ -0,0 +1,82 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hid/silabs,cp2112.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CP2112 HID USB to SMBus/I2C Bridge + +maintainers: + - Danny Kaehn <[email protected]> + +description: + This is a USB HID device which includes an I2C controller and 8 GPIO pins. + While USB devices typically aren't described in DeviceTree, doing so with the + CP2112 allows use of its i2c and gpio controllers with other DT nodes when + the chip is expected to be found on a USB port. + +properties: + compatible: + const: usb10c4,ea90 + reg: + maxItems: 1 + description: The USB port number on the host controller + i2c: + $ref: /schemas/i2c/i2c-controller.yaml# + gpio: + $ref: /schemas/gpio/gpio.yaml# + + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + #include <dt-bindings/input/input.h> + #include <dt-bindings/interrupt-controller/irq.h> + + usb1 { + #address-cells = <1>; + #size-cells = <0>; + + usb@1 { + compatible = "usb424,2514"; + reg = <1>; + + #address-cells = <1>; + #size-cells = <0>; + + device@1 { /* CP2112 I2C Bridge */ + compatible = "usb10c4,ea90"; + reg = <1>; + + cp2112_i2c0: i2c { + #address-cells = <1>; + #size-cells = <0>; + /* Child I2C Devices can be described as normal here */ + temp@48 { + compatible = "national,lm75"; + reg = <0x48>; + }; + }; + + cp2112_gpio0: gpio { + gpio-controller; + interrupt-controller; + #gpio-cells = <2>; + gpio-line-names = + "TEST0", + "TEST1", + "TEST2", + "TEST3", + "TEST4", + "TEST5", + "TEST6", + "TEST7"; + }; + }; + }; + };
Signature · 1 line
2.25.1
Re: [PATCH 1/4] dt-bindings: hid: Add CP2112 HID USB to SMBus Bridge
Quoted 2 lines · Danny Kaehn
This is a USB HID device which includes an I2C controller and 8 GPIO pins.
Thank you for your patch. There is something to discuss/improve.
Quoted 8 lines
The binding allows describing the chip's gpio and i2c controller in DT using the subnodes named "gpio" and "i2c", respectively. This is intended to be used in configurations where the CP2112 is permanently connected in hardware.
Signed-off-by Danny Kaehn <[email protected]>--- .../bindings/hid/silabs,cp2112.yaml | 82 +++++++++++++++++++
There is no "hid" directory, so I think such devices where going to different place, didn't they?
Quoted 12 lines
1 file changed, 82 insertions(+) create mode 100644 Documentation/devicetree/bindings/hid/silabs,cp2112.yamlDocumentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +3
-0@@ -0,0 +1,82 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +---
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 13
Quoted 10 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +10
-0+$id: http://devicetree.org/schemas/hid/silabs,cp2112.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CP2112 HID USB to SMBus/I2C Bridge + +maintainers: + - Danny Kaehn <[email protected]> + +description: + This is a USB HID device which includes an I2C controller and 8 GPIO pins.
s/This is/CP2112 is/
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 16
Quoted 3 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +3
-0+ While USB devices typically aren't described in DeviceTree, doing so with the + CP2112 allows use of its i2c and gpio controllers with other DT nodes when + the chip is expected to be found on a USB port.
Drop these three and replace with description of the hardware.
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 20
Quoted 4 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +4
-0+ +properties: + compatible: + const: usb10c4,ea90
So this is an USB device, so I guess they all go to usb?
Missing blank line.
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 23
Quoted 3 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +3
-0+ reg: + maxItems: 1 + description: The USB port number on the host controller
Blank line
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 25
Quoted 2 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +2
-0+ i2c: + $ref: /schemas/i2c/i2c-controller.yaml#
This is not specific enough. What controller is there?
Missing unevaluatedProperties: false, anyway.
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 27
Quoted 2 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +2
-0+ gpio: + $ref: /schemas/gpio/gpio.yaml#
Same comments.
Quoted 6 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +6
-0+ + +required: + - compatible + - reg +
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 43
Quoted 10 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +10
-0+additionalProperties: false + +examples: + - | + #include <dt-bindings/input/input.h> + #include <dt-bindings/interrupt-controller/irq.h> + + usb1 { + #address-cells = <1>; + #size-cells = <0>;
Drop, not related.
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 56
Quoted 13 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +13
-0+ + usb@1 { + compatible = "usb424,2514"; + reg = <1>; + + #address-cells = <1>; + #size-cells = <0>; + + device@1 { /* CP2112 I2C Bridge */ + compatible = "usb10c4,ea90"; + reg = <1>; + + cp2112_i2c0: i2c {
Drop unneeded labels.
Quoted 16 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +16
-0+ #address-cells = <1>; + #size-cells = <0>; + /* Child I2C Devices can be described as normal here */ + temp@48 { + compatible = "national,lm75"; + reg = <0x48>; + }; + }; + + cp2112_gpio0: gpio { + gpio-controller; + interrupt-controller; + #gpio-cells = <2>; + gpio-line-names = + "TEST0", + "TEST1",
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 82
Quoted 10 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +10
-0+ "TEST2", + "TEST3", + "TEST4", + "TEST5", + "TEST6", + "TEST7"; + }; + }; + }; + };
Best regards,
Krzysztof
Re: [PATCH 1/4] dt-bindings: hid: Add CP2112 HID USB to SMBus Bridge
Quoted 61 lines · Krzysztof Kozlowski
Quoted 2 lines · Danny Kaehn
This is a USB HID device which includes an I2C controller and 8 GPIO pins.
Thank you for your patch. There is something to discuss/improve.
Quoted 8 lines
The binding allows describing the chip's gpio and i2c controller in DT using the subnodes named "gpio" and "i2c", respectively. This is intended to be used in configurations where the CP2112 is permanently connected in hardware.
Signed-off-by Danny Kaehn <[email protected]>--- .../bindings/hid/silabs,cp2112.yaml | 82 +++++++++++++++++++There is no "hid" directory, so I think such devices where going to different place, didn't they?
Quoted 12 lines
1 file changed, 82 insertions(+) create mode 100644 Documentation/devicetree/bindings/hid/silabs,cp2112.yamlDocumentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +3
-0@@ -0,0 +1,82 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +---Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 13
Quoted 10 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +10
-0+$id: http://devicetree.org/schemas/hid/silabs,cp2112.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: CP2112 HID USB to SMBus/I2C Bridge + +maintainers: + - Danny Kaehn <[email protected]> + +description: + This is a USB HID device which includes an I2C controller and 8 GPIO pins.s/This is/CP2112 is/
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 16
Quoted 3 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +3
-0+ While USB devices typically aren't described in DeviceTree, doing so with the + CP2112 allows use of its i2c and gpio controllers with other DT nodes when + the chip is expected to be found on a USB port.Drop these three and replace with description of the hardware.
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 20
Quoted 4 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +4
-0+ +properties: + compatible: + const: usb10c4,ea90So this is an USB device, so I guess they all go to usb?
Missing blank line.
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 23
Quoted 3 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +3
-0+ reg: + maxItems: 1 + description: The USB port number on the host controller
Quoted 6 lines
Blank line
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 25
Quoted 2 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +2
-0+ i2c: + $ref: /schemas/i2c/i2c-controller.yaml#This is not specific enough. What controller is there?
OK, assuming this is tightly wired (with cp2112 I2C controller), then the compatible could be skipped as it is inferred from parent one. Yet still you need description and unevaluatedProperties.
Quoted 7 lines
Missing unevaluatedProperties: false, anyway.
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 27
Quoted 2 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +2
-0+ gpio: + $ref: /schemas/gpio/gpio.yaml#Same comments.
Description, unevaluatedProperties and constraints on properties (line names, reserved ranges, ranges).
Quoted 20 lines
Quoted 7 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +6
-0+ + +required: + - compatible + - reg +Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 43
Quoted 10 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +10
-0+additionalProperties: false + +examples: + - | + #include <dt-bindings/input/input.h> + #include <dt-bindings/interrupt-controller/irq.h> + + usb1 { + #address-cells = <1>; + #size-cells = <0>;Drop, not related.
Quoted 19 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 56
Quoted 13 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +13
-0+ + usb@1 { + compatible = "usb424,2514"; + reg = <1>; + + #address-cells = <1>; + #size-cells = <0>; + + device@1 { /* CP2112 I2C Bridge */ + compatible = "usb10c4,ea90"; + reg = <1>; + + cp2112_i2c0: i2c {Drop unneeded labels.
Quoted 3 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +3
-0+ #address-cells = <1>; + #size-cells = <0>; + /* Child I2C Devices can be described as normal here */
Drop also this comment.
Best regards,
Krzysztof
Re: [PATCH 1/4] dt-bindings: hid: Add CP2112 HID USB to SMBus Bridge
Thanks for all of the comments. All feedback is ACK'd and will be added in v2 -- what follows is just commentary on some comments.
Quoted 12 lines · Krzysztof Kozlowski
Quoted 10 lines · Krzysztof Kozlowski
Quoted 2 lines · Danny Kaehn
This is a USB HID device which includes an I2C controller and 8 GPIO pins.
Thank you for your patch. There is something to discuss/improve.
Quoted 5 lines
The binding allows describing the chip's gpio and i2c controller in DT using the subnodes named "gpio" and "i2c", respectively. This is intended to be used in configurations where the CP2112 is permanently connected in hardware.
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Signed-off-by Danny Kaehn <[email protected]>--- .../bindings/hid/silabs,cp2112.yaml | 82 +++++++++++++++++++There is no "hid" directory, so I think such devices where going to different place, didn't they?
Good point, I didn't notice other hid-related bindings went into input/ -- will change
Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 16
Quoted 4 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +3
-0+ While USB devices typically aren't described in DeviceTree, doing so with the + CP2112 allows use of its i2c and gpio controllers with other DT nodes when + the chip is expected to be found on a USB port.Drop these three and replace with description of the hardware.
Understood. I noticed that a similar usb-based binding included a similar description (net/marvell,mvusb.yaml) but I understand why we would not want this in new bindings.
Quoted 10 lines
Quoted 5 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 25
Quoted 3 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +2
-0+ i2c: + $ref: /schemas/i2c/i2c-controller.yaml#This is not specific enough. What controller is there?
OK, assuming this is tightly wired (with cp2112 I2C controller), then the compatible could be skipped as it is inferred from parent one. Yet still you need description and unevaluatedProperties.
Great point, will update -- I didn't quite understand that child nodes of the root could have properties/unevaluatedProperties/etc.. but I see now that that is well-documented (just not often done in existing bindings)!
Quoted 11 lines
Quoted 7 lines
Missing unevaluatedProperties: false, anyway.
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml line 27
Quoted 2 lines
Documentation/devicetree/bindings/hid/silabs,cp2112.yaml new file +2
-0+ gpio: + $ref: /schemas/gpio/gpio.yaml#Same comments.
Description, unevaluatedProperties and constraints on properties (line names, reserved ranges, ranges).
Will add.
Thanks,
Danny Kaehn
PATCH 2/4 Share USB device devicetree node with child HID device
In reply to Danny KaehnUSB HID core now shares its devicetree of_node with its child HID device. Since there can only be one HID device on a USB interface, it is redundant to specify a hid node under the USB device (and further, binding this way isn't currently possible, as hid_driver does not support of_match_table).
--- drivers/hid/usbhid/hid-core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/hid/usbhid/hid-core.c +2 -0
@@ -33,6 +33,7 @@#include <linux/hiddev.h> #include <linux/hid-debug.h> #include <linux/hidraw.h> +#include <linux/device.h> #include "usbhid.h" /*
@@ -1369,6 +1370,7 @@ static int usbhid_probe(struct usb_interface *intf, const struct usb_device_id * hid->hiddev_report_event = hiddev_report_event;#endif hid->dev.parent = &intf->dev; +device_set_of_node_from_dev (&hid->dev, &intf->dev); hid->bus =BUS_USB ; hid->vendor =le16_to_cpu (dev->descriptor.idVendor); hid->product =le16_to_cpu (dev->descriptor.idProduct);
Signature · 1 line
2.25.1
Re: [PATCH 2/4] Share USB device devicetree node with child HID device
Quoted 5 lines · Danny Kaehn
USB HID core now shares its devicetree
of_nodewith its child HID device. Since there can only be one HID device on a USB interface, it is redundant to specify a hid node under the USB device (and further, binding this way isn't currently possible, ashid_driverdoes not supportof_match_table).
Here and in other patches:
Use subject prefixes matching the subsystem (which you can get for example with git log --oneline -- DIRECTORY_OR_FILE on the directory your patch is touching).
Best regards,
Krzysztof
PATCH 3/4 Fix CP2112 driver not registering GPIO IRQ chip as threaded
In reply to Danny KaehnThe CP2112 generates interrupts from a polling routine on a thread, and can only support threaded interrupts. This patch configures the gpiochip irq chip with this flag, disallowing consumers to request a hard IRQ from this driver, which resulted in a segfault previously.
--- drivers/hid/hid-cp2112.c | 1 + 1 file changed, 1 insertion(+)
drivers/hid/hid-cp2112.c +1 -0
@@ -1354,6 +1354,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) girq->parents =NULL ; girq->default_type =IRQ_TYPE_NONE ; girq->handler = handle_simple_irq; + girq->threaded = true; ret =gpiochip_add_data (&dev->gc, dev);if (ret <0 ) {
Signature · 1 line
2.25.1
PATCH 4/4 CP2112 Devicetree Support
In reply to Danny KaehnBind i2c and gpio interfaces to subnodes with names "i2c" and "gpio" if they exist, respectively. This allows the gpio and i2c controllers to be described in DT as usual.
--- drivers/hid/hid-cp2112.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/hid/hid-cp2112.c +9 -0
@@ -1310,6 +1310,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) dev->adap.algo = &smbus_algorithm; dev->adap.algo_data = dev; dev->adap.dev.parent = &hdev->dev; + dev->adap.dev.of_node =of_get_child_by_name (hdev->dev.of_node,"i2c" );snprintf (dev->adap.name,sizeof (dev->adap.name),"CP2112 SMBus Bridge on hidraw%d" , ((struct hidraw *)hdev->hidraw)->minor);
@@ -1336,6 +1337,9 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) dev->gc.ngpio =8 ; dev->gc.can_sleep =1 ; dev->gc.parent = &hdev->dev; +#if defined(CONFIG_OF_GPIO ) + dev->gc.of_node =of_get_child_by_name (hdev->dev.of_node,"gpio" ); +#endif dev->irq.name ="cp2112-gpio" ; dev->irq.irq_startup = cp2112_gpio_irq_startup;
@@ -1391,6 +1395,11 @@ static void cp2112_remove(struct hid_device *hdev)struct cp2112_device *dev =hid_get_drvdata (hdev);int i; +of_node_put (dev->adap.dev.of_node); +#if defined(CONFIG_OF_GPIO ) +of_node_put (dev->gc.of_node); +#endif +sysfs_remove_group (&hdev->dev.kobj, &cp2112_attr_group);i2c_del_adapter (&dev->adap);
Signature · 1 line
2.25.1
Re: [PATCH 4/4] CP2112 Devicetree Support
Quoted 23 lines · Danny Kaehn
Bind i2c and gpio interfaces to subnodes with names "i2c" and "gpio" if they exist, respectively. This allows the gpio and i2c controllers to be described in DT as usual.
Signed-off-by Danny Kaehn <[email protected]>--- drivers/hid/hid-cp2112.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/hid/hid-cp2112.c +1
-0@@ -1310,6 +1310,7 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) dev->adap.algo = &smbus_algorithm; dev->adap.algo_data = dev; dev->adap.dev.parent = &hdev->dev; + dev->adap.dev.of_node =of_get_child_by_name (hdev->dev.of_node,"i2c" );snprintf (dev->adap.name,sizeof (dev->adap.name),"CP2112 SMBus Bridge on hidraw%d" , ((struct hidraw *)hdev->hidraw)->minor);
drivers/hid/hid-cp2112.c static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) · line 1340
Quoted 4 lines
drivers/hid/hid-cp2112.c +1
-0@@ -1336,6 +1337,9 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) dev->gc.ngpio =8 ; dev->gc.can_sleep =1 ; dev->gc.parent = &hdev->dev; +#if defined(CONFIG_OF_GPIO )
Don't use #if, but IS_ENABLED(). I think it should work here.
drivers/hid/hid-cp2112.c static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id) · line 1341
Quoted 1 line
drivers/hid/hid-cp2112.c +1
-0+ dev->gc.of_node =of_get_child_by_name (hdev->dev.of_node,"gpio" );
You leak it now on error paths.
Best regards,
Krzysztof
Re: [PATCH 4/4] CP2112 Devicetree Support
Quoted 5 lines · Krzysztof Kozlowski
Quoted 1 line · Danny Kaehn
+#if
defined(CONFIG_OF_GPIO)Don't use #if, but
IS_ENABLED(). I think it should work here.
I think I will still need to use an #if / some sort of preprocessor directive, since of_node is only a member of the gpio_chip struct if that is enabled (and thus causes a compile error if done outside of the preprocessor)... Unless I'm misinterpreting your comment?
Quoted 4 lines
Quoted 2 lines
+
dev->gc.of_node=of_get_child_by_name(hdev->dev.of_node, "gpio");You leak it now on error paths.
Ah, good point. Will fix!
Thanks,
Danny Kaehn
Re: [PATCH 4/4] CP2112 Devicetree Support
Quoted 4 lines · Daniel Kaehn
Quoted 2 lines · Krzysztof Kozlowski
On 28/01/2023 21:26, Danny Kaehn wrote:
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
+#if
defined(CONFIG_OF_GPIO)Don't use #if, but
IS_ENABLED(). I think it should work here.I think I will still need to use an #if / some sort of preprocessor directive, since
of_nodeis only a member of thegpio_chipstruct if that is enabled (and thus causes a compile error if done outside of the preprocessor)... Unless I'm misinterpreting your comment?
If of_node in gpio_chip is indeed hidden by #ifdef, then the code is ok.
Best regards,
Krzysztof
Hi Danny,
Quoted 7 lines · Danny Kaehn
This patchset allows USB-HID devices to have DeviceTree bindings through sharing the USB
of_nodewith 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 interoperate with other drivers, and exposed the threaded interrupt bug fixed in patch 0003.
That series is very interesting. I always wondered how I could declare an I2C device attached to the CP2112 over USB. Ideally if you can make this compatible with ACPI SSDT, that would be even better :) (one can always dream).
Quoted 4 lines
Plese correct if the assumption made that there is a 1:1 correlation between a USB device and its HID device is not always true. If so, patch 0002 would then need to be reworked.
I am not sure I understand patch 2 completely, but if your assumption is that each struct usb_interface can have at most one hid device, it seems that it is the case. However, nothing prevents another hid driver to add one more hid device on top of that USB dev. For instance, hid-logitech-dj does that: when it enumerates the devices connected to the wireless receiver, it creates matching HID devices with the parent being the current HID dev.
AFAICT, we already have DT enumeration for i2c-hid devices, so probably your solution is correct. Though the DT enumeration in i2c-hid-of.c relies on .of_match_table, which seems a little bit more integrated than this series (but I don't know enough of DT unfortunately).
So I personally won't push against that series, but I'd still like to have a rough idea on what is missing in patch 2 if we consider that your assumption might not always be the case.
Maybe (just random brain fart) we could have a separate usbhid-of.c in the usbhid subdir that builds up the same OF matching that i2c-hid-of.c is doing?
Cheers,
Benjamin
Quoted 17 lines
Danny Kaehn (4):
dt-bindings: hid: Add CP2112 HID USB to SMBus Bridge Share USB device devicetree node with child HID device Fix CP2112 driver not registering GPIO IRQ chip as threaded CP2112 Devicetree Support.../bindings/hid/silabs,cp2112.yaml | 82 +++++++++++++++++++ drivers/hid/hid-cp2112.c | 10 +++ drivers/hid/usbhid/hid-core.c | 2 + 3 files changed, 94 insertions(+) create mode 100644 Documentation/devicetree/bindings/hid/silabs,cp2112.yaml--
2.25.1