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