Re: [PATCH] dt-bindings: usb: usb-device: allow multiple compatibles

From: Rob Herring
Date: Tue Apr 15 2025 - 15:01:39 EST


On Tue, Apr 15, 2025 at 04:34:27PM +0200, Quentin Schulz wrote:
> From: Quentin Schulz <quentin.schulz@xxxxxxxxx>
>
> The dt-core typically allows multiple compatibles[1] but usb-device
> currently forces a single compatible.
>
> This is an issue when multiple devices with slightly different productID
> all behave the same. This would require the driver to keep updating its
> compatible matching table and the bindings to include this new productID
> instead of doing what is usually done: have two compatibles, the
> leftmost which matches exactly the HW device definition, and the
> rightmost one as a fallback which is assumed to be 100% compatible with
> the device at hand. If this assumption turns out to be wrong, it is easy
> to work around this without having to modify the device tree by handling
> the leftmost compatible in the driver.
>
> [1] https://github.com/devicetree-org/dt-schema/blob/main/dtschema/schemas/dt-core.yaml#L21-L25
>
> Signed-off-by: Quentin Schulz <quentin.schulz@xxxxxxxxx>
> ---
> This came up while working on fixing USB on an RK3399 Puma which has an
> onboard USB hub whose productID isn't in any driver compatible list
> but which can be supported by a driver with a slightly different
> productID matching another variant of the same IC, from the same
> datasheet.
>
> See https://lore.kernel.org/linux-rockchip/20250326-onboard_usb_dev-v1-0-a4b0a5d1b32c@xxxxxxxxxxxxx/
> ---
> Documentation/devicetree/bindings/usb/usb-device.yaml | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/usb/usb-device.yaml b/Documentation/devicetree/bindings/usb/usb-device.yaml
> index c676956810331b81f11f3624340fc3e612c98315..9d55be4fb5981164cca969dbda5ba70ab3a87773 100644
> --- a/Documentation/devicetree/bindings/usb/usb-device.yaml
> +++ b/Documentation/devicetree/bindings/usb/usb-device.yaml
> @@ -28,7 +28,8 @@ description: |
>
> properties:
> compatible:
> - pattern: "^usb[0-9a-f]{1,4},[0-9a-f]{1,4}$"
> + items:
> + pattern: "^usb[0-9a-f]{1,4},[0-9a-f]{1,4}$"

I would use 'contains' here rather than 'items'. That's even more
relaxed in allowing "normal" compatible strings, but is aligned with
what we have for PCI device.

Rob