Skip to content

Commit c7b9ca2

Browse files
committed
drivers: udc_dwc2: Add option to prefer 8-bit UTMI interface
The UDC DWC2 may support both 8- and 16-bit UTMI+ PHY interface widths. Added a Kconfig option that allows the user to prefer 8-bit interface width, if the hardware supports it. Signed-off-by: Rafał Kuźnia <[email protected]>
1 parent 4e201f2 commit c7b9ca2

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

drivers/usb/common/usb_dwc2_hw.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,9 @@ USB_DWC2_GET_FIELD_DEFINE(ghwcfg3_xfersizewidth, GHWCFG3_XFERSIZEWIDTH)
486486
#define USB_DWC2_GHWCFG4_NUMCTLEPS_MASK (0xFUL << USB_DWC2_GHWCFG4_NUMCTLEPS_POS)
487487
#define USB_DWC2_GHWCFG4_PHYDATAWIDTH_POS 14UL
488488
#define USB_DWC2_GHWCFG4_PHYDATAWIDTH_MASK (0x3UL << USB_DWC2_GHWCFG4_PHYDATAWIDTH_POS)
489+
#define USB_DWC2_GHWCFG4_PHYDATAWIDTH_8_BIT 0UL
490+
#define USB_DWC2_GHWCFG4_PHYDATAWIDTH_16_BIT 1UL
491+
#define USB_DWC2_GHWCFG4_PHYDATAWIDTH_8_16_BIT 2UL
489492
#define USB_DWC2_GHWCFG4_ENHANCEDLPMSUPT_POS 13UL
490493
#define USB_DWC2_GHWCFG4_ENHANCEDLPMSUPT BIT(USB_DWC2_GHWCFG4_ENHANCEDLPMSUPT_POS)
491494
#define USB_DWC2_GHWCFG4_ACGSUPT_POS 12UL

drivers/usb/udc/Kconfig.dwc2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,11 @@ config UDC_DWC2_USBHS_VBUS_READY_TIMEOUT
4848
UDC DWC2 USBHS VBUS ready event timeout. If the VBUS is not ready
4949
and the Nordic USBHS controller is used, the udc_enable() is
5050
blocked for this amount of time. Set it to zero to wait forever.
51+
52+
config UDC_DWC2_PREFER_8BIT_UTMI
53+
bool "Prefer 8-bit UTMI+ PHY interface width"
54+
depends on UDC_DWC2
55+
help
56+
UDC DWC2 may support both 8- and 16-bit UTMI+ PHY interface widths.
57+
Enable this config to prefer 8-bit interface. Otherwise 16-bit interface
58+
will be used.

drivers/usb/udc/udc_dwc2.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1895,7 +1895,10 @@ static int udc_dwc2_init_controller(const struct device *dev)
18951895
hs_phy = false;
18961896
}
18971897

1898-
if (usb_dwc2_get_ghwcfg4_phydatawidth(ghwcfg4)) {
1898+
if (IS_ENABLED(CONFIG_UDC_DWC2_PREFER_8BIT_UTMI) &&
1899+
usb_dwc2_get_ghwcfg4_phydatawidth(ghwcfg4) == USB_DWC2_GHWCFG4_PHYDATAWIDTH_8_16_BIT) {
1900+
LOG_DBG("Using 8-bit UTMI+");
1901+
} else if (usb_dwc2_get_ghwcfg4_phydatawidth(ghwcfg4)) {
18991902
gusbcfg |= USB_DWC2_GUSBCFG_PHYIF_16_BIT;
19001903
}
19011904

0 commit comments

Comments
 (0)