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

RFC: USB: Use maximum-speed DTS parameters #15140

Closed
wants to merge 7 commits into from

Conversation

finikorg
Copy link
Collaborator

@finikorg finikorg commented Apr 3, 2019

Add better HS support

Fixes #11000

@zephyrbot
Copy link
Collaborator

zephyrbot commented Apr 3, 2019

All checks are passing now.

Review history of this comment for details about previous failed status.
Note that some checks might have not completed yet.

@finikorg finikorg requested a review from jfischer-no as a code owner April 3, 2019 07:26
@aurel32
Copy link
Collaborator

aurel32 commented Apr 3, 2019

At the moment maximum-speed is a string making it impossible to use
with preprocessor macros.

The initial version of the PR didn't use strings. It has been switched to match the linux bindings. See:
#9062 (review)

@carlescufi carlescufi added the area: USB Universal Serial Bus label Apr 3, 2019
@carlescufi
Copy link
Member

@aurel32 understood, thanks for that.
@erwango can you also weigh in here?

@finikorg @jfischer-phytec-iot I think it might be better to stay with strings given @galak's original comment

#ifndef ZEPHYR_INCLUDE_DT_BINDINGS_USB_H_
#define ZEPHYR_INCLUDE_DT_BINDINGS_USB_H_

#define USB_MAXIMUM_SPEED_LOW_SPEED 0
Copy link
Member

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

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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.

galak
galak previously requested changes Apr 3, 2019
Copy link
Collaborator

@galak galak left a 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.

@finikorg
Copy link
Collaborator Author

finikorg commented Apr 3, 2019

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?

@finikorg
Copy link
Collaborator Author

finikorg commented Apr 3, 2019

@nashif @galak
Maybe our dts parser script can create out of strings like DT_USB_MAXIMUM_SPEED = "high-speed" something like

#define DT_USB_MAXIMUM_SPEED_HIGH_SPEED 1

@@ -74,6 +75,17 @@ extern "C" {

#define MAX_PACKET_SIZE0 64 /**< maximum packet size for EP 0 */

#if defined(DT_USBHS_MAXIMUM_SPEED) && \
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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

@carlescufi
Copy link
Member

Will be reworked

finikorg added 6 commits May 22, 2019 16:58
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]>
@finikorg finikorg changed the title USB: Make maximum-speed DTS parameter usable WIP: RFC: USB: Use maximum-speed DTS parameters May 23, 2019
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]>
@carlescufi carlescufi dismissed stale reviews from jfischer-no, galak, and themself June 5, 2019 09:54

stale

@carlescufi
Copy link
Member

@jfischer-phytec-iot can you re-review this one?

@finikorg finikorg changed the title WIP: RFC: USB: Use maximum-speed DTS parameters RFC: USB: Use maximum-speed DTS parameters Jun 5, 2019
@galak
Copy link
Collaborator

galak commented Sep 19, 2019

@finikorg is this still relevant? If not please close or update the PR.

@finikorg
Copy link
Collaborator Author

Closing for now

@finikorg finikorg closed this Sep 20, 2019
@finikorg finikorg deleted the usb_hs branch September 6, 2021 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

USB 2.0 high-speed support in Zephyr
6 participants