drivers: usb: Enhance USB and UDC drivers for STM32 OTG configurations
- Unified the handling of USB OTG HS and USB OTG FS by removing redundant preprocessor conditionals. - Introduced a new macro `UDC_STM32_BASE_ADDRESS` to dynamically set the USB base address. Signed-off-by: IBEN EL HADJ MESSAOUD Marwa <marwa.ibenelhadjmessaoud-ext@st.com>
This commit is contained in:
parent
6f005fdf7d
commit
1844e98d96
2 changed files with 10 additions and 17 deletions
|
@ -476,11 +476,7 @@ static int usb_dc_stm32_init(void)
|
|||
usb_dc_stm32_state.pcd.Init.ep0_mps = PCD_EP0MPS_64;
|
||||
usb_dc_stm32_state.pcd.Init.low_power_enable = 0;
|
||||
#else /* USB_OTG_FS || USB_OTG_HS */
|
||||
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_otghs)
|
||||
usb_dc_stm32_state.pcd.Instance = USB_OTG_HS;
|
||||
#else
|
||||
usb_dc_stm32_state.pcd.Instance = USB_OTG_FS;
|
||||
#endif
|
||||
usb_dc_stm32_state.pcd.Instance = (USB_OTG_GlobalTypeDef *)USB_BASE_ADDRESS;
|
||||
usb_dc_stm32_state.pcd.Init.dev_endpoints = USB_NUM_BIDIR_ENDPOINTS;
|
||||
#if USB_OTG_HS_EMB_PHYC || USB_OTG_HS_EMB_PHY
|
||||
usb_dc_stm32_state.pcd.Init.phy_itface = USB_OTG_HS_EMBEDDED_PHY;
|
||||
|
|
|
@ -37,9 +37,16 @@ LOG_MODULE_REGISTER(udc_stm32, CONFIG_UDC_DRIVER_LOG_LEVEL);
|
|||
#define UDC_STM32_IRQ_NAME usb
|
||||
#endif
|
||||
|
||||
#define UDC_STM32_BASE_ADDRESS DT_INST_REG_ADDR(0)
|
||||
#define UDC_STM32_IRQ DT_INST_IRQ_BY_NAME(0, UDC_STM32_IRQ_NAME, irq)
|
||||
#define UDC_STM32_IRQ_PRI DT_INST_IRQ_BY_NAME(0, UDC_STM32_IRQ_NAME, priority)
|
||||
|
||||
#define USB_OTG_HS_EMB_PHY (DT_HAS_COMPAT_STATUS_OKAY(st_stm32_usbphyc) && \
|
||||
DT_HAS_COMPAT_STATUS_OKAY(st_stm32_otghs))
|
||||
|
||||
#define USB_OTG_HS_ULPI_PHY (DT_HAS_COMPAT_STATUS_OKAY(usb_ulpi_phy) && \
|
||||
DT_HAS_COMPAT_STATUS_OKAY(st_stm32_otghs))
|
||||
|
||||
/**
|
||||
* The following defines are used to map the value of the "maxiumum-speed"
|
||||
* DT property to the corresponding definition used by the STM32 HAL.
|
||||
|
@ -962,12 +969,6 @@ static const struct udc_api udc_stm32_api = {
|
|||
#define USB_BTABLE_SIZE 0
|
||||
#endif /* USB */
|
||||
|
||||
#define USB_OTG_HS_EMB_PHY (DT_HAS_COMPAT_STATUS_OKAY(st_stm32_usbphyc) && \
|
||||
DT_HAS_COMPAT_STATUS_OKAY(st_stm32_otghs))
|
||||
|
||||
#define USB_OTG_HS_ULPI_PHY (DT_HAS_COMPAT_STATUS_OKAY(usb_ulpi_phy) && \
|
||||
DT_HAS_COMPAT_STATUS_OKAY(st_stm32_otghs))
|
||||
|
||||
static struct udc_stm32_data udc0_priv;
|
||||
|
||||
static struct udc_data udc0_data = {
|
||||
|
@ -1001,12 +1002,8 @@ static void priv_pcd_prepare(const struct device *dev)
|
|||
priv->pcd.Instance = USB;
|
||||
#elif defined(USB_DRD_FS)
|
||||
priv->pcd.Instance = USB_DRD_FS;
|
||||
#elif defined(USB_OTG_FS) || defined(USB_OTG_HS)
|
||||
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_otghs)
|
||||
priv->pcd.Instance = USB_OTG_HS;
|
||||
#else
|
||||
priv->pcd.Instance = USB_OTG_FS;
|
||||
#endif
|
||||
#elif DT_HAS_COMPAT_STATUS_OKAY(st_stm32_otgfs) || DT_HAS_COMPAT_STATUS_OKAY(st_stm32_otghs)
|
||||
priv->pcd.Instance = (USB_OTG_GlobalTypeDef *)UDC_STM32_BASE_ADDRESS;
|
||||
#endif /* USB */
|
||||
|
||||
#if USB_OTG_HS_EMB_PHY
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue