diff mbox series

[07/11] hw/arm/aspeed: Introduce TYPE_ASPEED2400_SOC

Message ID 20231024162423.40206-8-philmd@linaro.org
State New
Headers show
Series hw/arm/aspeed: Split AspeedSoCState per 2400/2600/10x0 | expand

Commit Message

Philippe Mathieu-Daudé Oct. 24, 2023, 4:24 p.m. UTC
TYPE_ASPEED2400_SOC inherits from TYPE_ASPEED_SOC.
In few commits we'll add more fields, but to keep
review process simple, don't add any yet.

TYPE_ASPEED_SOC is common to various Aspeed SoCs,
define it in aspeed_soc_common.c.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/arm/aspeed_soc.h |  7 +++++
 hw/arm/aspeed_soc.c         | 61 +++++++++++--------------------------
 hw/arm/aspeed_soc_common.c  | 29 ++++++++++++++++++
 3 files changed, 53 insertions(+), 44 deletions(-)

Comments

Cédric Le Goater Oct. 25, 2023, 7:10 a.m. UTC | #1
On 10/24/23 18:24, Philippe Mathieu-Daudé wrote:
> TYPE_ASPEED2400_SOC inherits from TYPE_ASPEED_SOC.
> In few commits we'll add more fields, but to keep
> review process simple, don't add any yet.
> 
> TYPE_ASPEED_SOC is common to various Aspeed SoCs,
> define it in aspeed_soc_common.c.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>


Reviewed-by: Cédric Le Goater <clg@kaod.org>

Thanks,

C.


> ---
>   include/hw/arm/aspeed_soc.h |  7 +++++
>   hw/arm/aspeed_soc.c         | 61 +++++++++++--------------------------
>   hw/arm/aspeed_soc_common.c  | 29 ++++++++++++++++++
>   3 files changed, 53 insertions(+), 44 deletions(-)
> 
> diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
> index 103b1598f6..ee7926b81c 100644
> --- a/include/hw/arm/aspeed_soc.h
> +++ b/include/hw/arm/aspeed_soc.h
> @@ -101,6 +101,13 @@ struct AspeedSoCState {
>   #define TYPE_ASPEED_SOC "aspeed-soc"
>   OBJECT_DECLARE_TYPE(AspeedSoCState, AspeedSoCClass, ASPEED_SOC)
>   
> +struct Aspeed2400SoCState {
> +    AspeedSoCState parent;
> +};
> +
> +#define TYPE_ASPEED2400_SOC "aspeed2400-soc"
> +OBJECT_DECLARE_SIMPLE_TYPE(Aspeed2400SoCState, ASPEED2400_SOC)
> +
>   struct Aspeed2600SoCState {
>       AspeedSoCState parent;
>   };
> diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
> index 191276a320..dfb97f6dbd 100644
> --- a/hw/arm/aspeed_soc.c
> +++ b/hw/arm/aspeed_soc.c
> @@ -497,29 +497,6 @@ static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp)
>       sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0,
>                          aspeed_soc_get_irq(s, ASPEED_DEV_HACE));
>   }
> -static Property aspeed_soc_properties[] = {
> -    DEFINE_PROP_LINK("memory", AspeedSoCState, memory, TYPE_MEMORY_REGION,
> -                     MemoryRegion *),
> -    DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION,
> -                     MemoryRegion *),
> -    DEFINE_PROP_END_OF_LIST(),
> -};
> -
> -static void aspeed_soc_class_init(ObjectClass *oc, void *data)
> -{
> -    DeviceClass *dc = DEVICE_CLASS(oc);
> -
> -    device_class_set_props(dc, aspeed_soc_properties);
> -}
> -
> -static const TypeInfo aspeed_soc_type_info = {
> -    .name           = TYPE_ASPEED_SOC,
> -    .parent         = TYPE_DEVICE,
> -    .instance_size  = sizeof(AspeedSoCState),
> -    .class_size     = sizeof(AspeedSoCClass),
> -    .class_init     = aspeed_soc_class_init,
> -    .abstract       = true,
> -};
>   
>   static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data)
>   {
> @@ -545,14 +522,6 @@ static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data)
>       sc->get_irq      = aspeed_soc_ast2400_get_irq;
>   }
>   
> -static const TypeInfo aspeed_soc_ast2400_type_info = {
> -    .name           = "ast2400-a1",
> -    .parent         = TYPE_ASPEED_SOC,
> -    .instance_init  = aspeed_ast2400_soc_init,
> -    .instance_size  = sizeof(AspeedSoCState),
> -    .class_init     = aspeed_soc_ast2400_class_init,
> -};
> -
>   static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data)
>   {
>       AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc);
> @@ -577,18 +546,22 @@ static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data)
>       sc->get_irq      = aspeed_soc_ast2400_get_irq;
>   }
>   
> -static const TypeInfo aspeed_soc_ast2500_type_info = {
> -    .name           = "ast2500-a1",
> -    .parent         = TYPE_ASPEED_SOC,
> -    .instance_init  = aspeed_ast2400_soc_init,
> -    .instance_size  = sizeof(AspeedSoCState),
> -    .class_init     = aspeed_soc_ast2500_class_init,
> -};
> -static void aspeed_soc_register_types(void)
> -{
> -    type_register_static(&aspeed_soc_type_info);
> -    type_register_static(&aspeed_soc_ast2400_type_info);
> -    type_register_static(&aspeed_soc_ast2500_type_info);
> +static const TypeInfo aspeed_soc_ast2400_types[] = {
> +    {
> +        .name           = TYPE_ASPEED2400_SOC,
> +        .parent         = TYPE_ASPEED_SOC,
> +        .instance_init  = aspeed_ast2400_soc_init,
> +        .instance_size  = sizeof(Aspeed2400SoCState),
> +        .abstract       = true,
> +    }, {
> +        .name           = "ast2400-a1",
> +        .parent         = TYPE_ASPEED2400_SOC,
> +        .class_init     = aspeed_soc_ast2400_class_init,
> +    }, {
> +        .name           = "ast2500-a1",
> +        .parent         = TYPE_ASPEED2400_SOC,
> +        .class_init     = aspeed_soc_ast2500_class_init,
> +    },
>   };
>   
> -type_init(aspeed_soc_register_types);
> +DEFINE_TYPES(aspeed_soc_ast2400_types)
> diff --git a/hw/arm/aspeed_soc_common.c b/hw/arm/aspeed_soc_common.c
> index a43f5d2a6f..b66f769d18 100644
> --- a/hw/arm/aspeed_soc_common.c
> +++ b/hw/arm/aspeed_soc_common.c
> @@ -12,6 +12,7 @@
>   
>   #include "qemu/osdep.h"
>   #include "qapi/error.h"
> +#include "hw/qdev-properties.h"
>   #include "hw/misc/unimp.h"
>   #include "hw/arm/aspeed_soc.h"
>   #include "hw/char/serial.h"
> @@ -112,3 +113,31 @@ void aspeed_mmio_map_unimplemented(AspeedSoCState *s, SysBusDevice *dev,
>       memory_region_add_subregion_overlap(s->memory, addr,
>                                           sysbus_mmio_get_region(dev, 0), -1000);
>   }
> +
> +static Property aspeed_soc_properties[] = {
> +    DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION,
> +                     MemoryRegion *),
> +    DEFINE_PROP_LINK("memory", AspeedSoCState, memory, TYPE_MEMORY_REGION,
> +                     MemoryRegion *),
> +    DEFINE_PROP_END_OF_LIST(),
> +};
> +
> +static void aspeed_soc_class_init(ObjectClass *oc, void *data)
> +{
> +    DeviceClass *dc = DEVICE_CLASS(oc);
> +
> +    device_class_set_props(dc, aspeed_soc_properties);
> +}
> +
> +static const TypeInfo aspeed_soc_types[] = {
> +    {
> +        .name           = TYPE_ASPEED_SOC,
> +        .parent         = TYPE_DEVICE,
> +        .instance_size  = sizeof(AspeedSoCState),
> +        .class_size     = sizeof(AspeedSoCClass),
> +        .class_init     = aspeed_soc_class_init,
> +        .abstract       = true,
> +    },
> +};
> +
> +DEFINE_TYPES(aspeed_soc_types)
diff mbox series

Patch

diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
index 103b1598f6..ee7926b81c 100644
--- a/include/hw/arm/aspeed_soc.h
+++ b/include/hw/arm/aspeed_soc.h
@@ -101,6 +101,13 @@  struct AspeedSoCState {
 #define TYPE_ASPEED_SOC "aspeed-soc"
 OBJECT_DECLARE_TYPE(AspeedSoCState, AspeedSoCClass, ASPEED_SOC)
 
+struct Aspeed2400SoCState {
+    AspeedSoCState parent;
+};
+
+#define TYPE_ASPEED2400_SOC "aspeed2400-soc"
+OBJECT_DECLARE_SIMPLE_TYPE(Aspeed2400SoCState, ASPEED2400_SOC)
+
 struct Aspeed2600SoCState {
     AspeedSoCState parent;
 };
diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
index 191276a320..dfb97f6dbd 100644
--- a/hw/arm/aspeed_soc.c
+++ b/hw/arm/aspeed_soc.c
@@ -497,29 +497,6 @@  static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp)
     sysbus_connect_irq(SYS_BUS_DEVICE(&s->hace), 0,
                        aspeed_soc_get_irq(s, ASPEED_DEV_HACE));
 }
-static Property aspeed_soc_properties[] = {
-    DEFINE_PROP_LINK("memory", AspeedSoCState, memory, TYPE_MEMORY_REGION,
-                     MemoryRegion *),
-    DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION,
-                     MemoryRegion *),
-    DEFINE_PROP_END_OF_LIST(),
-};
-
-static void aspeed_soc_class_init(ObjectClass *oc, void *data)
-{
-    DeviceClass *dc = DEVICE_CLASS(oc);
-
-    device_class_set_props(dc, aspeed_soc_properties);
-}
-
-static const TypeInfo aspeed_soc_type_info = {
-    .name           = TYPE_ASPEED_SOC,
-    .parent         = TYPE_DEVICE,
-    .instance_size  = sizeof(AspeedSoCState),
-    .class_size     = sizeof(AspeedSoCClass),
-    .class_init     = aspeed_soc_class_init,
-    .abstract       = true,
-};
 
 static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data)
 {
@@ -545,14 +522,6 @@  static void aspeed_soc_ast2400_class_init(ObjectClass *oc, void *data)
     sc->get_irq      = aspeed_soc_ast2400_get_irq;
 }
 
-static const TypeInfo aspeed_soc_ast2400_type_info = {
-    .name           = "ast2400-a1",
-    .parent         = TYPE_ASPEED_SOC,
-    .instance_init  = aspeed_ast2400_soc_init,
-    .instance_size  = sizeof(AspeedSoCState),
-    .class_init     = aspeed_soc_ast2400_class_init,
-};
-
 static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data)
 {
     AspeedSoCClass *sc = ASPEED_SOC_CLASS(oc);
@@ -577,18 +546,22 @@  static void aspeed_soc_ast2500_class_init(ObjectClass *oc, void *data)
     sc->get_irq      = aspeed_soc_ast2400_get_irq;
 }
 
-static const TypeInfo aspeed_soc_ast2500_type_info = {
-    .name           = "ast2500-a1",
-    .parent         = TYPE_ASPEED_SOC,
-    .instance_init  = aspeed_ast2400_soc_init,
-    .instance_size  = sizeof(AspeedSoCState),
-    .class_init     = aspeed_soc_ast2500_class_init,
-};
-static void aspeed_soc_register_types(void)
-{
-    type_register_static(&aspeed_soc_type_info);
-    type_register_static(&aspeed_soc_ast2400_type_info);
-    type_register_static(&aspeed_soc_ast2500_type_info);
+static const TypeInfo aspeed_soc_ast2400_types[] = {
+    {
+        .name           = TYPE_ASPEED2400_SOC,
+        .parent         = TYPE_ASPEED_SOC,
+        .instance_init  = aspeed_ast2400_soc_init,
+        .instance_size  = sizeof(Aspeed2400SoCState),
+        .abstract       = true,
+    }, {
+        .name           = "ast2400-a1",
+        .parent         = TYPE_ASPEED2400_SOC,
+        .class_init     = aspeed_soc_ast2400_class_init,
+    }, {
+        .name           = "ast2500-a1",
+        .parent         = TYPE_ASPEED2400_SOC,
+        .class_init     = aspeed_soc_ast2500_class_init,
+    },
 };
 
-type_init(aspeed_soc_register_types);
+DEFINE_TYPES(aspeed_soc_ast2400_types)
diff --git a/hw/arm/aspeed_soc_common.c b/hw/arm/aspeed_soc_common.c
index a43f5d2a6f..b66f769d18 100644
--- a/hw/arm/aspeed_soc_common.c
+++ b/hw/arm/aspeed_soc_common.c
@@ -12,6 +12,7 @@ 
 
 #include "qemu/osdep.h"
 #include "qapi/error.h"
+#include "hw/qdev-properties.h"
 #include "hw/misc/unimp.h"
 #include "hw/arm/aspeed_soc.h"
 #include "hw/char/serial.h"
@@ -112,3 +113,31 @@  void aspeed_mmio_map_unimplemented(AspeedSoCState *s, SysBusDevice *dev,
     memory_region_add_subregion_overlap(s->memory, addr,
                                         sysbus_mmio_get_region(dev, 0), -1000);
 }
+
+static Property aspeed_soc_properties[] = {
+    DEFINE_PROP_LINK("dram", AspeedSoCState, dram_mr, TYPE_MEMORY_REGION,
+                     MemoryRegion *),
+    DEFINE_PROP_LINK("memory", AspeedSoCState, memory, TYPE_MEMORY_REGION,
+                     MemoryRegion *),
+    DEFINE_PROP_END_OF_LIST(),
+};
+
+static void aspeed_soc_class_init(ObjectClass *oc, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(oc);
+
+    device_class_set_props(dc, aspeed_soc_properties);
+}
+
+static const TypeInfo aspeed_soc_types[] = {
+    {
+        .name           = TYPE_ASPEED_SOC,
+        .parent         = TYPE_DEVICE,
+        .instance_size  = sizeof(AspeedSoCState),
+        .class_size     = sizeof(AspeedSoCClass),
+        .class_init     = aspeed_soc_class_init,
+        .abstract       = true,
+    },
+};
+
+DEFINE_TYPES(aspeed_soc_types)