peterdelevoryas / rpms / qemu

Forked from rpms/qemu 2 years ago
Clone

Blame 0013-usb-uhci-Add-support-for-being-a-companion-controlle.patch

3f1f29
From 850d218026df41324430af62063f68afe652a7ac Mon Sep 17 00:00:00 2001
3f1f29
From: Hans de Goede <hdegoede@redhat.com>
3f1f29
Date: Fri, 24 Jun 2011 17:44:53 +0200
3f1f29
Subject: [PATCH 13/35] usb-uhci: Add support for being a companion controller
3f1f29
3f1f29
To use as a companion controller set the masterbus property.
3f1f29
3f1f29
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
3f1f29
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
3f1f29
---
3f1f29
 hw/usb-uhci.c |   41 ++++++++++++++++++++++++++++++++++++-----
3f1f29
 1 files changed, 36 insertions(+), 5 deletions(-)
3f1f29
3f1f29
diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
3f1f29
index a46d61a..925c03b 100644
3f1f29
--- a/hw/usb-uhci.c
3f1f29
+++ b/hw/usb-uhci.c
3f1f29
@@ -132,7 +132,7 @@ typedef struct UHCIPort {
3f1f29
 
3f1f29
 struct UHCIState {
3f1f29
     PCIDevice dev;
3f1f29
-    USBBus bus;
3f1f29
+    USBBus bus; /* Note unused when we're a companion controller */
3f1f29
     uint16_t cmd; /* cmd register */
3f1f29
     uint16_t status;
3f1f29
     uint16_t intr; /* interrupt enable register */
3f1f29
@@ -150,6 +150,10 @@ struct UHCIState {
3f1f29
     /* Active packets */
3f1f29
     QTAILQ_HEAD(,UHCIAsync) async_pending;
3f1f29
     uint8_t num_ports_vmstate;
3f1f29
+
3f1f29
+    /* Properties */
3f1f29
+    char *masterbus;
3f1f29
+    uint32_t firstport;
3f1f29
 };
3f1f29
 
3f1f29
 typedef struct UHCI_TD {
3f1f29
@@ -1126,10 +1130,22 @@ static int usb_uhci_common_initfn(PCIDevice *dev)
3f1f29
     pci_conf[PCI_INTERRUPT_PIN] = 4; // interrupt pin 3
3f1f29
     pci_conf[USB_SBRN] = USB_RELEASE_1; // release number
3f1f29
 
3f1f29
-    usb_bus_new(&s->bus, &uhci_bus_ops, &s->dev.qdev);
3f1f29
-    for(i = 0; i < NB_PORTS; i++) {
3f1f29
-        usb_register_port(&s->bus, &s->ports[i].port, s, i, &uhci_port_ops,
3f1f29
-                          USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
3f1f29
+    if (s->masterbus) {
3f1f29
+        USBPort *ports[NB_PORTS];
3f1f29
+        for(i = 0; i < NB_PORTS; i++) {
3f1f29
+            ports[i] = &s->ports[i].port;
3f1f29
+        }
3f1f29
+        if (usb_register_companion(s->masterbus, ports, NB_PORTS,
3f1f29
+                s->firstport, s, &uhci_port_ops,
3f1f29
+                USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL) != 0) {
3f1f29
+            return -1;
3f1f29
+        }
3f1f29
+    } else {
3f1f29
+        usb_bus_new(&s->bus, &uhci_bus_ops, &s->dev.qdev);
3f1f29
+        for (i = 0; i < NB_PORTS; i++) {
3f1f29
+            usb_register_port(&s->bus, &s->ports[i].port, s, i, &uhci_port_ops,
3f1f29
+                              USB_SPEED_MASK_LOW | USB_SPEED_MASK_FULL);
3f1f29
+        }
3f1f29
     }
3f1f29
     s->frame_timer = qemu_new_timer_ns(vm_clock, uhci_frame_timer, s);
3f1f29
     s->num_ports_vmstate = NB_PORTS;
3f1f29
@@ -1170,6 +1186,11 @@ static PCIDeviceInfo uhci_info[] = {
3f1f29
         .device_id    = PCI_DEVICE_ID_INTEL_82371SB_2,
3f1f29
         .revision     = 0x01,
3f1f29
         .class_id     = PCI_CLASS_SERIAL_USB,
3f1f29
+        .qdev.props   = (Property[]) {
3f1f29
+            DEFINE_PROP_STRING("masterbus", UHCIState, masterbus),
3f1f29
+            DEFINE_PROP_UINT32("firstport", UHCIState, firstport, 0),
3f1f29
+            DEFINE_PROP_END_OF_LIST(),
3f1f29
+        },
3f1f29
     },{
3f1f29
         .qdev.name    = "piix4-usb-uhci",
3f1f29
         .qdev.size    = sizeof(UHCIState),
3f1f29
@@ -1179,6 +1200,11 @@ static PCIDeviceInfo uhci_info[] = {
3f1f29
         .device_id    = PCI_DEVICE_ID_INTEL_82371AB_2,
3f1f29
         .revision     = 0x01,
3f1f29
         .class_id     = PCI_CLASS_SERIAL_USB,
3f1f29
+        .qdev.props   = (Property[]) {
3f1f29
+            DEFINE_PROP_STRING("masterbus", UHCIState, masterbus),
3f1f29
+            DEFINE_PROP_UINT32("firstport", UHCIState, firstport, 0),
3f1f29
+            DEFINE_PROP_END_OF_LIST(),
3f1f29
+        },
3f1f29
     },{
3f1f29
         .qdev.name    = "vt82c686b-usb-uhci",
3f1f29
         .qdev.size    = sizeof(UHCIState),
3f1f29
@@ -1188,6 +1214,11 @@ static PCIDeviceInfo uhci_info[] = {
3f1f29
         .device_id    = PCI_DEVICE_ID_VIA_UHCI,
3f1f29
         .revision     = 0x01,
3f1f29
         .class_id     = PCI_CLASS_SERIAL_USB,
3f1f29
+        .qdev.props   = (Property[]) {
3f1f29
+            DEFINE_PROP_STRING("masterbus", UHCIState, masterbus),
3f1f29
+            DEFINE_PROP_UINT32("firstport", UHCIState, firstport, 0),
3f1f29
+            DEFINE_PROP_END_OF_LIST(),
3f1f29
+        },
3f1f29
     },{
3f1f29
         /* end of list */
3f1f29
     }
3f1f29
-- 
3f1f29
1.7.5.1
3f1f29