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

usb: gadget: add usb3.0 descriptors to serial gadgets

This patch adds SS descriptors to the ACM & generic serial gadget. The
ACM part was tested with minicom + dummy + send / receive files over
ttyACM <=> ttyGS0.
The generic serial part (f_serial) was not tested (haven't found a
driver on the host side).
The nokia & multi gadget use HS at most.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Felipe Balbi <balbi@ti.com>

authored by

Sebastian Andrzej Siewior and committed by
Felipe Balbi
6fecfb05 609ca228

+93 -1
+50
drivers/usb/gadget/f_acm.c
··· 237 237 NULL, 238 238 }; 239 239 240 + static struct usb_endpoint_descriptor acm_ss_in_desc = { 241 + .bLength = USB_DT_ENDPOINT_SIZE, 242 + .bDescriptorType = USB_DT_ENDPOINT, 243 + .bmAttributes = USB_ENDPOINT_XFER_BULK, 244 + .wMaxPacketSize = cpu_to_le16(1024), 245 + }; 246 + 247 + static struct usb_endpoint_descriptor acm_ss_out_desc = { 248 + .bLength = USB_DT_ENDPOINT_SIZE, 249 + .bDescriptorType = USB_DT_ENDPOINT, 250 + .bmAttributes = USB_ENDPOINT_XFER_BULK, 251 + .wMaxPacketSize = cpu_to_le16(1024), 252 + }; 253 + 254 + static struct usb_ss_ep_comp_descriptor acm_ss_bulk_comp_desc = { 255 + .bLength = sizeof acm_ss_bulk_comp_desc, 256 + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, 257 + }; 258 + 259 + static struct usb_descriptor_header *acm_ss_function[] = { 260 + (struct usb_descriptor_header *) &acm_iad_descriptor, 261 + (struct usb_descriptor_header *) &acm_control_interface_desc, 262 + (struct usb_descriptor_header *) &acm_header_desc, 263 + (struct usb_descriptor_header *) &acm_call_mgmt_descriptor, 264 + (struct usb_descriptor_header *) &acm_descriptor, 265 + (struct usb_descriptor_header *) &acm_union_desc, 266 + (struct usb_descriptor_header *) &acm_hs_notify_desc, 267 + (struct usb_descriptor_header *) &acm_ss_bulk_comp_desc, 268 + (struct usb_descriptor_header *) &acm_data_interface_desc, 269 + (struct usb_descriptor_header *) &acm_ss_in_desc, 270 + (struct usb_descriptor_header *) &acm_ss_bulk_comp_desc, 271 + (struct usb_descriptor_header *) &acm_ss_out_desc, 272 + (struct usb_descriptor_header *) &acm_ss_bulk_comp_desc, 273 + NULL, 274 + }; 275 + 240 276 /* string descriptors: */ 241 277 242 278 #define ACM_CTRL_IDX 0 ··· 679 643 /* copy descriptors */ 680 644 f->hs_descriptors = usb_copy_descriptors(acm_hs_function); 681 645 } 646 + if (gadget_is_superspeed(c->cdev->gadget)) { 647 + acm_ss_in_desc.bEndpointAddress = 648 + acm_fs_in_desc.bEndpointAddress; 649 + acm_ss_out_desc.bEndpointAddress = 650 + acm_fs_out_desc.bEndpointAddress; 651 + 652 + /* copy descriptors, and track endpoint copies */ 653 + f->ss_descriptors = usb_copy_descriptors(acm_ss_function); 654 + if (!f->ss_descriptors) 655 + goto fail; 656 + } 682 657 683 658 DBG(cdev, "acm ttyGS%d: %s speed IN/%s OUT/%s NOTIFY/%s\n", 684 659 acm->port_num, 660 + gadget_is_superspeed(c->cdev->gadget) ? "super" : 685 661 gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", 686 662 acm->port.in->name, acm->port.out->name, 687 663 acm->notify->name); ··· 723 675 724 676 if (gadget_is_dualspeed(c->cdev->gadget)) 725 677 usb_free_descriptors(f->hs_descriptors); 678 + if (gadget_is_superspeed(c->cdev->gadget)) 679 + usb_free_descriptors(f->ss_descriptors); 726 680 usb_free_descriptors(f->descriptors); 727 681 gs_free_req(acm->notify, acm->notify_req); 728 682 kfree(acm);
+42
drivers/usb/gadget/f_serial.c
··· 99 99 NULL, 100 100 }; 101 101 102 + static struct usb_endpoint_descriptor gser_ss_in_desc __initdata = { 103 + .bLength = USB_DT_ENDPOINT_SIZE, 104 + .bDescriptorType = USB_DT_ENDPOINT, 105 + .bmAttributes = USB_ENDPOINT_XFER_BULK, 106 + .wMaxPacketSize = cpu_to_le16(1024), 107 + }; 108 + 109 + static struct usb_endpoint_descriptor gser_ss_out_desc __initdata = { 110 + .bLength = USB_DT_ENDPOINT_SIZE, 111 + .bDescriptorType = USB_DT_ENDPOINT, 112 + .bmAttributes = USB_ENDPOINT_XFER_BULK, 113 + .wMaxPacketSize = cpu_to_le16(1024), 114 + }; 115 + 116 + static struct usb_ss_ep_comp_descriptor gser_ss_bulk_comp_desc __initdata = { 117 + .bLength = sizeof gser_ss_bulk_comp_desc, 118 + .bDescriptorType = USB_DT_SS_ENDPOINT_COMP, 119 + }; 120 + 121 + static struct usb_descriptor_header *gser_ss_function[] __initdata = { 122 + (struct usb_descriptor_header *) &gser_interface_desc, 123 + (struct usb_descriptor_header *) &gser_ss_in_desc, 124 + (struct usb_descriptor_header *) &gser_ss_bulk_comp_desc, 125 + (struct usb_descriptor_header *) &gser_ss_out_desc, 126 + (struct usb_descriptor_header *) &gser_ss_bulk_comp_desc, 127 + NULL, 128 + }; 129 + 102 130 /* string descriptors: */ 103 131 104 132 static struct usb_string gser_string_defs[] = { ··· 229 201 /* copy descriptors, and track endpoint copies */ 230 202 f->hs_descriptors = usb_copy_descriptors(gser_hs_function); 231 203 } 204 + if (gadget_is_superspeed(c->cdev->gadget)) { 205 + gser_ss_in_desc.bEndpointAddress = 206 + gser_fs_in_desc.bEndpointAddress; 207 + gser_ss_out_desc.bEndpointAddress = 208 + gser_fs_out_desc.bEndpointAddress; 209 + 210 + /* copy descriptors, and track endpoint copies */ 211 + f->ss_descriptors = usb_copy_descriptors(gser_ss_function); 212 + if (!f->ss_descriptors) 213 + goto fail; 214 + } 232 215 233 216 DBG(cdev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n", 234 217 gser->port_num, 218 + gadget_is_superspeed(c->cdev->gadget) ? "super" : 235 219 gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full", 236 220 gser->port.in->name, gser->port.out->name); 237 221 return 0; ··· 265 225 { 266 226 if (gadget_is_dualspeed(c->cdev->gadget)) 267 227 usb_free_descriptors(f->hs_descriptors); 228 + if (gadget_is_superspeed(c->cdev->gadget)) 229 + usb_free_descriptors(f->ss_descriptors); 268 230 usb_free_descriptors(f->descriptors); 269 231 kfree(func_to_gser(f)); 270 232 }
+1 -1
drivers/usb/gadget/serial.c
··· 242 242 .name = "g_serial", 243 243 .dev = &device_desc, 244 244 .strings = dev_strings, 245 - .max_speed = USB_SPEED_HIGH, 245 + .max_speed = USB_SPEED_SUPER, 246 246 }; 247 247 248 248 static int __init init(void)