[PATCH v2 1/2] usb: dwc3-generic: allow fallback of dr_mode property to "otg"

Marek Vasut marek.vasut at mailbox.org
Sat Jan 3 19:06:27 CET 2026


On 1/3/26 1:28 PM, Kaustabh Chakraborty wrote:
> Documentation [1] states that the default value of the dr_mode property
> is "otg". It also isn't marked a mandatory node, so it may or may not be
> set. So, accordingly if dr_mode is not mentioned in the devicetree node,
> OTG mode must be assumed.
> 
> In this driver however, this case is not handled. If dr_mode is not
> mentioned, USB_DR_MODE_UNKNOWN is set. The logic implemented raises an
> error, instead of falling back to USB_DR_MODE_OTG. Correct this to
> conform to the specification.
> 
> Link: https://elixir.bootlin.com/u-boot/v2025.10/source/dts/upstream/Bindings/usb/usb-drd.yaml#L23 [1]

Please update the link to point to git.kernel.org , that's where the DT 
bindings reside.

> Signed-off-by: Kaustabh Chakraborty <kauschluss at disroot.org>
> ---
>   drivers/usb/dwc3/dwc3-generic.c | 8 ++++++--
>   1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> index c09014aec60..1967594f48a 100644
> --- a/drivers/usb/dwc3/dwc3-generic.c
> +++ b/drivers/usb/dwc3/dwc3-generic.c
> @@ -173,8 +173,8 @@ static int dwc3_generic_of_to_plat(struct udevice *dev)
>   		node = dev_ofnode(dev->parent);
>   		plat->dr_mode = usb_get_dr_mode(node);
>   		if (plat->dr_mode == USB_DR_MODE_UNKNOWN) {
> -			pr_err("Invalid usb mode setup\n");
> -			return -ENODEV;
> +			pr_info("No USB mode specified. Using 'otg'\n");

dev_info(dev, ...

> +			plat->dr_mode = USB_DR_MODE_OTG;
>   		}
>   	}
>   
> @@ -516,6 +516,10 @@ static int dwc3_glue_bind_common(struct udevice *parent, ofnode node)
>   	if (!dr_mode)
>   		dr_mode = usb_get_dr_mode(node);
>   
> +	/* usb mode must fallback to peripheral if not known */
> +	if (dr_mode == USB_DR_MODE_UNKNOWN)
> +		dr_mode = USB_DR_MODE_OTG;
With those two fixed:

Reviewed-by: Marek Vasut <marek.vasut at mailbox.org>

Thanks


More information about the U-Boot mailing list