From c87ed8eff1ac1305f69dd83144890f5a6f752a6f Mon Sep 17 00:00:00 2001 From: Jacob Potter Date: Sun, 18 Oct 2020 16:55:14 -0600 Subject: [PATCH] Allow use of internal FS PHY on OTG_HS interface Some ST parts (like STM32F74xxx / STM32F75xxx) allow the USB_OTG_HS core to be used with either an external high-speed ULPI PHY or an internal full-speed-only (12mbps) PHY. Currently the code assumes than an ULPI PHY is used unless the chip has an internal high-speed PHY (`#if defined(USB_HS_PHYC)`), with no provision to use the internal FS PHY. --- src/portable/st/synopsys/dcd_synopsys.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/portable/st/synopsys/dcd_synopsys.c b/src/portable/st/synopsys/dcd_synopsys.c index ca306ff8..11678857 100644 --- a/src/portable/st/synopsys/dcd_synopsys.c +++ b/src/portable/st/synopsys/dcd_synopsys.c @@ -416,7 +416,9 @@ void dcd_init (uint8_t rhport) if ( rhport == 1 ) { // On selected MCUs HS port1 can be used with external PHY via ULPI interface - +#if defined(TUD_OPT_SYNOPSYS_FS_PHY) + usb_otg->GUSBCFG |= USB_OTG_GUSBCFG_PHYSEL; +#else // deactivate internal PHY usb_otg->GCCFG &= ~USB_OTG_GCCFG_PWRDWN; @@ -425,6 +427,7 @@ void dcd_init (uint8_t rhport) // Select default internal VBUS Indicator and Drive for ULPI usb_otg->GUSBCFG &= ~(USB_OTG_GUSBCFG_ULPIEVBUSD | USB_OTG_GUSBCFG_ULPIEVBUSI); +#endif #if defined(USB_HS_PHYC) // Highspeed with embedded UTMI PHYC @@ -467,8 +470,13 @@ void dcd_init (uint8_t rhport) set_speed(rhport, TUD_OPT_HIGH_SPEED ? TUSB_SPEED_HIGH : TUSB_SPEED_FULL); - // Enable internal USB transceiver. + // Enable internal USB transceiver. Unconditional if using FS PHY on HS core. +#if defined(TUD_OPT_SYNOPSYS_FS_PHY) + usb_otg->GCCFG |= USB_OTG_GCCFG_PWRDWN; +#else if ( rhport == 0 ) usb_otg->GCCFG |= USB_OTG_GCCFG_PWRDWN; +#endif + usb_otg->GINTMSK |= USB_OTG_GINTMSK_USBRST | USB_OTG_GINTMSK_ENUMDNEM | USB_OTG_GINTMSK_USBSUSPM | USB_OTG_GINTMSK_WUIM |