From 5dd2756b149c19032d310584249de6edfbd65907 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Thu, 8 Jan 2026 00:32:48 +0000 Subject: [PATCH] usb-designware: allow setting FDMOD bit to force device mode If the PHY doesn't correctly report the ID pin state, then the DWC2 core may operate in host mode by default. Defining USB_DW_FORCE_DEVICE_MODE in the target config will set the FDMOD bit in the GUSBCFG register to force the core into device mode regardless of what the PHY reports. Change-Id: If2391aaa4a7c65ba6c90dd56074faeb3ed1ac2ca --- firmware/drivers/usb-designware.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/firmware/drivers/usb-designware.c b/firmware/drivers/usb-designware.c index d892b91efb..7078a571ac 100644 --- a/firmware/drivers/usb-designware.c +++ b/firmware/drivers/usb-designware.c @@ -87,6 +87,12 @@ #define USB_DW_TOUTCAL 0 #endif +#ifdef USB_DW_FORCE_DEVICE_MODE +#define USB_DW_FORCED_MODE FDMOD +#else +#define USB_DW_FORCED_MODE 0 +#endif + #define GET_DTXFNUM(ep) ((DWC_DIEPCTL(ep)>>22) & 0xf) #define USB_DW_NUM_DIRS 2 @@ -1417,7 +1423,7 @@ static void usb_dw_init(void) */ int USB_DW_TURNAROUND = (c->phytype == DWC_PHYTYPE_UTMI_16) ? 5 : 9; #endif - uint32_t gusbcfg = c->phytype|TRDT(USB_DW_TURNAROUND)|USB_DW_TOUTCAL; + uint32_t gusbcfg = c->phytype|TRDT(USB_DW_TURNAROUND)|USB_DW_TOUTCAL|USB_DW_FORCED_MODE; DWC_GUSBCFG = gusbcfg; /* Reset the whole USB core */