-
Notifications
You must be signed in to change notification settings - Fork 8k
USB STM32: clean up code and enhancements #86100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3495aa9
to
17bc665
Compare
17bc665
to
9b2fdac
Compare
93fb344
to
8c781c7
Compare
093c9b8
to
49b364e
Compare
drivers/usb/udc/udc_stm32.c
Outdated
uint8_t physel; | ||
|
||
#if DT_HAS_COMPAT_STATUS_OKAY(usb_ulpi_phy) | ||
physel = USB_OTG_HS_PHY_ULPI; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add a comment here stating that if "usb-ulpi-phy" is enabled on board.dts, we suppose it is selected (otherwise it doesn't make no sense to define it).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comment, otherwise LGTM
@jfischer-no PTAL |
drivers/usb/udc/udc_stm32.c
Outdated
/* Definitions aligned with HAL macros for PHY type selection */ | ||
#define USB_OTG_HS_PHY_ULPI 1U | ||
#define USB_FS_EMBEDDED_PHY 2U | ||
#define USB_OTG_HS_EMBEDDED_PHY 3U |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, maybe I missed the explanations for these. But these macros are not properly prefixed and USB_OTG_HS_EMBEDDED_PHY is already defined in the HAL, would it not clash at some point? Also, I see two other values defined there, why cannot they be used here in the UDC driver?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Macros are now prefixed with UDC_STM32 to avoid any naming conflicts.
Another value is defined there but is not used here:
#if !defined (USB_HS_PHYC_TUNE_VALUE)
#define USB_HS_PHYC_TUNE_VALUE 0x00000F13U /*!< Value of USB HS PHY Tune /
#endif / USB_HS_PHYC_TUNE_VALUE */
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
drivers/usb/udc/udc_stm32.c
Outdated
|
||
/* If the ULPI interface for an external high-speed PHY is enabled, it is assumed to be chosen. */ | ||
#if DT_HAS_COMPAT_STATUS_OKAY(usb_ulpi_phy) | ||
physel = USB_OTG_HS_PHY_ULPI; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
physel = USB_OTG_ULPI_PHY;
?
drivers/usb/udc/udc_stm32.c
Outdated
(DT_PHANDLE(DT_INST(0, st_stm32_usb), phys) == otgfs_phy) || \ | ||
(DT_PHANDLE(DT_INST(0, st_stm32_usb), phys) == usb_fs_phy)) && \ | ||
DT_HAS_COMPAT_STATUS_OKAY(usb_nop_xceiv)) | ||
physel = USB_FS_EMBEDDED_PHY; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
physel = USB_OTG_EMBEDDED_PHY;
?
Replace the conditional compilation blocks with a single assignment. Rely on the DT reg property for the USB controller instance IOMEM base address. Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
Replace the conditional compilation blocks with a single assignment. Rely on the DT reg property for the USB controller instance IOMEM base address. Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
Replace the conditional compilation blocks with a dedicated function to determine the USB PHY interface selection for STM32 using device tree configurations. Define generic macros for USB physel that supported by STM32 boards, while the HALs use different macro names for identical values. Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
Replace the conditional compilation blocks with a dedicated function to determine the USB PHY interface selection for STM32 using device tree configurations. Define generic macros for USB physel that supported by STM32 boards, while the HALs use different macro names for identical values. Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
Factorize 'USB_NUM_BIDIR_ENDPOINTS' macro use in usb_dc_stm32_init(). Modifie the condition to verify ep_idx from > to >=. Signed-off-by: Khaoula Bidani <khaoula.bidani-ext@st.com>
|
Dismissing in order not to block next steps.
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Mostly superseded by #96028. Feel free to re-open with only the clean-up commits; otherwise, they will be integrated as part of another PR with more cleanups. |
This pull request introduces several enhancements and refactorings to the USB code, device tree bindings, and board configurations for STM32 devices. The changes aim to improve the maintainability of the USB driver code.