diff mbox

[RFT,2/5] usb/ehci: Move capsbase and opregbase into SysBus EHCI class

Message ID 1354417042-8818-3-git-send-email-andreas.faerber@web.de
State New
Headers show

Commit Message

Andreas Färber Dec. 2, 2012, 2:57 a.m. UTC
This allows specific derived models to use different values.

Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
 hw/usb/hcd-ehci-sysbus.c |   26 ++++++++++++++++++++++++--
 1 Datei geändert, 24 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)

Comments

Mitsyanko Igor Dec. 3, 2012, 6:38 p.m. UTC | #1
On 12/02/2012 06:57 AM, Andreas Färber wrote:
> This allows specific derived models to use different values.
>
> Signed-off-by: Andreas Färber <andreas.faerber@web.de>
> ---
>   hw/usb/hcd-ehci-sysbus.c |   26 ++++++++++++++++++++++++--
>   1 Datei geändert, 24 Zeilen hinzugefügt(+), 2 Zeilen entfernt(-)
>
> diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c
> index c7b68b2..38e82bb 100644
> --- a/hw/usb/hcd-ehci-sysbus.c
> +++ b/hw/usb/hcd-ehci-sysbus.c
> @@ -21,6 +21,17 @@
>   #define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb"
>   #define SYS_BUS_EHCI(obj) \
>       OBJECT_CHECK(EHCISysBusState, (obj), TYPE_SYS_BUS_EHCI)
> +#define SYS_BUS_EHCI_CLASS(class) \
> +    OBJECT_CLASS_CHECK(SysBusEHCIClass, (class), TYPE_SYS_BUS_EHCI)
> +#define SYS_BUS_EHCI_GET_CLASS(obj) \
> +    OBJECT_GET_CLASS(SysBusEHCIClass, (obj), TYPE_SYS_BUS_EHCI)
> +
> +typedef struct SysBusEHCIClass {
> +    SysBusDeviceClass parent_class;
> +
> +    uint16_t capsbase;
> +    uint16_t opregbase;
> +} SysBusEHCIClass;
>
>   typedef struct EHCISysBusState {
>       SysBusDevice parent_obj;
> @@ -46,10 +57,11 @@ static Property ehci_sysbus_properties[] = {
>   static int usb_ehci_sysbus_initfn(SysBusDevice *dev)
>   {
>       EHCISysBusState *i = SYS_BUS_EHCI(dev);
> +    SysBusEHCIClass *sec = SYS_BUS_EHCI_GET_CLASS(dev);
>       EHCIState *s = &i->ehci;
>
> -    s->capsbase = 0x100;
> -    s->opregbase = 0x140;
> +    s->capsbase = sec->capsbase;
> +    s->opregbase = sec->opregbase;
>       s->dma = &dma_context_memory;
>
>       usb_ehci_initfn(s, DEVICE(dev));
> @@ -74,11 +86,21 @@ static const TypeInfo ehci_type_info = {
>       .instance_size = sizeof(EHCISysBusState),
>       .abstract      = true,
>       .class_init    = ehci_sysbus_class_init,
> +    .class_size    = sizeof(SysBusEHCIClass),
>   };
>
> +static void ehci_xlnx_class_init(ObjectClass *oc, void *data)
> +{
> +    SysBusEHCIClass *sec = SYS_BUS_EHCI_CLASS(oc);
> +
> +    sec->capsbase = 0x100;
> +    sec->opregbase = 0x140;
> +}
> +
>   static const TypeInfo ehci_xlnx_type_info = {
>       .name          = "xlnx,ps7-usb",
>       .parent        = TYPE_SYS_BUS_EHCI,
> +    .class_init    = ehci_xlnx_class_init,
>   };
>
>   static void ehci_sysbus_register_types(void)
>

Reviewed-by: Igor Mitsyanko <i.mitsyanko@samsung.com>
diff mbox

Patch

diff --git a/hw/usb/hcd-ehci-sysbus.c b/hw/usb/hcd-ehci-sysbus.c
index c7b68b2..38e82bb 100644
--- a/hw/usb/hcd-ehci-sysbus.c
+++ b/hw/usb/hcd-ehci-sysbus.c
@@ -21,6 +21,17 @@ 
 #define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb"
 #define SYS_BUS_EHCI(obj) \
     OBJECT_CHECK(EHCISysBusState, (obj), TYPE_SYS_BUS_EHCI)
+#define SYS_BUS_EHCI_CLASS(class) \
+    OBJECT_CLASS_CHECK(SysBusEHCIClass, (class), TYPE_SYS_BUS_EHCI)
+#define SYS_BUS_EHCI_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(SysBusEHCIClass, (obj), TYPE_SYS_BUS_EHCI)
+
+typedef struct SysBusEHCIClass {
+    SysBusDeviceClass parent_class;
+
+    uint16_t capsbase;
+    uint16_t opregbase;
+} SysBusEHCIClass;
 
 typedef struct EHCISysBusState {
     SysBusDevice parent_obj;
@@ -46,10 +57,11 @@  static Property ehci_sysbus_properties[] = {
 static int usb_ehci_sysbus_initfn(SysBusDevice *dev)
 {
     EHCISysBusState *i = SYS_BUS_EHCI(dev);
+    SysBusEHCIClass *sec = SYS_BUS_EHCI_GET_CLASS(dev);
     EHCIState *s = &i->ehci;
 
-    s->capsbase = 0x100;
-    s->opregbase = 0x140;
+    s->capsbase = sec->capsbase;
+    s->opregbase = sec->opregbase;
     s->dma = &dma_context_memory;
 
     usb_ehci_initfn(s, DEVICE(dev));
@@ -74,11 +86,21 @@  static const TypeInfo ehci_type_info = {
     .instance_size = sizeof(EHCISysBusState),
     .abstract      = true,
     .class_init    = ehci_sysbus_class_init,
+    .class_size    = sizeof(SysBusEHCIClass),
 };
 
+static void ehci_xlnx_class_init(ObjectClass *oc, void *data)
+{
+    SysBusEHCIClass *sec = SYS_BUS_EHCI_CLASS(oc);
+
+    sec->capsbase = 0x100;
+    sec->opregbase = 0x140;
+}
+
 static const TypeInfo ehci_xlnx_type_info = {
     .name          = "xlnx,ps7-usb",
     .parent        = TYPE_SYS_BUS_EHCI,
+    .class_init    = ehci_xlnx_class_init,
 };
 
 static void ehci_sysbus_register_types(void)