[PATCH v2 07/10] usb: dwc3: generic: add board_usb_init/cleanup hooks
Peng Fan (OSS)
peng.fan at oss.nxp.com
Sun Jun 21 04:06:43 CEST 2026
From: Ye Li <ye.li at nxp.com>
Call board_usb_init() during dwc3_generic_probe() and
board_usb_cleanup() during dwc3_generic_remove() to allow
board-level USB configuration (e.g. Type-C CC role, SS mux,
VBUS control) before DWC3 core initialization.
Signed-off-by: Ye Li <ye.li at nxp.com>
Signed-off-by: Peng Fan <peng.fan at nxp.com>
---
drivers/usb/dwc3/dwc3-generic.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 2356b3bc0aa..2c6f8e6d8ba 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -9,6 +9,7 @@
#include <dm.h>
#include <reset.h>
+#include <usb.h>
#include <asm/gpio.h>
#include <dm/device_compat.h>
#include <dm/lists.h>
@@ -118,6 +119,11 @@ static int dwc3_generic_probe(struct udevice *dev,
if (device_is_compatible(dev->parent, "rockchip,rk3399-dwc3"))
reset_deassert_bulk(&glue->resets);
+ if (mode == USB_DR_MODE_HOST)
+ board_usb_init(dev_seq(dev), USB_INIT_HOST);
+ else if (mode == USB_DR_MODE_PERIPHERAL)
+ board_usb_init(dev_seq(dev), USB_INIT_DEVICE);
+
priv->base = map_physmem(plat->base, DWC3_OTG_REGS_END, MAP_NOCACHE);
dwc3->regs = priv->base + DWC3_GLOBALS_REGS_START;
@@ -134,6 +140,7 @@ static int dwc3_generic_remove(struct udevice *dev,
struct dwc3_generic_priv *priv)
{
struct dwc3 *dwc3 = &priv->dwc3;
+ enum usb_dr_mode mode = dwc3->dr_mode;
if (CONFIG_IS_ENABLED(DM_GPIO) &&
device_is_compatible(dev->parent, "xlnx,zynqmp-dwc3") &&
@@ -147,6 +154,11 @@ static int dwc3_generic_remove(struct udevice *dev,
dwc3_shutdown_phy(dev, &priv->phys);
unmap_physmem(dwc3->regs, MAP_NOCACHE);
+ if (mode == USB_DR_MODE_HOST)
+ board_usb_cleanup(dev_seq(dev), USB_INIT_HOST);
+ else if (mode == USB_DR_MODE_PERIPHERAL)
+ board_usb_cleanup(dev_seq(dev), USB_INIT_DEVICE);
+
return 0;
}
--
2.51.0
More information about the U-Boot
mailing list