All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jamin Lin <jamin_lin@aspeedtech.com>
To: "Cédric Le Goater" <clg@kaod.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Steven Lee" <steven_lee@aspeedtech.com>,
	"Troy Lee" <leetroy@gmail.com>,
	"Kane Chen" <kane_chen@aspeedtech.com>,
	"Andrew Jeffery" <andrew@codeconstruct.com.au>,
	"Joel Stanley" <joel@jms.id.au>,
	"open list:ASPEED BMCs" <qemu-arm@nongnu.org>,
	"open list:All patches CC here" <qemu-devel@nongnu.org>
Cc: Jamin Lin <jamin_lin@aspeedtech.com>, Troy Lee <troy_lee@aspeedtech.com>
Subject: [PATCH v1 09/11] hw/arm/aspeed_ast1700: Use unimp array and table for unimplemented devices
Date: Wed, 30 Sep 2026 07:25:12 +0000	[thread overview]
Message-ID: <20260930072501.2612119-10-jamin_lin@aspeedtech.com> (raw)
In-Reply-To: <20260930072501.2612119-1-jamin_lin@aspeedtech.com>

Before this change, each unimplemented device needed its own field in
AspeedAST1700SoCState. This made the code hard to maintain.

Add an "unimp" array in AspeedAST1700SoCState for all unimplemented
devices, and use the AspeedUnimpDevice table to describe them. This
makes the code easier to maintain and read. Convert AST1700 to use
them.

No functional change.

Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
---
 include/hw/arm/aspeed_ast1700.h |  2 ++
 hw/arm/aspeed_ast1700.c         | 42 ++++++++++++++++++++-------------
 2 files changed, 28 insertions(+), 16 deletions(-)

diff --git a/include/hw/arm/aspeed_ast1700.h b/include/hw/arm/aspeed_ast1700.h
index 39c5977cf1..ed9b45e202 100644
--- a/include/hw/arm/aspeed_ast1700.h
+++ b/include/hw/arm/aspeed_ast1700.h
@@ -23,6 +23,7 @@
 
 #define AST1700_SGPIO_NUM            2
 #define AST1700_WDT_NUM              9
+#define AST1700_UNIMP_NUM            1
 
 #define TYPE_ASPEED_AST1700 "aspeed.ast1700"
 
@@ -49,6 +50,7 @@ struct AspeedAST1700SoCState {
     AspeedWDTState wdt[AST1700_WDT_NUM];
 
     UnimplementedDeviceState i3c;
+    UnimplementedDeviceState unimp[AST1700_UNIMP_NUM];
 };
 
 #endif /* ASPEED_AST1700_H */
diff --git a/hw/arm/aspeed_ast1700.c b/hw/arm/aspeed_ast1700.c
index 5af5da5b8a..f926851166 100644
--- a/hw/arm/aspeed_ast1700.c
+++ b/hw/arm/aspeed_ast1700.c
@@ -12,10 +12,10 @@
 #include "qapi/error.h"
 #include "hw/core/qdev-properties.h"
 #include "hw/arm/aspeed_ast1700.h"
+#include "hw/arm/aspeed_soc.h"
 
 #define AST2700_SOC_LTPI_SIZE        0x01000000
 #define AST1700_SOC_SRAM_SIZE        0x00040000
-#define AST1700_SOC_I3C_SIZE         0x00010000
 
 enum {
     ASPEED_AST1700_DEV_SPI0,
@@ -51,11 +51,18 @@ static const hwaddr aspeed_ast1700_io_memmap[] = {
     [ASPEED_AST1700_DEV_SPI0_MEM]  =  0x04000000,
 };
 
+static const AspeedUnimpDevice aspeed_ast1700_unimp_devs[] = {
+    { "ioexp-i3c", "ioexp-i3c", ASPEED_AST1700_DEV_I3C, 0x00010000 },
+};
+QEMU_BUILD_BUG_ON(ARRAY_SIZE(aspeed_ast1700_unimp_devs) > AST1700_UNIMP_NUM);
+
 static void aspeed_ast1700_realize(DeviceState *dev, Error **errp)
 {
     AspeedAST1700SoCState *s = ASPEED_AST1700(dev);
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
+    const AspeedUnimpDevice *unimp;
     char dev_name[32];
+    int i;
 
     if (!s->dram_mr) {
         error_setg(errp, TYPE_ASPEED_AST1700 ": 'dram' link not set");
@@ -156,7 +163,7 @@ static void aspeed_ast1700_realize(DeviceState *dev, Error **errp)
                         sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->ltpi), 0));
 
     /* SGPIOM */
-    for (int i = 0; i < AST1700_SGPIO_NUM; i++) {
+    for (i = 0; i < AST1700_SGPIO_NUM; i++) {
         if (!sysbus_realize(SYS_BUS_DEVICE(&s->sgpiom[i]), errp)) {
             return;
         }
@@ -166,7 +173,7 @@ static void aspeed_ast1700_realize(DeviceState *dev, Error **errp)
     }
 
     /* WDT */
-    for (int i = 0; i < AST1700_WDT_NUM; i++) {
+    for (i = 0; i < AST1700_WDT_NUM; i++) {
         AspeedWDTClass *awc = ASPEED_WDT_GET_CLASS(&s->wdt[i]);
         hwaddr wdt_offset = aspeed_ast1700_io_memmap[ASPEED_AST1700_DEV_WDT] +
                             i * awc->iosize;
@@ -181,19 +188,20 @@ static void aspeed_ast1700_realize(DeviceState *dev, Error **errp)
                         sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->wdt[i]), 0));
     }
 
-    /* I3C */
-    qdev_prop_set_string(DEVICE(&s->i3c), "name", "ioexp-i3c");
-    qdev_prop_set_uint64(DEVICE(&s->i3c), "size", AST1700_SOC_I3C_SIZE);
-    sysbus_realize(SYS_BUS_DEVICE(&s->i3c), errp);
-    memory_region_add_subregion_overlap(&s->iomem,
-                        aspeed_ast1700_io_memmap[ASPEED_AST1700_DEV_I3C],
-                        sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->i3c), 0),
-                        -1000);
+    /* Unimplemented devices */
+    for (i = 0; i < ARRAY_SIZE(aspeed_ast1700_unimp_devs); i++) {
+        unimp = &aspeed_ast1700_unimp_devs[i];
+        aspeed_mmio_map_unimplemented(&s->iomem, SYS_BUS_DEVICE(&s->unimp[i]),
+                        unimp->region_name,
+                        aspeed_ast1700_io_memmap[unimp->memmap_idx],
+                        unimp->size);
+    }
 }
 
 static void aspeed_ast1700_instance_init(Object *obj)
 {
     AspeedAST1700SoCState *s = ASPEED_AST1700(obj);
+    int i;
 
     /* UART */
     object_initialize_child(obj, "uart", &s->uart,
@@ -227,20 +235,22 @@ static void aspeed_ast1700_instance_init(Object *obj)
                             &s->ltpi, TYPE_ASPEED_LTPI);
 
     /* SGPIOM */
-    for (int i = 0; i < AST1700_SGPIO_NUM; i++) {
+    for (i = 0; i < AST1700_SGPIO_NUM; i++) {
         object_initialize_child(obj, "ioexp-sgpiom[*]", &s->sgpiom[i],
                                 "aspeed.sgpio-ast2700");
     }
 
     /* WDT */
-    for (int i = 0; i < AST1700_WDT_NUM; i++) {
+    for (i = 0; i < AST1700_WDT_NUM; i++) {
         object_initialize_child(obj, "ioexp-wdt[*]",
                                 &s->wdt[i], "aspeed.wdt-ast2700");
     }
 
-    /* I3C */
-    object_initialize_child(obj, "ioexp-i3c", &s->i3c,
-                            TYPE_UNIMPLEMENTED_DEVICE);
+    /* Unimplemented devices */
+    for (i = 0; i < ARRAY_SIZE(aspeed_ast1700_unimp_devs); i++) {
+        object_initialize_child(obj, aspeed_ast1700_unimp_devs[i].qom_name,
+                                &s->unimp[i], TYPE_UNIMPLEMENTED_DEVICE);
+    }
 
     return;
 }
-- 
2.53.0


  parent reply	other threads:[~2026-09-30  7:27 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30  7:25 [PATCH v1 00/11] hw/arm/aspeed: Use unimp array and table for unimplemented devices Jamin Lin
2026-09-30  7:25 ` [PATCH v1 01/11] hw/arm/aspeed_ast2400: " Jamin Lin
2026-09-30  7:37   ` Philippe Mathieu-Daudé
2026-09-30 11:50     ` Cédric Le Goater
2026-09-30 12:16       ` Philippe Mathieu-Daudé
2026-10-01  7:41         ` Cédric Le Goater
2026-10-01 11:51           ` Jamin Lin
2026-10-01 12:07             ` Cédric Le Goater
2026-10-02  9:02               ` Jamin Lin
2026-10-07 15:07                 ` Philippe Mathieu-Daudé
2026-09-30  7:25 ` [PATCH v1 02/11] hw/arm/aspeed_ast2600: " Jamin Lin
2026-09-30  7:38   ` Philippe Mathieu-Daudé
2026-09-30  7:25 ` [PATCH v1 03/11] hw/arm/aspeed_ast27x0: " Jamin Lin
2026-09-30  7:43   ` Philippe Mathieu-Daudé
2026-09-30  7:25 ` [PATCH v1 04/11] hw/arm/aspeed_ast10x0: " Jamin Lin
2026-09-30  7:39   ` Philippe Mathieu-Daudé
2026-09-30  7:25 ` [PATCH v1 05/11] hw/arm/aspeed_ast1040: " Jamin Lin
2026-09-30  7:42   ` Philippe Mathieu-Daudé
2026-09-30  7:25 ` [PATCH v1 06/11] hw/arm/aspeed: Remove unused unimplemented device fields Jamin Lin
2026-09-30  7:25 ` [PATCH v1 07/11] hw/arm/aspeed_ast27x0: Use unimp array and table for unimplemented devices for SSP/TSP Jamin Lin
2026-09-30  7:41   ` Philippe Mathieu-Daudé
2026-09-30  7:25 ` [PATCH v1 08/11] hw/arm/aspeed_coprocessor: Remove unused unimplemented device fields Jamin Lin
2026-09-30  7:25 ` Jamin Lin [this message]
2026-09-30  7:40   ` [PATCH v1 09/11] hw/arm/aspeed_ast1700: Use unimp array and table for unimplemented devices Philippe Mathieu-Daudé
2026-09-30  7:25 ` [PATCH v1 10/11] hw/arm/aspeed_ast1700: Remove unused unimplemented device field Jamin Lin
2026-09-30  7:25 ` [PATCH v1 11/11] hw/arm/aspeed: Sort device IDs alphabetically Jamin Lin
2026-09-30 11:50 ` [PATCH v1 00/11] hw/arm/aspeed: Use unimp array and table for unimplemented devices Cédric Le Goater

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260930072501.2612119-10-jamin_lin@aspeedtech.com \
    --to=jamin_lin@aspeedtech.com \
    --cc=andrew@codeconstruct.com.au \
    --cc=clg@kaod.org \
    --cc=joel@jms.id.au \
    --cc=kane_chen@aspeedtech.com \
    --cc=leetroy@gmail.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=steven_lee@aspeedtech.com \
    --cc=troy_lee@aspeedtech.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.