STM32/OTG_HS: Allow OTG_HS port to run at FS speed.

Add "REDUCE_SPEED=1" to the compile options.
This commit is contained in:
Uwe Bonnes 2020-07-01 23:07:18 +02:00
parent 4cec866994
commit fd38178189
6 changed files with 47 additions and 15 deletions

View File

@ -1,3 +1,6 @@
PORT ?= 1
REDUCE_SPEED ?= 0
CFLAGS += \ CFLAGS += \
-flto \ -flto \
-mthumb \ -mthumb \
@ -9,8 +12,19 @@ CFLAGS += \
-DSTM32F723xx \ -DSTM32F723xx \
-DHSE_VALUE=25000000 \ -DHSE_VALUE=25000000 \
-DCFG_TUSB_MCU=OPT_MCU_STM32F7 \ -DCFG_TUSB_MCU=OPT_MCU_STM32F7 \
-DBOARD_DEVICE_RHPORT_NUM=1 \ -DBOARD_DEVICE_RHPORT_NUM=$(PORT)
-DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_HIGH_SPEED
ifeq ($(PORT), 1)
ifeq ($(REDUCE_SPEED), 0)
CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_HIGH_SPEED
$(info "Using OTG_HS in HS mode")
else
CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_FULL_SPEED
$(info "Using OTG_HS in FS mode")
endif
else
$(info "Using OTG_FS")
endif
# mcu driver cause following warnings # mcu driver cause following warnings
CFLAGS += -Wno-error=shadow -Wno-error=cast-align CFLAGS += -Wno-error=shadow -Wno-error=cast-align

View File

@ -1,5 +1,5 @@
# Default is Highspeed port
PORT ?= 1 PORT ?= 1
REDUCE_SPEED ?= 0
CFLAGS += \ CFLAGS += \
-flto \ -flto \
@ -15,10 +15,15 @@ CFLAGS += \
-DBOARD_DEVICE_RHPORT_NUM=$(PORT) -DBOARD_DEVICE_RHPORT_NUM=$(PORT)
ifeq ($(PORT), 1) ifeq ($(PORT), 1)
CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_HIGH_SPEED ifeq ($(REDUCE_SPEED), 0)
$(info "PORT1 High Speed") CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_HIGH_SPEED
$(info "Using OTG_HS in HS mode")
else
CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_FULL_SPEED
$(info "Using OTG_HS in FS mode")
endif
else else
$(info "PORT0 Full Speed") $(info "Using OTG_FS")
endif endif
# mcu driver cause following warnings # mcu driver cause following warnings

View File

@ -1,4 +1,5 @@
PORT ?= 0 PORT ?= 0
REDUCE_SPEED ?= 0
CFLAGS += \ CFLAGS += \
-flto \ -flto \
@ -14,10 +15,15 @@ CFLAGS += \
-DBOARD_DEVICE_RHPORT_NUM=$(PORT) -DBOARD_DEVICE_RHPORT_NUM=$(PORT)
ifeq ($(PORT), 1) ifeq ($(PORT), 1)
ifeq ($(REDUCE_SPEED), 0)
CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_HIGH_SPEED CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_HIGH_SPEED
$(info "PORT1 HS") $(info "Using OTG_HS in HS mode")
else
CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_FULL_SPEED
$(info "Using OTG_HS in FS mode")
endif
else else
$(info "PORT0") $(info "Using OTG_FS")
endif endif
# mcu driver cause following warnings # mcu driver cause following warnings

View File

@ -1,3 +1,5 @@
REDUCE_SPEED ?= 0
CFLAGS += \ CFLAGS += \
-flto \ -flto \
-mthumb \ -mthumb \
@ -10,7 +12,14 @@ CFLAGS += \
-DHSE_VALUE=25000000 \ -DHSE_VALUE=25000000 \
-DCFG_TUSB_MCU=OPT_MCU_STM32F7 \ -DCFG_TUSB_MCU=OPT_MCU_STM32F7 \
-DBOARD_DEVICE_RHPORT_NUM=1 \ -DBOARD_DEVICE_RHPORT_NUM=1 \
-DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_HIGH_SPEED
ifeq ($(REDUCE_SPEED), 0)
CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_HIGH_SPEED
$(info "Using OTG_HS in HS mode")
else
CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_FULL_SPEED
$(info "Using OTG_HS in FS mode")
endif
# suppress warning caused by vendor mcu driver # suppress warning caused by vendor mcu driver
CFLAGS += -Wno-error=cast-align -Wno-error=shadow CFLAGS += -Wno-error=cast-align -Wno-error=shadow

@ -1 +1 @@
Subproject commit a5397bea558fb4b6838081a22d1ee679289d7417 Subproject commit 281cc2e178fd9a470d844b3afdea9eb322a0b0e8

View File

@ -312,7 +312,8 @@ static void set_speed(uint8_t rhport, tusb_speed_t speed)
dev->DCFG |= (bitvalue << USB_OTG_DCFG_DSPD_Pos); dev->DCFG |= (bitvalue << USB_OTG_DCFG_DSPD_Pos);
} }
#if defined(USB_HS_PHYC) && TUD_OPT_HIGH_SPEED
#if defined(USB_HS_PHYC)
static bool USB_HS_PHYCInit(void) static bool USB_HS_PHYCInit(void)
{ {
USB_HS_PHYC_GlobalTypeDef *usb_hs_phyc = (USB_HS_PHYC_GlobalTypeDef*) USB_HS_PHYC_CONTROLLER_BASE; USB_HS_PHYC_GlobalTypeDef *usb_hs_phyc = (USB_HS_PHYC_GlobalTypeDef*) USB_HS_PHYC_CONTROLLER_BASE;
@ -398,7 +399,6 @@ void dcd_init (uint8_t rhport)
USB_OTG_GlobalTypeDef * usb_otg = GLOBAL_BASE(rhport); USB_OTG_GlobalTypeDef * usb_otg = GLOBAL_BASE(rhport);
// No HNP/SRP (no OTG support), program timeout later. // No HNP/SRP (no OTG support), program timeout later.
#if TUD_OPT_HIGH_SPEED // TODO may pass parameter instead of using macro for HighSpeed
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
@ -421,10 +421,8 @@ void dcd_init (uint8_t rhport)
// Enables control of a High Speed USB PHY // Enables control of a High Speed USB PHY
USB_HS_PHYCInit(); USB_HS_PHYCInit();
#endif
}
else
#endif #endif
} else
{ {
// Enable internal PHY // Enable internal PHY
usb_otg->GUSBCFG |= USB_OTG_GUSBCFG_PHYSEL; usb_otg->GUSBCFG |= USB_OTG_GUSBCFG_PHYSEL;