usb: gadget: zero: add superspeed support
authorAmit Blay <ablay@codeaurora.org>
Sun, 3 Jul 2011 14:29:31 +0000 (17:29 +0300)
committerFelipe Balbi <balbi@ti.com>
Fri, 8 Jul 2011 10:57:54 +0000 (13:57 +0300)
This patch adds SuperSpeed descriptors to the
g_zero gadget.

The SuperSpeed descriptors were added both for
f_soursesink and f_loopback function drivers.

Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org>
Signed-off-by: Amit Blay <ablay@codeaurora.org>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/f_loopback.c
drivers/usb/gadget/f_sourcesink.c
drivers/usb/gadget/zero.c

index 375632659a03c9b6aaa6904b9a39ef132885e250..ca660d40b11a5c77e699b397a26852219900381f 100644 (file)
@@ -118,6 +118,49 @@ static struct usb_descriptor_header *hs_loopback_descs[] = {
        NULL,
 };
 
+/* super speed support: */
+
+static struct usb_endpoint_descriptor ss_loop_source_desc = {
+       .bLength =              USB_DT_ENDPOINT_SIZE,
+       .bDescriptorType =      USB_DT_ENDPOINT,
+
+       .bmAttributes =         USB_ENDPOINT_XFER_BULK,
+       .wMaxPacketSize =       cpu_to_le16(1024),
+};
+
+struct usb_ss_ep_comp_descriptor ss_loop_source_comp_desc = {
+       .bLength =              USB_DT_SS_EP_COMP_SIZE,
+       .bDescriptorType =      USB_DT_SS_ENDPOINT_COMP,
+       .bMaxBurst =            0,
+       .bmAttributes =         0,
+       .wBytesPerInterval =    0,
+};
+
+static struct usb_endpoint_descriptor ss_loop_sink_desc = {
+       .bLength =              USB_DT_ENDPOINT_SIZE,
+       .bDescriptorType =      USB_DT_ENDPOINT,
+
+       .bmAttributes =         USB_ENDPOINT_XFER_BULK,
+       .wMaxPacketSize =       cpu_to_le16(1024),
+};
+
+struct usb_ss_ep_comp_descriptor ss_loop_sink_comp_desc = {
+       .bLength =              USB_DT_SS_EP_COMP_SIZE,
+       .bDescriptorType =      USB_DT_SS_ENDPOINT_COMP,
+       .bMaxBurst =            0,
+       .bmAttributes =         0,
+       .wBytesPerInterval =    0,
+};
+
+static struct usb_descriptor_header *ss_loopback_descs[] = {
+       (struct usb_descriptor_header *) &loopback_intf,
+       (struct usb_descriptor_header *) &ss_loop_source_desc,
+       (struct usb_descriptor_header *) &ss_loop_source_comp_desc,
+       (struct usb_descriptor_header *) &ss_loop_sink_desc,
+       (struct usb_descriptor_header *) &ss_loop_sink_comp_desc,
+       NULL,
+};
+
 /* function-specific strings: */
 
 static struct usb_string strings_loopback[] = {
@@ -175,8 +218,18 @@ autoconf_fail:
                f->hs_descriptors = hs_loopback_descs;
        }
 
+       /* support super speed hardware */
+       if (gadget_is_superspeed(c->cdev->gadget)) {
+               ss_loop_source_desc.bEndpointAddress =
+                               fs_loop_source_desc.bEndpointAddress;
+               ss_loop_sink_desc.bEndpointAddress =
+                               fs_loop_sink_desc.bEndpointAddress;
+               f->ss_descriptors = ss_loopback_descs;
+       }
+
        DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n",
-                       gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full",
+           (gadget_is_superspeed(c->cdev->gadget) ? "super" :
+            (gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full")),
                        f->name, loop->in_ep->name, loop->out_ep->name);
        return 0;
 }
index 5a92883f4c8c7da4398a943455ce8bec3505e50b..e18b4f5209516f7a55c2b4e3ad4d75bc07e168c1 100644 (file)
@@ -131,6 +131,49 @@ static struct usb_descriptor_header *hs_source_sink_descs[] = {
        NULL,
 };
 
+/* super speed support: */
+
+static struct usb_endpoint_descriptor ss_source_desc = {
+       .bLength =              USB_DT_ENDPOINT_SIZE,
+       .bDescriptorType =      USB_DT_ENDPOINT,
+
+       .bmAttributes =         USB_ENDPOINT_XFER_BULK,
+       .wMaxPacketSize =       cpu_to_le16(1024),
+};
+
+struct usb_ss_ep_comp_descriptor ss_source_comp_desc = {
+       .bLength =              USB_DT_SS_EP_COMP_SIZE,
+       .bDescriptorType =      USB_DT_SS_ENDPOINT_COMP,
+       .bMaxBurst =            0,
+       .bmAttributes =         0,
+       .wBytesPerInterval =    0,
+};
+
+static struct usb_endpoint_descriptor ss_sink_desc = {
+       .bLength =              USB_DT_ENDPOINT_SIZE,
+       .bDescriptorType =      USB_DT_ENDPOINT,
+
+       .bmAttributes =         USB_ENDPOINT_XFER_BULK,
+       .wMaxPacketSize =       cpu_to_le16(1024),
+};
+
+struct usb_ss_ep_comp_descriptor ss_sink_comp_desc = {
+       .bLength =              USB_DT_SS_EP_COMP_SIZE,
+       .bDescriptorType =      USB_DT_SS_ENDPOINT_COMP,
+       .bMaxBurst =            0,
+       .bmAttributes =         0,
+       .wBytesPerInterval =    0,
+};
+
+static struct usb_descriptor_header *ss_source_sink_descs[] = {
+       (struct usb_descriptor_header *) &source_sink_intf,
+       (struct usb_descriptor_header *) &ss_source_desc,
+       (struct usb_descriptor_header *) &ss_source_comp_desc,
+       (struct usb_descriptor_header *) &ss_sink_desc,
+       (struct usb_descriptor_header *) &ss_sink_comp_desc,
+       NULL,
+};
+
 /* function-specific strings: */
 
 static struct usb_string strings_sourcesink[] = {
@@ -187,8 +230,18 @@ autoconf_fail:
                f->hs_descriptors = hs_source_sink_descs;
        }
 
+       /* support super speed hardware */
+       if (gadget_is_superspeed(c->cdev->gadget)) {
+               ss_source_desc.bEndpointAddress =
+                               fs_source_desc.bEndpointAddress;
+               ss_sink_desc.bEndpointAddress =
+                               fs_sink_desc.bEndpointAddress;
+               f->ss_descriptors = ss_source_sink_descs;
+       }
+
        DBG(cdev, "%s speed %s: IN/%s, OUT/%s\n",
-                       gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full",
+           (gadget_is_superspeed(c->cdev->gadget) ? "super" :
+            (gadget_is_dualspeed(c->cdev->gadget) ? "dual" : "full")),
                        f->name, ss->in_ep->name, ss->out_ep->name);
        return 0;
 }
index af7e7c3818d8b8588ce2909ec58d28b2c647fb98..00e2fd2d47912e985fa81ee555b744b386759c18 100644 (file)
@@ -340,7 +340,7 @@ static struct usb_composite_driver zero_driver = {
        .name           = "zero",
        .dev            = &device_desc,
        .strings        = dev_strings,
-       .max_speed      = USB_SPEED_HIGH,
+       .max_speed      = USB_SPEED_SUPER,
        .unbind         = zero_unbind,
        .suspend        = zero_suspend,
        .resume         = zero_resume,