* [U-Boot] [PATCH] usb: composite: add BOS descriptor support to composite framework
@ 2019-10-14 12:52 Michal Simek
2019-10-24 11:22 ` Michal Simek
2019-10-25 4:42 ` Vignesh Raghavendra
0 siblings, 2 replies; 8+ messages in thread
From: Michal Simek @ 2019-10-14 12:52 UTC (permalink / raw)
To: u-boot
From: T Karthik Reddy <t.karthik.reddy@xilinx.com>
To add usb-3.0 support to peripheral device add BOS & SS capability
descriptors to gadget composite framework.
Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---
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(-)
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index c7e762374752..618a7d5016ee 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -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;
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
index 264c9712a33a..989a5fcbd966 100644
--- a/include/linux/usb/ch9.h
+++ b/include/linux/usb/ch9.h
@@ -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
/*
diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
index 497798a32a87..58bfaddd036a 100644
--- a/include/linux/usb/gadget.h
+++ b/include/linux/usb/gadget.h
@@ -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
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] usb: composite: add BOS descriptor support to composite framework
2019-10-14 12:52 [U-Boot] [PATCH] usb: composite: add BOS descriptor support to composite framework Michal Simek
@ 2019-10-24 11:22 ` Michal Simek
2019-10-24 15:44 ` Jean-Jacques Hiblot
2019-10-25 4:42 ` Vignesh Raghavendra
1 sibling, 1 reply; 8+ messages in thread
From: Michal Simek @ 2019-10-24 11:22 UTC (permalink / raw)
To: u-boot
po 14. 10. 2019 v 14:52 odesÃlatel Michal Simek
<michal.simek@xilinx.com> napsal:
>
> From: T Karthik Reddy <t.karthik.reddy@xilinx.com>
>
> To add usb-3.0 support to peripheral device add BOS & SS capability
> descriptors to gadget composite framework.
>
> Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
> Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> 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(-)
>
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index c7e762374752..618a7d5016ee 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -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;
> diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
> index 264c9712a33a..989a5fcbd966 100644
> --- a/include/linux/usb/ch9.h
> +++ b/include/linux/usb/ch9.h
> @@ -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
>
> /*
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index 497798a32a87..58bfaddd036a 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -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
> --
> 2.17.1
>
Any comment on this one?
M
--
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] usb: composite: add BOS descriptor support to composite framework
2019-10-24 11:22 ` Michal Simek
@ 2019-10-24 15:44 ` Jean-Jacques Hiblot
2019-10-25 10:28 ` Roger Quadros
0 siblings, 1 reply; 8+ messages in thread
From: Jean-Jacques Hiblot @ 2019-10-24 15:44 UTC (permalink / raw)
To: u-boot
+ Vignesh and Roger
On 24/10/2019 13:22, Michal Simek wrote:
> po 14. 10. 2019 v 14:52 odesÃlatel Michal Simek
> <michal.simek@xilinx.com> napsal:
>> From: T Karthik Reddy <t.karthik.reddy@xilinx.com>
>>
>> To add usb-3.0 support to peripheral device add BOS & SS capability
>> descriptors to gadget composite framework.
>>
>> Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
>> Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>> ---
>>
>> 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(-)
>>
>> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
>> index c7e762374752..618a7d5016ee 100644
>> --- a/drivers/usb/gadget/composite.c
>> +++ b/drivers/usb/gadget/composite.c
>> @@ -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;
>> diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
>> index 264c9712a33a..989a5fcbd966 100644
>> --- a/include/linux/usb/ch9.h
>> +++ b/include/linux/usb/ch9.h
>> @@ -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
>>
>> /*
>> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
>> index 497798a32a87..58bfaddd036a 100644
>> --- a/include/linux/usb/gadget.h
>> +++ b/include/linux/usb/gadget.h
>> @@ -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
>> --
>> 2.17.1
>>
> Any comment on this one?
> M
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] usb: composite: add BOS descriptor support to composite framework
2019-10-14 12:52 [U-Boot] [PATCH] usb: composite: add BOS descriptor support to composite framework Michal Simek
2019-10-24 11:22 ` Michal Simek
@ 2019-10-25 4:42 ` Vignesh Raghavendra
2019-10-25 6:00 ` Michal Simek
2019-10-25 11:47 ` T Karthik Reddy
1 sibling, 2 replies; 8+ messages in thread
From: Vignesh Raghavendra @ 2019-10-25 4:42 UTC (permalink / raw)
To: u-boot
Hi Michal,
On 14/10/19 6:22 PM, Michal Simek wrote:
> From: T Karthik Reddy <t.karthik.reddy@xilinx.com>
>
> 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
> Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
> Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> 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(-)
>
> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
> index c7e762374752..618a7d5016ee 100644
> --- a/drivers/usb/gadget/composite.c
> +++ b/drivers/usb/gadget/composite.c
> @@ -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;
> diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
> index 264c9712a33a..989a5fcbd966 100644
> --- a/include/linux/usb/ch9.h
> +++ b/include/linux/usb/ch9.h
> @@ -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
>
> /*
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index 497798a32a87..58bfaddd036a 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -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
>
--
Regards
Vignesh
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] usb: composite: add BOS descriptor support to composite framework
2019-10-25 4:42 ` Vignesh Raghavendra
@ 2019-10-25 6:00 ` Michal Simek
2019-10-25 11:47 ` T Karthik Reddy
1 sibling, 0 replies; 8+ messages in thread
From: Michal Simek @ 2019-10-25 6:00 UTC (permalink / raw)
To: u-boot
Hi,
On 25. 10. 19 6:42, Vignesh Raghavendra wrote:
> Hi Michal,
>
> On 14/10/19 6:22 PM, Michal Simek wrote:
>> From: T Karthik Reddy <t.karthik.reddy@xilinx.com>
>>
>> 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?
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] usb: composite: add BOS descriptor support to composite framework
2019-10-24 15:44 ` Jean-Jacques Hiblot
@ 2019-10-25 10:28 ` Roger Quadros
2019-11-04 10:11 ` Michal Simek
0 siblings, 1 reply; 8+ messages in thread
From: Roger Quadros @ 2019-10-25 10:28 UTC (permalink / raw)
To: u-boot
On 24/10/2019 18:44, Jean-Jacques Hiblot wrote:
> + Vignesh and Roger
>
> On 24/10/2019 13:22, Michal Simek wrote:
>> po 14. 10. 2019 v 14:52 odesílatel Michal Simek
>> <michal.simek@xilinx.com> napsal:
>>> From: T Karthik Reddy <t.karthik.reddy@xilinx.com>
>>>
>>> To add usb-3.0 support to peripheral device add BOS & SS capability
>>> descriptors to gadget composite framework.
>>>
>>> Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
>>> Signed-off-by: Siva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Roger Quadros <rogerq@ti.com>
>>> ---
>>>
>>> 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(-)
>>>
>>> diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
>>> index c7e762374752..618a7d5016ee 100644
>>> --- a/drivers/usb/gadget/composite.c
>>> +++ b/drivers/usb/gadget/composite.c
>>> @@ -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;
>>> diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h
>>> index 264c9712a33a..989a5fcbd966 100644
>>> --- a/include/linux/usb/ch9.h
>>> +++ b/include/linux/usb/ch9.h
>>> @@ -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
>>>
>>> /*
>>> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
>>> index 497798a32a87..58bfaddd036a 100644
>>> --- a/include/linux/usb/gadget.h
>>> +++ b/include/linux/usb/gadget.h
>>> @@ -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
>>> --
>>> 2.17.1
>>>
>> Any comment on this one?
>> M
>
>>
>>
--
cheers,
-roger
Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki.
Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] usb: composite: add BOS descriptor support to composite framework
2019-10-25 4:42 ` Vignesh Raghavendra
2019-10-25 6:00 ` Michal Simek
@ 2019-10-25 11:47 ` T Karthik Reddy
1 sibling, 0 replies; 8+ messages in thread
From: T Karthik Reddy @ 2019-10-25 11:47 UTC (permalink / raw)
To: u-boot
Hi Vignesh,
> -----Original Message-----
> From: Vignesh Raghavendra <vigneshr@ti.com>
> Sent: Friday, October 25, 2019 10:13 AM
> To: Michal Simek <michals@xilinx.com>; u-boot at lists.denx.de; git
> <git@xilinx.com>
> Cc: Marek Vasut <marex@denx.de>; T Karthik Reddy <tkarthik@xilinx.com>
> Subject: Re: [U-Boot] [PATCH] usb: composite: add BOS descriptor support to
> composite framework
>
> Hi Michal,
>
> On 14/10/19 6:22 PM, Michal Simek wrote:
> > From: T Karthik Reddy <t.karthik.reddy@xilinx.com>
> >
> > 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?
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
>
> Regards
> Vignesh
>
> > Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
> > Signed-off-by: Siva Durga Prasad Paladugu
> > <siva.durga.paladugu@xilinx.com>
> > Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> > ---
> >
> > 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(-)
> >
> > diff --git a/drivers/usb/gadget/composite.c
> > b/drivers/usb/gadget/composite.c index c7e762374752..618a7d5016ee
> > 100644
> > --- a/drivers/usb/gadget/composite.c
> > +++ b/drivers/usb/gadget/composite.c
> > @@ -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;
> > diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index
> > 264c9712a33a..989a5fcbd966 100644
> > --- a/include/linux/usb/ch9.h
> > +++ b/include/linux/usb/ch9.h
> > @@ -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
> >
> > /*
> > diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> > index 497798a32a87..58bfaddd036a 100644
> > --- a/include/linux/usb/gadget.h
> > +++ b/include/linux/usb/gadget.h
> > @@ -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
> >
>
> --
> Regards
> Vignesh
^ permalink raw reply [flat|nested] 8+ messages in thread
* [U-Boot] [PATCH] usb: composite: add BOS descriptor support to composite framework
2019-10-25 10:28 ` Roger Quadros
@ 2019-11-04 10:11 ` Michal Simek
0 siblings, 0 replies; 8+ messages in thread
From: Michal Simek @ 2019-11-04 10:11 UTC (permalink / raw)
To: u-boot
On 25. 10. 19 12:28, Roger Quadros wrote:
>
>
> On 24/10/2019 18:44, Jean-Jacques Hiblot wrote:
>> + Vignesh and Roger
>>
>> On 24/10/2019 13:22, Michal Simek wrote:
>>> po 14. 10. 2019 v 14:52 odesÃlatel Michal Simek
>>> <michal.simek@xilinx.com> napsal:
>>>> From: T Karthik Reddy <t.karthik.reddy@xilinx.com>
>>>>
>>>> To add usb-3.0 support to peripheral device add BOS & SS capability
>>>> descriptors to gadget composite framework.
>>>>
>>>> Signed-off-by: T Karthik Reddy <t.karthik.reddy@xilinx.com>
>>>> Signed-off-by: Siva Durga Prasad Paladugu
>>>> <siva.durga.paladugu@xilinx.com>
>>>> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
>
> Reviewed-by: Roger Quadros <rogerq@ti.com>
Lukasz: This patch is assigned to you in patchwork. Can you please
comment it or take it via your tree?
Thanks,
Michal
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2019-11-04 10:11 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-14 12:52 [U-Boot] [PATCH] usb: composite: add BOS descriptor support to composite framework Michal Simek
2019-10-24 11:22 ` Michal Simek
2019-10-24 15:44 ` Jean-Jacques Hiblot
2019-10-25 10:28 ` Roger Quadros
2019-11-04 10:11 ` Michal Simek
2019-10-25 4:42 ` Vignesh Raghavendra
2019-10-25 6:00 ` Michal Simek
2019-10-25 11:47 ` T Karthik Reddy
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.