-
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
usb: device_next: usb3 support #82801
base: main
Are you sure you want to change the base?
Conversation
74d2fa4
to
d5fda25
Compare
force-push:
|
include/zephyr/drivers/usb/udc.h
Outdated
@@ -36,6 +37,8 @@ enum udc_mps0 { | |||
struct udc_device_caps { | |||
/** USB high speed capable controller */ | |||
uint32_t hs : 1; | |||
/** USB high speed capable controller */ |
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.
Copy and paste typo here. Should be "super" rather than "high"
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.
Good catch, thank you!
force-push:
|
The USB3 driver in question is soon to be contributed, and the implementation lives here in the meantime: |
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 fact that Super-Speed requires bulk endpoints wMaxPacketSize to be 1024 makes #76255 even more important
@@ -41,6 +42,13 @@ struct usb_bos_capability_lpm { | |||
uint32_t bmAttributes; | |||
} __packed; | |||
|
|||
/** Fields for @ref usb_bos_capability_lpm bmAttributes */ |
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.
LPM is for USB 2.0 EXTENSION capability descriptor and LTM is for SUPERSPEED USB capability descriptor. Please do not mix different bmAttributes
bits in single enum.
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 adjusted this in the latest commits, thank you!
include/zephyr/drivers/usb/udc.h
Outdated
* device can configure the hardware to match what is on the host. | ||
* That way, both side of the session have the same properties. | ||
*/ | ||
struct udc_exit_latency { |
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 specification refers to these as "System Exit Latency". udc_exit_latency
seems to suggests it is some software construct and not a standard requirement. Not sure what would be a better name though.
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.
#define USB_SREQ_SET_WUSB_DATA 0x14 | ||
#define USB_SREQ_LOOPBACK_DATA_WRITE 0x15 | ||
#define USB_SREQ_LOOPBACK_DATA_READ 0x16 | ||
#define USB_SREQ_SET_INTERFACE_DS 0x17 |
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.
What about GET_FW_STATUS
and SET_FW_STATUS
?
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 had no idea this existed!
https://usbpd.wordpress.com/wp-content/uploads/2019/02/25-usb_devdays_taipei_2017_cto_hour.pdf
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.
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.
Get USB 3.2 Revision 1.1 Specification from https://www.usb.org/document-library/usb-32-revision-11-june-2022
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 had the 2017 version somehow. Thank you!
@@ -121,6 +135,7 @@ static inline bool usb_reqtype_is_to_device(const struct usb_setup_packet *setup | |||
#define USB_DESC_INTERFACE_ASSOC 11 | |||
#define USB_DESC_BOS 15 | |||
#define USB_DESC_DEVICE_CAPABILITY 16 | |||
#define USB_DESC_ENDPOINT_COMPANION 48 |
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.
There is also SUPERSPEEDPLUS_ISOCHRONOUS_ENDPOINT_COMPANION
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.
That makes sense, SuperSpeed Plus devices using an RTOS are already on the market (but chips not available yet).
I might also need to add the structs for it then...
include/zephyr/usb/usb_ch9.h
Outdated
@@ -248,6 +263,15 @@ struct usb_association_descriptor { | |||
uint8_t iFunction; | |||
} __packed; | |||
|
|||
/** USB Endpoint Companion Descriptor defined in USB3 spec. Table 9-27. */ | |||
struct usb_co_descriptor { |
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 go with usb_ss_endpoint_companion_descriptor
.
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 did not dare to break the regularity of every class.
Should that be usb_ss_ep_companion_descriptor
for consistency with usb_ep_descriptor
?
I am applying usb_ss_endpoint_companion_descriptor
currently...
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 also renamed if..._ss_..._co
to if..._ss_..._ep_co
.
74cf9e3
to
7249333
Compare
force-push:
SuperSpeedPlus still lacks other modifications to be enabled: everywhere SuperSpeed (SS) is introduced, SuperSpeedPlus (SSP) needs to be introduced as well. |
Here is what this PR it looks like on top of #76255: I thought it would be more suited to wait #76255 to be rebased before force-pushing this here. |
force-push:
|
Introduce definitions to enable USB3 device controllers to be written. The USB3 support got added to the core implementaiton, and to the Loopback and CDC-ACM class only. Signed-off-by: Josuah Demangeon <me@josuah.net>
This adds definitions needed for USB3 support.
There is no USB3 controller supported upstream yet. Should I wait to have the driver contributed in the same PR?
Here is the result of USB3CV for a this upcoming driver:
https://josuah.net/paste/rOzDHBjCbAIWO8d4qZu3/Chapter_9_Tests_USB_3_Gen_X_Failed_2024_12_10_08_18_16.html
It fails at SetFeature, as well as re-enumerating as USB2 (but this is related to the driver, not the USB3 handling).
But everything else is passing.
It also runs well with Twister on SuperSpeed configuration:
west twister --platform native_sim --scenario tests/subsys/usb/device_next/usb.device_next --inline-logs