Commit d45e030bd0 for qemu.org
commit d45e030bd0b25c23d8b1979180d546b12f397a2b
Author: Jamin Lin <jamin_lin@aspeedtech.com>
Date: Mon Oct 12 06:44:48 2026 +0000
hw/arm/aspeed_ast2400: 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.
Add an 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 AST2400/AST2500
to use them.
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-3-jamin_lin@aspeedtech.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
diff --git a/hw/arm/aspeed_ast2400.c b/hw/arm/aspeed_ast2400.c
index 79a653f65f..fa2782da61 100644
--- a/hw/arm/aspeed_ast2400.c
+++ b/hw/arm/aspeed_ast2400.c
@@ -23,8 +23,6 @@
#include "system/system.h"
#include "target/arm/cpu-qom.h"
-#define ASPEED_SOC_IOMEM_SIZE 0x00200000
-
static const hwaddr aspeed_soc_ast2400_memmap[] = {
[ASPEED_DEV_SPI_BOOT] = 0x00000000,
[ASPEED_DEV_IOMEM] = 0x1E600000,
@@ -134,6 +132,12 @@ static const int aspeed_soc_ast2400_irqmap[] = {
#define aspeed_soc_ast2500_irqmap aspeed_soc_ast2400_irqmap
+static const UnimplementedDeviceConfig aspeed_soc_ast2400_unimp_devs[] = {
+ { "iomem", "aspeed.io", 0x1E600000, 0x00200000, -1000 },
+ { "video", "aspeed.video", 0x1E700000, 0x1000, -1000 },
+ { }
+};
+
static qemu_irq aspeed_soc_ast2400_get_irq(AspeedSoCState *s, int dev)
{
Aspeed2400SoCState *a = ASPEED2400_SOC(s);
@@ -239,9 +243,6 @@ static void aspeed_ast2400_soc_init(Object *obj)
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, "video", &s->video, TYPE_UNIMPLEMENTED_DEVICE);
}
static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp)
@@ -259,16 +260,8 @@ static void aspeed_ast2400_soc_realize(DeviceState *dev, Error **errp)
memory_region_add_subregion(s->memory, sc->memmap[ASPEED_DEV_SPI_BOOT],
&s->spi_boot_container);
- /* IO space */
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->iomem),
- "aspeed.io",
- sc->memmap[ASPEED_DEV_IOMEM],
- ASPEED_SOC_IOMEM_SIZE);
-
- /* Video engine stub */
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->video),
- "aspeed.video",
- sc->memmap[ASPEED_DEV_VIDEO], 0x1000);
+ /* Unimplemented devices */
+ create_unimplemented_devices(OBJECT(s), s->memory, sc->unimp_devs);
/* CPU */
for (i = 0; i < sc->num_cpus; i++) {
@@ -542,6 +535,7 @@ static void aspeed_soc_ast2400_class_init(ObjectClass *oc, const void *data)
sc->uarts_base = ASPEED_DEV_UART1;
sc->irqmap = aspeed_soc_ast2400_irqmap;
sc->memmap = aspeed_soc_ast2400_memmap;
+ sc->unimp_devs = aspeed_soc_ast2400_unimp_devs;
sc->num_cpus = 1;
}
@@ -569,6 +563,7 @@ static void aspeed_soc_ast2500_class_init(ObjectClass *oc, const void *data)
sc->uarts_base = ASPEED_DEV_UART1;
sc->irqmap = aspeed_soc_ast2500_irqmap;
sc->memmap = aspeed_soc_ast2500_memmap;
+ sc->unimp_devs = aspeed_soc_ast2400_unimp_devs;
sc->num_cpus = 1;
}
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
index a110385743..82e394f085 100644
--- a/include/hw/arm/aspeed_soc.h
+++ b/include/hw/arm/aspeed_soc.h
@@ -190,6 +190,7 @@ struct AspeedSoCClass {
int ioexp_num;
const int *irqmap;
const hwaddr *memmap;
+ const UnimplementedDeviceConfig *unimp_devs;
uint32_t num_cpus;
bool (*boot_from_emmc)(AspeedSoCState *s);
};