Просмотр исходного кода

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

Add "REDUCE_SPEED=1" to the compile options.
Uwe Bonnes 5 лет назад
Родитель
Сommit
fd38178189

+ 16 - 2
hw/bsp/stlinkv3mini/board.mk

@@ -1,3 +1,6 @@
+PORT ?= 1
+REDUCE_SPEED ?= 0
+
 CFLAGS += \
   -flto \
   -mthumb \
@@ -9,8 +12,19 @@ CFLAGS += \
   -DSTM32F723xx \
   -DHSE_VALUE=25000000 \
   -DCFG_TUSB_MCU=OPT_MCU_STM32F7 \
-  -DBOARD_DEVICE_RHPORT_NUM=1 \
-  -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_HIGH_SPEED
+  -DBOARD_DEVICE_RHPORT_NUM=$(PORT)
+
+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
 CFLAGS += -Wno-error=shadow -Wno-error=cast-align

+ 9 - 4
hw/bsp/stm32f723disco/board.mk

@@ -1,5 +1,5 @@
-# Default is Highspeed port
 PORT ?= 1
+REDUCE_SPEED ?= 0
 
 CFLAGS += \
   -flto \
@@ -15,10 +15,15 @@ CFLAGS += \
   -DBOARD_DEVICE_RHPORT_NUM=$(PORT)
 
 ifeq ($(PORT), 1)
-  CFLAGS += -DBOARD_DEVICE_RHPORT_SPEED=OPT_MODE_HIGH_SPEED
-  $(info "PORT1 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
 else
-  $(info "PORT0 Full Speed")
+$(info "Using OTG_FS")
 endif
 
 # mcu driver cause following warnings

+ 8 - 2
hw/bsp/stm32f746disco/board.mk

@@ -1,4 +1,5 @@
 PORT ?= 0
+REDUCE_SPEED ?= 0
 
 CFLAGS += \
   -flto \
@@ -14,10 +15,15 @@ CFLAGS += \
   -DBOARD_DEVICE_RHPORT_NUM=$(PORT)
 
 ifeq ($(PORT), 1)
+ ifeq ($(REDUCE_SPEED), 0)
 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
-$(info "PORT0")
+$(info "Using OTG_FS")
 endif
 
 # mcu driver cause following warnings

+ 10 - 1
hw/bsp/stm32f769disco/board.mk

@@ -1,3 +1,5 @@
+REDUCE_SPEED ?= 0
+
 CFLAGS += \
   -flto \
   -mthumb \
@@ -10,7 +12,14 @@ CFLAGS += \
   -DHSE_VALUE=25000000 \
   -DCFG_TUSB_MCU=OPT_MCU_STM32F7 \
   -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
 CFLAGS += -Wno-error=cast-align -Wno-error=shadow

+ 1 - 1
hw/mcu/nordic/nrfx

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

+ 3 - 5
src/portable/st/synopsys/dcd_synopsys.c

@@ -312,7 +312,8 @@ static void set_speed(uint8_t rhport, tusb_speed_t speed)
   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)
 {
   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);
 
   // 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 )
   {
     // 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
     USB_HS_PHYCInit();
-    #endif
-  }
-  else
 #endif
+  } else
   {
     // Enable internal PHY
     usb_otg->GUSBCFG |= USB_OTG_GUSBCFG_PHYSEL;