From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [PATCH 1/2] usb: add ich9_ehci_with_companion_init()
Date: Fri, 1 Jul 2011 13:27:25 +0200 [thread overview]
Message-ID: <1309519646-3206-2-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1309519646-3206-1-git-send-email-kraxel@redhat.com>
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 <kraxel@redhat.com>
---
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
next prev parent reply other threads:[~2011-07-01 11:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-01 11:27 [Qemu-devel] PCI: how handle multifunction / compound devices best? Gerd Hoffmann
2011-07-01 11:27 ` Gerd Hoffmann [this message]
2011-07-01 11:27 ` [Qemu-devel] [PATCH 2/2] usb: windup ich9_ehci_with_companion_init via -usb2 switch Gerd Hoffmann
2011-07-01 12:19 ` [Qemu-devel] PCI: how handle multifunction / compound devices best? Anthony Liguori
2011-07-04 15:19 ` Markus Armbruster
2011-07-04 16:09 ` Markus Armbruster
2011-07-05 7:41 ` Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1309519646-3206-2-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).