qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Liming Wang <walimisdev@gmail.com>
To: qemu-devel@nongnu.org, Gerd Hoffmann <kraxel@redhat.com>,
	Peter Crosthwaite <peter.crosthwaite@petalogix.com>,
	Mitsyanko Igor <i.mitsyanko@samsung.com>
Cc: Peter Maydell <peter.maydell@linaro.org>
Subject: [Qemu-devel] [PATCH 1/2] usb/ehci: Refactor ehci-sysbus to add exynos4210 ehci support
Date: Sat,  1 Dec 2012 23:27:38 +0800	[thread overview]
Message-ID: <1354375659-17056-1-git-send-email-walimisdev@gmail.com> (raw)

Refactor ehci-sysbus to accept different capsbase and opregbase.
And then add exynos4210 ehci support to ehci-sysbus.

Signed-off-by: Liming Wang <walimisdev@gmail.com>
---
 hw/usb/hcd-ehci-sysbus.c |   48 ++++++++++++++++++++++++++++++++++++----------
 1 file changed, 38 insertions(+), 10 deletions(-)

diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c
index 803df92..f4f3ffe 100644
--- a/hw/usb/hcd-ehci-sysbus.c
+++ b/hw/usb/hcd-ehci-sysbus.c
@@ -23,6 +23,11 @@ typedef struct EHCISysBusState {
     EHCIState ehci;
 } EHCISysBusState;
 
+typedef struct EHCISysBusClass {
+    SysBusDeviceClass sdc;
+    EHCIState ehci;
+} EHCISysBusClass;
+
 static const VMStateDescription vmstate_ehci_sysbus = {
     .name        = "ehci-sysbus",
     .version_id  = 2,
@@ -41,10 +46,11 @@ static Property ehci_sysbus_properties[] = {
 static int usb_ehci_sysbus_initfn(SysBusDevice *dev)
 {
     EHCISysBusState *i = FROM_SYSBUS(EHCISysBusState, dev);
+    EHCISysBusClass *c = (EHCISysBusClass *)object_get_class(OBJECT(dev));
     EHCIState *s = &i->ehci;
 
-    s->capsbase = 0x100;
-    s->opregbase = 0x140;
+    s->capsbase = c->ehci.capsbase;
+    s->opregbase = c->ehci.opregbase;
     s->dma = &dma_context_memory;
 
     usb_ehci_initfn(s, DEVICE(dev));
@@ -56,23 +62,45 @@ static int usb_ehci_sysbus_initfn(SysBusDevice *dev)
 static void ehci_sysbus_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
-    SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
+    EHCISysBusClass *k = (EHCISysBusClass *)klass;
+    EHCISysBusClass *c = (EHCISysBusClass *)data;
 
-    k->init = usb_ehci_sysbus_initfn;
+    k->sdc.init = usb_ehci_sysbus_initfn;
+    k->ehci = c->ehci;
     dc->vmsd = &vmstate_ehci_sysbus;
     dc->props = ehci_sysbus_properties;
 }
 
-TypeInfo ehci_xlnx_type_info = {
-    .name          = "xlnx,ps7-usb",
-    .parent        = TYPE_SYS_BUS_DEVICE,
-    .instance_size = sizeof(EHCISysBusState),
-    .class_init    = ehci_sysbus_class_init,
+static TypeInfo ehci_sysbus_type_info[] = {
+    {
+        .name          = "xlnx,ps7-usb",
+        .parent        = TYPE_SYS_BUS_DEVICE,
+        .instance_size = sizeof(EHCISysBusState),
+        .class_init    = ehci_sysbus_class_init,
+        .class_size    = sizeof(EHCISysBusClass),
+        .class_data    = (EHCISysBusClass[]) {{
+	    .ehci.capsbase  = 0x100,
+	    .ehci.opregbase = 0x140,
+        } }
+    }, {
+        .name          = "exynos4210.usb",
+        .parent        = TYPE_SYS_BUS_DEVICE,
+        .instance_size = sizeof(EHCISysBusState),
+        .class_init    = ehci_sysbus_class_init,
+        .class_size    = sizeof(EHCISysBusClass),
+        .class_data    = (EHCISysBusClass[]) {{
+            .ehci.capsbase  = 0x0,
+            .ehci.opregbase = 0x40,
+        } }
+    },
 };
 
 static void ehci_sysbus_register_types(void)
 {
-    type_register_static(&ehci_xlnx_type_info);
+    int i;
+    for (i = 0; i < ARRAY_SIZE(ehci_sysbus_type_info); i++) {
+        type_register_static(&ehci_sysbus_type_info[i]);
+    }
 }
 
 type_init(ehci_sysbus_register_types)
-- 
1.7.9.5

             reply	other threads:[~2012-12-01 15:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-01 15:27 Liming Wang [this message]
2012-12-01 15:27 ` [Qemu-devel] [PATCH 2/2] exynos4210: Add ehci support Liming Wang
2012-12-01 19:47 ` [Qemu-devel] [PATCH 1/2] usb/ehci: Refactor ehci-sysbus to add exynos4210 " Andreas Färber

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=1354375659-17056-1-git-send-email-walimisdev@gmail.com \
    --to=walimisdev@gmail.com \
    --cc=i.mitsyanko@samsung.com \
    --cc=kraxel@redhat.com \
    --cc=peter.crosthwaite@petalogix.com \
    --cc=peter.maydell@linaro.org \
    --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).