Commit da9544e3b4 for qemu.org
commit da9544e3b4d2afe5bca0af7e2be37ccf49673c51
Author: Jamin Lin <jamin_lin@aspeedtech.com>
Date: Mon Oct 12 06:44:52 2026 +0000
hw/arm/aspeed_ast1040: 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
AST1040 to use them.
This also fixes a type mismatch. AST1040 used the "pwm" field
(AspeedPWMState) to create an unimplemented device. It is 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-7-jamin_lin@aspeedtech.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
diff --git a/hw/arm/aspeed_ast1040.c b/hw/arm/aspeed_ast1040.c
index 57ffc0807a..0b078f10c4 100644
--- a/hw/arm/aspeed_ast1040.c
+++ b/hw/arm/aspeed_ast1040.c
@@ -81,6 +81,15 @@ static const int aspeed_soc_ast1040_irqmap[] = {
[ASPEED_DEV_PECI] = 164,
};
+static const UnimplementedDeviceConfig aspeed_soc_ast1040_unimp_devs[] = {
+ { "pwm", "aspeed.pwm", 0x740C0000, 0x10000, -1000 },
+ { "espi", "aspeed.espi", 0x74C05000, 0x1000, -1000 },
+ { "udc", "aspeed.udc", 0x74120000, 0x4000, -1000 },
+ { "jtag[0]", "aspeed.jtag0", 0x74C01000, 0x100, -1000 },
+ { "jtag[1]", "aspeed.jtag1", 0x74C09000, 0x100, -1000 },
+ { }
+};
+
static qemu_irq aspeed_soc_ast1040_get_irq(AspeedSoCState *s, int dev)
{
Aspeed10x0SoCState *a = ASPEED10X0_SOC(s);
@@ -123,14 +132,6 @@ static void aspeed_soc_ast1040_init(Object *obj)
object_initialize_child(obj, "wdt[*]", &s->wdt[i],
"aspeed.wdt-ast2700");
}
-
- 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, "jtag[0]", &s->jtag[0],
- TYPE_UNIMPLEMENTED_DEVICE);
- object_initialize_child(obj, "jtag[1]", &s->jtag[1],
- TYPE_UNIMPLEMENTED_DEVICE);
}
static void aspeed_soc_ast1040_realize(DeviceState *dev_soc, Error **errp)
@@ -267,26 +268,8 @@ static void aspeed_soc_ast1040_realize(DeviceState *dev_soc, Error **errp)
aspeed_mmio_map(s->memory, SYS_BUS_DEVICE(&s->wdt[i]), 0, wdt_offset);
}
- /* Unimplemented peripherals */
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->pwm),
- "aspeed.pwm",
- sc->memmap[ASPEED_DEV_PWM], 0x10000);
-
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->espi),
- "aspeed.espi",
- sc->memmap[ASPEED_DEV_ESPI], 0x1000);
-
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->udc),
- "aspeed.udc",
- sc->memmap[ASPEED_DEV_UDC], 0x4000);
-
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->jtag[0]),
- "aspeed.jtag0",
- sc->memmap[ASPEED_DEV_JTAG0], 0x100);
-
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->jtag[1]),
- "aspeed.jtag1",
- sc->memmap[ASPEED_DEV_JTAG1], 0x100);
+ /* Unimplemented devices */
+ create_unimplemented_devices(OBJECT(s), s->memory, sc->unimp_devs);
}
static void aspeed_soc_ast1040_class_init(ObjectClass *klass, const void *data)
@@ -312,6 +295,7 @@ static void aspeed_soc_ast1040_class_init(ObjectClass *klass, const void *data)
sc->uarts_base = ASPEED_DEV_UART0;
sc->irqmap = aspeed_soc_ast1040_irqmap;
sc->memmap = aspeed_soc_ast1040_memmap;
+ sc->unimp_devs = aspeed_soc_ast1040_unimp_devs;
sc->num_cpus = 1;
}