[PATCH] usb: dwc3-generic: use DR_MODE_OTG when dr_mode isn't specified
Caleb Connolly
caleb.connolly at linaro.org
Thu Oct 17 13:07:34 CEST 2024
On 16/10/2024 10:26, Neil Armstrong via groups.io wrote:
> The USB DRD bindingsa at [1] are clear, if not specified the dr_mode
> property defaults to otg, and this is how Linux behaves.
I guess this is (kind of?) a subset of
https://lore.kernel.org/u-boot/20240621021135.1600847-2-caleb.connolly@linaro.org/
I need to respin that one...
>
> A cleanup is ongoing on the Linux Device Trees to remove dr_mode when
> set to "otg", so take this in account and do not fail anymore when
> dr_mode isn't specified in the glue or dwc3 node.
Definitely an improvement over the status quo heh
Reviewed-by: Caleb Connolly <caleb.connolly at linaro.org>
>
> [1] https://www.kernel.org/doc/Documentation/devicetree/bindings/usb/usb-drd.yaml
>
> Signed-off-by: Neil Armstrong <neil.armstrong at linaro.org>
> ---
> drivers/usb/dwc3/dwc3-generic.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
> index 2ab41cbae45..d62d687ece3 100644
> --- a/drivers/usb/dwc3/dwc3-generic.c
> +++ b/drivers/usb/dwc3/dwc3-generic.c
> @@ -183,10 +183,10 @@ static int dwc3_generic_of_to_plat(struct udevice *dev)
> /* might be a leaf so check the parent for mode */
> 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;
> - }
> +
> + /* If none of the nodes have dr_mode, bindings says default is OTG */
> + if (!plat->dr_mode)
> + plat->dr_mode = USB_DR_MODE_OTG;
> }
>
> return 0;
> @@ -527,6 +527,10 @@ static int dwc3_glue_bind_common(struct udevice *parent, ofnode node)
> if (!dr_mode)
> dr_mode = usb_get_dr_mode(node);
>
> + /* If none of the nodes have dr_mode, bindings says default is OTG */
> + if (!dr_mode)
> + dr_mode = USB_DR_MODE_OTG;
> +
> if (CONFIG_IS_ENABLED(DM_USB_GADGET) &&
> (dr_mode == USB_DR_MODE_PERIPHERAL || dr_mode == USB_DR_MODE_OTG)) {
> debug("%s: dr_mode: OTG or Peripheral\n", __func__);
>
> ---
> base-commit: d5cab0d6adc26ec1bbd45c2fed101184d04454ae
> change-id: 20241016-topic-usb-dwc3-dr-mode-otg-88ec307e0970
>
> Best regards,
--
// Caleb (they/them)
More information about the U-Boot
mailing list