Skip to contentSkip to conversation

Add Axiado SoC AX3000 and EVK board

PATCH Superseded Kuan-Jui Chiu 2 participants 19 messages Jun 18 – Jun 22

Subsystems (2)

v5 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v5 cover Add Axiado SoC AX3000 and EVK board

This patchset introduces Axiado SoC AX3000 and a EVK SCM3003 for emulation The model for Axiado SoC AX3000 supports
4 Cortex-A53 CPUs
Arm Generic Interrupt Controller v3
4 Cadence UARTs
1 SDHCI controller with PHY
8 Cadence GPIOs

Verified the machine "axiado-scm3003" with following command

qemu-system-aarch64 \
    -m 4G \
    -machine axiado-scm3003 \
    -device loader,file=u-boot.bin,addr=0x3C000000,cpu-num=0 \
    -nographic \
    -serial null \
    -serial null \
    -serial null \
    -serial mon:stdio \
    -drive if=sd,file=obmc-phosphor-image-evk-axiado-qemu.wic,format=raw

Refer Axiado website for more product information
https://axiado.com/products/

Changes in v5:
1. Include Reviewed-by tag in reviewed patches
2. Add arm_load_kernel() in ax3000-boards
3. Add axiado_clk to support AXIADO_CLK

Changes in v4:
1. Remove ERRP_GUARD from axiado_sdhci
2. Optimize ISR update function of cadence gpio with logical operation

Changes in v3:
1. Add a new patch for Axiado SD host controller
2. Fill in valid/impl parameters of MemoryRegionOps in ax3000-soc/cadence_gpio/axiado_sdhci
3. Follow C99 standard to declare variable in for-loop
4. Remove comment "TBD" from empty function
5. Define marco for bit definition in axiado_sdhci
6. Move object_initialize_child() to instance_init() from realize() in axiado_sdhci
7. Remove callback of get_default_cpu_type() from ax3000-soc and set type of CPU to A53
8. Update the command to run "axiado-scm3003" in QEMU

Changes in v2:
1. Move axiado-* to ax3000-* in hw/arm and include/hw/arm
2. Add axiado_sdhci to support AXIADO_SDHCI
3. Move implementation for eMMC PHY device to axiado_sdhci
4. Use UNIMP to create dummy device "timerctrl"
5. Add cadence_gpio to support CADENCE_GPIO
6. Enable Cadence GPIO controllers on AX3000 SoC

Kuan-Jui Chiu (8):
hw/arm: Add Axiado SoC AX3000
hw/misc: Add AX3000 clock control
hw/arm: ax3000-soc: Enable Ax3000 clock control hw/sd: Add Axiado SD host controller with eMMC PHY hw/arm: ax3000-soc: Enable Axiado SD host controller hw/arm: Add Axiado EVK SCM3003
hw/gpio: Add Cadence GPIO controller hw/arm: ax3000-soc: Enable Cadence GPIO controllers

 MAINTAINERS                    |   9 +
 hw/arm/Kconfig                 |  15 ++
 hw/arm/ax3000-boards.c         |  56 +++++++
 hw/arm/ax3000-evk.c            |  27 +++
 hw/arm/ax3000-soc.c            | 238 +++++++++++++++++++++++++++
 hw/arm/meson.build             |   6 +
 hw/gpio/Kconfig                |   3 +
 hw/gpio/cadence_gpio.c         | 292 +++++++++++++++++++++++++++++++++
 hw/gpio/meson.build            |   1 +
 hw/gpio/trace-events           |   5 +
 hw/misc/Kconfig                |   3 +
 hw/misc/axiado_clk.c           |  73 +++++++++
 hw/misc/meson.build            |   3 +
 hw/sd/Kconfig                  |   4 +
 hw/sd/axiado_sdhci.c           | 114 +++++++++++++
 hw/sd/meson.build              |   1 +
 include/hw/arm/ax3000-boards.h |  28 ++++
 include/hw/arm/ax3000-soc.h    |  98 +++++++++++
 include/hw/gpio/cadence_gpio.h |  55 +++++++
 include/hw/misc/axiado_clk.h   |  26 +++
 include/hw/sd/axiado_sdhci.h   |  21 +++
 21 files changed, 1078 insertions(+)
 create mode 100644 hw/arm/ax3000-boards.c
 create mode 100644 hw/arm/ax3000-evk.c
 create mode 100644 hw/arm/ax3000-soc.c
 create mode 100644 hw/gpio/cadence_gpio.c
 create mode 100644 hw/misc/axiado_clk.c
 create mode 100644 hw/sd/axiado_sdhci.c
 create mode 100644 include/hw/arm/ax3000-boards.h
 create mode 100644 include/hw/arm/ax3000-soc.h
 create mode 100644 include/hw/gpio/cadence_gpio.h
 create mode 100644 include/hw/misc/axiado_clk.h
 create mode 100644 include/hw/sd/axiado_sdhci.h
Signature · 1 line
2.34.1
#1 lore raw

PATCH v5 1/8 hw/arm: Add Axiado SoC AX3000

This patch adds new model for Axiado SoC AX3000 which supports
4 Cortex-A53 ARM64 CPUs
Arm Generic Interrupt Controller v3
4 Cadence UARTs

---
 MAINTAINERS                 |   7 ++
 hw/arm/Kconfig              |   7 ++
 hw/arm/ax3000-soc.c         | 182 ++++++++++++++++++++++++++++++++++++
 hw/arm/meson.build          |   3 +
 include/hw/arm/ax3000-soc.h |  68 ++++++++++++++
 5 files changed, 267 insertions(+)
 create mode 100644 hw/arm/ax3000-soc.c
 create mode 100644 include/hw/arm/ax3000-soc.h
MAINTAINERS +7 -0
index 2b5b581e173..340428cda55 100644
@@ -1294,6 +1294,13 @@ M: Manos Pitsidianakis <[email protected]>
 S: Maintained
 F: rust/hw/char/pl011/
 
+Axiado SoCs and EVKs
+M: Kuan-Jui Chiu <[email protected]>
+L: [email protected]
+S: Maintained
+F: hw/arm/ax3000*.c
+F: include/hw/arm/ax3000*.h
+
 AVR Machines
 -------------
 
hw/arm/Kconfig +7 -0
index fb798ccbeed..818ffdbce56 100644
@@ -717,3 +717,10 @@ config ARMSSE
     select UNIMP
     select SSE_COUNTER
     select SSE_TIMER
+
+config AXIADO_SOC
+    bool
+    depends on ARM
+    select ARM_GIC
+    select CADENCE # UART
+    select UNIMP
hw/arm/ax3000-soc.c new file +182 -0

182 lines not on this page · raw message

hw/arm/meson.build +3 -0
index 8f66a80e10e..111ab2ba010 100644
@@ -108,6 +108,9 @@ arm_common_ss.add(when: 'CONFIG_SX1', if_true: files('omap_sx1.c'))
 arm_common_ss.add(when: 'CONFIG_VERSATILE', if_true: files('versatilepb.c'))
 arm_common_ss.add(when: 'CONFIG_VEXPRESS', if_true: files('vexpress.c'))
 
+arm_common_ss.add(when: ['CONFIG_AXIADO_SOC', 'TARGET_AARCH64'], if_true: files(
+  'ax3000-soc.c'))
+
 arm_common_ss.add(files('boot.c'))
 
 hw_common_arch += {'arm': arm_common_ss}
include/hw/arm/ax3000-soc.h new file +68 -0

68 lines not on this page · raw message

Signature · 1 line
2.34.1
#2 lore raw

PATCH v5 2/8 hw/misc: Add AX3000 clock control

In reply to Kuan-Jui Chiu

This patch adds a new model for Axiado AX3000 clock control which supports to read ID and status

---
 hw/misc/Kconfig              |  3 ++
 hw/misc/axiado_clk.c         | 73 ++++++++++++++++++++++++++++++++++++
 hw/misc/meson.build          |  3 ++
 include/hw/misc/axiado_clk.h | 26 +++++++++++++
 4 files changed, 105 insertions(+)
 create mode 100644 hw/misc/axiado_clk.c
 create mode 100644 include/hw/misc/axiado_clk.h
hw/misc/Kconfig +3 -0
index 1543ee66531..b8860dd3e77 100644
@@ -257,4 +257,7 @@ config XLNX_VERSAL_TRNG
 config XLNX_ZYNQ_DDRC
     bool
 
+config AXIADO_CLK
+    bool
+
 source macio/Kconfig
hw/misc/axiado_clk.c new file +73 -0

73 lines not on this page · raw message

hw/misc/meson.build +3 -0
index 23265f6035b..e86d9ad6b39 100644
@@ -1,4 +1,5 @@
 system_ss.add(when: 'CONFIG_APPLESMC', if_true: files('applesmc.c'))
+
 system_ss.add(when: 'CONFIG_EDU', if_true: files('edu.c'))
 system_ss.add(when: 'CONFIG_FW_CFG_DMA', if_true: files('vmcoreinfo.c'))
 system_ss.add(when: 'CONFIG_ISA_DEBUG', if_true: files('debugexit.c'))
@@ -168,3 +169,5 @@ system_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa_ec.c'))
 
 # HPPA devices
 system_ss.add(when: 'CONFIG_LASI', if_true: files('lasi.c'))
+
+system_ss.add(when: 'CONFIG_AXIADO_CLK', if_true: files('axiado_clk.c'))
include/hw/misc/axiado_clk.h new file +26 -0
new file mode 100644
index 00000000000..6e12a509d72
@@ -0,0 +1,26 @@
+/*
+ * Axiado AX3000 Clock Control
+ *
+ * Author: Kuan-Jui Chiu <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef AXIADO_AX3000_CLK_H
+#define AXIADO_AX3000_CLK_H
+
+#include "hw/core/sysbus.h"
+#include "qom/object.h"
+
+#define TYPE_AX3000_CLK "ax3000-clk"
+OBJECT_DECLARE_SIMPLE_TYPE(Ax3000ClkState, AX3000_CLK)
+
+#define AX3000_CLK_PLL_CTRL_SIZE    0x1000
+
+typedef struct Ax3000ClkState {
+    SysBusDevice        parent;
+
+    MemoryRegion        pll_ctrl;
+} Ax3000ClkState;
+
+#endif /* AXIADO_AX3000_CLK_H */
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH v5 2/8] hw/misc: Add AX3000 clock control

Quoted 38 lines · Kuan-Jui Chiu

This patch adds a new model for Axiado AX3000 clock control which supports to read ID and status

---
  hw/misc/Kconfig              |  3 ++
  hw/misc/axiado_clk.c         | 73 ++++++++++++++++++++++++++++++++++++
  hw/misc/meson.build          |  3 ++
  include/hw/misc/axiado_clk.h | 26 +++++++++++++
  4 files changed, 105 insertions(+)

create mode 100644 hw/misc/axiado_clk.c
create mode 100644 include/hw/misc/axiado_clk.h

hw/misc/axiado_clk.c new file +18 -0
new file mode 100644
index 00000000000..6967a5995c5
@@ -0,0 +1,73 @@
+/*
+ * Axiado Clock Control
+ *
+ * Author: Kuan-Jui Chiu <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/misc/axiado_clk.h"
+
+#define CLKRST_CPU_PLL_POSTDIV_OFFSET   0x0C
+#define CLKRST_CPU_PLL_STS_OFFSET       0x14
+
+static uint64_t pll_read(void *opaque, hwaddr offset, unsigned size)
+{
+    switch (offset) {
+    case CLKRST_CPU_PLL_POSTDIV_OFFSET:

hw/misc/axiado_clk.c line 28

Quoted 10 lines
hw/misc/axiado_clk.c new file +10 -0
+        return 0x20891b;
+    case CLKRST_CPU_PLL_STS_OFFSET:
+        return 0x01;
+    default:
+        return 0x00;
+    }
+}
+
+static void pll_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
+{

Again, is this allowed? Could we log unexpected accesses?

Quoted 15 lines
hw/misc/axiado_clk.c new file +15 -0
+}
+
+static const MemoryRegionOps pll_ops = {
+    .read = pll_read,
+    .write = pll_write,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .impl = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    },
+    .valid = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    }
+};
#4 lore raw

Re: [PATCH v5 2/8] hw/misc: Add AX3000 clock control

Philippe Mathieu-Daudé 於 2026/6/18 下午 11:23 寫道:

Quoted 47 lines

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 43 lines · Kuan-Jui Chiu

This patch adds a new model for Axiado AX3000 clock control which supports to read ID and status

---
  hw/misc/Kconfig              |  3 ++
  hw/misc/axiado_clk.c         | 73 ++++++++++++++++++++++++++++++++++++ hw/misc/meson.build          |  3 ++ include/hw/misc/axiado_clk.h | 26 +++++++++++++

  4 files changed, 105 insertions(+)

  create mode 100644 hw/misc/axiado_clk.c
  create mode 100644 include/hw/misc/axiado_clk.h

hw/misc/axiado_clk.c new file +23 -0
new file mode 100644
index 00000000000..6967a5995c5
@@ -0,0 +1,73 @@
+/*
+ * Axiado Clock Control
+ *
+ * Author: Kuan-Jui Chiu <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/misc/axiado_clk.h"
+
+#define CLKRST_CPU_PLL_POSTDIV_OFFSET   0x0C
+#define CLKRST_CPU_PLL_STS_OFFSET       0x14
+
+static uint64_t pll_read(void *opaque, hwaddr offset, unsigned size)
+{
+    switch (offset) {
+    case CLKRST_CPU_PLL_POSTDIV_OFFSET:
+        return 0x20891b;
+    case CLKRST_CPU_PLL_STS_OFFSET:
+        return 0x01;
+    default:
+        return 0x00;
Quoted 8 lines
Quoted 6 lines
hw/misc/axiado_clk.c new file +4 -0
+    }
+}
+
+static void pll_write(void *opaque, hwaddr offset, uint64_t val, 

unsigned size)
+{

Again, is this allowed? Could we log unexpected accesses?

It is allowed
Sure, we can have LOG_UNIMP here

Quoted 16 lines
Quoted 16 lines
hw/misc/axiado_clk.c new file +15 -0
+}
+
+static const MemoryRegionOps pll_ops = {
+    .read = pll_read,
+    .write = pll_write,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .impl = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    },
+    .valid = {
+        .min_access_size = 4,
+        .max_access_size = 4,
+    }
+};
#5 lore raw

PATCH v5 3/8 hw/arm: ax3000-soc: Enable Ax3000 clock control

In reply to Kuan-Jui Chiu
---
 hw/arm/Kconfig              | 1 +
 hw/arm/ax3000-soc.c         | 8 ++++++++
 include/hw/arm/ax3000-soc.h | 2 ++
 3 files changed, 11 insertions(+)
hw/arm/Kconfig +1 -0
index 818ffdbce56..866e4b14e6f 100644
@@ -723,4 +723,5 @@ config AXIADO_SOC
     depends on ARM
     select ARM_GIC
     select CADENCE # UART
+    select AXIADO_CLK
     select UNIMP
hw/arm/ax3000-soc.c +8 -0
index 8e8d2edfb71..9a01d23bcc6 100644
@@ -33,6 +33,8 @@ static void ax3000_init(Object *obj)
         g_autofree char *name = g_strdup_printf("uart%d", i);
         object_initialize_child(obj, name, &s->uart[i], TYPE_CADENCE_UART);
     }
+
+    object_initialize_child(obj, "clk", &s->ax3000_clk, TYPE_AX3000_CLK);
 }
 
 static void ax3000_realize(DeviceState *dev, Error **errp)
@@ -157,6 +159,12 @@ static void ax3000_realize(DeviceState *dev, Error **errp)
 
     /* Timer control */
     create_unimplemented_device("ax3000.timerctrl", AX3000_TIMER_CTRL, 32);
+
+    /* Clock control */
+    if (!sysbus_realize(SYS_BUS_DEVICE(&s->ax3000_clk), errp)) {
+        return;
+    }
+    sysbus_mmio_map(SYS_BUS_DEVICE(&s->ax3000_clk), 0, AX3000_PLL_BASE);
 }
 
 static void ax3000_class_init(ObjectClass *oc, const void *data)
include/hw/arm/ax3000-soc.h +2 -0
index b984d7a8ec3..329aa4e7698 100644
@@ -12,6 +12,7 @@
 #include "cpu.h"
 #include "hw/intc/arm_gicv3_common.h"
 #include "hw/char/cadence_uart.h"
+#include "hw/misc/axiado_clk.h"
 #include "hw/core/sysbus.h"
 #include "qemu/units.h"
 
@@ -49,6 +50,7 @@ typedef struct Ax3000SoCState {
     ARMCPU              cpu[AX3000_NUM_CPUS];
     GICv3State          gic;
     MemoryRegion        dram[AX3000_NUM_BANKS];
+    Ax3000ClkState      ax3000_clk;
     CadenceUARTState    uart[AX3000_NUM_UARTS];
 } Ax3000SoCState;
 
Signature · 1 line
2.34.1
#6 lore raw

PATCH v5 4/8 hw/sd: Add Axiado SD host controller with eMMC PHY

In reply to Kuan-Jui Chiu

This patch add a new model for Axiado SD host controller which is compatible with SDHCI 3.0 spec

This device model also includes a eMMC PHY which helps to control SD/eMMC

---
 MAINTAINERS                  |   2 +
 hw/sd/Kconfig                |   4 ++
 hw/sd/axiado_sdhci.c         | 114 +++++++++++++++++++++++++++++++++++
 hw/sd/meson.build            |   1 +
 include/hw/sd/axiado_sdhci.h |  21 +++++++
 5 files changed, 142 insertions(+)
 create mode 100644 hw/sd/axiado_sdhci.c
 create mode 100644 include/hw/sd/axiado_sdhci.h
MAINTAINERS +2 -0
index 340428cda55..0c112890818 100644
@@ -1299,7 +1299,9 @@ M: Kuan-Jui Chiu <[email protected]>
 L: [email protected]
 S: Maintained
 F: hw/arm/ax3000*.c
+F: hw/*/axiado*.c
 F: include/hw/arm/ax3000*.h
+F: include/hw/*/axiado*.h
 
 AVR Machines
 -------------
hw/sd/Kconfig +4 -0
index 633b9afec91..c69bf24f8de 100644
@@ -23,3 +23,7 @@ config SDHCI_PCI
 config CADENCE_SDHCI
     bool
     select SDHCI
+
+config AXIADO_SDHCI
+    bool
+    select SDHCI
hw/sd/axiado_sdhci.c new file +114 -0

114 lines not on this page · raw message

hw/sd/meson.build +1 -0
index b43d45bc564..ebf09e30a48 100644
@@ -10,3 +10,4 @@ system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_sdhci.c'))
 system_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true: files('allwinner-sdhost.c'))
 system_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx_sdhci.c'))
 system_ss.add(when: 'CONFIG_CADENCE_SDHCI', if_true: files('cadence_sdhci.c'))
+system_ss.add(when: 'CONFIG_AXIADO_SDHCI', if_true: files('axiado_sdhci.c'))
include/hw/sd/axiado_sdhci.h new file +21 -0
new file mode 100644
index 00000000000..85afebad931
@@ -0,0 +1,21 @@
+/*
+ * Axiado SD Host Controller
+ *
+ * Author: Kuan-Jui Chiu <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "hw/sd/sdhci.h"
+#include "qom/object.h"
+
+#define TYPE_AXIADO_SDHCI "axiado-sdhci"
+OBJECT_DECLARE_SIMPLE_TYPE(AxiadoSDHCIState, AXIADO_SDHCI)
+
+typedef struct AxiadoSDHCIState {
+    SysBusDevice parent;
+
+    SDHCIState sdhci;
+    MemoryRegion emmc_phy;
+    BusState *sd_bus;
+} AxiadoSDHCIState;
Signature · 1 line
2.34.1
#7 lore raw

Re: [PATCH v5 4/8] hw/sd: Add Axiado SD host controller with eMMC PHY

Hi Kuan-Jui,

Quoted 24 lines · Kuan-Jui Chiu

This patch add a new model for Axiado SD host controller which is compatible with SDHCI 3.0 spec

This device model also includes a eMMC PHY which helps to control SD/eMMC

---
  MAINTAINERS                  |   2 +
  hw/sd/Kconfig                |   4 ++
  hw/sd/axiado_sdhci.c         | 114 +++++++++++++++++++++++++++++++++++
  hw/sd/meson.build            |   1 +
  include/hw/sd/axiado_sdhci.h |  21 +++++++
  5 files changed, 142 insertions(+)

create mode 100644 hw/sd/axiado_sdhci.c
create mode 100644 include/hw/sd/axiado_sdhci.h

hw/sd/axiado_sdhci.c new file +0 -0
new file mode 100644
index 00000000000..e1a76b80a67

hw/sd/axiado_sdhci.c line 2

Quoted 2 lines
hw/sd/axiado_sdhci.c new file +2 -0
@@ -0,0 +1,114 @@
+/*
+ * Axiado SD Host Controller

"Axiado SD Host Controller with embedded PHY"

Quoted 18 lines
hw/sd/axiado_sdhci.c new file +18 -0
+ *
+ * Author: Kuan-Jui Chiu <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/sd/axiado_sdhci.h"
+#include "sdhci-internal.h"
+#include "qapi/error.h"
+#include "hw/core/qdev-properties.h"
+
+#define EMMC_PHY_ID     0x00
+#define EMMC_PHY_STATUS 0x50
+
+#define DLL_RDY  (1u << 0)
+#define CAL_DONE (1u << 6)
+

hw/sd/axiado_sdhci.c line 30

Quoted 10 lines
hw/sd/axiado_sdhci.c new file +10 -0
+static uint64_t emmc_phy_read(void *opaque, hwaddr offset, unsigned size)
+{
+    uint32_t val = 0x00;
+
+    switch (offset) {
+    case EMMC_PHY_ID:
+        val = 0x3dff6870;
+        break;
+    case EMMC_PHY_STATUS:
+        val = DLL_RDY | CAL_DONE;

Out of curiosity, how long a PHY generally takes to be ready? (We had issues with firmware when not modelling a micro delay to allow PLLs to stabilize).

hw/sd/axiado_sdhci.c line 32

Quoted 2 lines
hw/sd/axiado_sdhci.c new file +2 -0
+        break;
+    default:

I suppose there are other registers, could we qemu_log_mask(LOG_UNIMP)?

hw/sd/axiado_sdhci.c line 41

Quoted 9 lines
hw/sd/axiado_sdhci.c new file +9 -0
+        break;
+    }
+
+    return val;
+}
+
+static void emmc_phy_write(void *opaque, hwaddr offset, uint64_t value,
+                           unsigned size)
+{

Is it legal to write? Can we log LOG_UNIMP / LOG_GUEST_ERROR?

hw/sd/axiado_sdhci.c line 49

Quoted 8 lines
hw/sd/axiado_sdhci.c new file +8 -0
+}
+
+static const MemoryRegionOps emmc_phy_ops = {
+    .read = emmc_phy_read,
+    .write = emmc_phy_write,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .impl = {
+        .min_access_size = 2,

Your current implementation is min_access_size = 4 (you are not handling EMMC_PHY_ID+2). Using min_access_size = 4 is simpler, the core memory layer will deal with the 16-bit access for you.

Quoted 17 lines
hw/sd/axiado_sdhci.c new file +17 -0
+        .max_access_size = 4,
+    },
+    .valid = {
+        .min_access_size = 2,
+        .max_access_size = 4,
+    }
+};
+
+static void axiado_sdhci_realize(DeviceState *dev, Error **errp)
+{
+    AxiadoSDHCIState *s = AXIADO_SDHCI(dev);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
+    SysBusDevice *sdhci_sbd;
+
+    qdev_prop_set_uint64(DEVICE(&s->sdhci), "capareg", 0x216737eed0b0);
+    qdev_prop_set_uint64(DEVICE(&s->sdhci), "sd-spec-version", 3);
+

hw/sd/axiado_sdhci.c line 76

Quoted 10 lines
hw/sd/axiado_sdhci.c new file +10 -0
+    sdhci_sbd = SYS_BUS_DEVICE(&s->sdhci);
+    if (!sysbus_realize(sdhci_sbd, errp)) {
+        return;
+    }
+
+    sysbus_init_mmio(sbd, sysbus_mmio_get_region(sdhci_sbd, 0));
+
+    /* Propagate IRQ from SDHCI and SD bus  */
+    sysbus_pass_irq(sbd, sdhci_sbd);
+    s->sd_bus = qdev_get_child_bus(DEVICE(sdhci_sbd), "sd-bus");

@sd_bus is not used AFAICT.

Quoted 12 lines
hw/sd/axiado_sdhci.c new file +12 -0
+
+    /* Initialize eMMC PHY MMIO */
+    memory_region_init_io(&s->emmc_phy, OBJECT(s), &emmc_phy_ops, s,
+                          "axiado.emmc-phy", 0x1000);
+
+    sysbus_init_mmio(sbd, &s->emmc_phy);
+}
+
+static void axiado_sdhci_instance_init(Object *obj)
+{
+    AxiadoSDHCIState *s = AXIADO_SDHCI(obj);
+

hw/sd/axiado_sdhci.c line 98

Quoted 10 lines
hw/sd/axiado_sdhci.c new file +10 -0
+    object_initialize_child(OBJECT(s), "sdhci", &s->sdhci,
+                            TYPE_SYSBUS_SDHCI);
+}
+
+static void axiado_sdhci_class_init(ObjectClass *klass, const void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+
+    dc->realize = axiado_sdhci_realize;
+    dc->desc = "Axiado SD Host Controller with eMMC PHY";

Shouldn't we have a reset handler to propagate to the SDHC block?

hw/sd/axiado_sdhci.c line 111

Quoted 13 lines
hw/sd/axiado_sdhci.c new file +13 -0
+}
+
+static const TypeInfo axiado_sdhci_info = {
+    .name          = TYPE_AXIADO_SDHCI,
+    .parent        = TYPE_SYS_BUS_DEVICE,
+    .instance_size = sizeof(AxiadoSDHCIState),
+    .instance_init = axiado_sdhci_instance_init,
+    .class_init    = axiado_sdhci_class_init,
+};
+
+static void axiado_sdhci_register_types(void)
+{
+    type_register_static(&axiado_sdhci_info);

DEFINE_TYPES() is preferred for style but not required.

hw/sd/axiado_sdhci.c line 114

Quoted 3 lines
hw/sd/axiado_sdhci.c new file +3 -0
+}
+
+type_init(axiado_sdhci_register_types);

Regards,

Phil.

#8 lore raw

Re: [PATCH v5 4/8] hw/sd: Add Axiado SD host controller with eMMC PHY

Philippe Mathieu-Daudé 於 2026/6/18 下午 10:55 寫道:

Quoted 24 lines

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Hi Kuan-Jui,

Quoted 16 lines · Kuan-Jui Chiu

This patch add a new model for Axiado SD host controller which is compatible with SDHCI 3.0 spec

This device model also includes a eMMC PHY which helps to control SD/eMMC

---
  MAINTAINERS                  |   2 +
  hw/sd/Kconfig                |   4 ++
  hw/sd/axiado_sdhci.c         | 114 +++++++++++++++++++++++++++++++++++ hw/sd/meson.build            |   1 + include/hw/sd/axiado_sdhci.h |  21 +++++++

  5 files changed, 142 insertions(+)

  create mode 100644 hw/sd/axiado_sdhci.c
  create mode 100644 include/hw/sd/axiado_sdhci.h

Quoted 11 lines

hw/sd/axiado_sdhci.c line 2

Quoted 8 lines
hw/sd/axiado_sdhci.c new file +2 -0
new file mode 100644
index 00000000000..e1a76b80a67
@@ -0,0 +1,114 @@
+/*
+ * Axiado SD Host Controller

"Axiado SD Host Controller with embedded PHY"

Sure

Quoted 25 lines
Quoted 25 lines
hw/sd/axiado_sdhci.c new file +19 -0
+ *
+ * Author: Kuan-Jui Chiu <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/sd/axiado_sdhci.h"
+#include "sdhci-internal.h"
+#include "qapi/error.h"
+#include "hw/core/qdev-properties.h"
+
+#define EMMC_PHY_ID     0x00
+#define EMMC_PHY_STATUS 0x50
+
+#define DLL_RDY  (1u << 0)
+#define CAL_DONE (1u << 6)
+
+static uint64_t emmc_phy_read(void *opaque, hwaddr offset, unsigned 

size)

hw/sd/axiado_sdhci.c new file +5 -0
+{
+    uint32_t val = 0x00;
+
+    switch (offset) {
+    case EMMC_PHY_ID:
Quoted 9 lines
Quoted 4 lines

+        val = 0x3dff6870;
+        break;
+    case EMMC_PHY_STATUS:
+        val = DLL_RDY | CAL_DONE;

Out of curiosity, how long a PHY generally takes to be ready? (We had issues with firmware when not modelling a micro delay to allow PLLs to stabilize).

I did not have experience on how long it should be ready

The driver in u-boot/kernel would check the value of these registers in probe function This device model just simply returns the value for verification.

Quoted 4 lines
Quoted 2 lines

+        break;
+    default:

I suppose there are other registers, could we qemu_log_mask(LOG_UNIMP)?

Sure

Quoted 12 lines

hw/sd/axiado_sdhci.c line 41

Quoted 10 lines

+        break;
+    }

hw/sd/axiado_sdhci.c new file +7 -0
+
+    return val;
+}
+
+static void emmc_phy_write(void *opaque, hwaddr offset, uint64_t value,
+                           unsigned size)
+{

Is it legal to write? Can we log LOG_UNIMP / LOG_GUEST_ERROR?

The memory region should be able to write but I did not implement it We can log LOG_UNIMP here

Quoted 13 lines

hw/sd/axiado_sdhci.c line 49

Quoted 9 lines
hw/sd/axiado_sdhci.c new file +8 -0
+}
+
+static const MemoryRegionOps emmc_phy_ops = {
+    .read = emmc_phy_read,
+    .write = emmc_phy_write,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+    .impl = {
+        .min_access_size = 2,

Your current implementation is min_access_size = 4 (you are not handling EMMC_PHY_ID+2). Using min_access_size = 4 is simpler, the core memory layer will deal with the 16-bit access for you.

Sure

Quoted 22 lines
Quoted 22 lines

+        .max_access_size = 4,
+    },
+    .valid = {
+        .min_access_size = 2,
+        .max_access_size = 4,
+    }

hw/sd/axiado_sdhci.c new file +15 -0
+};
+
+static void axiado_sdhci_realize(DeviceState *dev, Error **errp)
+{
+    AxiadoSDHCIState *s = AXIADO_SDHCI(dev);
+    SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
+    SysBusDevice *sdhci_sbd;
+
+    qdev_prop_set_uint64(DEVICE(&s->sdhci), "capareg", 0x216737eed0b0);
+    qdev_prop_set_uint64(DEVICE(&s->sdhci), "sd-spec-version", 3);
+
+    sdhci_sbd = SYS_BUS_DEVICE(&s->sdhci);
+    if (!sysbus_realize(sdhci_sbd, errp)) {
+        return;
+    }
Quoted 8 lines

hw/sd/axiado_sdhci.c line 76

Quoted 6 lines
hw/sd/axiado_sdhci.c new file +6 -0
+
+    sysbus_init_mmio(sbd, sysbus_mmio_get_region(sdhci_sbd, 0));
+
+    /* Propagate IRQ from SDHCI and SD bus  */
+    sysbus_pass_irq(sbd, sdhci_sbd);
+    s->sd_bus = qdev_get_child_bus(DEVICE(sdhci_sbd), "sd-bus");

@sd_bus is not used AFAICT.

This sd_bus is used in of ax3000-soc

Quoted 18 lines
Quoted 18 lines
hw/sd/axiado_sdhci.c new file +17 -0
+
+    /* Initialize eMMC PHY MMIO */
+    memory_region_init_io(&s->emmc_phy, OBJECT(s), &emmc_phy_ops, s,
+                          "axiado.emmc-phy", 0x1000);
+
+    sysbus_init_mmio(sbd, &s->emmc_phy);
+}
+
+static void axiado_sdhci_instance_init(Object *obj)
+{
+    AxiadoSDHCIState *s = AXIADO_SDHCI(obj);
+
+    object_initialize_child(OBJECT(s), "sdhci", &s->sdhci,
+                            TYPE_SYSBUS_SDHCI);
+}
+
+static void axiado_sdhci_class_init(ObjectClass *klass, const void 
Quoted 8 lines

hw/sd/axiado_sdhci.c line 98

Quoted 6 lines

*data)

hw/sd/axiado_sdhci.c new file +5 -0
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+
+    dc->realize = axiado_sdhci_realize;
+    dc->desc = "Axiado SD Host Controller with eMMC PHY";

Shouldn't we have a reset handler to propagate to the SDHC block?

This device model is using the default functions that general SDHC provided then add an eMMC PHY only

I did not implement any specific function for now.

Quoted 16 lines
Quoted 4 lines
hw/sd/axiado_sdhci.c new file +3 -0
+}
+
+static const TypeInfo axiado_sdhci_info = {

hw/sd/axiado_sdhci.c line 111

Quoted 10 lines
hw/sd/axiado_sdhci.c new file +10 -0
+    .name          = TYPE_AXIADO_SDHCI,
+    .parent        = TYPE_SYS_BUS_DEVICE,
+    .instance_size = sizeof(AxiadoSDHCIState),
+    .instance_init = axiado_sdhci_instance_init,
+    .class_init    = axiado_sdhci_class_init,
+};
+
+static void axiado_sdhci_register_types(void)
+{
+    type_register_static(&axiado_sdhci_info);

DEFINE_TYPES() is preferred for style but not required.

Sure

Quoted 8 lines

hw/sd/axiado_sdhci.c line 114

Quoted 4 lines
hw/sd/axiado_sdhci.c new file +3 -0
+}
+
+type_init(axiado_sdhci_register_types);

Regards,

Phil.

#9 lore raw

PATCH v5 5/8 hw/arm: ax3000-soc: Enable Axiado SD host controller

In reply to Kuan-Jui Chiu

Enable SD host controller into Axiado AX3000 SoC to load kernel and rootfs from eMMC.

---
 hw/arm/Kconfig              |  1 +
 hw/arm/ax3000-soc.c         | 18 ++++++++++++++++++
 include/hw/arm/ax3000-soc.h |  7 +++++++
 3 files changed, 26 insertions(+)
hw/arm/Kconfig +1 -0
index 866e4b14e6f..13c0b44a180 100644
@@ -724,4 +724,5 @@ config AXIADO_SOC
     select ARM_GIC
     select CADENCE # UART
     select AXIADO_CLK
+    select AXIADO_SDHCI
     select UNIMP
hw/arm/ax3000-soc.c +18 -0
index 9a01d23bcc6..159385cf913 100644
@@ -35,6 +35,7 @@ static void ax3000_init(Object *obj)
     }
 
     object_initialize_child(obj, "clk", &s->ax3000_clk, TYPE_AX3000_CLK);
+    object_initialize_child(obj, "sdhci0", &s->sdhci0, TYPE_AXIADO_SDHCI);
 }
 
 static void ax3000_realize(DeviceState *dev, Error **errp)
@@ -165,6 +166,23 @@ static void ax3000_realize(DeviceState *dev, Error **errp)
         return;
     }
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->ax3000_clk), 0, AX3000_PLL_BASE);
+
+    /* SDHCI */
+    sdhci0_sbd = SYS_BUS_DEVICE(&s->sdhci0);
+    if (!sysbus_realize(sdhci0_sbd, errp)) {
+        return;
+    }
+
+    sysbus_mmio_map(sdhci0_sbd, 0, AX3000_SDHCI0_BASE);
+    sysbus_mmio_map(sdhci0_sbd, 1, AX3000_EMMC_PHY_BASE);
+    sysbus_connect_irq(sdhci0_sbd, 0,
+                       qdev_get_gpio_in(gic_dev, AX3000_SDHCI0_IRQ));
+
+    card = qdev_new(TYPE_SD_CARD);
+    qdev_prop_set_drive_err(card, "drive",
+                            blk_by_legacy_dinfo((drive_get(IF_SD, 0, 0))),
+                            &error_fatal);
+    qdev_realize_and_unref(card, s->sdhci0.sd_bus, &error_fatal);
 }
 
 static void ax3000_class_init(ObjectClass *oc, const void *data)
include/hw/arm/ax3000-soc.h +7 -0
index 329aa4e7698..52b47aa8294 100644
@@ -13,6 +13,7 @@
 #include "hw/intc/arm_gicv3_common.h"
 #include "hw/char/cadence_uart.h"
 #include "hw/misc/axiado_clk.h"
+#include "hw/sd/axiado_sdhci.h"
 #include "hw/core/sysbus.h"
 #include "qemu/units.h"
 
@@ -34,6 +35,9 @@ OBJECT_DECLARE_TYPE(Ax3000SoCState, Ax3000SoCClass, AX3000_SOC)
 #define AX3000_UART2_BASE       0x80620000
 #define AX3000_UART3_BASE       0x80520800
 
+#define AX3000_SDHCI0_BASE      0x86000000
+#define AX3000_EMMC_PHY_BASE    0x80801C00
+
 #define AX3000_TIMER_CTRL       0x8A020000
 #define AX3000_PLL_BASE         0x80000000
 
@@ -52,6 +56,7 @@ typedef struct Ax3000SoCState {
     MemoryRegion        dram[AX3000_NUM_BANKS];
     Ax3000ClkState      ax3000_clk;
     CadenceUARTState    uart[AX3000_NUM_UARTS];
+    AxiadoSDHCIState    sdhci0;
 } Ax3000SoCState;
 
 typedef struct Ax3000SoCClass {
@@ -65,6 +70,8 @@ enum Ax3000Irqs {
     AX3000_UART1_IRQ    = 113,
     AX3000_UART2_IRQ    = 114,
     AX3000_UART3_IRQ    = 170,
+
+    AX3000_SDHCI0_IRQ   = 123,
 };
 
 #endif /* AXIADO_AX3000_H */
Signature · 1 line
2.34.1
#10 lore raw

Re: [PATCH v5 5/8] hw/arm: ax3000-soc: Enable Axiado SD host controller

Hi Kuan-Jui,

Quoted 38 lines · Kuan-Jui Chiu

Enable SD host controller into Axiado AX3000 SoC to load kernel and rootfs from eMMC.

---
  hw/arm/Kconfig              |  1 +
  hw/arm/ax3000-soc.c         | 18 ++++++++++++++++++
  include/hw/arm/ax3000-soc.h |  7 +++++++
  3 files changed, 26 insertions(+)
hw/arm/Kconfig +1 -0
index 866e4b14e6f..13c0b44a180 100644
@@ -724,4 +724,5 @@ config AXIADO_SOC
      select ARM_GIC
      select CADENCE # UART
      select AXIADO_CLK
+    select AXIADO_SDHCI
      select UNIMP
hw/arm/ax3000-soc.c +2 -0
index 9a01d23bcc6..159385cf913 100644
@@ -35,6 +35,7 @@ static void ax3000_init(Object *obj)
      }
 
      object_initialize_child(obj, "clk", &s->ax3000_clk, TYPE_AX3000_CLK);
+    object_initialize_child(obj, "sdhci0", &s->sdhci0, TYPE_AXIADO_SDHCI);
  }
 
  static void ax3000_realize(DeviceState *dev, Error **errp)
@@ -165,6 +166,23 @@ static void ax3000_realize(DeviceState *dev, Error **errp)
          return;
      }
      sysbus_mmio_map(SYS_BUS_DEVICE(&s->ax3000_clk), 0, AX3000_PLL_BASE);
+

hw/arm/ax3000-soc.c static void ax3000_realize(DeviceState *dev, Error **errp) · line 179

Quoted 10 lines
hw/arm/ax3000-soc.c +10 -0
+    /* SDHCI */
+    sdhci0_sbd = SYS_BUS_DEVICE(&s->sdhci0);
+    if (!sysbus_realize(sdhci0_sbd, errp)) {
+        return;
+    }
+
+    sysbus_mmio_map(sdhci0_sbd, 0, AX3000_SDHCI0_BASE);
+    sysbus_mmio_map(sdhci0_sbd, 1, AX3000_EMMC_PHY_BASE);
+    sysbus_connect_irq(sdhci0_sbd, 0,
+                       qdev_get_gpio_in(gic_dev, AX3000_SDHCI0_IRQ));

So there is no link between the SDHCI and the PHY. Thus no need for a particular AXIADO_SDHCI, simply instantiate a generic SDHCI here, and register the MMIO region for the PHY.

in ax3000_init():

    object_initialize_child(obj, "sdhci[0]", &s->sdhci[0],
                            TYPE_SYSBUS_SDHCI);

and in ax3000_realize():

    object_property_set_uint(OBJECT(&s->sdhci[0]), "sd-spec-version", 3,
                             &error_abort);
    object_property_set_uint(OBJECT(&s->sdhci[0]), "capareg",
                             0x216737eed0b0, &error_abort);

    if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhci[0]), errp)) {
        return;
    }
    sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci[0]), 0,
                       qdev_get_gpio_in(gic_dev, AX3000_SDHCI0_IRQ));
    sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci[0]),
                    0, AX3000_SDHCI0_BASE);

Then you simply map the state-less eMMC PHY region:

    memory_region_init_io(&s->emmc_phy, OBJECT(s), &emmc_phy_ops, s,
                          "axiado.emmc-phy", 0x1000);
    memory_region_add_subregion(get_system_memory(),
                                AX3000_EMMC_PHY_BASE, &s->emmc_phy);
Quoted 48 lines
hw/arm/ax3000-soc.c +6 -0
+
+    card = qdev_new(TYPE_SD_CARD);
+    qdev_prop_set_drive_err(card, "drive",
+                            blk_by_legacy_dinfo((drive_get(IF_SD, 0, 0))),
+                            &error_fatal);
+    qdev_realize_and_unref(card, s->sdhci0.sd_bus, &error_fatal);
  }
 
  static void ax3000_class_init(ObjectClass *oc, const void *data)
include/hw/arm/ax3000-soc.h +7 -0
index 329aa4e7698..52b47aa8294 100644
@@ -13,6 +13,7 @@
  #include "hw/intc/arm_gicv3_common.h"
  #include "hw/char/cadence_uart.h"
  #include "hw/misc/axiado_clk.h"
+#include "hw/sd/axiado_sdhci.h"
  #include "hw/core/sysbus.h"
  #include "qemu/units.h"
 
@@ -34,6 +35,9 @@ OBJECT_DECLARE_TYPE(Ax3000SoCState, Ax3000SoCClass, AX3000_SOC)
  #define AX3000_UART2_BASE       0x80620000
  #define AX3000_UART3_BASE       0x80520800
 
+#define AX3000_SDHCI0_BASE      0x86000000
+#define AX3000_EMMC_PHY_BASE    0x80801C00
+
  #define AX3000_TIMER_CTRL       0x8A020000
  #define AX3000_PLL_BASE         0x80000000
 
@@ -52,6 +56,7 @@ typedef struct Ax3000SoCState {
      MemoryRegion        dram[AX3000_NUM_BANKS];
      Ax3000ClkState      ax3000_clk;
      CadenceUARTState    uart[AX3000_NUM_UARTS];
+    AxiadoSDHCIState    sdhci0;
  } Ax3000SoCState;
 
  typedef struct Ax3000SoCClass {
@@ -65,6 +70,8 @@ enum Ax3000Irqs {
      AX3000_UART1_IRQ    = 113,
      AX3000_UART2_IRQ    = 114,
      AX3000_UART3_IRQ    = 170,
+
+    AX3000_SDHCI0_IRQ   = 123,
  };
 
  #endif /* AXIADO_AX3000_H */
#11 lore raw

Re: [PATCH v5 5/8] hw/arm: ax3000-soc: Enable Axiado SD host controller

Philippe Mathieu-Daudé 於 2026/6/18 下午 11:17 寫道:

Quoted 81 lines

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Hi Kuan-Jui,

Quoted 40 lines · Kuan-Jui Chiu

Enable SD host controller into Axiado AX3000 SoC to load kernel and rootfs from eMMC.

---
  hw/arm/Kconfig              |  1 + hw/arm/ax3000-soc.c         | 18 ++++++++++++++++++ include/hw/arm/ax3000-soc.h |  7 +++++++

  3 files changed, 26 insertions(+)
hw/arm/Kconfig +0 -0
index 866e4b14e6f..13c0b44a180 100644
@@ -724,4 +724,5 @@ config AXIADO_SOC

      select ARM_GIC
      select CADENCE # UART
      select AXIADO_CLK
+    select AXIADO_SDHCI
      select UNIMP

hw/arm/ax3000-soc.c +1 -0
index 9a01d23bcc6..159385cf913 100644
@@ -35,6 +35,7 @@ static void ax3000_init(Object *obj)
       }
 
       object_initialize_child(obj, "clk", &s->ax3000_clk, TYPE_AX3000_CLK);
+    object_initialize_child(obj, "sdhci0", &s->sdhci0, 
 TYPE_AXIADO_SDHCI);
   }
 

  static void ax3000_realize(DeviceState *dev, Error **errp)

hw/arm/ax3000-soc.c +1 -0
@@ -165,6 +166,23 @@ static void ax3000_realize(DeviceState *dev, 
 Error **errp)
           return;
       }
       sysbus_mmio_map(SYS_BUS_DEVICE(&s->ax3000_clk), 0, AX3000_PLL_BASE);
+

hw/arm/ax3000-soc.c static void ax3000_realize(DeviceState *dev, · line 180

Quoted 10 lines
hw/arm/ax3000-soc.c +10 -0
+    /* SDHCI */
+    sdhci0_sbd = SYS_BUS_DEVICE(&s->sdhci0);
+    if (!sysbus_realize(sdhci0_sbd, errp)) {
+        return;
+    }
+
+    sysbus_mmio_map(sdhci0_sbd, 0, AX3000_SDHCI0_BASE);
+    sysbus_mmio_map(sdhci0_sbd, 1, AX3000_EMMC_PHY_BASE);
+    sysbus_connect_irq(sdhci0_sbd, 0,
+                       qdev_get_gpio_in(gic_dev, AX3000_SDHCI0_IRQ));

So there is no link between the SDHCI and the PHY. Thus no need for a particular AXIADO_SDHCI, simply instantiate a generic SDHCI here, and register the MMIO region for the PHY.

in ax3000_init():

    object_initialize_child(obj, "sdhci[0]", &s->sdhci[0], TYPE_SYSBUS_SDHCI);

and in ax3000_realize():

    object_property_set_uint(OBJECT(&s->sdhci[0]), "sd-spec-version", 3, &error_abort); object_property_set_uint(OBJECT(&s->sdhci[0]), "capareg", 0x216737eed0b0, &error_abort);

    if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhci[0]), errp)) { return;
    }
    sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci[0]), 0, qdev_get_gpio_in(gic_dev, AX3000_SDHCI0_IRQ)); sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci[0]),
                    0, AX3000_SDHCI0_BASE);

Quoted 7 lines

Then you simply map the state-less eMMC PHY region:

    memory_region_init_io(&s->emmc_phy, OBJECT(s), &emmc_phy_ops, s, "axiado.emmc-phy", 0x1000); memory_region_add_subregion(get_system_memory(), AX3000_EMMC_PHY_BASE, &s->emmc_phy);

This is the original design in previous patch but PMM preferred to have an independent device model for this SDHC

Quoted 50 lines
Quoted 49 lines
hw/arm/ax3000-soc.c +6 -0
+
+    card = qdev_new(TYPE_SD_CARD);
+    qdev_prop_set_drive_err(card, "drive",
+ blk_by_legacy_dinfo((drive_get(IF_SD, 0, 0))),
+                            &error_fatal);
+    qdev_realize_and_unref(card, s->sdhci0.sd_bus, &error_fatal);
   }
 

  static void ax3000_class_init(ObjectClass *oc, const void *data)

include/hw/arm/ax3000-soc.h +7 -0
index 329aa4e7698..52b47aa8294 100644
@@ -13,6 +13,7 @@
   #include "hw/intc/arm_gicv3_common.h"
   #include "hw/char/cadence_uart.h"
   #include "hw/misc/axiado_clk.h"
+#include "hw/sd/axiado_sdhci.h"
   #include "hw/core/sysbus.h"
   #include "qemu/units.h"
 
@@ -34,6 +35,9 @@ OBJECT_DECLARE_TYPE(Ax3000SoCState, Ax3000SoCClass, 
 AX3000_SOC)
   #define AX3000_UART2_BASE       0x80620000
   #define AX3000_UART3_BASE       0x80520800
 
+#define AX3000_SDHCI0_BASE      0x86000000
+#define AX3000_EMMC_PHY_BASE    0x80801C00
+
   #define AX3000_TIMER_CTRL       0x8A020000
   #define AX3000_PLL_BASE         0x80000000
@@ -52,6 +56,7 @@ typedef struct Ax3000SoCState {
       MemoryRegion        dram[AX3000_NUM_BANKS];
       Ax3000ClkState      ax3000_clk;
       CadenceUARTState    uart[AX3000_NUM_UARTS];
+    AxiadoSDHCIState    sdhci0;
   } Ax3000SoCState;
 
   typedef struct Ax3000SoCClass {
@@ -65,6 +70,8 @@ enum Ax3000Irqs {
       AX3000_UART1_IRQ    = 113,
       AX3000_UART2_IRQ    = 114,
       AX3000_UART3_IRQ    = 170,
+
+    AX3000_SDHCI0_IRQ   = 123,
   };
 
   #endif /* AXIADO_AX3000_H */
#12 lore raw

Re: [PATCH v5 5/8] hw/arm: ax3000-soc: Enable Axiado SD host controller

Quoted 83 lines · Kuan-Jui Chiu

Philippe Mathieu-Daudé 於 2026/6/18 下午 11:17 寫道:

Quoted 81 lines

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Hi Kuan-Jui,

Quoted 40 lines · Kuan-Jui Chiu

Enable SD host controller into Axiado AX3000 SoC to load kernel and rootfs from eMMC.

---
  hw/arm/Kconfig              |  1 + hw/arm/ax3000-soc.c         | 18 ++++++++++++++++++ include/hw/arm/ax3000-soc.h |  7 +++++++

  3 files changed, 26 insertions(+)
hw/arm/Kconfig +0 -0
index 866e4b14e6f..13c0b44a180 100644
@@ -724,4 +724,5 @@ config AXIADO_SOC

      select ARM_GIC
      select CADENCE # UART
      select AXIADO_CLK
+    select AXIADO_SDHCI
      select UNIMP

hw/arm/ax3000-soc.c +1 -0
index 9a01d23bcc6..159385cf913 100644
@@ -35,6 +35,7 @@ static void ax3000_init(Object *obj)
       }
 
       object_initialize_child(obj, "clk", &s->ax3000_clk, TYPE_AX3000_CLK);
+    object_initialize_child(obj, "sdhci0", &s->sdhci0, 
 TYPE_AXIADO_SDHCI);
   }
 

  static void ax3000_realize(DeviceState *dev, Error **errp)

hw/arm/ax3000-soc.c +1 -0
@@ -165,6 +166,23 @@ static void ax3000_realize(DeviceState *dev, 
 Error **errp)
           return;
       }
       sysbus_mmio_map(SYS_BUS_DEVICE(&s->ax3000_clk), 0, AX3000_PLL_BASE);
+

hw/arm/ax3000-soc.c static void ax3000_realize(DeviceState *dev, · line 180

Quoted 10 lines
hw/arm/ax3000-soc.c +10 -0
+    /* SDHCI */
+    sdhci0_sbd = SYS_BUS_DEVICE(&s->sdhci0);
+    if (!sysbus_realize(sdhci0_sbd, errp)) {
+        return;
+    }
+
+    sysbus_mmio_map(sdhci0_sbd, 0, AX3000_SDHCI0_BASE);
+    sysbus_mmio_map(sdhci0_sbd, 1, AX3000_EMMC_PHY_BASE);
+    sysbus_connect_irq(sdhci0_sbd, 0,
+                       qdev_get_gpio_in(gic_dev, AX3000_SDHCI0_IRQ));

So there is no link between the SDHCI and the PHY. Thus no need for a particular AXIADO_SDHCI, simply instantiate a generic SDHCI here, and register the MMIO region for the PHY.

in ax3000_init():

    object_initialize_child(obj, "sdhci[0]", &s->sdhci[0], TYPE_SYSBUS_SDHCI);

and in ax3000_realize():

    object_property_set_uint(OBJECT(&s->sdhci[0]), "sd-spec-version", 3, &error_abort); object_property_set_uint(OBJECT(&s->sdhci[0]), "capareg", 0x216737eed0b0, &error_abort);

    if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhci[0]), errp)) { return;
    }
    sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci[0]), 0, qdev_get_gpio_in(gic_dev, AX3000_SDHCI0_IRQ)); sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci[0]),
                    0, AX3000_SDHCI0_BASE);

Quoted 8 lines
Quoted 7 lines

Then you simply map the state-less eMMC PHY region:

    memory_region_init_io(&s->emmc_phy, OBJECT(s), &emmc_phy_ops, s, "axiado.emmc-phy", 0x1000); memory_region_add_subregion(get_system_memory(), AX3000_EMMC_PHY_BASE, &s->emmc_phy);

This is the original design in previous patch but PMM preferred to have an independent device model for this SDHC

AFAICT nothing on v1.

On v2 Peter said "Adding the new SDHCI controller should be its own patch." This is about the code contribution process, not how to structure the model in code. Is there another reference I missed?

As it this AXIADO_SDHCI is unnecessary maintenance burden.

v1: https://lore.kernel.org/qemu-devel/[email protected]/
v2: https://lore.kernel.org/qemu-devel/CAFEAcA8dRq+hqCZ+eSHdafwEccd4coqHZ12nxWAkyDOG3GEkgg@mail.gmail.com/

#13 lore raw

Re: [PATCH v5 5/8] hw/arm: ax3000-soc: Enable Axiado SD host controller

Philippe Mathieu-Daudé 於 2026/6/22 下午 04:21 寫道:

Quoted 108 lines

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 90 lines · Kuan-Jui Chiu

Philippe Mathieu-Daudé 於 2026/6/18 下午 11:17 寫道:

Quoted 88 lines

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Hi Kuan-Jui,

Quoted 43 lines · Kuan-Jui Chiu

Enable SD host controller into Axiado AX3000 SoC to load kernel and rootfs
from eMMC.

---
  hw/arm/Kconfig              |  1 + hw/arm/ax3000-soc.c         | 18 ++++++++++++++++++ include/hw/arm/ax3000-soc.h |  7 +++++++

  3 files changed, 26 insertions(+)
hw/arm/Kconfig +0 -0
index 866e4b14e6f..13c0b44a180 100644
@@ -724,4 +724,5 @@ config AXIADO_SOC

      select ARM_GIC
      select CADENCE # UART
      select AXIADO_CLK
+    select AXIADO_SDHCI
      select UNIMP

hw/arm/ax3000-soc.c +1 -0
index 9a01d23bcc6..159385cf913 100644
@@ -35,6 +35,7 @@ static void ax3000_init(Object *obj)
       }
 
       object_initialize_child(obj, "clk", &s->ax3000_clk,
 TYPE_AX3000_CLK);
+    object_initialize_child(obj, "sdhci0", &s->sdhci0,
 TYPE_AXIADO_SDHCI);
   }

  static void ax3000_realize(DeviceState *dev, Error **errp)

hw/arm/ax3000-soc.c +1 -0
@@ -165,6 +166,23 @@ static void ax3000_realize(DeviceState *dev,
 Error **errp)
           return;
       }
       sysbus_mmio_map(SYS_BUS_DEVICE(&s->ax3000_clk), 0,
 AX3000_PLL_BASE);
+

hw/arm/ax3000-soc.c static void ax3000_realize(DeviceState *dev, · line 181

Quoted 10 lines
hw/arm/ax3000-soc.c +10 -0
+    /* SDHCI */
+    sdhci0_sbd = SYS_BUS_DEVICE(&s->sdhci0);
+    if (!sysbus_realize(sdhci0_sbd, errp)) {
+        return;
+    }
+
+    sysbus_mmio_map(sdhci0_sbd, 0, AX3000_SDHCI0_BASE);
+    sysbus_mmio_map(sdhci0_sbd, 1, AX3000_EMMC_PHY_BASE);
+    sysbus_connect_irq(sdhci0_sbd, 0,
+                       qdev_get_gpio_in(gic_dev, AX3000_SDHCI0_IRQ));

So there is no link between the SDHCI and the PHY. Thus no need for a particular AXIADO_SDHCI, simply instantiate a generic SDHCI here, and register the MMIO region for the PHY.

in ax3000_init():

    object_initialize_child(obj, "sdhci[0]", &s->sdhci[0], TYPE_SYSBUS_SDHCI);

and in ax3000_realize():

    object_property_set_uint(OBJECT(&s->sdhci[0]), "sd-spec-version", 3, &error_abort); object_property_set_uint(OBJECT(&s->sdhci[0]), "capareg", 0x216737eed0b0, &error_abort);

    if (!sysbus_realize(SYS_BUS_DEVICE(&s->sdhci[0]), errp)) { return;
    }
    sysbus_connect_irq(SYS_BUS_DEVICE(&s->sdhci[0]), 0, qdev_get_gpio_in(gic_dev, AX3000_SDHCI0_IRQ)); sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdhci[0]),
                    0, AX3000_SDHCI0_BASE);

Then you simply map the state-less eMMC PHY region:

Quoted 7 lines
Quoted 5 lines

    memory_region_init_io(&s->emmc_phy, OBJECT(s), &emmc_phy_ops, s, "axiado.emmc-phy", 0x1000); memory_region_add_subregion(get_system_memory(), AX3000_EMMC_PHY_BASE, &s->emmc_phy);

This is the original design in previous patch but PMM preferred to have an independent device model for this SDHC

AFAICT nothing on v1.

On v2 Peter said "Adding the new SDHCI controller should be its own patch." This is about the code contribution process, not how to structure the model in code. Is there another reference I missed?

Quoted 8 lines

As it this AXIADO_SDHCI is unnecessary maintenance burden.

v1:
https://lore.kernel.org/qemu-devel/[email protected]/

v2:
https://lore.kernel.org/qemu-devel/CAFEAcA8dRq+hqCZ+eSHdafwEccd4coqHZ12nxWAkyDOG3GEkgg@mail.gmail.com/

Look like I misunderstood this

Quoted 1 line

+static uint64_t sdhci_phy_read(void *opaque, hwaddr offset, unsigned

size)

Quoted 9 lines
(quoted diff) +9 -0
+{
+    uint32_t val = 0x00;
+
+    switch (offset) {
+    case REG_ID:
+        val = 0x3dff6870;
+        break;
+    case REG_STATUS:
+        // Make DLL_RDY | CAL_DONE

Review

Quoted 10 lines
(quoted diff) +10 -0
+        val =  (1u << 0) | (1u << 6);
+        break;
+    default:
+        break;
+    }
+
+    return val;
+}
+
+static void sdhci_phy_write(void *opaque, hwaddr offset, uint64_t 

val, unsigned size)

Review

Quoted 9 lines
(quoted diff) +9 -0
+{
+    /* TBD */
+}
+
+static const MemoryRegionOps sdhci_phy_ops = {
+    .read = sdhci_phy_read,
+    .write = sdhci_phy_write,
+    .endianness = DEVICE_LITTLE_ENDIAN,
+};

Please put models of sub-devices of the SoC into their own source files in the appropriate subdirectory of the hw/ directory.

I thought he was talking about the SDHC
Now he probably just wanted me to move PHY out of ax3000-soc

Should I remove axiado_sdhci then add misc device for eMMC PHY in v7 patch?

#14 lore raw

PATCH v5 6/8 hw/arm: Add Axiado EVK SCM3003

In reply to Kuan-Jui Chiu

Add EVK axiado-scm3003 built with AX3000 SoC

---
 hw/arm/Kconfig                 |  5 +++
 hw/arm/ax3000-boards.c         | 56 ++++++++++++++++++++++++++++++++++
 hw/arm/ax3000-evk.c            | 27 ++++++++++++++++
 hw/arm/meson.build             |  3 ++
 include/hw/arm/ax3000-boards.h | 28 +++++++++++++++++
 5 files changed, 119 insertions(+)
 create mode 100644 hw/arm/ax3000-boards.c
 create mode 100644 hw/arm/ax3000-evk.c
 create mode 100644 include/hw/arm/ax3000-boards.h
hw/arm/Kconfig +5 -0
index 13c0b44a180..7fc6fae9673 100644
@@ -726,3 +726,8 @@ config AXIADO_SOC
     select AXIADO_CLK
     select AXIADO_SDHCI
     select UNIMP
+
+config AXIADO_EVK
+    bool
+    default y
+    select AXIADO_SOC
hw/arm/ax3000-boards.c new file +56 -0

56 lines not on this page · raw message

hw/arm/ax3000-evk.c new file +27 -0
new file mode 100644
index 00000000000..a1708488710
@@ -0,0 +1,27 @@
+/*
+ * Axiado Evaluation Kit Emulation
+ *
+ * Author: Kuan-Jui Chiu <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/arm/ax3000-boards.h"
+
+static void axiado_scm3003_class_init(ObjectClass *oc, const void *data)
+{
+    MachineClass *mc = MACHINE_CLASS(oc);
+
+    mc->desc = "Axiado SCM3003 EVK Board";
+}
+
+static const TypeInfo ax3000_evk_types[] = {
+    {
+        .name          = MACHINE_TYPE_NAME("axiado-scm3003"),
+        .parent        = TYPE_AX3000_MACHINE,
+        .class_init    = axiado_scm3003_class_init,
+    }
+};
+
+DEFINE_TYPES(ax3000_evk_types)
hw/arm/meson.build +3 -0
index 111ab2ba010..feef999f36a 100644
@@ -110,6 +110,9 @@ arm_common_ss.add(when: 'CONFIG_VEXPRESS', if_true: files('vexpress.c'))
 
 arm_common_ss.add(when: ['CONFIG_AXIADO_SOC', 'TARGET_AARCH64'], if_true: files(
   'ax3000-soc.c'))
+arm_common_ss.add(when: ['CONFIG_AXIADO_EVK', 'TARGET_AARCH64'], if_true: files(
+  'ax3000-boards.c',
+  'ax3000-evk.c'))
 
 arm_common_ss.add(files('boot.c'))
 
include/hw/arm/ax3000-boards.h new file +28 -0
new file mode 100644
index 00000000000..4a632661e1e
@@ -0,0 +1,28 @@
+/*
+ * Axiado Boards
+ *
+ * Author: Kuan-Jui Chiu <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef AXIADO_BOARD_H
+#define AXIADO_BOARD_H
+
+#include "hw/core/boards.h"
+#include "hw/arm/ax3000-soc.h"
+
+#define TYPE_AX3000_MACHINE       MACHINE_TYPE_NAME("ax3000")
+OBJECT_DECLARE_TYPE(Ax3000MachineState, Ax3000MachineClass, AX3000_MACHINE)
+
+typedef struct Ax3000MachineState {
+    MachineState parent;
+
+    Ax3000SoCState *soc;
+} Ax3000MachineState;
+
+typedef struct Ax3000MachineClass {
+    MachineClass parent;
+
+} Ax3000MachineClass;
+#endif
Signature · 1 line
2.34.1
#15 lore raw

PATCH v5 7/8 hw/gpio: Add Cadence GPIO controller

In reply to Kuan-Jui Chiu

This patch add a new model for Cadence GPIO controller which supports 32 pins and interrupts for level-triggered/edge-triggered type on input pins.

Also define new trace functions for analysis purpose and new configuration to enable this model.

---
 hw/gpio/Kconfig                |   3 +
 hw/gpio/cadence_gpio.c         | 292 +++++++++++++++++++++++++++++++++
 hw/gpio/meson.build            |   1 +
 hw/gpio/trace-events           |   5 +
 include/hw/gpio/cadence_gpio.h |  55 +++++++
 5 files changed, 356 insertions(+)
 create mode 100644 hw/gpio/cadence_gpio.c
 create mode 100644 include/hw/gpio/cadence_gpio.h
hw/gpio/Kconfig +3 -0
index a209294c20c..fcc7c70bd50 100644
@@ -30,3 +30,6 @@ config PCF8574
 
 config ZAURUS_SCOOP
     bool
+
+config CADENCE_GPIO
+    bool
hw/gpio/cadence_gpio.c new file +292 -0

292 lines not on this page · raw message

hw/gpio/meson.build +1 -0
index 6a67ee958fa..0555f44b6a7 100644
@@ -19,3 +19,4 @@ system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_gpio.c'))
 system_ss.add(when: 'CONFIG_ASPEED_SOC', if_true: files('aspeed_sgpio.c'))
 system_ss.add(when: 'CONFIG_SIFIVE_GPIO', if_true: files('sifive_gpio.c'))
 system_ss.add(when: 'CONFIG_PCF8574', if_true: files('pcf8574.c'))
+system_ss.add(when: 'CONFIG_CADENCE_GPIO', if_true: files('cadence_gpio.c'))
hw/gpio/trace-events +5 -0
index cea896b28f6..80ca783a039 100644
@@ -46,3 +46,8 @@ stm32l4x5_gpio_read(char *gpio, uint64_t addr) "GPIO%s addr: 0x%" PRIx64 " "
 stm32l4x5_gpio_write(char *gpio, uint64_t addr, uint64_t data) "GPIO%s addr: 0x%" PRIx64 " val: 0x%" PRIx64 ""
 stm32l4x5_gpio_update_idr(char *gpio, uint32_t old_idr, uint32_t new_idr) "GPIO%s from: 0x%x to: 0x%x"
 stm32l4x5_gpio_pins(char *gpio, uint16_t disconnected, uint16_t high) "GPIO%s disconnected pins: 0x%x levels: 0x%x"
+
+# cadence_gpio.c
+cdns_gpio_read(const char *path, uint64_t offset, uint32_t value) "%s:reg[0x%04" PRIx64 "] -> 0x%" PRIx32
+cdns_gpio_write(const char *path, uint64_t offset, uint64_t value) "%s:reg[0x%04" PRIx64 "] <- 0x%04" PRIx64
+cdns_gpio_set(const char *path, int line, int level) "%s:[%d] <- %d"
include/hw/gpio/cadence_gpio.h new file +55 -0

55 lines not on this page · raw message

Signature · 1 line
2.34.1
#16 lore raw

PATCH v5 8/8 hw/arm: ax3000-soc: Enable Cadence GPIO controllers

In reply to Kuan-Jui Chiu

Enable 8 Cadence GPIO controllers into Axiado AX3000 SoC

---
 hw/arm/Kconfig              |  1 +
 hw/arm/ax3000-soc.c         | 30 ++++++++++++++++++++++++++++++
 include/hw/arm/ax3000-soc.h | 21 +++++++++++++++++++++
 3 files changed, 52 insertions(+)
hw/arm/Kconfig +1 -0
index 7fc6fae9673..84810b0eadd 100644
@@ -724,6 +724,7 @@ config AXIADO_SOC
     select ARM_GIC
     select CADENCE # UART
     select AXIADO_CLK
+    select CADENCE_GPIO
     select AXIADO_SDHCI
     select UNIMP
 
hw/arm/ax3000-soc.c +30 -0
index 159385cf913..98b4f1697ce 100644
@@ -36,6 +36,11 @@ static void ax3000_init(Object *obj)
 
     object_initialize_child(obj, "clk", &s->ax3000_clk, TYPE_AX3000_CLK);
     object_initialize_child(obj, "sdhci0", &s->sdhci0, TYPE_AXIADO_SDHCI);
+
+    for (int i = 0; i < AX3000_NUM_GPIOS; i++) {
+        g_autofree char *name = g_strdup_printf("gpio%d", i);
+        object_initialize_child(obj, name, &s->gpio[i], TYPE_CADENCE_GPIO);
+    }
 }
 
 static void ax3000_realize(DeviceState *dev, Error **errp)
@@ -183,6 +188,31 @@ static void ax3000_realize(DeviceState *dev, Error **errp)
                             blk_by_legacy_dinfo((drive_get(IF_SD, 0, 0))),
                             &error_fatal);
     qdev_realize_and_unref(card, s->sdhci0.sd_bus, &error_fatal);
+
+    /* GPIOs */
+    for (int i = 0; i < AX3000_NUM_GPIOS; i++) {
+        struct {
+            hwaddr addr;
+            unsigned int irq;
+        } gpio_table[] = {
+            { AX3000_GPIO0_BASE, AX3000_GPIO0_IRQ },
+            { AX3000_GPIO1_BASE, AX3000_GPIO1_IRQ },
+            { AX3000_GPIO2_BASE, AX3000_GPIO2_IRQ },
+            { AX3000_GPIO3_BASE, AX3000_GPIO3_IRQ },
+            { AX3000_GPIO4_BASE, AX3000_GPIO4_IRQ },
+            { AX3000_GPIO5_BASE, AX3000_GPIO5_IRQ },
+            { AX3000_GPIO6_BASE, AX3000_GPIO6_IRQ },
+            { AX3000_GPIO7_BASE, AX3000_GPIO7_IRQ }
+        };
+
+        if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio[i]), errp)) {
+            return;
+        }
+
+        sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr);
+        sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0,
+                           qdev_get_gpio_in(gic_dev, gpio_table[i].irq));
+    }
 }
 
 static void ax3000_class_init(ObjectClass *oc, const void *data)
include/hw/arm/ax3000-soc.h +21 -0
index 52b47aa8294..344fcb6f3c2 100644
@@ -13,6 +13,7 @@
 #include "hw/intc/arm_gicv3_common.h"
 #include "hw/char/cadence_uart.h"
 #include "hw/misc/axiado_clk.h"
+#include "hw/gpio/cadence_gpio.h"
 #include "hw/sd/axiado_sdhci.h"
 #include "hw/core/sysbus.h"
 #include "qemu/units.h"
@@ -38,6 +39,15 @@ OBJECT_DECLARE_TYPE(Ax3000SoCState, Ax3000SoCClass, AX3000_SOC)
 #define AX3000_SDHCI0_BASE      0x86000000
 #define AX3000_EMMC_PHY_BASE    0x80801C00
 
+#define AX3000_GPIO0_BASE       0x80500000
+#define AX3000_GPIO1_BASE       0x80580000
+#define AX3000_GPIO2_BASE       0x80600000
+#define AX3000_GPIO3_BASE       0x80680000
+#define AX3000_GPIO4_BASE       0x80700000
+#define AX3000_GPIO5_BASE       0x80780000
+#define AX3000_GPIO6_BASE       0x80800000
+#define AX3000_GPIO7_BASE       0x80880000
+
 #define AX3000_TIMER_CTRL       0x8A020000
 #define AX3000_PLL_BASE         0x80000000
 
@@ -46,6 +56,7 @@ enum Ax3000Configuration {
     AX3000_NUM_IRQS     = 224,
     AX3000_NUM_BANKS    = 2,
     AX3000_NUM_UARTS    = 4,
+    AX3000_NUM_GPIOS    = 8,
 };
 
 typedef struct Ax3000SoCState {
@@ -56,6 +67,7 @@ typedef struct Ax3000SoCState {
     MemoryRegion        dram[AX3000_NUM_BANKS];
     Ax3000ClkState      ax3000_clk;
     CadenceUARTState    uart[AX3000_NUM_UARTS];
+    CadenceGPIOState    gpio[AX3000_NUM_GPIOS];
     AxiadoSDHCIState    sdhci0;
 } Ax3000SoCState;
 
@@ -72,6 +84,15 @@ enum Ax3000Irqs {
     AX3000_UART3_IRQ    = 170,
 
     AX3000_SDHCI0_IRQ   = 123,
+
+    AX3000_GPIO0_IRQ    = 183,
+    AX3000_GPIO1_IRQ    = 184,
+    AX3000_GPIO2_IRQ    = 185,
+    AX3000_GPIO3_IRQ    = 186,
+    AX3000_GPIO4_IRQ    = 187,
+    AX3000_GPIO5_IRQ    = 188,
+    AX3000_GPIO6_IRQ    = 189,
+    AX3000_GPIO7_IRQ    = 190,
 };
 
 #endif /* AXIADO_AX3000_H */
Signature · 1 line
2.34.1
Reviewed-by on v5 8/8
#17 lore raw

Re: [PATCH v5 8/8] hw/arm: ax3000-soc: Enable Cadence GPIO controllers

Quoted 13 lines · Kuan-Jui Chiu

Enable 8 Cadence GPIO controllers into Axiado AX3000 SoC

---
  hw/arm/Kconfig              |  1 +
  hw/arm/ax3000-soc.c         | 30 ++++++++++++++++++++++++++++++
  include/hw/arm/ax3000-soc.h | 21 +++++++++++++++++++++
  3 files changed, 52 insertions(+)

static void ax3000_realize(DeviceState *dev, Error **errp)

hw/arm/ax3000-soc.c static void ax3000_realize(DeviceState *dev, Error **errp) · line 193

Quoted 6 lines
hw/arm/ax3000-soc.c +3 -0
@@ -183,6 +188,31 @@ static void ax3000_realize(DeviceState *dev, Error **errp)
                              blk_by_legacy_dinfo((drive_get(IF_SD, 0, 0))),
                              &error_fatal);
      qdev_realize_and_unref(card, s->sdhci0.sd_bus, &error_fatal);
+
+    /* GPIOs */
+    for (int i = 0; i < AX3000_NUM_GPIOS; i++) {

static const

Quoted 13 lines
hw/arm/ax3000-soc.c +13 -0
+        struct {
+            hwaddr addr;
+            unsigned int irq;
+        } gpio_table[] = {
+            { AX3000_GPIO0_BASE, AX3000_GPIO0_IRQ },
+            { AX3000_GPIO1_BASE, AX3000_GPIO1_IRQ },
+            { AX3000_GPIO2_BASE, AX3000_GPIO2_IRQ },
+            { AX3000_GPIO3_BASE, AX3000_GPIO3_IRQ },
+            { AX3000_GPIO4_BASE, AX3000_GPIO4_IRQ },
+            { AX3000_GPIO5_BASE, AX3000_GPIO5_IRQ },
+            { AX3000_GPIO6_BASE, AX3000_GPIO6_IRQ },
+            { AX3000_GPIO7_BASE, AX3000_GPIO7_IRQ }
+        };

hw/arm/ax3000-soc.c static void ax3000_realize(DeviceState *dev, Error **errp) · line 216

Quoted 10 lines
hw/arm/ax3000-soc.c +9 -0
+
+        if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio[i]), errp)) {
+            return;
+        }
+
+        sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, gpio_table[i].addr);
+        sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0,
+                           qdev_get_gpio_in(gic_dev, gpio_table[i].irq));
+    }
  }
#18 lore raw

Re: [PATCH v5 8/8] hw/arm: ax3000-soc: Enable Cadence GPIO controllers

Philippe Mathieu-Daudé 於 2026/6/18 下午 11:21 寫道:

Quoted 15 lines

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Quoted 9 lines · Kuan-Jui Chiu

Enable 8 Cadence GPIO controllers into Axiado AX3000 SoC

---
  hw/arm/Kconfig              |  1 + hw/arm/ax3000-soc.c         | 30 ++++++++++++++++++++++++++++++ include/hw/arm/ax3000-soc.h | 21 +++++++++++++++++++++

  3 files changed, 52 insertions(+)
Quoted 11 lines

hw/arm/ax3000-soc.c static void ax3000_realize(DeviceState *dev, · line 194

Quoted 9 lines

  static void ax3000_realize(DeviceState *dev, Error **errp)

hw/arm/ax3000-soc.c +3 -0
@@ -183,6 +188,31 @@ static void ax3000_realize(DeviceState *dev, 
 Error **errp)
 blk_by_legacy_dinfo((drive_get(IF_SD, 0, 0))),
                               &error_fatal);
       qdev_realize_and_unref(card, s->sdhci0.sd_bus, &error_fatal);
+
+    /* GPIOs */
+    for (int i = 0; i < AX3000_NUM_GPIOS; i++) {

static const

I don't think we need static here because we don't need this struct for entire lifetime I can add const here to mark it as read-only and others

Quoted 29 lines
Quoted 25 lines
hw/arm/ax3000-soc.c +22 -0
+        struct {
+            hwaddr addr;
+            unsigned int irq;
+        } gpio_table[] = {
+            { AX3000_GPIO0_BASE, AX3000_GPIO0_IRQ },
+            { AX3000_GPIO1_BASE, AX3000_GPIO1_IRQ },
+            { AX3000_GPIO2_BASE, AX3000_GPIO2_IRQ },
+            { AX3000_GPIO3_BASE, AX3000_GPIO3_IRQ },
+            { AX3000_GPIO4_BASE, AX3000_GPIO4_IRQ },
+            { AX3000_GPIO5_BASE, AX3000_GPIO5_IRQ },
+            { AX3000_GPIO6_BASE, AX3000_GPIO6_IRQ },
+            { AX3000_GPIO7_BASE, AX3000_GPIO7_IRQ }
+        };
+
+        if (!sysbus_realize(SYS_BUS_DEVICE(&s->gpio[i]), errp)) {
+            return;
+        }
+
+        sysbus_mmio_map(SYS_BUS_DEVICE(&s->gpio[i]), 0, 
 gpio_table[i].addr);
+        sysbus_connect_irq(SYS_BUS_DEVICE(&s->gpio[i]), 0,
+                           qdev_get_gpio_in(gic_dev, 
 gpio_table[i].irq));
+    }
Quoted 1 line

  }