-
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
dts: bindings: usb: Add maximum-speed property #9062
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9062 +/- ##
=========================================
Coverage ? 53.14%
=========================================
Files ? 210
Lines ? 25747
Branches ? 5673
=========================================
Hits ? 13682
Misses ? 9755
Partials ? 2310 Continue to review full report at Codecov.
|
@ydamigos it is weird that I still have to add the line
here to make my STM32F4 board work on its USB-HS full-speed mode. I found a link which also talked abut the similar issue:
|
@jli157 Thanks for testing. The reset value for RCC_AHB1LPENR register is |
@jli157 I updated it. Could you test it again? |
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.
@ydamigos Yes, the rebased PR works on my custom board pretty well now. Thank you!
Thanks @ydamigos for this patch. I have tested it on my STM32F723 board and it works. I have a few comments though:
|
@aurel32 Thanks for testing. Could you test it again?
The reference manual also mentions for the OTG_HS/FS_DCFG register:
Done
Done |
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 have justed tested it, it looks all good to me. Thanks for your work on that.
drivers/usb/device/usb_dc_stm32.c
Outdated
* If max-speed is not passed via DT, set it to USB controller's | ||
* maximum hardware capability. | ||
*/ | ||
#if defined(USB_HS_PHYC) && defined(CONFIG_USB_HS_BASE_ADDRESS) |
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.
Small nitpick, it might be a good idea to move that code at the beginning of the function when USB_OTG_SPEED_FULL
is assigned to speed
.
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.
Done
I think this PR is ready to be merged. Can any reviewer give approval to it? I like to have this one in my project. :) |
u32_t speed = USB_OTG_SPEED_FULL; | ||
#endif /* USB_HS_PHYC && CONFIG_USB_HS_BASE_ADDRESS */ | ||
|
||
#ifdef CONFIG_USB_MAXIMUM_SPEED |
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.
In Zephyr current state of the art, this code is fine.
In the evolution foreseen for device tree information usage, a clearer Kconfig/dts split is expected, along with fixup files removal.
Here this is clearly a case where we're using CONFIG_ #define which does not belong to Kconfig space but is purely device HW description, hence dts 'space'.
So, as a heads up, it is likely this piece will have to be reworked in some time, to make a clearer split between HW boot time configuration and device instantiation (device tree) and SW configuration (Kconfig).
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.
Thanks for the heads up. I will do the rework when the time comes.
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 know its a bit of a pain, but can we match the linux binding use of a string for this.
- maximum-speed: tells USB controllers we want to work up to a certain
speed. Valid arguments are "super-speed", "high-speed",
"full-speed" and "low-speed". In case this isn't passed
via DT, USB controllers should default to their maximum
HW capability.
@galak I'll do the changes to use string in max-speed property. Right now the driver fails to compile if unsupported speed is defined in device tree:
I would like to inform user if an unsupported speed is defined in device tree. I can't use |
We should probably put this check/parsing in the device tree generation script. Having some means in the yaml to describe a set of know string values that get checked against. |
I am not sure it's something possible as the allowed values depends on the controller version, which is not known at the time the device-tree is parsed. For example some STM32F7 have an HS internal PHY, while on others the internal PHY is limited to FS. This is known by checking the USB_HS_PHYC defined in the HAL code. |
We are responsible the device tree to have the correct values for each SoC. The check/parsing is just to avoid typos or invalid values (e.g. "super-fast-speed"). |
Its annoying, but we should have different compatibles for this, and have different yaml if we want to error check the values. |
Could we use phy bindings like it is done in linux, instead of different compatibles and different yaml? For example in stm32429i-eval.dts in linux::
|
that works for me. |
I'll study a bit more the phy bindings in linux and I'll create a different PR to add it in Zephyr asap. |
@ydamigos did you create a new PR to address the same issue on this PR? I want to follow it until it is merged. |
@jli157 Not yet, it is in my todo list. |
Rebased to resolve conflicts. |
@galak any more comments? Could we merge it? |
Rebased to resolve conflicts. |
Add maximum-speed property to usb node. It configures USB controllers to work up to a specific speed. Valid arguments are "super-speed", "high-speed", "full-speed" and "low-speed". Signed-off-by: Yannis Damigos <[email protected]>
Add maximum-speed property to usb nodes and set it to their maximum on-chip PHY capability. SoCs with USB device controllers only support full speed, so we don't add maximum-speed to these nodes. Signed-off-by: Yannis Damigos <[email protected]>
Add CONFIG_USB_MAXIMUM_SPEED defines to dts fixup files. Signed-off-by: Yannis Damigos <[email protected]>
Get maximum-speed from device tree for OTG FS/HS. Signed-off-by: Yannis Damigos <[email protected]>
Add maximum-speed property to usb node.
It configures USB controllers to work up to a specific speed.
Valid arguments are 0 for super-speed, 1 for high-speed, 2
for full-speed and 3 for low-speed.