Skip to content

Commit f228a8d

Browse files
jysnpsfelipebalbi
authored andcommitted
usb: gadget: composite: Return SSP Dev Cap descriptor
If a gadget supports SuperSpeedPlus or higher speeds, return a SuperSpeedPlus USB Device Capability descriptor. Currently this implementation returns a fixed descriptor with typical values set. Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent 1a85329 commit f228a8d

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

drivers/usb/gadget/composite.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,48 @@ static int bos_desc(struct usb_composite_dev *cdev)
597597
ss_cap->bU1devExitLat = dcd_config_params.bU1devExitLat;
598598
ss_cap->bU2DevExitLat = dcd_config_params.bU2DevExitLat;
599599

600+
/* The SuperSpeedPlus USB Device Capability descriptor */
601+
if (gadget_is_superspeed_plus(cdev->gadget)) {
602+
struct usb_ssp_cap_descriptor *ssp_cap;
603+
604+
ssp_cap = cdev->req->buf + le16_to_cpu(bos->wTotalLength);
605+
bos->bNumDeviceCaps++;
606+
607+
/*
608+
* Report typical values.
609+
*/
610+
611+
le16_add_cpu(&bos->wTotalLength, USB_DT_USB_SSP_CAP_SIZE(1));
612+
ssp_cap->bLength = USB_DT_USB_SSP_CAP_SIZE(1);
613+
ssp_cap->bDescriptorType = USB_DT_DEVICE_CAPABILITY;
614+
ssp_cap->bDevCapabilityType = USB_SSP_CAP_TYPE;
615+
616+
/* SSAC = 1 (2 attributes) */
617+
ssp_cap->bmAttributes = cpu_to_le32(1);
618+
619+
/* Min RX/TX Lane Count = 1 */
620+
ssp_cap->wFunctionalitySupport = (1 << 8) | (1 << 12);
621+
622+
/*
623+
* bmSublinkSpeedAttr[0]:
624+
* ST = Symmetric, RX
625+
* LSE = 3 (Gbps)
626+
* LP = 1 (SuperSpeedPlus)
627+
* LSM = 10 (10 Gbps)
628+
*/
629+
ssp_cap->bmSublinkSpeedAttr[0] =
630+
(3 << 4) | (1 << 14) | (0xa << 16);
631+
/*
632+
* bmSublinkSpeedAttr[1] =
633+
* ST = Symmetric, TX
634+
* LSE = 3 (Gbps)
635+
* LP = 1 (SuperSpeedPlus)
636+
* LSM = 10 (10 Gbps)
637+
*/
638+
ssp_cap->bmSublinkSpeedAttr[1] =
639+
(3 << 4) | (1 << 14) | (0xa << 16) | (1 << 7);
640+
}
641+
600642
return le16_to_cpu(bos->wTotalLength);
601643
}
602644

0 commit comments

Comments
 (0)