Add Axiado SoC AX3000 and EVK board
Subsystems (2)
v2 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-github.wic,format=rawRefer Axiado website for more product information
https://axiado.com/products/
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 (4):
hw/arm: Add Axiado SoC AX3000
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 | 14 ++ hw/arm/ax3000-boards.c | 52 ++++++ hw/arm/ax3000-evk.c | 27 +++ hw/arm/ax3000-soc.c | 262 +++++++++++++++++++++++++++ hw/arm/meson.build | 6 + hw/gpio/Kconfig | 3 + hw/gpio/cadence_gpio.c | 312 +++++++++++++++++++++++++++++++++ hw/gpio/meson.build | 1 + hw/gpio/trace-events | 5 + hw/sd/Kconfig | 4 + hw/sd/axiado_sdhci.c | 100 +++++++++++ hw/sd/meson.build | 1 + include/hw/arm/ax3000-boards.h | 28 +++ include/hw/arm/ax3000-soc.h | 99 +++++++++++ include/hw/gpio/cadence_gpio.h | 66 +++++++ include/hw/sd/axiado_sdhci.h | 21 +++ 17 files changed, 1010 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/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/sd/axiado_sdhci.h
Signature · 1 line
2.34.1
PATCH v2 1/4 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
1 SDHCI controller with eMMC PHY
--- MAINTAINERS | 9 ++ hw/arm/Kconfig | 8 ++ hw/arm/ax3000-soc.c | 232 +++++++++++++++++++++++++++++++++++ hw/arm/meson.build | 3 + hw/sd/Kconfig | 4 + hw/sd/axiado_sdhci.c | 100 +++++++++++++++ hw/sd/meson.build | 1 + include/hw/arm/ax3000-soc.h | 78 ++++++++++++ include/hw/sd/axiado_sdhci.h | 21 ++++ 9 files changed, 456 insertions(+) create mode 100644 hw/arm/ax3000-soc.c create mode 100644 hw/sd/axiado_sdhci.c create mode 100644 include/hw/arm/ax3000-soc.h create mode 100644 include/hw/sd/axiado_sdhci.h
MAINTAINERS +9 -0
@@ -1285,6 +1285,15 @@ 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: hw/*/axiado*.c +F: include/hw/arm/ax3000*.h +F: include/hw/*/axiado*.h + AVR Machines -------------
hw/arm/Kconfig +8 -0
@@ -691,3 +691,11 @@ config ARMSSE select UNIMP select SSE_COUNTER select SSE_TIMER + +config AXIADO_SOC + bool + depends on ARM + select ARM_GIC + select CADENCE # UART + select AXIADO_SDHCI + select UNIMP
hw/arm/ax3000-soc.c new file +232 -0
232 lines not on this page · raw message
hw/arm/meson.build +3 -0
@@ -105,6 +105,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_arch += {'arm': arm_ss}
hw/sd/Kconfig +4 -0
@@ -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 +100 -0
100 lines not on this page · raw message
hw/sd/meson.build +1 -0
@@ -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/arm/ax3000-soc.h new file +78 -0
78 lines not on this page · raw message
include/hw/sd/axiado_sdhci.h new file +21 -0
@@ -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
Re: [PATCH v2 1/4] hw/arm: Add Axiado SoC AX3000
Quoted 7 lines · Kuan-Jui Chiu
This patch adds new model for Axiado SoC AX3000 which supports
4 Cortex-A53 ARM64 CPUs
Arm Generic Interrupt Controller v3
4 Cadence UARTs
1 SDHCI controller with eMMC PHY
Quoted 8 lines
Signed-off-by Kuan-Jui Chiu <[email protected]>--- MAINTAINERS | 9 ++ hw/arm/Kconfig | 8 ++ hw/arm/ax3000-soc.c | 232 +++++++++++++++++++++++++++++++++++ hw/arm/meson.build | 3 + hw/sd/Kconfig | 4 + hw/sd/axiado_sdhci.c | 100 +++++++++++++++
Adding the new SDHCI controller should be its own patch.
Quoted 22 lines
hw/sd/meson.build | 1 + include/hw/arm/ax3000-soc.h | 78 ++++++++++++ include/hw/sd/axiado_sdhci.h | 21 ++++ 9 files changed, 456 insertions(+) create mode 100644 hw/arm/ax3000-soc.c create mode 100644 hw/sd/axiado_sdhci.c create mode 100644 include/hw/arm/ax3000-soc.h create mode 100644 include/hw/sd/axiado_sdhci.hhw/arm/ax3000-soc.c new file +11
-0+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 ; + } +}
hw/arm/ax3000-soc.c line 39
Quoted 10 lines
hw/arm/ax3000-soc.c new file +10
-0+ +static void pll_write (void *opaque,hwaddr offset,uint64_t val,unsigned size) +{ +/* TBD */ +} + +static const MemoryRegionOps pll_ops = { + .read = pll_read, + .write = pll_write, + .endianness =DEVICE_LITTLE_ENDIAN ,
MemoryRegionOps should always explicitly specify a set of .impl and .valid fields to say what the min_access_size and max_access_size are. (.valid is what the hardware permits; .impl is what the functions handle; the memory system core code can somewhat bridge the gap if your implementation handles a more restrictive set of sizes than the guest is allowed to use.) e.g. if the hardware is "must always be 32 bit accesses then set all of .valid.min_access_size, .valid.max_access_size, .impl.min_access_size, .impl.max_access_size to 4.
Quoted 1 line
+};
This looks like it should be its own device in its own file, not a free-standing set of MemoryRegionOps and MemoryRegion in this file.
hw/arm/ax3000-soc.c line 46
Quoted 5 lines
hw/arm/ax3000-soc.c new file +5
-0+static void ax3000_init (Object *obj) +{ +Ax3000SoCState *s =AX3000_SOC (obj); +Ax3000SoCClass *sc =AX3000_SOC_GET_CLASS (s); +int i;
These days we tend to favour declaring the variable inside the for loop:
for (int i = 0; ... ; ...)
Quoted 236 lines
hw/arm/ax3000-soc.c new file +186
-0+ +for (i =0 ; i < sc->num_cpus; i++) { + g_autofree char *name = g_strdup_printf("cpu%d", i); +object_initialize_child (obj, name, &s->cpu[i], +ARM_CPU_TYPE_NAME ("cortex-a53" )); + } + +object_initialize_child (obj,"gic" , &s->gic,gicv3_class_name ()); + +for (i =0 ; i <AX3000_NUM_UARTS ; i++) { + 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,"sdhci0" , &s->sdhci0,TYPE_AXIADO_SDHCI ); +} + +static void ax3000_realize (DeviceState *dev,Error **errp) +{ +Ax3000SoCState *s =AX3000_SOC (dev); +Ax3000SoCClass *sc =AX3000_SOC_GET_CLASS (s); +SysBusDevice *gic_sbd =SYS_BUS_DEVICE (&s->gic); +DeviceState *gic_dev =DEVICE (&s->gic); +QList *redist_region_count; +SysBusDevice *sdhci0_sbd; +DeviceState *card; +int i; + +/* CPUs */ +for (i =0 ; i < sc->num_cpus; i++) { +object_property_set_int (OBJECT (&s->cpu[i]),"cntfrq" ,8000000 , + &error_abort); + +if (object_property_find (OBJECT (&s->cpu[i]),"has_el3" )) { +object_property_set_bool (OBJECT (&s->cpu[i]),"has_el3" , + false, &error_abort); + } + +if (!qdev_realize (DEVICE (&s->cpu[i]),NULL , errp)) { +return ; + } + } + +/* GIC */ +qdev_prop_set_uint32 (gic_dev,"num-cpu" , sc->num_cpus); +qdev_prop_set_uint32 (gic_dev,"num-irq" , +AX3000_NUM_IRQS +GIC_INTERNAL ); + + redist_region_count =qlist_new (); +qlist_append_int (redist_region_count, sc->num_cpus); +qdev_prop_set_array (gic_dev,"redist-region-count" , redist_region_count); + +if (!sysbus_realize (gic_sbd, errp)) { +return ; + } + +sysbus_mmio_map (gic_sbd,0 ,AX3000_GIC_DIST_BASE ); +sysbus_mmio_map (gic_sbd,1 ,AX3000_GIC_REDIST_BASE ); + +/* +* Wire the outputs from each CPU's generic timer and the GICv3 +* maintenance interrupt signal to the appropriate GIC PPI inputs, and +* the GIC's IRQ/FIQ interrupt outputs to the CPU's inputs. +*/ +for (i =0 ; i < sc->num_cpus; i++) { +DeviceState *cpu_dev =DEVICE (&s->cpu[i]); +int intidbase =AX3000_NUM_IRQS + i *GIC_INTERNAL ; +qemu_irq irq; + +/* +* Mapping from the output timer irq lines from the CPU to the +* GIC PPI inputs. +*/ +static const int timer_irqs[] = { + [GTIMER_PHYS ] =ARCH_TIMER_NS_EL1_IRQ , + [GTIMER_VIRT ] =ARCH_TIMER_VIRT_IRQ , + [GTIMER_HYP ] =ARCH_TIMER_NS_EL2_IRQ , + [GTIMER_SEC ] =ARCH_TIMER_S_EL1_IRQ + }; + +for (int j =0 ; j <ARRAY_SIZE (timer_irqs); j++) { + irq =qdev_get_gpio_in (gic_dev, intidbase + timer_irqs[j]); +qdev_connect_gpio_out (cpu_dev, j, irq); + } + + irq =qdev_get_gpio_in (gic_dev, intidbase +ARCH_GIC_MAINT_IRQ ); +qdev_connect_gpio_out_named (cpu_dev,"gicv3-maintenance-interrupt" , +0 , irq); + +sysbus_connect_irq (gic_sbd, i, +qdev_get_gpio_in (cpu_dev,ARM_CPU_IRQ )); +sysbus_connect_irq (gic_sbd, i + sc->num_cpus, +qdev_get_gpio_in (cpu_dev,ARM_CPU_FIQ )); +sysbus_connect_irq (gic_sbd, i +2 * sc->num_cpus, +qdev_get_gpio_in (cpu_dev,ARM_CPU_VIRQ )); +sysbus_connect_irq (gic_sbd, i +3 * sc->num_cpus, +qdev_get_gpio_in (cpu_dev,ARM_CPU_VFIQ )); + } + +/* DRAM */ +for (i =0 ; i <AX3000_NUM_BANKS ; i++) { +struct { +hwaddr addr; +size_t size; +const char *name; + } dram_table[] = { + {AX3000_DRAM0_BASE ,AX3000_DRAM0_SIZE ,"dram0" }, + {AX3000_DRAM1_BASE ,AX3000_DRAM1_SIZE ,"dram1" } + }; + +memory_region_init_ram (&s->dram[i],OBJECT (s), dram_table[i].name, + dram_table[i].size, &error_fatal); +memory_region_add_subregion (get_system_memory (), dram_table[i].addr, + &s->dram[i]); + } + +/* UARTs */ +for (i =0 ; i <AX3000_NUM_UARTS ; i++) { +struct { +hwaddr addr; +unsigned int irq; + } serial_table[] = { + {AX3000_UART0_BASE ,AX3000_UART0_IRQ }, + {AX3000_UART1_BASE ,AX3000_UART1_IRQ }, + {AX3000_UART2_BASE ,AX3000_UART2_IRQ }, + {AX3000_UART3_BASE ,AX3000_UART3_IRQ } + }; + +qdev_prop_set_chr (DEVICE (&s->uart[i]),"chardev" ,serial_hd (i)); +if (!sysbus_realize (SYS_BUS_DEVICE (&s->uart[i]), errp)) { +return ; + } + +sysbus_mmio_map (SYS_BUS_DEVICE (&s->uart[i]),0 , serial_table[i].addr); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->uart[i]),0 , +qdev_get_gpio_in (gic_dev, serial_table[i].irq)); + } + +/* Timer control */ +create_unimplemented_device ("ax3000.timerctrl" ,AX3000_TIMER_CTRL ,32 ); + +/* PLL control */ +memory_region_init_io (&s->pll_ctrl,OBJECT (s), &pll_ops, s, +"ax3000.pllctrl" ,32 ); +memory_region_add_subregion (get_system_memory (),AX3000_PLL_BASE , + &s->pll_ctrl); + +/* 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) +{ +DeviceClass *dc =DEVICE_CLASS (oc); +Ax3000SoCClass *sc =AX3000_SOC_CLASS (oc); + + dc->desc ="Axiado SoC AX3000" ; + dc->realize = ax3000_realize; + sc->num_cpus =AX3000_NUM_CPUS ; +} + +static const TypeInfo axiado_soc_types[] = { + { + .name =TYPE_AX3000_SOC , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (Ax3000SoCState), + .instance_init = ax3000_init, + .class_init = ax3000_class_init, + } +}; + +DEFINE_TYPES (axiado_soc_types)hw/arm/meson.build +3
-0@@ -105,6 +105,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_arch += {'arm': arm_ss}hw/sd/Kconfig +4
-0@@ -23,3 +23,7 @@ config SDHCI_PCI config CADENCE_SDHCI bool select SDHCI + +config AXIADO_SDHCI + bool + select SDHCIhw/sd/axiado_sdhci.c new file +18
-0@@ -0,0 +1,100 @@ +/* +* Axiado SD Host Controller +* +* 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 + +static uint64_t emmc_phy_read (void *opaque,hwaddr offset,unsigned size)
hw/sd/axiado_sdhci.c line 28
Quoted 10 lines
hw/sd/axiado_sdhci.c new file +10
-0+{ +uint32_t val =0x00 ; + +switch (offset) { +case EMMC_PHY_ID : + val =0x3dff6870 ; +break ; +case EMMC_PHY_STATUS : +/* Make DLL_RDY | CAL_DONE */ + val = (1u <<0 ) | (1u <<6 );
If this comment is trying to say what these bits are, better to define symbolic constants for the bits and use those.
hw/sd/axiado_sdhci.c line 40
Quoted 12 lines
hw/sd/axiado_sdhci.c new file +12
-0+break ; +default : +break ; + } + +return val; +} + +static void emmc_phy_write (void *opaque,hwaddr offset,uint64_t value, +unsigned size) +{ +/* TBD */
Don't leave bare TBD/TODO comments in the code. It's OK not to necessarily implement everything at the start, but the comment should explain what is missing. In six months time, will somebody other than you be able to look at the file and know what is still to do ?
hw/sd/axiado_sdhci.c line 46
Quoted 6 lines
hw/sd/axiado_sdhci.c new file +6
-0+} + +static const MemoryRegionOps emmc_phy_ops = { + .read = emmc_phy_read, + .write = emmc_phy_write, + .endianness =DEVICE_LITTLE_ENDIAN ,
This should specify access sizes too.
hw/sd/axiado_sdhci.c line 56
Quoted 10 lines
hw/sd/axiado_sdhci.c new file +10
-0+}; + +static void axiado_sdhci_realize (DeviceState *dev,Error **errp) +{ +AxiadoSDHCIState *s =AXIADO_SDHCI (dev); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); +SysBusDevice *sdhci_sbd; + +object_initialize_child (OBJECT (s),"sdhci" , &s->sdhci, +TYPE_SYSBUS_SDHCI );
Generally devices should do the object_initialize_child for child-objects in their instance_init function, and realize in their realize function. (Occasionally there's a reason this isn't possible.)
Quoted 34 lines
hw/sd/axiado_sdhci.c new file +34
-0+ +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); +sysbus_realize (sdhci_sbd, errp); +if (*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" ); + +/* 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_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" ; +} + +static const TypeInfo axiado_sdhci_info = { + .name =TYPE_AXIADO_SDHCI , + .parent =TYPE_SYS_BUS_DEVICE ,
hw/sd/axiado_sdhci.c line 100
Quoted 10 lines
hw/sd/axiado_sdhci.c new file +10
-0+ .instance_size = sizeof(AxiadoSDHCIState), + .class_init = axiado_sdhci_class_init, +}; + +static void axiado_sdhci_register_types (void ) +{ +type_register_static (&axiado_sdhci_info); +} + +type_init (axiado_sdhci_register_types);
thanks
-- PMM
Re: [PATCH v2 1/4] hw/arm: Add Axiado SoC AX3000
Peter Maydell 於 2026/5/26 下午 10:06 寫道:
Quoted 18 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 6 lines · Kuan-Jui Chiu
This patch adds new model for Axiado SoC AX3000 which supports
4 Cortex-A53 ARM64 CPUs
Arm Generic Interrupt Controller v3
4 Cadence UARTs
1 SDHCI controller with eMMC PHYQuoted 8 lines
Signed-off-by Kuan-Jui Chiu <[email protected]>--- MAINTAINERS | 9 ++ hw/arm/Kconfig | 8 ++ hw/arm/ax3000-soc.c | 232 +++++++++++++++++++++++++++++++++++ hw/arm/meson.build | 3 + hw/sd/Kconfig | 4 + hw/sd/axiado_sdhci.c | 100 +++++++++++++++
Quoted 1 line
Adding the new SDHCI controller should be its own patch.
No problem, I will separate it
Quoted 34 lines
Quoted 22 lines
hw/sd/meson.build | 1 + include/hw/arm/ax3000-soc.h | 78 ++++++++++++ include/hw/sd/axiado_sdhci.h | 21 ++++ 9 files changed, 456 insertions(+)create mode 100644
hw/arm/ax3000-soc.c
create mode 100644hw/sd/axiado_sdhci.c
create mode 100644include/hw/arm/ax3000-soc.h
create mode 100644include/hw/sd/axiado_sdhci.hhw/arm/ax3000-soc.c new file +11
-0+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 ; + } +}hw/arm/ax3000-soc.c line 39
Quoted 10 lines
hw/arm/ax3000-soc.c new file +10
-0+ +static void pll_write (void *opaque,hwaddr offset,uint64_t val,unsigned size) +{ +/* TBD */ +} + +static const MemoryRegionOps pll_ops = { + .read = pll_read, + .write = pll_write, + .endianness =DEVICE_LITTLE_ENDIAN ,MemoryRegionOps should always explicitly specify a set of .impl and .valid fields to say what the
min_access_size
Quoted 8 lines
and
max_access_sizeare. (.valid is what the hardware permits; .impl is what the functions handle; the memory system core code can somewhat bridge the gap if your implementation handles a more restrictive set of sizes than the guest is allowed to use.) e.g. if the hardware is "must always be 32 bit accesses then set all of .valid.min_access_size, .valid.max_access_size, .impl.min_access_size, .impl.max_access_size to 4.
No problem, I will add fill in these parameters
Quoted 5 lines
Quoted 1 line
+};
This looks like it should be its own device in its own file, not a free-standing set of MemoryRegionOps and MemoryRegion in this file.
Quoted 9 lines
hw/arm/ax3000-soc.c line 46
Quoted 5 lines
hw/arm/ax3000-soc.c new file +5
-0+static void ax3000_init (Object *obj) +{ +Ax3000SoCState *s =AX3000_SOC (obj); +Ax3000SoCClass *sc =AX3000_SOC_GET_CLASS (s); +int i;These days we tend to favour declaring the variable inside the for loop:
for (int i = 0; ... ; ...)
No problem, I will correct them
Quoted 240 lines
Quoted 240 lines
hw/arm/ax3000-soc.c new file +186
-0+ +for (i =0 ; i < sc->num_cpus; i++) { + g_autofree char *name = g_strdup_printf("cpu%d", i); +object_initialize_child (obj, name, &s->cpu[i], +ARM_CPU_TYPE_NAME ("cortex-a53" )); + } + +object_initialize_child (obj,"gic" , &s->gic,gicv3_class_name ()); + +for (i =0 ; i <AX3000_NUM_UARTS ; i++) { + 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,"sdhci0" , &s->sdhci0,TYPE_AXIADO_SDHCI ); +} + +static void ax3000_realize (DeviceState *dev,Error **errp) +{ +Ax3000SoCState *s =AX3000_SOC (dev); +Ax3000SoCClass *sc =AX3000_SOC_GET_CLASS (s); +SysBusDevice *gic_sbd =SYS_BUS_DEVICE (&s->gic); +DeviceState *gic_dev =DEVICE (&s->gic); +QList *redist_region_count; +SysBusDevice *sdhci0_sbd; +DeviceState *card; +int i; + +/* CPUs */ +for (i =0 ; i < sc->num_cpus; i++) { +object_property_set_int (OBJECT (&s->cpu[i]),"cntfrq" ,8000000 , + &error_abort); + +if (object_property_find (OBJECT (&s->cpu[i]),"has_el3" )) { +object_property_set_bool (OBJECT (&s->cpu[i]),"has_el3" , + false, &error_abort); + } + +if (!qdev_realize (DEVICE (&s->cpu[i]),NULL , errp)) { +return ; + } + } + +/* GIC */ +qdev_prop_set_uint32 (gic_dev,"num-cpu" , sc->num_cpus); +qdev_prop_set_uint32 (gic_dev,"num-irq" , +AX3000_NUM_IRQS +GIC_INTERNAL ); + + redist_region_count =qlist_new (); +qlist_append_int (redist_region_count, sc->num_cpus); +qdev_prop_set_array (gic_dev,"redist-region-count" , redist_region_count); + +if (!sysbus_realize (gic_sbd, errp)) { +return ; + } + +sysbus_mmio_map (gic_sbd,0 ,AX3000_GIC_DIST_BASE ); +sysbus_mmio_map (gic_sbd,1 ,AX3000_GIC_REDIST_BASE ); + +/* +* Wire the outputs from each CPU's generic timer and the GICv3 +* maintenance interrupt signal to the appropriate GIC PPI inputs, and +* the GIC's IRQ/FIQ interrupt outputs to the CPU's inputs. +*/ +for (i =0 ; i < sc->num_cpus; i++) { +DeviceState *cpu_dev =DEVICE (&s->cpu[i]); +int intidbase =AX3000_NUM_IRQS + i *GIC_INTERNAL ; +qemu_irq irq; + +/* +* Mapping from the output timer irq lines from the CPU to the +* GIC PPI inputs. +*/ +static const int timer_irqs[] = { + [GTIMER_PHYS ] =ARCH_TIMER_NS_EL1_IRQ , + [GTIMER_VIRT ] =ARCH_TIMER_VIRT_IRQ , + [GTIMER_HYP ] =ARCH_TIMER_NS_EL2_IRQ , + [GTIMER_SEC ] =ARCH_TIMER_S_EL1_IRQ + }; + +for (int j =0 ; j <ARRAY_SIZE (timer_irqs); j++) { + irq =qdev_get_gpio_in (gic_dev, intidbase + timer_irqs[j]); +qdev_connect_gpio_out (cpu_dev, j, irq); + } + + irq =qdev_get_gpio_in (gic_dev, intidbase +ARCH_GIC_MAINT_IRQ ); +qdev_connect_gpio_out_named (cpu_dev,"gicv3-maintenance-interrupt" , +0 , irq); + +sysbus_connect_irq (gic_sbd, i, +qdev_get_gpio_in (cpu_dev,ARM_CPU_IRQ )); +sysbus_connect_irq (gic_sbd, i + sc->num_cpus, +qdev_get_gpio_in (cpu_dev,ARM_CPU_FIQ )); +sysbus_connect_irq (gic_sbd, i +2 * sc->num_cpus, +qdev_get_gpio_in (cpu_dev,ARM_CPU_VIRQ )); +sysbus_connect_irq (gic_sbd, i +3 * sc->num_cpus, +qdev_get_gpio_in (cpu_dev,ARM_CPU_VFIQ )); + } + +/* DRAM */ +for (i =0 ; i <AX3000_NUM_BANKS ; i++) { +struct { +hwaddr addr; +size_t size; +const char *name; + } dram_table[] = { + {AX3000_DRAM0_BASE ,AX3000_DRAM0_SIZE ,"dram0" }, + {AX3000_DRAM1_BASE ,AX3000_DRAM1_SIZE ,"dram1" } + }; + +memory_region_init_ram (&s->dram[i],OBJECT (s), dram_table[i].name, + dram_table[i].size, &error_fatal); +memory_region_add_subregion (get_system_memory (), dram_table[i].addr, + &s->dram[i]); + } + +/* UARTs */ +for (i =0 ; i <AX3000_NUM_UARTS ; i++) { +struct { +hwaddr addr; +unsigned int irq; + } serial_table[] = { + {AX3000_UART0_BASE ,AX3000_UART0_IRQ }, + {AX3000_UART1_BASE ,AX3000_UART1_IRQ }, + {AX3000_UART2_BASE ,AX3000_UART2_IRQ }, + {AX3000_UART3_BASE ,AX3000_UART3_IRQ } + }; + +qdev_prop_set_chr (DEVICE (&s->uart[i]),"chardev" ,serial_hd (i)); +if (!sysbus_realize (SYS_BUS_DEVICE (&s->uart[i]), errp)) { +return ; + } + +sysbus_mmio_map (SYS_BUS_DEVICE (&s->uart[i]),0 , serial_table[i].addr); +sysbus_connect_irq (SYS_BUS_DEVICE (&s->uart[i]),0 , +qdev_get_gpio_in (gic_dev, serial_table[i].irq)); + } + +/* Timer control */ +create_unimplemented_device ("ax3000.timerctrl" ,AX3000_TIMER_CTRL ,32 ); + +/* PLL control */ +memory_region_init_io (&s->pll_ctrl,OBJECT (s), &pll_ops, s, +"ax3000.pllctrl" ,32 ); +memory_region_add_subregion (get_system_memory (),AX3000_PLL_BASE , + &s->pll_ctrl); + +/* 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) +{ +DeviceClass *dc =DEVICE_CLASS (oc); +Ax3000SoCClass *sc =AX3000_SOC_CLASS (oc); + + dc->desc ="Axiado SoC AX3000" ; + dc->realize = ax3000_realize; + sc->num_cpus =AX3000_NUM_CPUS ; +} + +static const TypeInfo axiado_soc_types[] = { + { + .name =TYPE_AX3000_SOC , + .parent =TYPE_SYS_BUS_DEVICE , + .instance_size =sizeof (Ax3000SoCState), + .instance_init = ax3000_init, + .class_init = ax3000_class_init, + } +}; + +DEFINE_TYPES (axiado_soc_types)hw/arm/meson.build +3
-0@@ -105,6 +105,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_arch += {'arm': arm_ss}hw/sd/Kconfig +4
-0@@ -23,3 +23,7 @@ config SDHCI_PCI config CADENCE_SDHCI bool select SDHCI + +config AXIADO_SDHCI + bool + select SDHCIhw/sd/axiado_sdhci.c new file +22
-0@@ -0,0 +1,100 @@ +/* +* Axiado SD Host Controller +* +* 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 + +static uint64_t emmc_phy_read (void *opaque,hwaddr offset,unsigned size) +{ +uint32_t val =0x00 ; + +switch (offset) {
Quoted 8 lines
hw/sd/axiado_sdhci.c line 28
Quoted 6 lines
hw/sd/axiado_sdhci.c new file +6
-0+case EMMC_PHY_ID : + val =0x3dff6870 ; +break ; +case EMMC_PHY_STATUS : +/* Make DLL_RDY | CAL_DONE */ + val = (1u <<0 ) | (1u <<6 );If this comment is trying to say what these bits are, better to define symbolic constants for the bits and use those.
No problem, I will define these two bits as macro
Quoted 9 lines
Quoted 9 lines
hw/sd/axiado_sdhci.c new file +9
-0+break ; +default : +break ; + } + +return val; +} + +static void emmc_phy_write(void *opaque, hwaddr offset, uint64_t value,
Quoted 8 lines
hw/sd/axiado_sdhci.c line 40
Quoted 3 lines
hw/sd/axiado_sdhci.c new file +3
-0+ unsigned size) +{ +/* TBD */ Don't leave bare TBD/TODO comments in the code. It's OK not to necessarily implement everything at the start, but the comment should explain what is missing. In six months time, will somebody other than you be able to look at the file and know what is still to do ?
Understood.
Currently I don't have idea to implement this write function, I will keep it empty.
Quoted 7 lines
hw/sd/axiado_sdhci.c line 46
Quoted 6 lines
hw/sd/axiado_sdhci.c new file +6
-0+} + +static const MemoryRegionOps emmc_phy_ops = { + .read = emmc_phy_read, + .write = emmc_phy_write, + .endianness =DEVICE_LITTLE_ENDIAN ,This should specify access sizes too.
No problem, I will add fill in these parameters
Quoted 6 lines
Quoted 6 lines
hw/sd/axiado_sdhci.c new file +6
-0+}; + +static void axiado_sdhci_realize (DeviceState *dev,Error **errp) +{ +AxiadoSDHCIState *s =AXIADO_SDHCI (dev); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev);
Quoted 8 lines
hw/sd/axiado_sdhci.c line 56
Quoted 4 lines
hw/sd/axiado_sdhci.c new file +4
-0+SysBusDevice *sdhci_sbd; + +object_initialize_child (OBJECT (s),"sdhci" , &s->sdhci, +TYPE_SYSBUS_SDHCI );Generally devices should do the
object_initialize_childfor child-objects in theirinstance_initfunction, and realize in their realize function. (Occasionally there's a reason this isn't possible.)
Sure, I will move it to instance_init()
Quoted 46 lines
Quoted 34 lines
hw/sd/axiado_sdhci.c new file +34
-0+ +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); +sysbus_realize (sdhci_sbd, errp); +if (*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" ); + +/* 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_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" ; +} + +static const TypeInfo axiado_sdhci_info = { + .name =TYPE_AXIADO_SDHCI , + .parent =TYPE_SYS_BUS_DEVICE ,hw/sd/axiado_sdhci.c line 100
Quoted 10 lines
hw/sd/axiado_sdhci.c new file +10
-0+ .instance_size = sizeof(AxiadoSDHCIState), + .class_init = axiado_sdhci_class_init, +}; + +static void axiado_sdhci_register_types (void ) +{ +type_register_static (&axiado_sdhci_info); +} + +type_init (axiado_sdhci_register_types);thanks
-- PMM
PATCH v2 2/4 hw/arm: Add Axiado EVK SCM3003
In reply to Kuan-Jui ChiuAdd EVK axiado-scm3003 built with AX3000 SoC
--- hw/arm/Kconfig | 5 ++++ hw/arm/ax3000-boards.c | 52 ++++++++++++++++++++++++++++++++++ hw/arm/ax3000-evk.c | 27 ++++++++++++++++++ hw/arm/meson.build | 3 ++ include/hw/arm/ax3000-boards.h | 28 ++++++++++++++++++ 5 files changed, 115 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
@@ -699,3 +699,8 @@ config AXIADO_SOC select CADENCE # UART select AXIADO_SDHCI select UNIMP + +config AXIADO_EVK + bool + default y + select AXIADO_SOC
hw/arm/ax3000-boards.c new file +52 -0
52 lines not on this page · raw message
hw/arm/ax3000-evk.c new file +27 -0
@@ -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
@@ -107,6 +107,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
@@ -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
Re: [PATCH v2 2/4] hw/arm: Add Axiado EVK SCM3003
Quoted 41 lines · Kuan-Jui Chiu
Add EVK axiado-scm3003 built with AX3000 SoC
Signed-off-by Kuan-Jui Chiu <[email protected]>--- hw/arm/Kconfig | 5 ++++ hw/arm/ax3000-boards.c | 52 ++++++++++++++++++++++++++++++++++ hw/arm/ax3000-evk.c | 27 ++++++++++++++++++ hw/arm/meson.build | 3 ++ include/hw/arm/ax3000-boards.h | 28 ++++++++++++++++++ 5 files changed, 115 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.hhw/arm/Kconfig +5
-0@@ -699,3 +699,8 @@ config AXIADO_SOC select CADENCE # UART select AXIADO_SDHCI select UNIMP + +config AXIADO_EVK + bool + default y + select AXIADO_SOChw/arm/ax3000-boards.c new file +7
-0@@ -0,0 +1,52 @@ +/* +* Axiado Boards +* +* Author: Kuan-Jui Chiu <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/
hw/arm/ax3000-boards.c line 17
Quoted 10 lines
hw/arm/ax3000-boards.c new file +10
-0+ +#include "qemu/osdep.h" +#include "hw/arm/ax3000-boards.h" +#include "hw/arm/machines-qom.h" +#include "qemu/error-report.h" +#include "qom/object.h" + +static const char *ax3000_machine_get_default_cpu_type (const MachineState *ms) +{ +return ARM_CPU_TYPE_NAME ("cortex-a53" );
There's no point in having a function just for this; you can use
mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a35");
without the indirection.
hw/arm/ax3000-boards.c line 26
Quoted 9 lines
hw/arm/ax3000-boards.c new file +9
-0+} + +static void ax3000_machine_init (MachineState *machine) +{ +Ax3000MachineState *ams =AX3000_MACHINE (machine); + + ams->soc =AX3000_SOC (object_new (TYPE_AX3000_SOC )); +object_property_add_child (OBJECT (machine),"soc" ,OBJECT (ams->soc)); +sysbus_realize_and_unref (SYS_BUS_DEVICE (ams->soc), &error_fatal);
The machine init function for an Arm board always needs to end by calling arm_load_kernel(). As well as implementing the handling for the -kernel "load this kernel/image file" option, it also sets up some things like getting CPU reset to work correctly.
Quoted 13 lines
hw/arm/ax3000-boards.c new file +13
-0+} + +static void ax3000_machine_class_init (ObjectClass *oc,const void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + + mc->init = ax3000_machine_init; + mc->default_cpus =AX3000_NUM_CPUS ; + mc->min_cpus =AX3000_NUM_CPUS ; + mc->max_cpus =AX3000_NUM_CPUS ; + mc->get_default_cpu_type = ax3000_machine_get_default_cpu_type; +} +
hw/arm/ax3000-boards.c line 49
Quoted 10 lines
hw/arm/ax3000-boards.c new file +10
-0+static const TypeInfo ax3000_machine_types[] = { + { + .name =TYPE_AX3000_MACHINE , + .parent =TYPE_MACHINE , + .instance_size =sizeof (Ax3000MachineState), + .class_size =sizeof (Ax3000MachineClass), + .class_init = ax3000_machine_class_init, + .interfaces = aarch64_machine_interfaces, + .abstract = true, + }
Do you really expect to have a lot of boards which are all different subclasses of AX3000? Unless you really need this, better to do the simple thing and implement the MACHINE_TYPE_NAME("axiado-scm3003") without the extra layer of class structure which is doing nothing at all.
thanks
-- PMM
Re: [PATCH v2 2/4] hw/arm: Add Axiado EVK SCM3003
Peter Maydell 於 2026/5/26 下午 10:12 寫道:
Quoted 49 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 45 lines · Kuan-Jui Chiu
Add EVK axiado-scm3003 built with AX3000 SoC
Signed-off-by Kuan-Jui Chiu <[email protected]>--- hw/arm/Kconfig | 5 ++++ hw/arm/ax3000-boards.c | 52 ++++++++++++++++++++++++++++++++++ hw/arm/ax3000-evk.c | 27 ++++++++++++++++++ hw/arm/meson.build | 3 ++ include/hw/arm/ax3000-boards.h | 28 ++++++++++++++++++ 5 files changed, 115 insertions(+)create mode 100644
hw/arm/ax3000-boards.ccreate mode 100644hw/arm/ax3000-evk.ccreate mode 100644include/hw/arm/ax3000-boards.hhw/arm/Kconfig +5
-0@@ -699,3 +699,8 @@ config AXIADO_SOC select CADENCE # UART select AXIADO_SDHCI select UNIMP + +config AXIADO_EVK + bool + default y + select AXIADO_SOChw/arm/ax3000-boards.c new file +12
-0@@ -0,0 +1,52 @@ +/* +* Axiado Boards +* +* Author: Kuan-Jui Chiu <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#include "qemu/osdep.h" +#include "hw/arm/ax3000-boards.h" +#include "hw/arm/machines-qom.h" +#include "qemu/error-report.h"
Quoted 8 lines
hw/arm/ax3000-boards.c line 17
Quoted 5 lines
hw/arm/ax3000-boards.c new file +5
-0+#include "qom/object.h" + +static const char *ax3000_machine_get_default_cpu_type (const MachineState *ms) +{ +return ARM_CPU_TYPE_NAME ("cortex-a53" );There's no point in having a function just for this; you can use
mc->default_cpu_type=ARM_CPU_TYPE_NAME("cortex-a35");
without the indirection.
Understood.
I will remove this function and assign directly
Quoted 5 lines
Quoted 5 lines
hw/arm/ax3000-boards.c new file +5
-0+} + +static void ax3000_machine_init (MachineState *machine) +{ +Ax3000MachineState *ams =AX3000_MACHINE (machine);
Quoted 8 lines
hw/arm/ax3000-boards.c line 26
Quoted 4 lines
hw/arm/ax3000-boards.c new file +4
-0+ + ams->soc =AX3000_SOC (object_new (TYPE_AX3000_SOC )); +object_property_add_child (OBJECT (machine),"soc" ,OBJECT (ams->soc)); +sysbus_realize_and_unref (SYS_BUS_DEVICE (ams->soc), &error_fatal);The machine init function for an Arm board always needs to end by calling
arm_load_kernel(). As well as implementing the handling for the -kernel "load this kernel/image file" option, it also sets up some things like getting CPU reset to work correctly.
For ax3000 SoC, we assumed that the kernel image,which is stored in an eMMC device, would be loaded into a specific DDR address by u-boot then start booting
So I do not expect that user should use "-kernel" argument to pass the kernel image to QEMU for AX3000 SoC This is what the command I used to launch axiado-scm3003 machine in QEMU
./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
Quoted 20 lines
Quoted 20 lines
hw/arm/ax3000-boards.c new file +20
-0+} + +static void ax3000_machine_class_init (ObjectClass *oc,const void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + + mc->init = ax3000_machine_init; + mc->default_cpus =AX3000_NUM_CPUS ; + mc->min_cpus =AX3000_NUM_CPUS ; + mc->max_cpus =AX3000_NUM_CPUS ; + mc->get_default_cpu_type = ax3000_machine_get_default_cpu_type; +} + +static const TypeInfo ax3000_machine_types[] = { + { + .name =TYPE_AX3000_MACHINE , + .parent =TYPE_MACHINE , + .instance_size =sizeof (Ax3000MachineState), + .class_size =sizeof (Ax3000MachineClass), + .class_init = ax3000_machine_class_init,
Quoted 8 lines
hw/arm/ax3000-boards.c line 49
Quoted 3 lines
hw/arm/ax3000-boards.c new file +3
-0+ .interfaces = aarch64_machine_interfaces, + .abstract = true, + }Do you really expect to have a lot of boards which are all different subclasses of AX3000? Unless you really need this, better to do the simple thing and implement the
MACHINE_TYPE_NAME("axiado-scm3003")without the extra layer of class structure which is doing nothing at all.
I will introduce another machine "axiado-scm3002" in future for sensors implementation
Both of scm3002 and scm3003 are built with AX3000 SoC and they are the different EVK boards
Quoted 2 lines
thanks
-- PMM
PATCH v2 3/4 hw/gpio: Add Cadence GPIO controller
In reply to Kuan-Jui ChiuThis 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 | 301 +++++++++++++++++++++++++++++++++ hw/gpio/meson.build | 1 + hw/gpio/trace-events | 5 + include/hw/gpio/cadence_gpio.h | 55 ++++++ 5 files changed, 365 insertions(+) create mode 100644 hw/gpio/cadence_gpio.c create mode 100644 include/hw/gpio/cadence_gpio.h
hw/gpio/Kconfig +3 -0
@@ -30,3 +30,6 @@ config PCF8574 config ZAURUS_SCOOP bool + +config CADENCE_GPIO + bool
hw/gpio/cadence_gpio.c new file +301 -0
301 lines not on this page · raw message
hw/gpio/meson.build +1 -0
@@ -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
@@ -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
Re: [PATCH v2 3/4] hw/gpio: Add Cadence GPIO controller
Quoted 36 lines · 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.
Signed-off-by Kuan-Jui Chiu <[email protected]>--- hw/gpio/Kconfig | 3 + hw/gpio/cadence_gpio.c | 301 +++++++++++++++++++++++++++++++++ hw/gpio/meson.build | 1 + hw/gpio/trace-events | 5 + include/hw/gpio/cadence_gpio.h | 55 ++++++ 5 files changed, 365 insertions(+) create mode 100644 hw/gpio/cadence_gpio.c create mode 100644 include/hw/gpio/cadence_gpio.hhw/gpio/Kconfig +3
-0@@ -30,3 +30,6 @@ config PCF8574 config ZAURUS_SCOOP bool + +config CADENCE_GPIO + boolhw/gpio/cadence_gpio.c new file +0
-0
hw/gpio/cadence_gpio.c line 6
Quoted 6 lines
hw/gpio/cadence_gpio.c new file +6
-0@@ -0,0 +1,301 @@ +/* +* Cadence GPIO emulation. +* +* Author: Kuan-Jui Chiu <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later
Is there an available data sheet for this device?
What is the actual device model name? "Cadence GPIO" is extremely vague...
thanks
-- PMM
Re: [PATCH v2 3/4] hw/gpio: Add Cadence GPIO controller
Peter Maydell 於 2026/5/26 下午 10:18 寫道:
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 35 lines · 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.
Signed-off-by Kuan-Jui Chiu <[email protected]>--- hw/gpio/Kconfig | 3 + hw/gpio/cadence_gpio.c | 301 +++++++++++++++++++++++++++++++++ hw/gpio/meson.build | 1 + hw/gpio/trace-events | 5 + include/hw/gpio/cadence_gpio.h | 55 ++++++ 5 files changed, 365 insertions(+)create mode 100644
hw/gpio/cadence_gpio.ccreate mode 100644include/hw/gpio/cadence_gpio.hhw/gpio/Kconfig +3
-0@@ -30,3 +30,6 @@ config PCF8574 config ZAURUS_SCOOP bool + +config CADENCE_GPIO + boolhw/gpio/cadence_gpio.c new file +0
-0hw/gpio/cadence_gpio.c line 6
Quoted 6 lines
hw/gpio/cadence_gpio.c new file +6
-0@@ -0,0 +1,301 @@ +/* +* Cadence GPIO emulation. +* +* Author: Kuan-Jui Chiu <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later Is there an available data sheet for this device?
Quoted 2 lines
What is the actual device model name? "Cadence GPIO" is extremely vague...
Axiado SoC is using Cadence IP for GPIO controller
I am afraid of that I can't share the data sheet publicly
Here is the link to Cadence official website
Artisan Foundation and Mixed‑Signal IP | Cadence <https://www.cadence.com/en_US/home/tools/silicon-solutions/artisan-ip.html#gpio>
Quoted 2 lines
thanks
-- PMM
PATCH v2 4/4 hw/arm: ax3000-soc: Enable Cadence GPIO controllers
In reply to Kuan-Jui ChiuEnable 8 Cadence GPIO controllers into Axiado AX3000 SoC
--- hw/arm/Kconfig | 1 + hw/arm/ax3000-soc.c | 30 ++++++++++++++++++++++++++++++ include/hw/arm/ax3000-soc.h | 23 ++++++++++++++++++++++- 3 files changed, 53 insertions(+), 1 deletion(-)
hw/arm/Kconfig +1 -0
@@ -697,6 +697,7 @@ config AXIADO_SOC depends on ARM select ARM_GIC select CADENCE # UART + select CADENCE_GPIO select AXIADO_SDHCI select UNIMP
hw/arm/ax3000-soc.c +30 -0
@@ -59,6 +59,11 @@ static void ax3000_init(Object *obj) }object_initialize_child (obj,"sdhci0" , &s->sdhci0,TYPE_AXIADO_SDHCI ); + +for (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)
@@ -207,6 +212,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 (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 +22 -1
@@ -12,6 +12,7 @@#include "cpu.h" #include "hw/intc/arm_gicv3_common.h" #include "hw/char/cadence_uart.h" +#include "hw/gpio/cadence_gpio.h" #include "hw/sd/axiado_sdhci.h" #include "hw/core/sysbus.h" #include "qemu/units.h"
@@ -37,6 +38,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#define CLKRST_CPU_PLL_POSTDIV_OFFSET 0x0C
@@ -47,6 +57,7 @@ enum Ax3000Configuration {AX3000_NUM_IRQS =224 ,AX3000_NUM_BANKS =2 ,AX3000_NUM_UARTS =4 , + AX3000_NUM_GPIOS = 8, }; typedef struct Ax3000SoCState {
@@ -57,6 +68,7 @@ typedef struct Ax3000SoCState {MemoryRegion dram[AX3000_NUM_BANKS ];MemoryRegion pll_ctrl;CadenceUARTState uart[AX3000_NUM_UARTS ]; +CadenceGPIOState gpio[AX3000_NUM_GPIOS ];AxiadoSDHCIState sdhci0; } Ax3000SoCState;
@@ -72,7 +84,16 @@ enum Ax3000Irqs {AX3000_UART2_IRQ =114 ,AX3000_UART3_IRQ =170 , - AX3000_SDHCI0_IRQ = 123, +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
Re: [PATCH v2 4/4] hw/arm: ax3000-soc: Enable Cadence GPIO controllers
Quoted 4 lines · Kuan-Jui Chiu
Enable 8 Cadence GPIO controllers into Axiado AX3000 SoC
Signed-off-by Kuan-Jui Chiu <[email protected]>
thanks
-- PMM
Ping
Please review this patch
[v2] Add Axiado SoC AX3000 and EVK board | Patchew<https://patchew.org/QEMU/[email protected]/>
________________________________
寄件者: Kuan-Jui Chiu <[email protected]>
寄件日期: 2026年4月30日 下午 05:18
收件者: [email protected] <[email protected]>
副本: Kuan-Jui Chiu <[email protected]>
主旨: [PATCH v2 0/4] 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-github.wic,format=rawRefer Axiado website for more product information
https://axiado.com/products/
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 (4):
hw/arm: Add Axiado SoC AX3000
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 | 14 ++ hw/arm/ax3000-boards.c | 52 ++++++ hw/arm/ax3000-evk.c | 27 +++ hw/arm/ax3000-soc.c | 262 +++++++++++++++++++++++++++ hw/arm/meson.build | 6 + hw/gpio/Kconfig | 3 + hw/gpio/cadence_gpio.c | 312 +++++++++++++++++++++++++++++++++ hw/gpio/meson.build | 1 + hw/gpio/trace-events | 5 + hw/sd/Kconfig | 4 + hw/sd/axiado_sdhci.c | 100 +++++++++++ hw/sd/meson.build | 1 + include/hw/arm/ax3000-boards.h | 28 +++ include/hw/arm/ax3000-soc.h | 99 +++++++++++ include/hw/gpio/cadence_gpio.h | 66 +++++++ include/hw/sd/axiado_sdhci.h | 21 +++ 17 files changed, 1010 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/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/sd/axiado_sdhci.h
--
2.34.1