Commit 306bb8c819 for qemu.org
commit 306bb8c8199e2e44cf58208eab5feae827760471
Author: Jamin Lin <jamin_lin@aspeedtech.com>
Date: Mon Oct 12 06:44:55 2026 +0000
hw/arm/aspeed_ast27x0: Use a table for unimplemented devices for SSP/TSP
Before this change, each unimplemented device needed its own field in
the coprocessor state. This made the code hard to maintain.
Add an unimp_devs table in AspeedCoprocessorClass 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
AST2700 SSP and TSP to use them.
This also fixes a type mismatch. SSP and TSP used the "timerctrl"
field (AspeedTimerCtrlState) 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-9-jamin_lin@aspeedtech.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
diff --git a/hw/arm/aspeed_ast27x0-ssp.c b/hw/arm/aspeed_ast27x0-ssp.c
index e03653086c..0238dc3672 100644
--- a/hw/arm/aspeed_ast27x0-ssp.c
+++ b/hw/arm/aspeed_ast27x0-ssp.c
@@ -101,6 +101,16 @@ static struct nvic_intc_irq_info ast2700_ssp_intcmap[] = {
{169, 1, 9, NULL},
};
+static const UnimplementedDeviceConfig aspeed_soc_ast27x0ssp_unimp_devs[] = {
+ { "timerctrl", "aspeed.timerctrl", 0x72C10000, 0x200, -1000 },
+ { "ipc0", "aspeed.ipc0", 0x72C1C000, 0x1000, -1000 },
+ { "ipc1", "aspeed.ipc1", 0x74C39000, 0x1000, -1000 },
+ { "pric0", "aspeed.pric0", 0x72140000, 0x1000, -1000 },
+ { "pric1", "aspeed.pric1", 0x74100000, 0x1000, -1000 },
+ { "otp", "aspeed.otp", 0x74C07000, 0x800, -1000 },
+ { }
+};
+
static qemu_irq aspeed_soc_ast27x0ssp_get_irq(AspeedCoprocessorState *s,
int dev)
{
@@ -136,19 +146,6 @@ static void aspeed_soc_ast27x0ssp_init(Object *obj)
TYPE_ASPEED_2700SSP_INTC);
object_initialize_child(obj, "intc1", &a->intc[1],
TYPE_ASPEED_2700SSP_INTCIO);
-
- object_initialize_child(obj, "timerctrl", &s->timerctrl,
- TYPE_UNIMPLEMENTED_DEVICE);
- object_initialize_child(obj, "ipc0", &a->ipc[0],
- TYPE_UNIMPLEMENTED_DEVICE);
- object_initialize_child(obj, "ipc1", &a->ipc[1],
- TYPE_UNIMPLEMENTED_DEVICE);
- object_initialize_child(obj, "pric0", &a->pric[0],
- TYPE_UNIMPLEMENTED_DEVICE);
- object_initialize_child(obj, "pric1", &a->pric[1],
- TYPE_UNIMPLEMENTED_DEVICE);
- object_initialize_child(obj, "otp", &a->otp,
- TYPE_UNIMPLEMENTED_DEVICE);
}
static void aspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp)
@@ -283,24 +280,8 @@ static void aspeed_soc_ast27x0ssp_realize(DeviceState *dev_soc, Error **errp)
memory_region_add_subregion(s->memory, sc->memmap[ASPEED_DEV_FMC],
&a->fmc_alias);
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->timerctrl),
- "aspeed.timerctrl",
- sc->memmap[ASPEED_DEV_TIMER1], 0x200);
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&a->ipc[0]),
- "aspeed.ipc0",
- sc->memmap[ASPEED_DEV_IPC0], 0x1000);
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&a->ipc[1]),
- "aspeed.ipc1",
- sc->memmap[ASPEED_DEV_IPC1], 0x1000);
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&a->pric[0]),
- "aspeed.pric0",
- sc->memmap[ASPEED_DEV_PRIC0], 0x1000);
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&a->pric[1]),
- "aspeed.pric1",
- sc->memmap[ASPEED_DEV_PRIC1], 0x1000);
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&a->otp),
- "aspeed.otp",
- sc->memmap[ASPEED_DEV_OTP], 0x800);
+ /* Unimplemented devices */
+ create_unimplemented_devices(OBJECT(s), s->memory, sc->unimp_devs);
}
static const Property aspeed_27x0_coprocessor_properties[] = {
@@ -330,6 +311,7 @@ static void aspeed_soc_ast27x0ssp_class_init(ObjectClass *klass,
sc->valid_cpu_types = valid_cpu_types;
sc->irqmap = aspeed_soc_ast27x0ssp_irqmap;
sc->memmap = aspeed_soc_ast27x0ssp_memmap;
+ sc->unimp_devs = aspeed_soc_ast27x0ssp_unimp_devs;
}
static const TypeInfo aspeed_soc_ast27x0ssp_types[] = {
diff --git a/hw/arm/aspeed_ast27x0-tsp.c b/hw/arm/aspeed_ast27x0-tsp.c
index 39ba062a20..7f057ff135 100644
--- a/hw/arm/aspeed_ast27x0-tsp.c
+++ b/hw/arm/aspeed_ast27x0-tsp.c
@@ -101,6 +101,16 @@ static struct nvic_intc_irq_info ast2700_tsp_intcmap[] = {
{169, 1, 9, NULL},
};
+static const UnimplementedDeviceConfig aspeed_soc_ast27x0tsp_unimp_devs[] = {
+ { "timerctrl", "aspeed.timerctrl", 0x72C10000, 0x200, -1000 },
+ { "ipc0", "aspeed.ipc0", 0x72C1C000, 0x1000, -1000 },
+ { "ipc1", "aspeed.ipc1", 0x74C39000, 0x1000, -1000 },
+ { "pric0", "aspeed.pric0", 0x72140000, 0x1000, -1000 },
+ { "pric1", "aspeed.pric1", 0x74100000, 0x1000, -1000 },
+ { "otp", "aspeed.otp", 0x74C07000, 0x800, -1000 },
+ { }
+};
+
static qemu_irq aspeed_soc_ast27x0tsp_get_irq(AspeedCoprocessorState *s,
int dev)
{
@@ -136,19 +146,6 @@ static void aspeed_soc_ast27x0tsp_init(Object *obj)
TYPE_ASPEED_2700TSP_INTC);
object_initialize_child(obj, "intc1", &a->intc[1],
TYPE_ASPEED_2700TSP_INTCIO);
-
- object_initialize_child(obj, "timerctrl", &s->timerctrl,
- TYPE_UNIMPLEMENTED_DEVICE);
- object_initialize_child(obj, "ipc0", &a->ipc[0],
- TYPE_UNIMPLEMENTED_DEVICE);
- object_initialize_child(obj, "ipc1", &a->ipc[1],
- TYPE_UNIMPLEMENTED_DEVICE);
- object_initialize_child(obj, "pric0", &a->pric[0],
- TYPE_UNIMPLEMENTED_DEVICE);
- object_initialize_child(obj, "pric1", &a->pric[1],
- TYPE_UNIMPLEMENTED_DEVICE);
- object_initialize_child(obj, "otp", &a->otp,
- TYPE_UNIMPLEMENTED_DEVICE);
}
static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp)
@@ -283,24 +280,8 @@ static void aspeed_soc_ast27x0tsp_realize(DeviceState *dev_soc, Error **errp)
memory_region_add_subregion(s->memory, sc->memmap[ASPEED_DEV_FMC],
&a->fmc_alias);
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&s->timerctrl),
- "aspeed.timerctrl",
- sc->memmap[ASPEED_DEV_TIMER1], 0x200);
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&a->ipc[0]),
- "aspeed.ipc0",
- sc->memmap[ASPEED_DEV_IPC0], 0x1000);
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&a->ipc[1]),
- "aspeed.ipc1",
- sc->memmap[ASPEED_DEV_IPC1], 0x1000);
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&a->pric[0]),
- "aspeed.pric0",
- sc->memmap[ASPEED_DEV_PRIC0], 0x1000);
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&a->pric[1]),
- "aspeed.pric1",
- sc->memmap[ASPEED_DEV_PRIC1], 0x1000);
- aspeed_mmio_map_unimplemented(s->memory, SYS_BUS_DEVICE(&a->otp),
- "aspeed.otp",
- sc->memmap[ASPEED_DEV_OTP], 0x800);
+ /* Unimplemented devices */
+ create_unimplemented_devices(OBJECT(s), s->memory, sc->unimp_devs);
}
static const Property aspeed_27x0_coprocessor_properties[] = {
@@ -330,6 +311,7 @@ static void aspeed_soc_ast27x0tsp_class_init(ObjectClass *klass,
sc->valid_cpu_types = valid_cpu_types;
sc->irqmap = aspeed_soc_ast27x0tsp_irqmap;
sc->memmap = aspeed_soc_ast27x0tsp_memmap;
+ sc->unimp_devs = aspeed_soc_ast27x0tsp_unimp_devs;
}
static const TypeInfo aspeed_soc_ast27x0tsp_types[] = {
diff --git a/include/hw/arm/aspeed_coprocessor.h b/include/hw/arm/aspeed_coprocessor.h
index acb8b06457..39209d2579 100644
--- a/include/hw/arm/aspeed_coprocessor.h
+++ b/include/hw/arm/aspeed_coprocessor.h
@@ -37,6 +37,7 @@ struct AspeedCoprocessorClass {
/** valid_cpu_types: NULL terminated array of a single CPU type. */
const char * const *valid_cpu_types;
const hwaddr *memmap;
+ const UnimplementedDeviceConfig *unimp_devs;
const int *irqmap;
};