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.
This commit is contained in:
Jacob Potter 2020-10-18 16:55:14 -06:00
parent 43cb5fabfd
commit c87ed8eff1
1 changed files with 10 additions and 2 deletions

View File

@ -416,7 +416,9 @@ void dcd_init (uint8_t rhport)
if ( rhport == 1 ) if ( rhport == 1 )
{ {
// On selected MCUs HS port1 can be used with external PHY via ULPI interface // 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 // deactivate internal PHY
usb_otg->GCCFG &= ~USB_OTG_GCCFG_PWRDWN; 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 // Select default internal VBUS Indicator and Drive for ULPI
usb_otg->GUSBCFG &= ~(USB_OTG_GUSBCFG_ULPIEVBUSD | USB_OTG_GUSBCFG_ULPIEVBUSI); usb_otg->GUSBCFG &= ~(USB_OTG_GUSBCFG_ULPIEVBUSD | USB_OTG_GUSBCFG_ULPIEVBUSI);
#endif
#if defined(USB_HS_PHYC) #if defined(USB_HS_PHYC)
// Highspeed with embedded UTMI 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); 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; 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 |= USB_OTG_GINTMSK_USBRST | USB_OTG_GINTMSK_ENUMDNEM |
USB_OTG_GINTMSK_USBSUSPM | USB_OTG_GINTMSK_WUIM | USB_OTG_GINTMSK_USBSUSPM | USB_OTG_GINTMSK_WUIM |