usb: composite: add BOS descriptor support to composite framework
PATCH 1/1 usb: composite: add BOS descriptor support to composite framework
From: T Karthik Reddy <[email protected]>
To add usb-3.0 support to peripheral device add BOS & SS capability descriptors to gadget composite framework.
---
drivers/usb/gadget/composite.c | 61 ++++++++++++++++++++++++++++++---- include/linux/usb/ch9.h | 3 ++ include/linux/usb/gadget.h | 9 +++++ 3 files changed, 67 insertions(+), 6 deletions(-)
drivers/usb/gadget/composite.c +55 -6
@@ -688,6 +688,57 @@ static void composite_setup_complete(struct usb_ep *ep, struct usb_request *req) req->status, req->actual, req->length); } +static int bos_desc (struct usb_composite_dev *cdev) +{ +struct usb_ext_cap_descriptor *usb_ext; +struct usb_bos_descriptor *bos = cdev->req->buf; + + bos->bLength =USB_DT_BOS_SIZE ; + bos->bDescriptorType =USB_DT_BOS ; + + bos->wTotalLength =cpu_to_le16 (USB_DT_BOS_SIZE ); + bos->bNumDeviceCaps =0 ; + +/* +* A SuperSpeed device shall include the USB2.0 extension descriptor +* and shall support LPM when operating in USB2.0 HS mode. +*/ + usb_ext = cdev->req->buf +le16_to_cpu (bos->wTotalLength); + bos->bNumDeviceCaps++; +le16_add_cpu (&bos->wTotalLength,USB_DT_USB_EXT_CAP_SIZE ); + usb_ext->bLength =USB_DT_USB_EXT_CAP_SIZE ; + usb_ext->bDescriptorType =USB_DT_DEVICE_CAPABILITY ; + usb_ext->bDevCapabilityType =USB_CAP_TYPE_EXT ; + usb_ext->bmAttributes = +cpu_to_le32 (USB_LPM_SUPPORT |USB_BESL_SUPPORT ); + +/* +* The Superspeed USB Capability descriptor shall be implemented +* by all SuperSpeed devices. +*/ +if (gadget_is_superspeed (cdev->gadget)) { +struct usb_ss_cap_descriptor *ss_cap; + + ss_cap = cdev->req->buf +le16_to_cpu (bos->wTotalLength); + bos->bNumDeviceCaps++; +le16_add_cpu (&bos->wTotalLength,USB_DT_USB_SS_CAP_SIZE ); + ss_cap->bLength =USB_DT_USB_SS_CAP_SIZE ; + ss_cap->bDescriptorType =USB_DT_DEVICE_CAPABILITY ; + ss_cap->bDevCapabilityType =USB_SS_CAP_TYPE ; + ss_cap->bmAttributes =0 ;/* LTM is not supported yet */ + ss_cap->wSpeedSupported = +cpu_to_le16 (USB_LOW_SPEED_OPERATION | +USB_FULL_SPEED_OPERATION | +USB_HIGH_SPEED_OPERATION | +USB_5GBPS_OPERATION ); + ss_cap->bFunctionalitySupport =USB_LOW_SPEED_OPERATION ; + ss_cap->bU1devExitLat =USB_DEFAULT_U1_DEV_EXIT_LAT ; + ss_cap->bU2DevExitLat = +cpu_to_le16 (USB_DEFAULT_U2_DEV_EXIT_LAT ); + } +return le16_to_cpu (bos->wTotalLength); +} +/* * The setup() callback implements all the ep0 functionality that's * not handled lower down, in hardware or the hardware driver(like
@@ -776,12 +827,10 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) value =min (w_length, (u16 ) value);break ;case USB_DT_BOS : -/* -* The USB compliance test (USB 2.0 Command Verifier) -* issues this request. We should not run into the -* default path here. But return for now until -* the superspeed support is added. -*/ +if (gadget_is_superspeed (cdev->gadget)) + value =bos_desc (cdev); +if (value >=0 ) + value =min (w_length, (u16 )value);break ;default : goto unknown;
include/linux/usb/ch9.h +3 -0
@@ -878,6 +878,9 @@ struct usb_ss_cap_descriptor { /* Link Power Management */__le16 bU2DevExitLat; } __attribute__((packed)); +#define USB_DEFAULT_U1_DEV_EXIT_LAT 0x01/* Less then 1 microsec */ +#define USB_DEFAULT_U2_DEV_EXIT_LAT 0x01F4/* Less then 500 microsec */ +#define USB_DT_USB_SS_CAP_SIZE 10/*
include/linux/usb/gadget.h +9 -0
@@ -566,6 +566,15 @@ static inline int gadget_is_otg(struct usb_gadget *g)#endif } +/** +* gadget_is_superspeed() - return true if the hardware handles superspeed +* @g: controller that might support superspeed +*/ +static inline int gadget_is_superspeed (struct usb_gadget *g) +{ +return g->max_speed >=USB_SPEED_SUPER ; +} +/** * usb_gadget_frame_number - returns the current frame number * @gadget: controller that reports the frame number
Signature · 1 line
2.17.1
PATCH 1/1 usb: composite: add BOS descriptor support to composite framework
po 14. 10. 2019 v 14:52 odesÃlatel Michal Simek
<[email protected]> napsal:
Quoted 130 lines
From: T Karthik Reddy <[email protected]>
To add usb-3.0 support to peripheral device add BOS & SS capability descriptors to gadget composite framework.
Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Siva Durga Prasad Paladugu <[email protected]>Signed-off-by Michal Simek <[email protected]>---
drivers/usb/gadget/composite.c | 61 ++++++++++++++++++++++++++++++---- include/linux/usb/ch9.h | 3 ++ include/linux/usb/gadget.h | 9 +++++ 3 files changed, 67 insertions(+), 6 deletions(-)drivers/usb/gadget/composite.c +55
-6@@ -688,6 +688,57 @@ static void composite_setup_complete(struct usb_ep *ep, struct usb_request *req) req->status, req->actual, req->length); } +static int bos_desc (struct usb_composite_dev *cdev) +{ +struct usb_ext_cap_descriptor *usb_ext; +struct usb_bos_descriptor *bos = cdev->req->buf; + + bos->bLength =USB_DT_BOS_SIZE ; + bos->bDescriptorType =USB_DT_BOS ; + + bos->wTotalLength =cpu_to_le16 (USB_DT_BOS_SIZE ); + bos->bNumDeviceCaps =0 ; + +/* +* A SuperSpeed device shall include the USB2.0 extension descriptor +* and shall support LPM when operating in USB2.0 HS mode. +*/ + usb_ext = cdev->req->buf +le16_to_cpu (bos->wTotalLength); + bos->bNumDeviceCaps++; +le16_add_cpu (&bos->wTotalLength,USB_DT_USB_EXT_CAP_SIZE ); + usb_ext->bLength =USB_DT_USB_EXT_CAP_SIZE ; + usb_ext->bDescriptorType =USB_DT_DEVICE_CAPABILITY ; + usb_ext->bDevCapabilityType =USB_CAP_TYPE_EXT ; + usb_ext->bmAttributes = +cpu_to_le32 (USB_LPM_SUPPORT |USB_BESL_SUPPORT ); + +/* +* The Superspeed USB Capability descriptor shall be implemented +* by all SuperSpeed devices. +*/ +if (gadget_is_superspeed (cdev->gadget)) { +struct usb_ss_cap_descriptor *ss_cap; + + ss_cap = cdev->req->buf +le16_to_cpu (bos->wTotalLength); + bos->bNumDeviceCaps++; +le16_add_cpu (&bos->wTotalLength,USB_DT_USB_SS_CAP_SIZE ); + ss_cap->bLength =USB_DT_USB_SS_CAP_SIZE ; + ss_cap->bDescriptorType =USB_DT_DEVICE_CAPABILITY ; + ss_cap->bDevCapabilityType =USB_SS_CAP_TYPE ; + ss_cap->bmAttributes =0 ;/* LTM is not supported yet */ + ss_cap->wSpeedSupported = +cpu_to_le16 (USB_LOW_SPEED_OPERATION | +USB_FULL_SPEED_OPERATION | +USB_HIGH_SPEED_OPERATION | +USB_5GBPS_OPERATION ); + ss_cap->bFunctionalitySupport =USB_LOW_SPEED_OPERATION ; + ss_cap->bU1devExitLat =USB_DEFAULT_U1_DEV_EXIT_LAT ; + ss_cap->bU2DevExitLat = +cpu_to_le16 (USB_DEFAULT_U2_DEV_EXIT_LAT ); + } +return le16_to_cpu (bos->wTotalLength); +} +/* * The setup() callback implements all the ep0 functionality that's * not handled lower down, in hardware or the hardware driver(like @@ -776,12 +827,10 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) value =min (w_length, (u16 ) value);break ;case USB_DT_BOS : -/* -* The USB compliance test (USB 2.0 Command Verifier) -* issues this request. We should not run into the -* default path here. But return for now until -* the superspeed support is added. -*/ +if (gadget_is_superspeed (cdev->gadget)) + value =bos_desc (cdev); +if (value >=0 ) + value =min (w_length, (u16 )value);break ;default : goto unknown;include/linux/usb/ch9.h +3
-0@@ -878,6 +878,9 @@ struct usb_ss_cap_descriptor { /* Link Power Management */__le16 bU2DevExitLat; } __attribute__((packed)); +#define USB_DEFAULT_U1_DEV_EXIT_LAT 0x01/* Less then 1 microsec */ +#define USB_DEFAULT_U2_DEV_EXIT_LAT 0x01F4/* Less then 500 microsec */ +#define USB_DT_USB_SS_CAP_SIZE 10/* include/linux/usb/gadget.h +9
-1@@ -566,6 +566,15 @@ static inline int gadget_is_otg(struct usb_gadget *g)#endif } +/** +* gadget_is_superspeed() - return true if the hardware handles superspeed +* @g: controller that might support superspeed +*/ +static inline int gadget_is_superspeed (struct usb_gadget *g) +{ +return g->max_speed >=USB_SPEED_SUPER ; +} +/** * usb_gadget_frame_number - returns the current frame number * @gadget: controller that reports the frame number --
Quoted 2 lines
2.17.1
Any comment on this one?
M
Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
PATCH 1/1 usb: composite: add BOS descriptor support to composite framework
+ Vignesh and Roger
Quoted 138 lines · Michal Simek
po 14. 10. 2019 v 14:52 odesÃlatel Michal Simek
<[email protected]> napsal:Quoted 129 lines
From: T Karthik Reddy <[email protected]>
To add usb-3.0 support to peripheral device add BOS & SS capability descriptors to gadget composite framework.
Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Siva Durga Prasad Paladugu <[email protected]>Signed-off-by Michal Simek <[email protected]>---
drivers/usb/gadget/composite.c | 61 ++++++++++++++++++++++++++++++---- include/linux/usb/ch9.h | 3 ++ include/linux/usb/gadget.h | 9 +++++ 3 files changed, 67 insertions(+), 6 deletions(-)drivers/usb/gadget/composite.c +55
-6@@ -688,6 +688,57 @@ static void composite_setup_complete(struct usb_ep *ep, struct usb_request *req) req->status, req->actual, req->length); } +static int bos_desc (struct usb_composite_dev *cdev) +{ +struct usb_ext_cap_descriptor *usb_ext; +struct usb_bos_descriptor *bos = cdev->req->buf; + + bos->bLength =USB_DT_BOS_SIZE ; + bos->bDescriptorType =USB_DT_BOS ; + + bos->wTotalLength =cpu_to_le16 (USB_DT_BOS_SIZE ); + bos->bNumDeviceCaps =0 ; + +/* +* A SuperSpeed device shall include the USB2.0 extension descriptor +* and shall support LPM when operating in USB2.0 HS mode. +*/ + usb_ext = cdev->req->buf +le16_to_cpu (bos->wTotalLength); + bos->bNumDeviceCaps++; +le16_add_cpu (&bos->wTotalLength,USB_DT_USB_EXT_CAP_SIZE ); + usb_ext->bLength =USB_DT_USB_EXT_CAP_SIZE ; + usb_ext->bDescriptorType =USB_DT_DEVICE_CAPABILITY ; + usb_ext->bDevCapabilityType =USB_CAP_TYPE_EXT ; + usb_ext->bmAttributes = +cpu_to_le32 (USB_LPM_SUPPORT |USB_BESL_SUPPORT ); + +/* +* The Superspeed USB Capability descriptor shall be implemented +* by all SuperSpeed devices. +*/ +if (gadget_is_superspeed (cdev->gadget)) { +struct usb_ss_cap_descriptor *ss_cap; + + ss_cap = cdev->req->buf +le16_to_cpu (bos->wTotalLength); + bos->bNumDeviceCaps++; +le16_add_cpu (&bos->wTotalLength,USB_DT_USB_SS_CAP_SIZE ); + ss_cap->bLength =USB_DT_USB_SS_CAP_SIZE ; + ss_cap->bDescriptorType =USB_DT_DEVICE_CAPABILITY ; + ss_cap->bDevCapabilityType =USB_SS_CAP_TYPE ; + ss_cap->bmAttributes =0 ;/* LTM is not supported yet */ + ss_cap->wSpeedSupported = +cpu_to_le16 (USB_LOW_SPEED_OPERATION | +USB_FULL_SPEED_OPERATION | +USB_HIGH_SPEED_OPERATION | +USB_5GBPS_OPERATION ); + ss_cap->bFunctionalitySupport =USB_LOW_SPEED_OPERATION ; + ss_cap->bU1devExitLat =USB_DEFAULT_U1_DEV_EXIT_LAT ; + ss_cap->bU2DevExitLat = +cpu_to_le16 (USB_DEFAULT_U2_DEV_EXIT_LAT ); + } +return le16_to_cpu (bos->wTotalLength); +} +/* * The setup() callback implements all the ep0 functionality that's * not handled lower down, in hardware or the hardware driver(like @@ -776,12 +827,10 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) value =min (w_length, (u16 ) value);break ;case USB_DT_BOS : -/* -* The USB compliance test (USB 2.0 Command Verifier) -* issues this request. We should not run into the -* default path here. But return for now until -* the superspeed support is added. -*/ +if (gadget_is_superspeed (cdev->gadget)) + value =bos_desc (cdev); +if (value >=0 ) + value =min (w_length, (u16 )value);break ;default : goto unknown;include/linux/usb/ch9.h +3
-0@@ -878,6 +878,9 @@ struct usb_ss_cap_descriptor { /* Link Power Management */__le16 bU2DevExitLat; } __attribute__((packed)); +#define USB_DEFAULT_U1_DEV_EXIT_LAT 0x01/* Less then 1 microsec */ +#define USB_DEFAULT_U2_DEV_EXIT_LAT 0x01F4/* Less then 500 microsec */ +#define USB_DT_USB_SS_CAP_SIZE 10/* include/linux/usb/gadget.h +9
-1@@ -566,6 +566,15 @@ static inline int gadget_is_otg(struct usb_gadget *g)#endif } +/** +* gadget_is_superspeed() - return true if the hardware handles superspeed +* @g: controller that might support superspeed +*/ +static inline int gadget_is_superspeed (struct usb_gadget *g) +{ +return g->max_speed >=USB_SPEED_SUPER ; +} +/** * usb_gadget_frame_number - returns the current frame number * @gadget: controller that reports the frame number -- Quoted 2 lines
2.17.1
Any comment on this one?
M
PATCH 1/1 usb: composite: add BOS descriptor support to composite framework
Quoted 13 lines · Jean-Jacques Hiblot
+ Vignesh and Roger
Quoted 10 lines · Michal Simek
po 14. 10. 2019 v 14:52 odesílatel Michal Simek
<[email protected]> napsal:Quoted 8 lines
From: T Karthik Reddy <[email protected]>
To add usb-3.0 support to peripheral device add BOS & SS capability descriptors to gadget composite framework.
Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Siva Durga Prasad Paladugu <[email protected]>Signed-off-by Michal Simek <[email protected]>
Quoted 128 lines
Quoted 128 lines
Quoted 123 lines
---
drivers/usb/gadget/composite.c| 61 ++++++++++++++++++++++++++++++---- include/linux/usb/ch9.h | 3 ++ include/linux/usb/gadget.h | 9 +++++3 files changed, 67 insertions(+), 6 deletions(-)drivers/usb/gadget/composite.c +51
-0@@ -688,6 +688,57 @@ static void composite_setup_complete(struct usb_ep *ep, struct usb_request *req) req->status, req->actual, req->length); } +static int bos_desc (struct usb_composite_dev *cdev) +{ + struct usb_ext_cap_descriptor *usb_ext; + struct usb_bos_descriptor *bos = cdev->req->buf; + + bos->bLength = USB_DT_BOS_SIZE; + bos->bDescriptorType = USB_DT_BOS; + + bos->wTotalLength = cpu_to_le16(USB_DT_BOS_SIZE); + bos->bNumDeviceCaps = 0; + + /* + * A SuperSpeed device shall include the USB2.0 extension descriptor + * and shall support LPM when operating in USB2.0 HS mode. + */ + usb_ext = cdev->req->buf + le16_to_cpu(bos->wTotalLength); + bos->bNumDeviceCaps++; + le16_add_cpu(&bos->wTotalLength, USB_DT_USB_EXT_CAP_SIZE); + usb_ext->bLength = USB_DT_USB_EXT_CAP_SIZE; + usb_ext->bDescriptorType = USB_DT_DEVICE_CAPABILITY; + usb_ext->bDevCapabilityType = USB_CAP_TYPE_EXT; + usb_ext->bmAttributes = + cpu_to_le32(USB_LPM_SUPPORT | USB_BESL_SUPPORT); + + /* + * The Superspeed USB Capability descriptor shall be implemented + * by all SuperSpeed devices. + */ + if (gadget_is_superspeed(cdev->gadget)) { + struct usb_ss_cap_descriptor *ss_cap; + + ss_cap = cdev->req->buf + le16_to_cpu(bos->wTotalLength); + bos->bNumDeviceCaps++; + le16_add_cpu(&bos->wTotalLength, USB_DT_USB_SS_CAP_SIZE); + ss_cap->bLength = USB_DT_USB_SS_CAP_SIZE; + ss_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY; + ss_cap->bDevCapabilityType = USB_SS_CAP_TYPE; + ss_cap->bmAttributes = 0; /* LTM is not supported yet */ + ss_cap->wSpeedSupported = + cpu_to_le16(USB_LOW_SPEED_OPERATION | + USB_FULL_SPEED_OPERATION | + USB_HIGH_SPEED_OPERATION | + USB_5GBPS_OPERATION); + ss_cap->bFunctionalitySupport = USB_LOW_SPEED_OPERATION; + ss_cap->bU1devExitLat = USB_DEFAULT_U1_DEV_EXIT_LAT; + ss_cap->bU2DevExitLat = + cpu_to_le16(USB_DEFAULT_U2_DEV_EXIT_LAT); + } + return le16_to_cpu(bos->wTotalLength); +} + /** The setup() callback implements all the ep0 functionality that's * not handled lower down, in hardware or the hardware driver(like @@ -776,12 +827,10 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) value = min(w_length, (u16) value); break;case
USB_DT_BOS:
- /*
- * The USB compliance test (USB 2.0 Command Verifier) - * issues this request. We should not run into the - * default path here. But return for now until - * the superspeed support is added.
- */
+ if (gadget_is_superspeed(cdev->gadget))
+ value =bos_desc(cdev);
+ if (value >= 0)
+ value =min(w_length, (u16)value); break;
default:
goto unknown;include/linux/usb/ch9.h +3
-0@@ -878,6 +878,9 @@ struct usb_ss_cap_descriptor { /* Link Power Management */ __le16 bU2DevExitLat; } __attribute__((packed)); +#define USB_DEFAULT_U1_DEV_EXIT_LAT 0x01/* Less then 1 microsec */ +#define USB_DEFAULT_U2_DEV_EXIT_LAT 0x01F4/* Less then 500 microsec */ + #define USB_DT_USB_SS_CAP_SIZE 10 /*include/linux/usb/gadget.h +9
-0@@ -566,6 +566,15 @@ static inline int gadget_is_otg(struct usb_gadget *g) #endif } +/** +* gadget_is_superspeed() - return true if the hardware handles superspeed +* @g: controller that might support superspeed +*/ +static inline int gadget_is_superspeed (struct usb_gadget *g) +{ + return g->max_speed >= USB_SPEED_SUPER; +} + /*** usb_gadget_frame_number - returns the current frame number * @gadget: controller that reports the frame number Signature · 1 line
2.17.1Any comment on this one?
M
Signature · 5 lines
cheers, -roger Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
PATCH 1/1 usb: composite: add BOS descriptor support to composite framework
Quoted 13 lines · Roger Quadros
Quoted 10 lines · Jean-Jacques Hiblot
+ Vignesh and Roger
Quoted 7 lines · Michal Simek
po 14. 10. 2019 v 14:52 odesÃlatel Michal Simek
<[email protected]> napsal:Quoted 5 lines
From: T Karthik Reddy <[email protected]>
To add usb-3.0 support to peripheral device add BOS & SS capability descriptors to gadget composite framework.
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Siva Durga Prasad PaladuguSigned-off-by Michal Simek <[email protected]>Reviewed-by Roger Quadros <[email protected]>
Lukasz: This patch is assigned to you in patchwork. Can you please comment it or take it via your tree?
Thanks,
Michal
PATCH 1/1 usb: composite: add BOS descriptor support to composite framework
In reply to Michal SimekHi Michal,
Quoted 5 lines · Michal Simek
From: T Karthik Reddy <[email protected]>
To add usb-3.0 support to peripheral device add BOS & SS capability descriptors to gadget composite framework.
How was this patch tested? With what gadget function driver was this tested? I don't see *any* function drivers claiming SS support. (For e.g.: UMS only declares fsg_hs_bulk_in_desc but not fsg_ss_bulk_in_desc like in kernel), Without any function drivers claiming and implementing SS support how is this supposed to work? Or did I miss something?
Regards
Vignesh
Quoted 124 lines
Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Siva Durga Prasad Paladugu <[email protected]>Signed-off-by Michal Simek <[email protected]>---
drivers/usb/gadget/composite.c | 61 ++++++++++++++++++++++++++++++---- include/linux/usb/ch9.h | 3 ++ include/linux/usb/gadget.h | 9 +++++ 3 files changed, 67 insertions(+), 6 deletions(-)drivers/usb/gadget/composite.c +55
-6@@ -688,6 +688,57 @@ static void composite_setup_complete(struct usb_ep *ep, struct usb_request *req) req->status, req->actual, req->length); } +static int bos_desc (struct usb_composite_dev *cdev) +{ +struct usb_ext_cap_descriptor *usb_ext; +struct usb_bos_descriptor *bos = cdev->req->buf; + + bos->bLength =USB_DT_BOS_SIZE ; + bos->bDescriptorType =USB_DT_BOS ; + + bos->wTotalLength =cpu_to_le16 (USB_DT_BOS_SIZE ); + bos->bNumDeviceCaps =0 ; + +/* +* A SuperSpeed device shall include the USB2.0 extension descriptor +* and shall support LPM when operating in USB2.0 HS mode. +*/ + usb_ext = cdev->req->buf +le16_to_cpu (bos->wTotalLength); + bos->bNumDeviceCaps++; +le16_add_cpu (&bos->wTotalLength,USB_DT_USB_EXT_CAP_SIZE ); + usb_ext->bLength =USB_DT_USB_EXT_CAP_SIZE ; + usb_ext->bDescriptorType =USB_DT_DEVICE_CAPABILITY ; + usb_ext->bDevCapabilityType =USB_CAP_TYPE_EXT ; + usb_ext->bmAttributes = +cpu_to_le32 (USB_LPM_SUPPORT |USB_BESL_SUPPORT ); + +/* +* The Superspeed USB Capability descriptor shall be implemented +* by all SuperSpeed devices. +*/ +if (gadget_is_superspeed (cdev->gadget)) { +struct usb_ss_cap_descriptor *ss_cap; + + ss_cap = cdev->req->buf +le16_to_cpu (bos->wTotalLength); + bos->bNumDeviceCaps++; +le16_add_cpu (&bos->wTotalLength,USB_DT_USB_SS_CAP_SIZE ); + ss_cap->bLength =USB_DT_USB_SS_CAP_SIZE ; + ss_cap->bDescriptorType =USB_DT_DEVICE_CAPABILITY ; + ss_cap->bDevCapabilityType =USB_SS_CAP_TYPE ; + ss_cap->bmAttributes =0 ;/* LTM is not supported yet */ + ss_cap->wSpeedSupported = +cpu_to_le16 (USB_LOW_SPEED_OPERATION | +USB_FULL_SPEED_OPERATION | +USB_HIGH_SPEED_OPERATION | +USB_5GBPS_OPERATION ); + ss_cap->bFunctionalitySupport =USB_LOW_SPEED_OPERATION ; + ss_cap->bU1devExitLat =USB_DEFAULT_U1_DEV_EXIT_LAT ; + ss_cap->bU2DevExitLat = +cpu_to_le16 (USB_DEFAULT_U2_DEV_EXIT_LAT ); + } +return le16_to_cpu (bos->wTotalLength); +} +/* * The setup() callback implements all the ep0 functionality that's * not handled lower down, in hardware or the hardware driver(like @@ -776,12 +827,10 @@ composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl) value =min (w_length, (u16 ) value);break ;case USB_DT_BOS : -/* -* The USB compliance test (USB 2.0 Command Verifier) -* issues this request. We should not run into the -* default path here. But return for now until -* the superspeed support is added. -*/ +if (gadget_is_superspeed (cdev->gadget)) + value =bos_desc (cdev); +if (value >=0 ) + value =min (w_length, (u16 )value);break ;default : goto unknown;include/linux/usb/ch9.h +3
-0@@ -878,6 +878,9 @@ struct usb_ss_cap_descriptor { /* Link Power Management */__le16 bU2DevExitLat; } __attribute__((packed)); +#define USB_DEFAULT_U1_DEV_EXIT_LAT 0x01/* Less then 1 microsec */ +#define USB_DEFAULT_U2_DEV_EXIT_LAT 0x01F4/* Less then 500 microsec */ +#define USB_DT_USB_SS_CAP_SIZE 10/* include/linux/usb/gadget.h +9
-0@@ -566,6 +566,15 @@ static inline int gadget_is_otg(struct usb_gadget *g)#endif } +/** +* gadget_is_superspeed() - return true if the hardware handles superspeed +* @g: controller that might support superspeed +*/ +static inline int gadget_is_superspeed (struct usb_gadget *g) +{ +return g->max_speed >=USB_SPEED_SUPER ; +} +/** * usb_gadget_frame_number - returns the current frame number * @gadget: controller that reports the frame number
Signature · 2 lines
Regards Vignesh
PATCH 1/1 usb: composite: add BOS descriptor support to composite framework
Hi,
Quoted 9 lines · Vignesh Raghavendra
Hi Michal,
Quoted 5 lines · Michal Simek
From: T Karthik Reddy <[email protected]>
To add usb-3.0 support to peripheral device add BOS & SS capability descriptors to gadget composite framework.
Quoted 5 lines
How was this patch tested? With what gadget function driver was this tested? I don't see *any* function drivers claiming SS support. (For e.g.: UMS only declares
fsg_hs_bulk_in_descbut notfsg_ss_bulk_in_desclike in kernel), Without any function drivers claiming and implementing SS support how is this supposed to work? Or did I miss something?
Karthik/Siva: Can you please provide details?
What I see is that it was developed on ultra96 to fix issue around usb-3.0.
Thanks,
Michal
PATCH 1/1 usb: composite: add BOS descriptor support to composite framework
In reply to Vignesh RaghavendraHi Vignesh,
Quoted 18 lines
-----Original Message-----
From: Vignesh Raghavendra <[email protected]>
Sent: Friday, October 25, 2019 10:13 AM
To: Michal Simek <[email protected]>; u-boot at lists.denx.de; git <[email protected]>
Cc: Marek Vasut <[email protected]>; T Karthik Reddy <[email protected]>
Subject: Re: [U-Boot] [PATCH] usb: composite: add BOS descriptor support to composite frameworkHi Michal,
Quoted 5 lines · Michal Simek
From: T Karthik Reddy <[email protected]>
To add usb-3.0 support to peripheral device add BOS & SS capability descriptors to gadget composite framework.
Quoted 6 lines
How was this patch tested? With what gadget function driver was this tested?
I don't see *any* function drivers claiming SS support. (For e.g.: UMS only declaresfsg_hs_bulk_in_descbut notfsg_ss_bulk_in_desclike in kernel), Without any function drivers claiming and implementing SS support how is this supposed to work? Or did I miss something?
Commit 771e76515ed5abe7eff73a54ccb0c9ae55f34388 has added support for detecting usb 3.0 device. For the enquiry from host we are sending bos descriptor to host as a part to support 3.0 & we have tested it with DFU function.
Regards
T karthik
Quoted 137 lines
Regards
VigneshQuoted 7 lines
Signed-off-by T Karthik Reddy <[email protected]>Signed-off-by Siva Durga Prasad PaladuguSigned-off-by Michal Simek <[email protected]>---
drivers/usb/gadget/composite.c | 61++++++++++++++++++++++++++++++----
drivers/usb/gadget/composite.c static void composite_setup_complete(struct
Quoted 10 lines
include/linux/usb/ch9.h | 3 ++ include/linux/usb/gadget.h | 9 +++++ 3 files changed, 67 insertions(+), 6 deletions(-)(quoted diff) +0
-0
b/drivers/usb/gadget/composite.cindexc7e762374752..618a7d5016ee100644drivers/usb/gadget/composite.c +0
-0@@ -688,6 +688,57 @@ static void composite_setup_complete(struct
usb_ep*ep, structusb_request*req)Quoted 25 lines
drivers/usb/gadget/composite.c +23
-0req->status, req->actual, req->length); } +static int bos_desc (struct usb_composite_dev *cdev) { +struct usb_ext_cap_descriptor *usb_ext; +struct usb_bos_descriptor *bos = cdev->req->buf; + + bos->bLength =USB_DT_BOS_SIZE ; + bos->bDescriptorType =USB_DT_BOS ; + + bos->wTotalLength =cpu_to_le16 (USB_DT_BOS_SIZE ); + bos->bNumDeviceCaps =0 ; + +/* +* A SuperSpeed device shall include the USB2.0 extension descriptor +* and shall support LPM when operating in USB2.0 HS mode. +*/ + usb_ext = cdev->req->buf +le16_to_cpu (bos->wTotalLength); + bos->bNumDeviceCaps++; +le16_add_cpu (&bos->wTotalLength,USB_DT_USB_EXT_CAP_SIZE ); + usb_ext->bLength =USB_DT_USB_EXT_CAP_SIZE ; + usb_ext->bDescriptorType =USB_DT_DEVICE_CAPABILITY ; + usb_ext->bDevCapabilityType =USB_CAP_TYPE_EXT ; + usb_ext->bmAttributes = +cpu_to_le32 (USB_LPM_SUPPORT |USB_BESL_SUPPORT ); +drivers/usb/gadget/composite.c static void composite_setup_complete(struct usb_ep *ep, struct usb_request *req)
Quoted 10 lines
drivers/usb/gadget/composite.c +10
-0+/* +* The Superspeed USB Capability descriptor shall be implemented +* by all SuperSpeed devices. +*/ +if (gadget_is_superspeed (cdev->gadget)) { +struct usb_ss_cap_descriptor *ss_cap; + + ss_cap = cdev->req->buf +le16_to_cpu (bos->wTotalLength); + bos->bNumDeviceCaps++; + le16_add_cpu(&bos->wTotalLength,
USB_DT_USB_SS_CAP_SIZE);drivers/usb/gadget/composite.c static void composite_setup_complete(struct usb_ep *ep, struct usb_request *req)
Quoted 10 lines
drivers/usb/gadget/composite.c +10
-0+ ss_cap->bLength =USB_DT_USB_SS_CAP_SIZE ; + ss_cap->bDescriptorType =USB_DT_DEVICE_CAPABILITY ; + ss_cap->bDevCapabilityType =USB_SS_CAP_TYPE ; + ss_cap->bmAttributes =0 ;/* LTM is not supported yet */ + ss_cap->wSpeedSupported = +cpu_to_le16 (USB_LOW_SPEED_OPERATION | +USB_FULL_SPEED_OPERATION | +USB_HIGH_SPEED_OPERATION | +USB_5GBPS_OPERATION ); + ss_cap->bFunctionalitySupport =
USB_LOW_SPEED_OPERATION;drivers/usb/gadget/composite.c static void composite_setup_complete(struct usb_ep *ep, struct usb_request *req)
Quoted 10 lines
drivers/usb/gadget/composite.c +6
-1+ ss_cap->bU1devExitLat =USB_DEFAULT_U1_DEV_EXIT_LAT ; + ss_cap->bU2DevExitLat = +cpu_to_le16 (USB_DEFAULT_U2_DEV_EXIT_LAT ); + } +return le16_to_cpu (bos->wTotalLength); } +/* * The setup() callback implements all the ep0 functionality that's * not handled lower down, in hardware or the hardware driver(like @@ -776,12 +827,10 @@ composite_setup(struct usb_gadget *gadget, const struct
usb_ctrlrequest*ctrl)drivers/usb/gadget/composite.c composite_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *ctrl)
Quoted 5 lines
drivers/usb/gadget/composite.c +0
-2value =min (w_length, (u16 ) value);break ;case USB_DT_BOS : -/* -* The USB compliance test (USB 2.0 Command Verifier)
include/linux/usb/ch9.h struct usb_ss_cap_descriptor { /*
Quoted 16 lines
drivers/usb/gadget/composite.c +4
-4-* issues this request. We should not run into the -* default path here. But return for now until -* the superspeed support is added. -*/ +if (gadget_is_superspeed (cdev->gadget)) + value =bos_desc (cdev); +if (value >=0 ) + value =min (w_length, (u16 )value);break ;default : goto unknown;include/linux/usb/ch9.h index renamed from include/linux/usb/ch9.h +0
-0
264c9712a33a..989a5fcbd966100644include/linux/usb/ch9.h +0
-0@@ -878,6 +878,9 @@ struct usb_ss_cap_descriptor { /*Link Power Management */
include/linux/usb/ch9.h struct usb_ss_cap_descriptor { /* Link Power Management */
Quoted 4 lines
include/linux/usb/ch9.h +1
-0__le16 bU2DevExitLat; } __attribute__((packed)); +#define USB_DEFAULT_U1_DEV_EXIT_LAT 0x01/* Less then 1 microsec */
include/linux/usb/ch9.h struct usb_ss_cap_descriptor { /* · line 882
Quoted 1 line
include/linux/usb/ch9.h +1
-0+#define USB_DEFAULT_U2_DEV_EXIT_LAT 0x01F4/* Less then 500 microsec */
Quoted 12 lines
include/linux/usb/ch9.h +1
-0+#define USB_DT_USB_SS_CAP_SIZE 10/* include/linux/usb/gadget.h +1
-0@@ -566,6 +566,15 @@ static inline int gadget_is_otg(struct usb_gadget *g) #endif } +/** include/linux/usb/gadget.h static inline int gadget_is_otg(struct usb_gadget · line 578
Quoted 10 lines
include/linux/usb/gadget.h +6
-0+* gadget_is_superspeed() - return true if the hardware handles +superspeed +* @g: controller that might support superspeed */ static inline int +gadget_is_superspeed (struct usb_gadget *g) { +return g->max_speed >=USB_SPEED_SUPER ; } +/** * usb_gadget_frame_number - returns the current frame number * @gadget: controller that reports the frame number --
Regards
Vignesh