Skip to content
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

stm32: usb: Drivers clean up #85372

Open
erwango opened this issue Feb 7, 2025 · 0 comments
Open

stm32: usb: Drivers clean up #85372

erwango opened this issue Feb 7, 2025 · 0 comments
Assignees
Labels
area: USB Universal Serial Bus Enhancement Changes/Updates/Additions to existing features platform: STM32 ST Micro STM32

Comments

@erwango
Copy link
Member

erwango commented Feb 7, 2025

Is your enhancement proposal related to a problem? Please describe.
STM32 USB drivers have been implemented and maintained w/o using dts information sufficiently.
They have became hard to read and maintain.

Describe the solution you'd like
Review driver implementation to maximize usage of dt information. Ultimately, driver should be fully instantiable (at least for usb next version).
There are multiple steps from low hanging fruits from bindings overhaul.
#71248 should be part of this effort.

Example of low hanging fruit:

#if defined(USB)
	priv->pcd.Instance = DT_INST_REG_ADDR(0);
#elif defined(USB_DRD_FS)
	priv->pcd.Instance = USB_DRD_FS;
#elif defined(USB_OTG_FS) || defined(USB_OTG_HS)
	priv->pcd.Init.speed = usb_dc_stm32_get_maximum_speed();
#if DT_HAS_COMPAT_STATUS_OKAY(st_stm32_otghs)
	priv->pcd.Instance = USB_OTG_HS;
#else
	priv->pcd.Instance = USB_OTG_FS;
#endif
#endif /* USB */

could be replaced by

	priv->pcd.Instance = (USB_OTG_GlobalTypeDef *)DT_INST_REG_ADDR(0);

#if defined(USB_OTG_FS) || defined(USB_OTG_HS)
	priv->pcd.Init.speed = usb_dc_stm32_get_maximum_speed();
#endif

Side notes:
Implementation should get rid of STM32Cube defines, such as:
USB, USB_DRD_FS

@erwango erwango added the Enhancement Changes/Updates/Additions to existing features label Feb 7, 2025
@erwango erwango added platform: STM32 ST Micro STM32 area: USB Universal Serial Bus labels Feb 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus Enhancement Changes/Updates/Additions to existing features platform: STM32 ST Micro STM32
Projects
None yet
Development

No branches or pull requests

2 participants