diff options
author | Jonas Karlman <jonas@kwiboo.se> | 2023-07-30 22:59:56 +0000 |
---|---|---|
committer | Kever Yang <kever.yang@rock-chips.com> | 2023-07-31 14:40:38 +0800 |
commit | 6913c30516022f86104c9fbe315499e43eee4ed6 (patch) | |
tree | 4e6905d43940410e713b22fcd0a26a252225791c | |
parent | 4412a2bf0b674d7438821531a0a19bbcd4b80eda (diff) | |
download | u-boot-6913c30516022f86104c9fbe315499e43eee4ed6.zip u-boot-6913c30516022f86104c9fbe315499e43eee4ed6.tar.gz u-boot-6913c30516022f86104c9fbe315499e43eee4ed6.tar.bz2 |
usb: dwc3-generic: Relax unsupported dr_mode check
When dr_mode is peripheral or otg and U-Boot has not been built with
DM_USB_GADGET support, booting such device may end up with:
dwc3_glue_bind_common: subnode name: usb@fcc00000
Error binding driver 'dwc3-generic-wrapper': -6
Some drivers failed to bind
initcall sequence 00000000effbca08 failed at call 0000000000a217c8 (err=-6)
### ERROR ### Please RESET the board ###
Instead fail gracfully with ENODEV to allow board continue booting.
dwc3_glue_bind_common: subnode name: usb@fcc00000
dwc3_glue_bind_common: unsupported dr_mode 3
Also use CONFIG_IS_ENABLED(USB_HOST) and change switch to if statements
to improve readability of the code.
Fixes: 446e3a205b87 ("dwc3-generic: Handle the PHYs, the clocks and the reset lines")
Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Marek Vasut <marex@denx.de>
-rw-r--r-- | drivers/usb/dwc3/dwc3-generic.c | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c index 4d5d500..2331ac4 100644 --- a/drivers/usb/dwc3/dwc3-generic.c +++ b/drivers/usb/dwc3/dwc3-generic.c @@ -226,8 +226,7 @@ U_BOOT_DRIVER(dwc3_generic_peripheral) = { }; #endif -#if defined(CONFIG_SPL_USB_HOST) || \ - !defined(CONFIG_SPL_BUILD) && defined(CONFIG_USB_HOST) +#if CONFIG_IS_ENABLED(USB_HOST) static int dwc3_generic_host_probe(struct udevice *dev) { struct xhci_hcor *hcor; @@ -409,7 +408,7 @@ struct dwc3_glue_ops ti_ops = { static int dwc3_glue_bind_common(struct udevice *parent, ofnode node) { const char *name = ofnode_get_name(node); - const char *driver = NULL; + const char *driver; enum usb_dr_mode dr_mode; struct udevice *dev; int ret; @@ -421,27 +420,17 @@ static int dwc3_glue_bind_common(struct udevice *parent, ofnode node) if (!dr_mode) dr_mode = usb_get_dr_mode(node); - switch (dr_mode) { - case USB_DR_MODE_PERIPHERAL: - case USB_DR_MODE_OTG: -#if CONFIG_IS_ENABLED(DM_USB_GADGET) + 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__); driver = "dwc3-generic-peripheral"; -#endif - break; -#if defined(CONFIG_SPL_USB_HOST) || !defined(CONFIG_SPL_BUILD) - case USB_DR_MODE_HOST: + } else if (CONFIG_IS_ENABLED(USB_HOST) && dr_mode == USB_DR_MODE_HOST) { debug("%s: dr_mode: HOST\n", __func__); driver = "dwc3-generic-host"; - break; -#endif - default: - debug("%s: unsupported dr_mode\n", __func__); + } else { + debug("%s: unsupported dr_mode %d\n", __func__, dr_mode); return -ENODEV; - }; - - if (!driver) - return -ENXIO; + } ret = device_bind_driver_to_node(parent, driver, name, node, &dev); |