Blame 0615-usb-storage-usb3-support.patch

5544c1
From 9a6fd10bf6a85c4df63a7ba1cf7d6203220d722e Mon Sep 17 00:00:00 2001
Hans de Goede c8dfc6
From: Gerd Hoffmann <kraxel@redhat.com>
Hans de Goede c8dfc6
Date: Tue, 28 Aug 2012 17:29:15 +0200
5544c1
Subject: [PATCH] usb-storage: usb3 support
Hans de Goede c8dfc6
Hans de Goede c8dfc6
Add usb3 descriptors to usb-storage, so it shows up as superspeed
Hans de Goede c8dfc6
device when connected to xhci.
Hans de Goede c8dfc6
Hans de Goede c8dfc6
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Hans de Goede c8dfc6
---
Hans de Goede c8dfc6
 hw/usb/dev-storage.c | 46 +++++++++++++++++++++++++++++++++++++++++++---
Hans de Goede c8dfc6
 1 file changed, 43 insertions(+), 3 deletions(-)
Hans de Goede c8dfc6
Hans de Goede c8dfc6
diff --git a/hw/usb/dev-storage.c b/hw/usb/dev-storage.c
Hans de Goede c8dfc6
index ff48d91..e732191 100644
Hans de Goede c8dfc6
--- a/hw/usb/dev-storage.c
Hans de Goede c8dfc6
+++ b/hw/usb/dev-storage.c
Hans de Goede c8dfc6
@@ -78,6 +78,7 @@ enum {
Hans de Goede c8dfc6
     STR_SERIALNUMBER,
Hans de Goede c8dfc6
     STR_CONFIG_FULL,
Hans de Goede c8dfc6
     STR_CONFIG_HIGH,
Hans de Goede c8dfc6
+    STR_CONFIG_SUPER,
Hans de Goede c8dfc6
 };
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
 static const USBDescStrings desc_strings = {
Hans de Goede c8dfc6
@@ -86,6 +87,7 @@ static const USBDescStrings desc_strings = {
Hans de Goede c8dfc6
     [STR_SERIALNUMBER] = "1",
Hans de Goede c8dfc6
     [STR_CONFIG_FULL]  = "Full speed config (usb 1.1)",
Hans de Goede c8dfc6
     [STR_CONFIG_HIGH]  = "High speed config (usb 2.0)",
Hans de Goede c8dfc6
+    [STR_CONFIG_SUPER] = "Super speed config (usb 3.0)",
Hans de Goede c8dfc6
 };
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
 static const USBDescIface desc_iface_full = {
Hans de Goede c8dfc6
@@ -158,6 +160,43 @@ static const USBDescDevice desc_device_high = {
Hans de Goede c8dfc6
     },
Hans de Goede c8dfc6
 };
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
+static const USBDescIface desc_iface_super = {
Hans de Goede c8dfc6
+    .bInterfaceNumber              = 0,
Hans de Goede c8dfc6
+    .bNumEndpoints                 = 2,
Hans de Goede c8dfc6
+    .bInterfaceClass               = USB_CLASS_MASS_STORAGE,
Hans de Goede c8dfc6
+    .bInterfaceSubClass            = 0x06, /* SCSI */
Hans de Goede c8dfc6
+    .bInterfaceProtocol            = 0x50, /* Bulk */
Hans de Goede c8dfc6
+    .eps = (USBDescEndpoint[]) {
Hans de Goede c8dfc6
+        {
Hans de Goede c8dfc6
+            .bEndpointAddress      = USB_DIR_IN | 0x01,
Hans de Goede c8dfc6
+            .bmAttributes          = USB_ENDPOINT_XFER_BULK,
Hans de Goede c8dfc6
+            .wMaxPacketSize        = 1024,
Hans de Goede c8dfc6
+            .bMaxBurst             = 15,
Hans de Goede c8dfc6
+        },{
Hans de Goede c8dfc6
+            .bEndpointAddress      = USB_DIR_OUT | 0x02,
Hans de Goede c8dfc6
+            .bmAttributes          = USB_ENDPOINT_XFER_BULK,
Hans de Goede c8dfc6
+            .wMaxPacketSize        = 1024,
Hans de Goede c8dfc6
+            .bMaxBurst             = 15,
Hans de Goede c8dfc6
+        },
Hans de Goede c8dfc6
+    }
Hans de Goede c8dfc6
+};
Hans de Goede c8dfc6
+
Hans de Goede c8dfc6
+static const USBDescDevice desc_device_super = {
Hans de Goede c8dfc6
+    .bcdUSB                        = 0x0300,
Hans de Goede c8dfc6
+    .bMaxPacketSize0               = 9,
Hans de Goede c8dfc6
+    .bNumConfigurations            = 1,
Hans de Goede c8dfc6
+    .confs = (USBDescConfig[]) {
Hans de Goede c8dfc6
+        {
Hans de Goede c8dfc6
+            .bNumInterfaces        = 1,
Hans de Goede c8dfc6
+            .bConfigurationValue   = 1,
Hans de Goede c8dfc6
+            .iConfiguration        = STR_CONFIG_SUPER,
Hans de Goede c8dfc6
+            .bmAttributes          = 0xc0,
Hans de Goede c8dfc6
+            .nif = 1,
Hans de Goede c8dfc6
+            .ifs = &desc_iface_super,
Hans de Goede c8dfc6
+        },
Hans de Goede c8dfc6
+    },
Hans de Goede c8dfc6
+};
Hans de Goede c8dfc6
+
Hans de Goede c8dfc6
 static const USBDesc desc = {
Hans de Goede c8dfc6
     .id = {
Hans de Goede c8dfc6
         .idVendor          = 0x46f4, /* CRC16() of "QEMU" */
Hans de Goede c8dfc6
@@ -167,9 +206,10 @@ static const USBDesc desc = {
Hans de Goede c8dfc6
         .iProduct          = STR_PRODUCT,
Hans de Goede c8dfc6
         .iSerialNumber     = STR_SERIALNUMBER,
Hans de Goede c8dfc6
     },
Hans de Goede c8dfc6
-    .full = &desc_device_full,
Hans de Goede c8dfc6
-    .high = &desc_device_high,
Hans de Goede c8dfc6
-    .str  = desc_strings,
Hans de Goede c8dfc6
+    .full  = &desc_device_full,
Hans de Goede c8dfc6
+    .high  = &desc_device_high,
Hans de Goede c8dfc6
+    .super = &desc_device_super,
Hans de Goede c8dfc6
+    .str   = desc_strings,
Hans de Goede c8dfc6
 };
Hans de Goede c8dfc6
 
Hans de Goede c8dfc6
 static void usb_msd_copy_data(MSDState *s, USBPacket *p)
Hans de Goede c8dfc6
-- 
5544c1
1.7.12.1
Hans de Goede c8dfc6