Commit 2898a1c587 for qemu.org

commit 2898a1c587f6012fc0e870fb480ffe9ccc3c2282
Author: Jamin Lin <jamin_lin@aspeedtech.com>
Date:   Mon Oct 12 06:44:51 2026 +0000

    hw/arm/aspeed_ast10x0: Use a table for unimplemented devices

    Before this change, each unimplemented device needed its own field in
    AspeedSoCState. This made the variable names confusing. For example,
    AspeedSoCState has "udc" as an unimplemented device, but
    Aspeed2600SoCState also has "udc" as the real UDC model.

    Use the unimp_devs table in AspeedSoCClass to describe the
    unimplemented devices, and use create_unimplemented_devices() to create
    and map them. This makes the code easier to maintain and read. Convert
    AST1030/AST1060 to use them.

    This also fixes a type mismatch. AST10x0 used the "pwm" field
    (AspeedPWMState) and the "sgpiom" field (AspeedSGPIOState array) to
    create unimplemented devices. They are not used for that anymore.

    No functional change.

    Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
    Reviewed-by: Cédric Le Goater <clg@redhat.com>
    Link: https://lore.kernel.org/qemu-devel/20261012064445.2571633-6-jamin_lin@aspeedtech.com
    Signed-off-by: Cédric Le Goater <clg@redhat.com>

diff --git a/hw/arm/aspeed_ast10x0.c b/hw/arm/aspeed_ast10x0.c
index aeb5a4423d..0790859735 100644
--- a/hw/arm/aspeed_ast10x0.c
+++ b/hw/arm/aspeed_ast10x0.c
@@ -17,8 +17,6 @@
 #include "hw/misc/unimp.h"
 #include "hw/arm/aspeed_soc.h"

-#define ASPEED_SOC_IOMEM_SIZE 0x00200000
-
 static const hwaddr aspeed_soc_ast1030_memmap[] = {
     [ASPEED_DEV_SRAM0]     = 0x00000000,
     [ASPEED_DEV_SRAM1]     = 0x79000000, /* SEC SRAM */
@@ -99,6 +97,17 @@ static const int aspeed_soc_ast1030_irqmap[] = {
     [ASPEED_DEV_JTAG1]     = 53,
 };

+static const UnimplementedDeviceConfig aspeed_soc_ast10x0_unimp_devs[] = {
+    { "iomem", "aspeed.io", 0x7E600000, 0x00200000, -1000 },
+    { "pwm", "aspeed.pwm", 0x7E610000, 0x100, -1000 },
+    { "espi", "aspeed.espi", 0x7E6EE000, 0x800, -1000 },
+    { "udc", "aspeed.udc", 0x7E6A2000, 0x1000, -1000 },
+    { "sgpiom", "aspeed.sgpiom", 0x7E780500, 0x100, -1000 },
+    { "jtag[0]", "aspeed.jtag0", 0x7E6E4000, 0x20, -1000 },
+    { "jtag[1]", "aspeed.jtag1", 0x7E6E4100, 0x20, -1000 },
+    { }
+};
+
 static qemu_irq aspeed_soc_ast1030_get_irq(AspeedSoCState *s, int dev)
 {
     Aspeed10x0SoCState *a = ASPEED10X0_SOC(s);
@@ -161,17 +170,6 @@ static void aspeed_soc_ast10x0_init(Object *obj, const char *socname)

     snprintf(typename, sizeof(typename), "aspeed.hace-%s", socname);
     object_initialize_child(obj, "hace", &s->hace, typename);
-
-    object_initialize_child(obj, "iomem", &s->iomem, TYPE_UNIMPLEMENTED_DEVICE);
-    object_initialize_child(obj, "pwm", &s->pwm, TYPE_UNIMPLEMENTED_DEVICE);
-    object_initialize_child(obj, "espi", &s->espi, TYPE_UNIMPLEMENTED_DEVICE);
-    object_initialize_child(obj, "udc", &s->udc, TYPE_UNIMPLEMENTED_DEVICE);
-    object_initialize_child(obj, "sgpiom", &s->sgpiom,
-                            TYPE_UNIMPLEMENTED_DEVICE);
-    object_initialize_child(obj, "jtag[0]", &s->jtag[0],
-                            TYPE_UNIMPLEMENTED_DEVICE);
-    object_initialize_child(obj, "jtag[1]", &s->jtag[1],
-                            TYPE_UNIMPLEMENTED_DEVICE);
 }

 static void aspeed_soc_ast1030_init(Object *obj)
@@ -215,11 +213,8 @@ static bool aspeed_soc_ast10x0_realize(Aspeed10x0SoCState *a, Error **errp)
         return false;
     }

-    /* General I/O memory space to catch all unimplemented device */
-    aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->iomem),
-                                  "aspeed.io",
-                                  sc->memmap[ASPEED_DEV_IOMEM],
-                                  ASPEED_SOC_IOMEM_SIZE);
+    /* Unimplemented devices */
+    create_unimplemented_devices(OBJECT(s), s->memory, sc->unimp_devs);
     /* AST10x0 CPU Core */
     armv7m = DEVICE(&a->armv7m);
     qdev_prop_set_uint32(armv7m, "num-irq", 256);
@@ -394,28 +389,6 @@ static bool aspeed_soc_ast10x0_realize(Aspeed10x0SoCState *a, Error **errp)
     sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio), 0,
                        aspeed_soc_ast1030_get_irq(s, ASPEED_DEV_GPIO));

-    aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->pwm),
-                                  "aspeed.pwm",
-                                  sc->memmap[ASPEED_DEV_PWM], 0x100);
-
-    aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->espi),
-                                  "aspeed.espi",
-                                  sc->memmap[ASPEED_DEV_ESPI], 0x800);
-
-    aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->udc),
-                                  "aspeed.udc",
-                                  sc->memmap[ASPEED_DEV_UDC], 0x1000);
-    aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->sgpiom),
-                                  "aspeed.sgpiom",
-                                  sc->memmap[ASPEED_DEV_SGPIOM0], 0x100);
-
-    aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->jtag[0]),
-                                  "aspeed.jtag",
-                                  sc->memmap[ASPEED_DEV_JTAG0], 0x20);
-    aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->jtag[1]),
-                                  "aspeed.jtag",
-                                  sc->memmap[ASPEED_DEV_JTAG1], 0x20);
-
     return true;
 }

@@ -503,6 +476,7 @@ static void aspeed_soc_ast1030_class_init(ObjectClass *klass, const void *data)
     sc->uarts_base = ASPEED_DEV_UART1;
     sc->irqmap = aspeed_soc_ast1030_irqmap;
     sc->memmap = aspeed_soc_ast1030_memmap;
+    sc->unimp_devs = aspeed_soc_ast10x0_unimp_devs;
     sc->num_cpus = 1;
 }

@@ -529,6 +503,7 @@ static void aspeed_soc_ast1060_class_init(ObjectClass *klass, const void *data)
     sc->uarts_base = ASPEED_DEV_UART5;
     sc->irqmap = aspeed_soc_ast1030_irqmap;
     sc->memmap = aspeed_soc_ast1030_memmap;
+    sc->unimp_devs = aspeed_soc_ast10x0_unimp_devs;
     sc->num_cpus = 1;
 }