-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Add USB FS (USBFS0) support on NXP MCX N94x #84590
Conversation
96ddd1d
to
b3f6802
Compare
dts/arm/nxp/nxp_mcxn23x_common.dtsi
Outdated
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.
Please check the commit message as the change is made to mcxn23x
file.
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, I modified the wrong file. It's my bad.
boards/nxp/frdm_mcxn947/board.c
Outdated
CLOCK_EnableClock(kCLOCK_Usb0Ram); | ||
CLOCK_EnableClock(kCLOCK_Usb0Fs); | ||
CLOCK_EnableUsbfsClock(); | ||
#endif |
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.
How was this tested?
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.
With a custom board that I made...
You're right, on the FRDM board the USB0 pins are only connected to two TP. Therefore it is not pertinent to put this configuration in the board.c
file.
But why all these configurations are not done in a soc.c
file, "at the soc level"?
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.
We are moving to making the clock configuration board specific as these should be managed at a board level. Kindly delete this from board.c
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.
It is a bit a shame because it means that if someone wants to create a custom board based on this soc, he necessarily needs to do some research how to use the HAL.
But I also understand the intention to manage it at the board level, I will remove this modification.
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.
Need clarification on how this was tested.
USBFS0 configuration is missing in Devicetree for NXP MCX N94x. Add the configuration to dtsi file. Signed-off-by: Alexandre Rey <alx.rey@icloud.com>
b3f6802
to
565a77a
Compare
Please help address the CI failures |
565a77a
to
92e7fd4
Compare
Some NXP socs use USBFS0 macro as base address for accessing the USB registers, rather than USB0. It generates compile-time errors, since USB0 is not defined. Fix by defining USB0 if USB0 is not defined and USBFS0 is. Signed-off-by: Alexandre Rey <alx.rey@icloud.com>
92e7fd4
to
51043b6
Compare
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 am not sure if it is the best way to handle this. we could also run conditional checks on the soc used.
Opened to be discussed...
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.
@alxrey. Zephyr is USB support is going through a rework. Below is the new driver we should be using for this IP.
https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/usb/udc/udc_kinetis.c
Eventually this driver will be deprecated. I would suggest testing and using the above driver.
This is the issue that is tracking progress on the USB rework.
#42066
* In some SoC USB0 base register is defined as USBFS0 | ||
*/ | ||
#if !defined(USB0) && defined(USBFS0) | ||
#define USB0 USBFS0 |
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.
Just a note, #define USB0 (USB_Type *)DT_INST_REG_ADDR(0)
should work as well (not tested 😄).
zephyr/drivers/usb/udc/udc_kinetis.c
Line 1182 in b80a058
.base = (USB_Type *)DT_INST_REG_ADDR(n), \ |
Hi @alxrey! To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge. Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁 |
Add USB FS support on NXP mcx n94x soc: