Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <johnyoun@synopsys.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>

authored by

John Youn and committed by
Felipe Balbi
f228a8de 1a853291

+42
+42
drivers/usb/gadget/composite.c
··· 597 597 ss_cap->bU1devExitLat = dcd_config_params.bU1devExitLat; 598 598 ss_cap->bU2DevExitLat = dcd_config_params.bU2DevExitLat; 599 599 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 + 600 642 return le16_to_cpu(bos->wTotalLength); 601 643 } 602 644