Skip to content

Commit 5f3fce6

Browse files
kbidanikartben
authored andcommitted
drivers: usb: device_stm32: Update USB_DC speed macros
Updated USB_DC speed definition macros for STM32 series to handle different speed configurations based on the SoC compatibility. Added conditional checks for full-speed definitions using DT_HAS_COMPAT_STATUS_OKAY for st_stm32_usb. Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com> Signed-off-by: IBEN EL HADJ MESSAOUD Marwa <marwa.ibenelhadjmessaoud-ext@st.com>
1 parent 76969f8 commit 5f3fce6

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

drivers/usb/device/usb_dc_stm32.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,16 @@ static const struct gpio_dt_spec ulpi_reset =
9191
*/
9292
#if defined(CONFIG_SOC_SERIES_STM32H7X) || defined(USB_OTG_HS_EMB_PHYC) || \
9393
defined(USB_OTG_HS_EMB_PHY)
94-
#define HIGH_SPEED USB_OTG_SPEED_HIGH_IN_FULL
94+
#define USB_DC_STM32_HIGH_SPEED USB_OTG_SPEED_HIGH_IN_FULL
9595
#else
96-
#define HIGH_SPEED USB_OTG_SPEED_HIGH
96+
#define USB_DC_STM32_HIGH_SPEED USB_OTG_SPEED_HIGH
9797
#endif
9898

99-
#define FULL_SPEED USB_OTG_SPEED_FULL
99+
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_usb)
100+
#define USB_DC_STM32_FULL_SPEED PCD_SPEED_FULL
101+
#else
102+
#define USB_DC_STM32_FULL_SPEED USB_OTG_SPEED_FULL
103+
#endif
100104
/*
101105
* USB, USB_OTG_FS and USB_DRD_FS are defined in STM32Cube HAL and allows to
102106
* distinguish between two kind of USB DC. STM32 F0, F3, L0 and G4 series
@@ -446,7 +450,9 @@ static int usb_dc_stm32_init(void)
446450
int ret;
447451
unsigned int i;
448452

449-
usb_dc_stm32_state.pcd.Init.speed = DT_INST_STRING_UPPER_TOKEN(0, maximum_speed);
453+
usb_dc_stm32_state.pcd.Init.speed =
454+
UTIL_CAT(USB_DC_STM32_, DT_INST_STRING_UPPER_TOKEN(0, maximum_speed));
455+
450456
#if defined(USB) || defined(USB_DRD_FS)
451457
#ifdef USB
452458
usb_dc_stm32_state.pcd.Instance = USB;

0 commit comments

Comments
 (0)