From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:53019) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qcbsv-0005Gw-T3 for qemu-devel@nongnu.org; Fri, 01 Jul 2011 07:27:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qcbst-0005Cb-F4 for qemu-devel@nongnu.org; Fri, 01 Jul 2011 07:27:45 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35746) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qcbss-0005C4-Ht for qemu-devel@nongnu.org; Fri, 01 Jul 2011 07:27:42 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p61BRfJs003780 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 1 Jul 2011 07:27:41 -0400 From: Gerd Hoffmann Date: Fri, 1 Jul 2011 13:27:25 +0200 Message-Id: <1309519646-3206-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1309519646-3206-1-git-send-email-kraxel@redhat.com> References: <1309519646-3206-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PATCH 1/2] usb: add ich9_ehci_with_companion_init() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann Add convinience function which creates a ehci controller with three companion uhci controllers, with all properties are setup correctly. The guest will see this: [root@fedora64 ~]# lspci -s2 00:02.0 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #1 (rev 03) 00:02.1 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #2 (rev 03) 00:02.2 USB Controller: Intel Corporation 82801I (ICH9 Family) USB UHCI Controller #3 (rev 03) 00:02.7 USB Controller: Intel Corporation 82801I (ICH9 Family) USB2 EHCI Controller #1 (rev 03) Signed-off-by: Gerd Hoffmann --- hw/usb-ehci.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ hw/usb.h | 3 +++ 2 files changed, 52 insertions(+), 0 deletions(-) diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c index a4758f9..d24eecb 100644 --- a/hw/usb-ehci.c +++ b/hw/usb-ehci.c @@ -2354,6 +2354,55 @@ static void ehci_register(void) } device_init(ehci_register); +int ich9_ehci_with_companion_init(PCIBus *bus, int devfn, const char *id) +{ + PCIDevice *ehci = NULL, *uhci1 = NULL, *uhci2 = NULL, *uhci3 = NULL; + char masterbus[32]; + int slot = PCI_SLOT(devfn); + + snprintf(masterbus, sizeof(masterbus), "%s.0", id); + + ehci = pci_create_multifunction(bus, PCI_DEVFN(slot, 7), true, + "ich9-usb-ehci1"); + if (NULL == ehci) { + goto fail; + } + ehci->qdev.id = id; + qdev_init_nofail(&ehci->qdev); + + uhci1 = pci_create_multifunction(bus, PCI_DEVFN(slot, 0), true, + "ich9-usb-uhci1"); + if (NULL == uhci1) { + goto fail; + } + qdev_prop_set_string(&uhci1->qdev, "masterbus", masterbus); + qdev_prop_set_uint32(&uhci1->qdev, "firstport", 0); + qdev_init_nofail(&uhci1->qdev); + + uhci2 = pci_create_multifunction(bus, PCI_DEVFN(slot, 1), true, + "ich9-usb-uhci2"); + if (NULL == uhci2) { + goto fail; + } + qdev_prop_set_string(&uhci2->qdev, "masterbus", masterbus); + qdev_prop_set_uint32(&uhci2->qdev, "firstport", 2); + qdev_init_nofail(&uhci2->qdev); + + uhci3 = pci_create_multifunction(bus, PCI_DEVFN(slot, 2), true, + "ich9-usb-uhci3"); + if (NULL == uhci3) { + goto fail; + } + qdev_prop_set_string(&uhci3->qdev, "masterbus", masterbus); + qdev_prop_set_uint32(&uhci3->qdev, "firstport", 4); + qdev_init_nofail(&uhci3->qdev); + return 0; + +fail: + return -1; +} + + /* * vim: expandtab ts=4 */ diff --git a/hw/usb.h b/hw/usb.h index ded2de2..2f90b3a 100644 --- a/hw/usb.h +++ b/hw/usb.h @@ -313,6 +313,9 @@ void usb_hid_datain_cb(USBDevice *dev, void *opaque, void (*datain)(void *)); /* usb-bt.c */ USBDevice *usb_bt_init(HCIInfo *hci); +/* usb-ehci.c */ +int ich9_ehci_with_companion_init(PCIBus *bus, int devfn, const char *id); + /* usb ports of the VM */ #define VM_USB_HUB_SIZE 8 -- 1.7.1