-
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
RFC: USB: Use maximum-speed DTS parameters #15140
Conversation
All checks are passing now. Review history of this comment for details about previous failed status. |
The initial version of the PR didn't use strings. It has been switched to match the linux bindings. See: |
include/dt-bindings/usb/usb.h
Outdated
#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_USB_H_ | ||
#define ZEPHYR_INCLUDE_DT_BINDINGS_USB_H_ | ||
|
||
#define USB_MAXIMUM_SPEED_LOW_SPEED 0 |
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 would move those to usb_dc.h
or similar and then have some code that translates the string into a variable containing one of the values. I would do this directly in PR #14977
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 need this kind of stuff
b441bba68a64a3ba8a6f389b4845b8878d632921
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.
And especially here 6098067af34951b0ef7bf2ab1dae2721213f49a1. This is just the example, should be changed to every place we define endpoints.
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.
The DTS proper maximum-speed should be a string, it should NOT be a int. This matches dts binding specs from Linux for this property.
How can we use strings for preprocessor macros? Maybe we use then Kconfig for that? |
include/usb/usb_device.h
Outdated
@@ -74,6 +75,17 @@ extern "C" { | |||
|
|||
#define MAX_PACKET_SIZE0 64 /**< maximum packet size for EP 0 */ | |||
|
|||
#if defined(DT_USBHS_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.
I think doing it this way is not good, readability suffers and worse, we need to touch it again to support more then one device controller, e.g. a SoC may have one FS controller and one HS controller. That why I want to check it explicit for at least HS and FS.
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.
To support several device controllers we need to rewrite a lot anyway, so it is probably better to touch less code. And we do compare against one global DT_USBHS_MAXIMUM_SPEED
which does not depends on the controller. Probably that check should be done in usb_dc_***
function.
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.
3c750df make usb device controller check
Will be reworked |
Fix handling for sam boards. Replace definitions like DT_USBHS_MAXIMUM_SPEED with DT_USB_MAXIMUM_SPEED which is more correct, since HS implies that speed is High Speed and similar to definitions for other boards. Signed-off-by: Andrei Emeltchenko <[email protected]>
Use maximum speed enum making it consistent with the rest of the code and making code faster. Signed-off-by: Andrei Emeltchenko <[email protected]>
Define MPS for endpoints based on maximum speed DTS parameter. Signed-off-by: Andrei Emeltchenko <[email protected]>
Use defined USB_MAX_BULK_MPS for endpoint wMaxPacketSize. Signed-off-by: Andrei Emeltchenko <[email protected]>
Use macros since we need to use them in the preprocessor conditionals. Signed-off-by: Andrei Emeltchenko <[email protected]>
For the devices defining DT_USB_MAXIMUM_SPEED_ENUM and equal to DT_USB_MAXIMUM_SPEED_HIGH_SPEED return Device Qualifier. Signed-off-by: Andrei Emeltchenko <[email protected]>
Use USB_MAX_BULK_MPS instead of hardcoded TEST_BULK_EP_MPS and check size for High Speed. Signed-off-by: Andrei Emeltchenko <[email protected]>
@jfischer-phytec-iot can you re-review this one? |
@finikorg is this still relevant? If not please close or update the PR. |
Closing for now |
Add better HS support
Fixes #11000