]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/arm/aspeed_ast10x0: Pass SoC name to common init for AST10x0 family reuse
authorJamin Lin <jamin_lin@aspeedtech.com>
Wed, 12 Nov 2025 03:05:44 +0000 (11:05 +0800)
committerCédric Le Goater <clg@redhat.com>
Mon, 5 Jan 2026 09:38:01 +0000 (10:38 +0100)
Refactor the AST10x0 common initialization to accept a socname
parameter.

The AST1030 model can be reused by AST1060 since they share most of the
same controllers. This approach allows AST1060 to leverage the existing
AST1030 initialization flow while keeping separate SoC-specific init
functions for components that differ.

This prepares the framework for AST1060 support, allowing it to reuse
AST1030 device models and initialization flow without code duplication.

No functional changes.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20251112030553.291734-8-jamin_lin@aspeedtech.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
hw/arm/aspeed_ast10x0.c

index 72a8c78ff89021db9d413fa26c98b4de4f34906e..4ed6649e5546533ec715f0583c0d8a7e7c0efa93 100644 (file)
@@ -107,19 +107,14 @@ static qemu_irq aspeed_soc_ast1030_get_irq(AspeedSoCState *s, int dev)
     return qdev_get_gpio_in(DEVICE(&a->armv7m), sc->irqmap[dev]);
 }
 
-static void aspeed_soc_ast10x0_init(Object *obj)
+static void aspeed_soc_ast10x0_init(Object *obj, const char *socname)
 {
     Aspeed10x0SoCState *a = ASPEED10X0_SOC(obj);
     AspeedSoCState *s = ASPEED_SOC(obj);
     AspeedSoCClass *sc = ASPEED_SOC_GET_CLASS(s);
-    char socname[8];
     char typename[64];
     int i;
 
-    if (sscanf(object_get_typename(obj), "%7s", socname) != 1) {
-        g_assert_not_reached();
-    }
-
     object_initialize_child(obj, "armv7m", &a->armv7m, TYPE_ARMV7M);
 
     s->sysclk = qdev_init_clock_in(DEVICE(s), "sysclk", NULL, NULL, 0);
@@ -185,7 +180,7 @@ static void aspeed_soc_ast1030_init(Object *obj)
 {
     AspeedSoCState *s = ASPEED_SOC(obj);
 
-    aspeed_soc_ast10x0_init(obj);
+    aspeed_soc_ast10x0_init(obj, "ast1030");
     object_initialize_child(obj, "lpc", &s->lpc, TYPE_ASPEED_LPC);
     object_initialize_child(obj, "peci", &s->peci, TYPE_ASPEED_PECI);
 }