From b47187a422c8379c0a9eac672bb03ab65450d51f Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Thu, 21 Jul 2011 16:44:02 -0300
Subject: [RHEL6 qemu-kvm PATCH 24/65] ehci: add ich9 controller.

RH-Author: Gerd Hoffmann <kraxel@redhat.com>
Message-id: <1311266648-1179-25-git-send-email-kraxel@redhat.com>
Patchwork-id: 30147
O-Subject: [RHEL-6.2 kvm PATCH 24/30] ehci: add ich9 controller.
Bugzilla: 723858 723863
RH-Acked-by: Hans de Goede <hdegoede@redhat.com>
RH-Acked-by: Jes Sorensen <Jes.Sorensen@redhat.com>
RH-Acked-by: Alex Williamson <alex.williamson@redhat.com>

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
(cherry picked from commit 3028376ea0239e3820842bb596b21822e2373e9d)

Conflicts:

	hw/usb-ehci.c
---
 hw/usb-ehci.c |   46 +++++++++++++++++++++++++++++++++++-----------
 1 files changed, 35 insertions(+), 11 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/usb-ehci.c |   46 +++++++++++++++++++++++++++++++++++-----------
 1 files changed, 35 insertions(+), 11 deletions(-)

diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
index 0979313..54f092e 100644
--- a/hw/usb-ehci.c
+++ b/hw/usb-ehci.c
@@ -2238,6 +2238,7 @@ static void ehci_map(PCIDevice *pci_dev, int region_num,
 }
 
 static int usb_ehci_initfn(PCIDevice *dev);
+static int usb_ehci_initfn_ich9(PCIDevice *dev);
 
 static USBPortOps ehci_port_ops = {
     .attach = ehci_attach,
@@ -2251,15 +2252,26 @@ static USBBusOps ehci_bus_ops = {
     .register_companion = ehci_register_companion,
 };
 
-static PCIDeviceInfo ehci_info = {
-    .qdev.name    = "usb-ehci",
-    .qdev.size    = sizeof(EHCIState),
-    .init         = usb_ehci_initfn,
-    .qdev.props   = (Property[]) {
-        DEFINE_PROP_UINT32("freq",      EHCIState, freq, FRAME_TIMER_FREQ),
-        DEFINE_PROP_UINT32("maxframes", EHCIState, maxframes, 128),
-        DEFINE_PROP_END_OF_LIST(),
-    },
+static Property ehci_properties[] = {
+    DEFINE_PROP_UINT32("freq",      EHCIState, freq, FRAME_TIMER_FREQ),
+    DEFINE_PROP_UINT32("maxframes", EHCIState, maxframes, 128),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static PCIDeviceInfo ehci_info[] = {
+    {
+        .qdev.name    = "usb-ehci",
+        .qdev.size    = sizeof(EHCIState),
+        .init         = usb_ehci_initfn,
+        .qdev.props   = ehci_properties,
+    },{
+        .qdev.name    = "ich9-usb-ehci1",
+        .qdev.size    = sizeof(EHCIState),
+        .init         = usb_ehci_initfn_ich9,
+        .qdev.props   = ehci_properties,
+    },{
+        /* end of list */
+    }
 };
 
 static int usb_ehci_initfn(PCIDevice *dev)
@@ -2269,7 +2281,7 @@ static int usb_ehci_initfn(PCIDevice *dev)
     int i;
 
     pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
-    pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82801D);
+    pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82801D); /* ich4 */
     pci_set_byte(&pci_conf[PCI_REVISION_ID], 0x10);
     pci_set_byte(&pci_conf[PCI_CLASS_PROG], 0x20);
     pci_config_set_class(pci_conf, PCI_CLASS_SERIAL_USB);
@@ -2340,9 +2352,21 @@ static int usb_ehci_initfn(PCIDevice *dev)
     return 0;
 }
 
+static int usb_ehci_initfn_ich9(PCIDevice *dev)
+{
+    EHCIState *s = DO_UPCAST(EHCIState, dev, dev);
+    uint8_t *pci_conf = s->dev.config;
+
+    int ret = usb_ehci_initfn(dev);
+    pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL);
+    pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82801I_EHCI1);
+    pci_set_byte(&pci_conf[PCI_REVISION_ID], 0x03);
+    return ret;
+}
+
 static void ehci_register(void)
 {
-    pci_qdev_register(&ehci_info);
+    pci_qdev_register_many(ehci_info);
 }
 device_init(ehci_register);
 
-- 
1.7.3.2

