Skip to content

Commit 79f2615

Browse files
tmon-nordickartben
authored andcommitted
drivers: udc_dwc2: Limit operating speed to stack configuration
Limit maximum operating speed in DCFG register if USB stack is configured to support only Full-Speed. Signed-off-by: Tomasz Moń <[email protected]>
1 parent b3eb6f2 commit 79f2615

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

drivers/usb/udc/udc_dwc2.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,15 +2041,21 @@ static int udc_dwc2_init_controller(const struct device *dev)
20412041
case USB_DWC2_GHWCFG2_HSPHYTYPE_ULPI:
20422042
gusbcfg |= USB_DWC2_GUSBCFG_PHYSEL_USB20 |
20432043
USB_DWC2_GUSBCFG_ULPI_UTMI_SEL_ULPI;
2044-
dcfg |= USB_DWC2_DCFG_DEVSPD_USBHS20
2045-
<< USB_DWC2_DCFG_DEVSPD_POS;
2044+
if (IS_ENABLED(CONFIG_UDC_DRIVER_HIGH_SPEED_SUPPORT_ENABLED)) {
2045+
dcfg |= usb_dwc2_set_dcfg_devspd(USB_DWC2_DCFG_DEVSPD_USBHS20);
2046+
} else {
2047+
dcfg |= usb_dwc2_set_dcfg_devspd(USB_DWC2_DCFG_DEVSPD_USBFS20);
2048+
}
20462049
hs_phy = true;
20472050
break;
20482051
case USB_DWC2_GHWCFG2_HSPHYTYPE_UTMIPLUS:
20492052
gusbcfg |= USB_DWC2_GUSBCFG_PHYSEL_USB20 |
20502053
USB_DWC2_GUSBCFG_ULPI_UTMI_SEL_UTMI;
2051-
dcfg |= USB_DWC2_DCFG_DEVSPD_USBHS20
2052-
<< USB_DWC2_DCFG_DEVSPD_POS;
2054+
if (IS_ENABLED(CONFIG_UDC_DRIVER_HIGH_SPEED_SUPPORT_ENABLED)) {
2055+
dcfg |= usb_dwc2_set_dcfg_devspd(USB_DWC2_DCFG_DEVSPD_USBHS20);
2056+
} else {
2057+
dcfg |= usb_dwc2_set_dcfg_devspd(USB_DWC2_DCFG_DEVSPD_USBFS20);
2058+
}
20532059
hs_phy = true;
20542060
break;
20552061
case USB_DWC2_GHWCFG2_HSPHYTYPE_NO_HS:
@@ -2060,8 +2066,7 @@ static int udc_dwc2_init_controller(const struct device *dev)
20602066
gusbcfg |= USB_DWC2_GUSBCFG_PHYSEL_USB11;
20612067
}
20622068

2063-
dcfg |= USB_DWC2_DCFG_DEVSPD_USBFS1148
2064-
<< USB_DWC2_DCFG_DEVSPD_POS;
2069+
dcfg |= usb_dwc2_set_dcfg_devspd(USB_DWC2_DCFG_DEVSPD_USBFS1148);
20652070
hs_phy = false;
20662071
}
20672072

0 commit comments

Comments
 (0)