hw/arm: Add Phytium E2000Q SoC and board support
cover hw/arm: Add Phytium E2000Q SoC and board support
The Phytium E2000Q is a heterogeneous Armv8 SoC with two FTC664 cores and two FTC310 cores. This series adds CPU definitions and a shared SoC model, then uses it for two machines:
- phytium-pi, with firmware and Linux on SD0
- phytium-e2000-come, with firmware in QSPI NOR and Linux on an AHCI1 SATA disk
The machines support the vendor firmware path from the on-chip Phytium Boot ROM (PBR) handoff through Processor Base Firmware (PBF), TF-A, OP-TEE, U-Boot, and Linux. They can also directly boot SDK Linux kernels when supplied with matching board device trees.
The PBR model does not execute undocumented ROM code. It parses the selected fip-all.bin, validates the PBF, TF-A FIP, and platform parameter records, and reconstructs the observed handoff state. The MHU model handles the private SCMI power-domain requests needed to release secondary CPUs and exposes a separate Base-protocol channel to Linux.
The shared E2000Q machine provides GICv3/ITS, UARTs, GPEX PCIe, SMMUv3, four Cadence GEM controllers, two DesignWare-derived MCI controllers, QSPI, I2C, xHCI, AHCI, a random generator, and the firmware-facing DDR and control regions. Unimplemented register windows remain visible to firmware without claiming unsupported behavior.
Functional tests exercise both firmware and direct Linux boot on the Phytium Pi with an SDK Buildroot image. Manual testing covers Phytium Pi SD boot, COMe QSPI-to-SATA boot, all four CPUs, and network access.
Known limitations are documented. In particular, the PBR handoff is a behavioral model validated against the available SDK firmware samples.
Bin Meng (33):
target/arm: Add Phytium FTC310 and FTC664 CPU models hw/arm: Add basic Phytium Pi machine
hw/arm: phytium: Add Phytium E2000 PCIe host
hw/sd: Add Synopsys DesignWare MCI controller
hw/sd: Add Phytium E2000 MCI controller
hw/arm: phytium: Connect Phytium E2000 MCI controllers tests/qtest: Add Synopsys DesignWare MCI coverage hw/arm: phytium: Connect Phytium E2000 GEM controllers hw/misc: Add Phytium E2000 DDR status
hw/arm: phytium: Connect the Phytium E2000 DDR status hw/misc: Add Phytium E2000 MHU doorbell
hw/arm: phytium: Connect the Phytium E2000 MHU hw/ssi: Add Phytium E2000 QSPI controller
hw/arm: phytium: Connect the Phytium E2000 QSPI controller hw/misc: Add Phytium E2000 PBR model
hw/arm: phytium: Integrate the Phytium E2000 PBR hw/arm: phytium: Add Phytium E2000 control region placeholders hw/misc: Support Phytium E2000 SCMI CPU power control hw/arm: phytium: Select the Phytium E2000 PBR boot medium hw/arm: phytium: Connect the Phytium E2000 I2C controller hw/arm: phytium: Add Phytium E2000 xHCI controllers hw/misc: Model the Phytium E2000 random generator hw/arm: phytium: Connect the Phytium E2000 random generator hw/arm: phytium: Support Phytium E2000 direct Linux boot hw/arm: phytium: Add Phytium E2000Q COMe machine hw/block: m25p80: Add GigaDevice GD25Q128 flash hw/arm: phytium: Connect the Phytium E2000Q COMe QSPI flash hw/arm: phytium: Add Phytium E2000 AHCI controllers hw/arm: Add Phytium E2000 Linux SCMI channel
hw/arm: phytium: Connect the Phytium E2000 SMMUv3 docs/system/arm: Document Phytium E2000 machines tests/functional/aarch64: Add Phytium Pi boot tests
MAINTAINERS: Add Phytium E2000Q machines
MAINTAINERS | 17 + docs/system/arm/phytium_e2000.rst | 412 ++++++ docs/system/target-arm.rst | 1 + hw/arm/Kconfig | 22 + hw/arm/meson.build | 1 + hw/arm/phytium_e2000.c | 1181 ++++++++++++++++ hw/block/m25p80.c | 1 + hw/misc/meson.build | 4 + hw/misc/phytium_e2000_ddr.c | 197 +++ hw/misc/phytium_e2000_mhu.c | 818 +++++++++++ hw/misc/phytium_e2000_pbr.c | 1366 ++++++++++++++++++ hw/misc/phytium_e2000_rng.c | 182 +++ hw/sd/Kconfig | 5 + hw/sd/dw_mci.c | 1382 +++++++++++++++++++ hw/sd/meson.build | 2 + hw/sd/phytium_e2000_mci.c | 95 ++ hw/ssi/Kconfig | 5 + hw/ssi/meson.build | 1 + hw/ssi/phytium_qspi.c | 398 ++++++ include/hw/misc/phytium_e2000_ddr.h | 23 + include/hw/misc/phytium_e2000_mhu.h | 34 + include/hw/misc/phytium_e2000_pbr.h | 62 + include/hw/misc/phytium_e2000_rng.h | 23 + include/hw/sd/dw_mci.h | 74 + include/hw/sd/phytium_e2000_mci.h | 21 + include/hw/ssi/phytium_qspi.h | 23 + target/arm/tcg/cpu64.c | 81 ++ tests/functional/aarch64/meson.build | 2 + tests/functional/aarch64/test_phytium_pi.py | 77 ++ tests/qtest/dw_mci-test.c | 417 ++++++ tests/qtest/meson.build | 1 + 31 files changed, 6928 insertions(+) create mode 100644 docs/system/arm/phytium_e2000.rst create mode 100644 hw/arm/phytium_e2000.c create mode 100644 hw/misc/phytium_e2000_ddr.c create mode 100644 hw/misc/phytium_e2000_mhu.c create mode 100644 hw/misc/phytium_e2000_pbr.c create mode 100644 hw/misc/phytium_e2000_rng.c create mode 100644 hw/sd/dw_mci.c create mode 100644 hw/sd/phytium_e2000_mci.c create mode 100644 hw/ssi/phytium_qspi.c create mode 100644 include/hw/misc/phytium_e2000_ddr.h create mode 100644 include/hw/misc/phytium_e2000_mhu.h create mode 100644 include/hw/misc/phytium_e2000_pbr.h create mode 100644 include/hw/misc/phytium_e2000_rng.h create mode 100644 include/hw/sd/dw_mci.h create mode 100644 include/hw/sd/phytium_e2000_mci.h create mode 100644 include/hw/ssi/phytium_qspi.h create mode 100644 tests/functional/aarch64/test_phytium_pi.py create mode 100644 tests/qtest/dw_mci-test.c
---
base-commit: 61d82640e03f5fdbeb70c455e2b3cbff539600ec
branch: phytium
Signature · 1 line
2.53.0
PATCH 1/33 target/arm: Add Phytium FTC310 and FTC664 CPU models
The Phytium E2000Q combines two FTC310 cores and two FTC664 cores. Its EL3 firmware accesses implementation-defined system registers while setting up the cores. Using generic Cortex-A72 CPUs leaves these registers undefined and traps firmware before it can reach U-Boot.
Add FTC310 and FTC664 CPU types using Cortex-A72 as their common execution base. Provide conservative RAZ/WI and NOP stubs for the firmware-visible E2000 controls that have no modeled behavior.
Set each CPU DT compatible string, MIDR, instruction feature fields, AArch32 floating-point feature fields, and CTR_EL0.L1Ip field to values observed on an E2000Q board. The FTC310 reports a VIPT instruction cache, while the FTC664 reports a PIPT instruction cache.
---
target/arm/tcg/cpu64.c | 81 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+)
target/arm/tcg/cpu64.c +81 -0
@@ -336,6 +336,85 @@ static void aarch64_a72_initfn(Object *obj)define_cortex_a72_a57_a53_cp_reginfo (cpu); } +static const ARMCPRegInfo phytium_e2000_cp_reginfo[] = { +/* +* The E2000 EL3 firmware touches implementation-defined CPU registers +* during the PBF/BL1 cache and core setup. QEMU does not model these +* controls, so expose conservative RAZ/WI stubs for the boot firmware. +* +* PBF reads these identification and cluster controls after writing +* them. Returning zero preserves the reset state without claiming that +* QEMU implements the associated cache or coherency controls. +*/ + { .name ="E2000_CPUID_CTL1" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =1 , .crn =15 , .crm =1 , .opc2 =0 , + .access =PL1_RW , .type =ARM_CP_CONST |ARM_CP_NO_RAW , + .resetvalue =0 }, + { .name ="E2000_CLUSTER_CTL" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =1 , .crn =11 , .crm =8 , .opc2 =6 , + .access =PL1_RW , .type =ARM_CP_CONST |ARM_CP_NO_RAW , + .resetvalue =0 }, +/* +* The remaining controls are only programmed as part of firmware setup. +* Accept the writes without retaining state because no modeled CPU +* behavior depends on their values. +*/ + { .name ="E2000_EL1_CTL" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =2 , .crn =15 , .crm =15 , .opc2 =0 , + .access =PL1_RW , .type =ARM_CP_NOP |ARM_CP_NO_RAW }, + { .name ="E2000_EL2_CTL" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =4 , .crn =15 , .crm =15 , .opc2 =0 , + .access =PL2_RW , .type =ARM_CP_NOP |ARM_CP_NO_RAW }, + { .name ="E2000_EL2_CTL2" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =4 , .crn =15 , .crm =2 , .opc2 =4 , + .access =PL2_RW , .type =ARM_CP_NOP |ARM_CP_NO_RAW }, + { .name ="E2000_EL3_CTL" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =6 , .crn =15 , .crm =15 , .opc2 =0 , + .access =PL3_RW , .type =ARM_CP_NOP |ARM_CP_NO_RAW }, +}; + +/* +* Use the Cortex-A72 execution model as the common E2000 TCG base, then +* replace the architected identity fields that differ between the two +* physical core types. +*/ +static void aarch64_phytium_e2000_base_initfn (Object *obj) +{ +ARMCPU *cpu =ARM_CPU (obj); + +aarch64_a72_initfn (obj); +define_arm_cp_regs (cpu, phytium_e2000_cp_reginfo); +} + +static void aarch64_phytium_ftc310_initfn (Object *obj) +{ +ARMCPU *cpu =ARM_CPU (obj); +ARMISARegisters *isar = &cpu->isar; + +aarch64_phytium_e2000_base_initfn (obj); + +/* FTC310 cores identify with the FTC303 part number */ + cpu->dtb_compatible ="phytium,ftc310" ; + cpu->midr =0x700f3034 ; +SET_IDREG (isar,ID_AA64ISAR0 ,0x00011100012120 ); + cpu->isar.mvfr0 =0x10110222 ; + cpu->ctr =FIELD_DP64 (cpu->ctr,CTR_EL0 ,L1IP ,2 );/* VIPT */ +} + +static void aarch64_phytium_ftc664_initfn (Object *obj) +{ +ARMCPU *cpu =ARM_CPU (obj); +ARMISARegisters *isar = &cpu->isar; + +aarch64_phytium_e2000_base_initfn (obj); + + cpu->dtb_compatible ="phytium,ftc664" ; + cpu->midr =0x701f6643 ; +SET_IDREG (isar,ID_AA64ISAR0 ,0x00000100012120 ); + cpu->isar.mvfr0 =0x10111222 ; + cpu->ctr =FIELD_DP64 (cpu->ctr,CTR_EL0 ,L1IP ,3 );/* PIPT */ +} +static void aarch64_a76_initfn (Object *obj) {ARMCPU *cpu =ARM_CPU (obj);
@@ -1533,6 +1612,8 @@ static const ARMCPUInfo aarch64_cpus[] = { { .name = "cortex-a55", .initfn = aarch64_a55_initfn }, { .name = "cortex-a72", .initfn = aarch64_a72_initfn }, { .name = "cortex-a76", .initfn = aarch64_a76_initfn }, + { .name = "phytium-ftc310", .initfn = aarch64_phytium_ftc310_initfn }, + { .name = "phytium-ftc664", .initfn = aarch64_phytium_ftc664_initfn },/* * The Cortex-A78AE differs slightly from the plain Cortex-A78. We don't * currently model the latter.
Signature · 1 line
2.53.0
Re: [PATCH 01/33] target/arm: Add Phytium FTC310 and FTC664 CPU models
Quoted 15 lines · Bin Meng
The Phytium E2000Q combines two FTC310 cores and two FTC664 cores. Its EL3 firmware accesses implementation-defined system registers while setting up the cores. Using generic Cortex-A72 CPUs leaves these registers undefined and traps firmware before it can reach U-Boot.
Add FTC310 and FTC664 CPU types using Cortex-A72 as their common execution base. Provide conservative RAZ/WI and NOP stubs for the firmware-visible E2000 controls that have no modeled behavior.
Set each CPU DT compatible string, MIDR, instruction feature fields, AArch32 floating-point feature fields, and CTR_EL0.L1Ip field to values observed on an E2000Q board. The FTC310 reports a VIPT instruction cache, while the FTC664 reports a PIPT instruction cache.
Quoted 5 lines
Signed-off-by Bin Meng <[email protected]>---
target/arm/tcg/cpu64.c | 81++++++++++++++++++++++++++++++++++++++++++
I wonder if cpu64 is the best place to model this? The alternative is to treat it like other SoCs (e.g. the Pi's BCM SoCs). Was the reason it ended up here because you needed access to aarch64_a72_initfn? Could you not instantiate:
soc_base->cpu_type = ARM_CPU_TYPE_NAME("cortex-a72");and then at realize:
object_initialize_child(OBJECT(dev), "cpu[*]", &s->cpu[n].core,
soc_base->cpu_type);or does that not allow for tweaking the CP regs?
Quoted 101 lines
1 file changed, 81 insertions(+)target/arm/tcg/cpu64.c +81
-0@@ -336,6 +336,85 @@ static void aarch64_a72_initfn(Object *obj)define_cortex_a72_a57_a53_cp_reginfo (cpu); } +static const ARMCPRegInfo phytium_e2000_cp_reginfo[] = { +/* +* The E2000 EL3 firmware touches implementation-defined CPU registers +* during the PBF/BL1 cache and core setup. QEMU does not model these +* controls, so expose conservative RAZ/WI stubs for the boot firmware. +* +* PBF reads these identification and cluster controls after writing +* them. Returning zero preserves the reset state without claiming that +* QEMU implements the associated cache or coherency controls. +*/ + { .name ="E2000_CPUID_CTL1" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =1 , .crn =15 , .crm =1 , .opc2 =0 , + .access =PL1_RW , .type =ARM_CP_CONST |ARM_CP_NO_RAW , + .resetvalue =0 }, + { .name ="E2000_CLUSTER_CTL" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =1 , .crn =11 , .crm =8 , .opc2 =6 , + .access =PL1_RW , .type =ARM_CP_CONST |ARM_CP_NO_RAW , + .resetvalue =0 }, +/* +* The remaining controls are only programmed as part of firmware setup. +* Accept the writes without retaining state because no modeled CPU +* behavior depends on their values. +*/ + { .name ="E2000_EL1_CTL" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =2 , .crn =15 , .crm =15 , .opc2 =0 , + .access =PL1_RW , .type =ARM_CP_NOP |ARM_CP_NO_RAW }, + { .name ="E2000_EL2_CTL" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =4 , .crn =15 , .crm =15 , .opc2 =0 , + .access =PL2_RW , .type =ARM_CP_NOP |ARM_CP_NO_RAW }, + { .name ="E2000_EL2_CTL2" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =4 , .crn =15 , .crm =2 , .opc2 =4 , + .access =PL2_RW , .type =ARM_CP_NOP |ARM_CP_NO_RAW }, + { .name ="E2000_EL3_CTL" , .state =ARM_CP_STATE_AA64 , + .opc0 =3 , .opc1 =6 , .crn =15 , .crm =15 , .opc2 =0 , + .access =PL3_RW , .type =ARM_CP_NOP |ARM_CP_NO_RAW }, +}; + +/* +* Use the Cortex-A72 execution model as the common E2000 TCG base, then +* replace the architected identity fields that differ between the two +* physical core types. +*/ +static void aarch64_phytium_e2000_base_initfn (Object *obj) +{ +ARMCPU *cpu =ARM_CPU (obj); + +aarch64_a72_initfn (obj); +define_arm_cp_regs (cpu, phytium_e2000_cp_reginfo); +} + +static void aarch64_phytium_ftc310_initfn (Object *obj) +{ +ARMCPU *cpu =ARM_CPU (obj); +ARMISARegisters *isar = &cpu->isar; + +aarch64_phytium_e2000_base_initfn (obj); + +/* FTC310 cores identify with the FTC303 part number */ + cpu->dtb_compatible ="phytium,ftc310" ; + cpu->midr =0x700f3034 ; +SET_IDREG (isar,ID_AA64ISAR0 ,0x00011100012120 ); + cpu->isar.mvfr0 =0x10110222 ; + cpu->ctr =FIELD_DP64 (cpu->ctr,CTR_EL0 ,L1IP ,2 );/* VIPT */ +} + +static void aarch64_phytium_ftc664_initfn (Object *obj) +{ +ARMCPU *cpu =ARM_CPU (obj); +ARMISARegisters *isar = &cpu->isar; + +aarch64_phytium_e2000_base_initfn (obj); + + cpu->dtb_compatible ="phytium,ftc664" ; + cpu->midr =0x701f6643 ; +SET_IDREG (isar,ID_AA64ISAR0 ,0x00000100012120 ); + cpu->isar.mvfr0 =0x10111222 ; + cpu->ctr =FIELD_DP64 (cpu->ctr,CTR_EL0 ,L1IP ,3 );/* PIPT */ +} +static void aarch64_a76_initfn (Object *obj) {ARMCPU *cpu =ARM_CPU (obj);@@ -1533,6 +1612,8 @@ static const ARMCPUInfo aarch64_cpus[] = { { .name = "cortex-a55", .initfn = aarch64_a55_initfn }, { .name = "cortex-a72", .initfn = aarch64_a72_initfn }, { .name = "cortex-a76", .initfn = aarch64_a76_initfn }, + { .name = "phytium-ftc310", .initfn = aarch64_phytium_ftc310_initfn }, + { .name = "phytium-ftc664", .initfn = aarch64_phytium_ftc664_initfn },/* * The Cortex-A78AE differs slightly from the plain Cortex-A78. We don't * currently model the latter.
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Re: [PATCH 01/33] target/arm: Add Phytium FTC310 and FTC664 CPU models
Hi Alex,
Quoted 29 lines · Alex Bennée
Quoted 15 lines · Bin Meng
The Phytium E2000Q combines two FTC310 cores and two FTC664 cores. Its EL3 firmware accesses implementation-defined system registers while setting up the cores. Using generic Cortex-A72 CPUs leaves these registers undefined and traps firmware before it can reach U-Boot.
Add FTC310 and FTC664 CPU types using Cortex-A72 as their common execution base. Provide conservative RAZ/WI and NOP stubs for the firmware-visible E2000 controls that have no modeled behavior.
Set each CPU DT compatible string, MIDR, instruction feature fields, AArch32 floating-point feature fields, and CTR_EL0.L1Ip field to values observed on an E2000Q board. The FTC310 reports a VIPT instruction cache, while the FTC664 reports a PIPT instruction cache.
Quoted 5 lines
Signed-off-by Bin Meng <[email protected]>---
target/arm/tcg/cpu64.c | 81++++++++++++++++++++++++++++++++++++++++++
I wonder if cpu64 is the best place to model this? The alternative is to treat it like other SoCs (e.g. the Pi's BCM SoCs). Was the reason it ended up here because you needed access to
aarch64_a72_initfn? Could you not instantiate:
Quoted 9 lines
soc_base->cpu_type = ARM_CPU_TYPE_NAME("cortex-a72");and then at realize:
object_initialize_child(OBJECT(dev), "cpu[*]", &s->cpu[n].core, soc_base->cpu_type);or does that not allow for tweaking the CP regs?
I followed your advice and that worked like a charm. Will move the Phytium-specific CPU type in the SoC/machine codes in v2.
Quoted 11 lines
target/arm/tcg/cpu64.c static void aarch64_a72_initfn(Object *obj) · line 338
Quoted 11 lines
1 file changed, 81 insertions(+)target/arm/tcg/cpu64.c +0
-0@@ -336,6 +336,85 @@ static void aarch64_a72_initfn(Object *obj)define_cortex_a72_a57_a53_cp_reginfo (cpu); }
Regards,
Bin
PATCH 2/33 hw/arm: Add basic Phytium Pi machine
In reply to Bin MengAdd the base topology for the Phytium Pi board built around the E2000Q SoC, with two FTC310 and two FTC664 CPUs, RAM, GICv3/ITS, and PL011 UARTs.
Describe the CPUs as three non-uniform clusters matching the vendor Linux device tree. Preserve the board CPU slot order so firmware MPIDR 0x200 maps to QEMU CPU index 2.
---
hw/arm/Kconfig | 8 + hw/arm/meson.build | 1 + hw/arm/phytium_e2000.c | 406 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 415 insertions(+) create mode 100644 hw/arm/phytium_e2000.c
hw/arm/Kconfig +8 -0
@@ -126,6 +126,14 @@ config OMAP select SD select SERIAL_MM +config PHYTIUM_E2000 + bool + default y + depends on TCG && AARCH64 + select ARM_GIC + select PL011 + select UNIMP + config REALVIEW bool default y
hw/arm/meson.build +1 -0
@@ -10,6 +10,7 @@ arm_common_ss.add(when: 'CONFIG_NETDUINOPLUS2', if_true: files('netduinoplus2.c' arm_common_ss.add(when: 'CONFIG_OLIMEX_STM32_H405', if_true: files('olimex-stm32-h405.c')) arm_common_ss.add(when: 'CONFIG_NPCM7XX', if_true: files('npcm7xx.c', 'npcm7xx_boards.c')) arm_common_ss.add(when: 'CONFIG_NPCM8XX', if_true: files('npcm8xx.c', 'npcm8xx_boards.c')) +arm_common_ss.add(when: 'CONFIG_PHYTIUM_E2000', if_true: files('phytium_e2000.c')) arm_common_ss.add(when: 'CONFIG_REALVIEW', if_true: files('realview.c')) arm_common_ss.add(when: 'CONFIG_SBSA_REF', if_true: files('sbsa-ref.c')) arm_common_ss.add(when: 'CONFIG_STELLARIS', if_true: files('stellaris.c'))
hw/arm/phytium_e2000.c new file +406 -0
406 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH 02/33] hw/arm: Add basic Phytium Pi machine
Quoted 47 lines · Bin Meng
Add the base topology for the Phytium Pi board built around the E2000Q SoC, with two FTC310 and two FTC664 CPUs, RAM, GICv3/ITS, and PL011 UARTs.
Describe the CPUs as three non-uniform clusters matching the vendor Linux device tree. Preserve the board CPU slot order so firmware MPIDR
0x200maps to QEMU CPU index 2.Signed-off-by Bin Meng <[email protected]>---
hw/arm/Kconfig | 8 + hw/arm/meson.build | 1 + hw/arm/phytium_e2000.c | 406 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 415 insertions(+)create mode 100644
hw/arm/phytium_e2000.chw/arm/phytium_e2000.c new file +27
-0+struct PhytiumE2000State { +MachineState parent; +struct arm_boot_info bootinfo; +DeviceState *gic; +MemoryRegion ram_low; +MemoryRegion ram_high; +}; +static void phytium_e2000_create_gic (PhytiumE2000State *s) +{ +MachineState *ms =MACHINE (s); +SysBusDevice *gicbusdev; +QList *redist_region_count; +int i; + + s->gic =qdev_new (gicv3_class_name ()); +qdev_prop_set_uint32 (s->gic,"revision" ,3 ); +qdev_prop_set_uint32 (s->gic,"num-cpu" , ms->smp.cpus); +qdev_prop_set_uint32 (s->gic,"num-irq" ,PHYTIUM_E2000_NUM_IRQS +32 ); +qdev_prop_set_bit (s->gic,"has-security-extensions" , true); +qdev_prop_set_bit (s->gic,"has-lpi" , true); + + redist_region_count =qlist_new (); +qlist_append_int (redist_region_count, ms->smp.cpus); +qdev_prop_set_array (s->gic,"redist-region-count" , redist_region_count); + +object_property_set_link (OBJECT (s->gic),"sysmem" , +OBJECT (get_system_memory ()), &error_fatal);
hw/arm/phytium_e2000.c line 181
Quoted 10 lines
hw/arm/phytium_e2000.c new file +10
-0+ + gicbusdev =SYS_BUS_DEVICE (s->gic); +sysbus_realize_and_unref (gicbusdev, &error_fatal); +sysbus_mmio_map (gicbusdev,0 , + phytium_e2000_memmap[PHYTIUM_E2000_GIC_DIST ].base); +sysbus_mmio_map (gicbusdev,1 , + phytium_e2000_memmap[PHYTIUM_E2000_GIC_REDIST ].base); + +for (i =0 ; i < ms->smp.cpus; i++) { +DeviceState *cpudev =DEVICE (qemu_get_cpu (i));
I'd rather you keep a reference in PhytiumE2000State when creating in [*] and access the CPUs that way, not with qemu_get_cpu() (because we plan to restrict it to accel/, as it is problematic on heterogeneous emulation).
Quoted 30 lines
hw/arm/phytium_e2000.c new file +28
-0+int intidbase =PHYTIUM_E2000_NUM_IRQS + i *GIC_INTERNAL ; +static const int timer_irq[] = { + [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 irq =0 ; irq <ARRAY_SIZE (timer_irq); irq++) { +qdev_connect_gpio_out (cpudev, irq, +qdev_get_gpio_in (s->gic, intidbase + timer_irq[irq])); + } +qdev_connect_gpio_out_named (cpudev,"gicv3-maintenance-interrupt" ,0 , +qdev_get_gpio_in (s->gic, intidbase +ARCH_GIC_MAINT_IRQ )); +qdev_connect_gpio_out_named (cpudev,"pmu-interrupt" ,0 , +qdev_get_gpio_in (s->gic, intidbase +VIRTUAL_PMU_IRQ )); + +sysbus_connect_irq (gicbusdev, i,qdev_get_gpio_in (cpudev,ARM_CPU_IRQ )); +sysbus_connect_irq (gicbusdev, i + ms->smp.cpus, +qdev_get_gpio_in (cpudev,ARM_CPU_FIQ )); +sysbus_connect_irq (gicbusdev, i +2 * ms->smp.cpus, +qdev_get_gpio_in (cpudev,ARM_CPU_VIRQ )); +sysbus_connect_irq (gicbusdev, i +3 * ms->smp.cpus, +qdev_get_gpio_in (cpudev,ARM_CPU_VFIQ )); + } + +phytium_e2000_create_its (s); +}
hw/arm/phytium_e2000.c line 277
Quoted 10 lines
hw/arm/phytium_e2000.c new file +10
-0+static void phytium_e2000_create_cpus (PhytiumE2000State *s) +{ +MachineState *ms =MACHINE (s); +const CPUArchIdList *possible_cpus; +int i; + + possible_cpus =MACHINE_GET_CLASS (ms)->possible_cpu_arch_ids (ms); + +for (i =0 ; i < ms->smp.cpus; i++) { +Object *cpuobj =object_new (possible_cpus->cpus[i].type);
[*]
Quoted 20 lines
hw/arm/phytium_e2000.c new file +20
-0+CPUState *cs; + +object_property_set_int (cpuobj,"mp-affinity" , + possible_cpus->cpus[i].arch_id, + &error_abort); +object_property_set_int (cpuobj,"cntfrq" ,PHYTIUM_E2000_GTIMER_HZ , + &error_abort); +if (object_property_find (cpuobj,"has_el3" )) { +/* +* The generic-loader U-Boot path starts after the EL3 firmware +* stages that normally provide the Phytium SMC services. +*/ +object_property_set_bool (cpuobj,"has_el3" , false, &error_abort); + } +object_property_set_link (cpuobj,"memory" ,OBJECT (get_system_memory ()), + &error_abort); + cs =CPU (cpuobj); + cs->cpu_index = i; +qdev_realize (DEVICE (cpuobj),NULL , &error_fatal); +object_unref (cpuobj);
hw/arm/phytium_e2000.c line 307
Quoted 10 lines
hw/arm/phytium_e2000.c new file +10
-0+ } +} + +static void phytium_pi_init (MachineState *ms) +{ +PhytiumE2000State *s =PHYTIUM_PI (ms); +int i; + +if (kvm_enabled ()) { +error_report ("phytium-pi: KVM is not supported" );
Why is it relevant?
hw/arm/phytium_e2000.c line 315
Quoted 4 lines
hw/arm/phytium_e2000.c new file +3
-0+exit (1 ); + } +}
Conditional to not using qemu_get_cpu():
Re: [PATCH 02/33] hw/arm: Add basic Phytium Pi machine
Hi Philippe,
Quoted 56 lines · Philippe Mathieu-Daudé
Quoted 54 lines · Bin Meng
Add the base topology for the Phytium Pi board built around the E2000Q SoC, with two FTC310 and two FTC664 CPUs, RAM, GICv3/ITS, and PL011 UARTs.
Describe the CPUs as three non-uniform clusters matching the vendor Linux device tree. Preserve the board CPU slot order so firmware MPIDR
0x200maps to QEMU CPU index 2.Signed-off-by Bin Meng <[email protected]>---
hw/arm/Kconfig | 8 + hw/arm/meson.build | 1 + hw/arm/phytium_e2000.c | 406 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 415 insertions(+)create mode 100644
hw/arm/phytium_e2000.chw/arm/phytium_e2000.c new file +34
-0+struct PhytiumE2000State { +MachineState parent; +struct arm_boot_info bootinfo; +DeviceState *gic; +MemoryRegion ram_low; +MemoryRegion ram_high; +}; +static void phytium_e2000_create_gic (PhytiumE2000State *s) +{ +MachineState *ms =MACHINE (s); +SysBusDevice *gicbusdev; +QList *redist_region_count; +int i; + + s->gic =qdev_new (gicv3_class_name ()); +qdev_prop_set_uint32 (s->gic,"revision" ,3 ); +qdev_prop_set_uint32 (s->gic,"num-cpu" , ms->smp.cpus); +qdev_prop_set_uint32 (s->gic,"num-irq" ,PHYTIUM_E2000_NUM_IRQS +32 ); +qdev_prop_set_bit (s->gic,"has-security-extensions" , true); +qdev_prop_set_bit (s->gic,"has-lpi" , true); + + redist_region_count =qlist_new (); +qlist_append_int (redist_region_count, ms->smp.cpus); +qdev_prop_set_array (s->gic,"redist-region-count" , redist_region_count); + +object_property_set_link (OBJECT (s->gic),"sysmem" , +OBJECT (get_system_memory ()), &error_fatal); + + gicbusdev =SYS_BUS_DEVICE (s->gic); +sysbus_realize_and_unref (gicbusdev, &error_fatal); +sysbus_mmio_map (gicbusdev,0 , + phytium_e2000_memmap[PHYTIUM_E2000_GIC_DIST ].base); +sysbus_mmio_map (gicbusdev,1 , + phytium_e2000_memmap[PHYTIUM_E2000_GIC_REDIST ].base);
Quoted 8 lines
hw/arm/phytium_e2000.c line 181
Quoted 3 lines
hw/arm/phytium_e2000.c new file +3
-0+ +for (i =0 ; i < ms->smp.cpus; i++) { +DeviceState *cpudev =DEVICE (qemu_get_cpu (i));I'd rather you keep a reference in PhytiumE2000State when creating in [*] and access the CPUs that way, not with
qemu_get_cpu()(because we plan to restrict it to accel/, as it is problematic on heterogeneous emulation).
Will fix in v2.
Quoted 68 lines
Quoted 31 lines
hw/arm/phytium_e2000.c new file +28
-0+int intidbase =PHYTIUM_E2000_NUM_IRQS + i *GIC_INTERNAL ; +static const int timer_irq[] = { + [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 irq =0 ; irq <ARRAY_SIZE (timer_irq); irq++) { +qdev_connect_gpio_out (cpudev, irq, +qdev_get_gpio_in (s->gic, intidbase + timer_irq[irq])); + } +qdev_connect_gpio_out_named (cpudev,"gicv3-maintenance-interrupt" ,0 , +qdev_get_gpio_in (s->gic, intidbase +ARCH_GIC_MAINT_IRQ )); +qdev_connect_gpio_out_named (cpudev,"pmu-interrupt" ,0 , +qdev_get_gpio_in (s->gic, intidbase +VIRTUAL_PMU_IRQ )); + +sysbus_connect_irq (gicbusdev, i,qdev_get_gpio_in (cpudev,ARM_CPU_IRQ )); +sysbus_connect_irq (gicbusdev, i + ms->smp.cpus, +qdev_get_gpio_in (cpudev,ARM_CPU_FIQ )); +sysbus_connect_irq (gicbusdev, i +2 * ms->smp.cpus, +qdev_get_gpio_in (cpudev,ARM_CPU_VIRQ )); +sysbus_connect_irq (gicbusdev, i +3 * ms->smp.cpus, +qdev_get_gpio_in (cpudev,ARM_CPU_VFIQ )); + } + +phytium_e2000_create_its (s); +}hw/arm/phytium_e2000.c line 277
Quoted 10 lines
hw/arm/phytium_e2000.c new file +10
-0+static void phytium_e2000_create_cpus (PhytiumE2000State *s) +{ +MachineState *ms =MACHINE (s); +const CPUArchIdList *possible_cpus; +int i; + + possible_cpus =MACHINE_GET_CLASS (ms)->possible_cpu_arch_ids (ms); + +for (i =0 ; i < ms->smp.cpus; i++) { +Object *cpuobj =object_new (possible_cpus->cpus[i].type);[*]
Quoted 24 lines
hw/arm/phytium_e2000.c new file +24
-0+CPUState *cs; + +object_property_set_int (cpuobj,"mp-affinity" , + possible_cpus->cpus[i].arch_id, + &error_abort); +object_property_set_int (cpuobj,"cntfrq" ,PHYTIUM_E2000_GTIMER_HZ , + &error_abort); +if (object_property_find (cpuobj,"has_el3" )) { +/* +* The generic-loader U-Boot path starts after the EL3 firmware +* stages that normally provide the Phytium SMC services. +*/ +object_property_set_bool (cpuobj,"has_el3" , false, &error_abort); + } +object_property_set_link (cpuobj,"memory" ,OBJECT (get_system_memory ()), + &error_abort); + cs =CPU (cpuobj); + cs->cpu_index = i; +qdev_realize (DEVICE (cpuobj),NULL , &error_fatal); +object_unref (cpuobj); + } +} + +static void phytium_pi_init (MachineState *ms)
Quoted 8 lines
hw/arm/phytium_e2000.c line 307
Quoted 6 lines
hw/arm/phytium_e2000.c new file +6
-0+{ +PhytiumE2000State *s =PHYTIUM_PI (ms); +int i; + +if (kvm_enabled ()) { +error_report ("phytium-pi: KVM is not supported" );Why is it relevant?
This is because the machine relies on heterogeneous named FTC310/FTC664 TCG CPU models and Arm KVM generally requires the host CPU model. KVM is rejected explicitly instead of failing later during vCPU initialization.
Quoted 6 lines
hw/arm/phytium_e2000.c line 315
Quoted 4 lines
hw/arm/phytium_e2000.c new file +3
-0+exit (1 ); + } +}Conditional to not using
qemu_get_cpu():Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Thanks for the review!
Regards,
Bin
Re: [PATCH 02/33] hw/arm: Add basic Phytium Pi machine
Quoted 34 lines · Bin Meng
Hi Philippe,
Quoted 20 lines · Philippe Mathieu-Daudé
Quoted 16 lines · Bin Meng
Add the base topology for the Phytium Pi board built around the E2000Q SoC, with two FTC310 and two FTC664 CPUs, RAM, GICv3/ITS, and PL011 UARTs.
Describe the CPUs as three non-uniform clusters matching the vendor Linux device tree. Preserve the board CPU slot order so firmware MPIDR
0x200maps to QEMU CPU index 2.Signed-off-by Bin Meng <[email protected]>---
hw/arm/Kconfig | 8 + hw/arm/meson.build | 1 + hw/arm/phytium_e2000.c | 406 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 415 insertions(+)create mode 100644
hw/arm/phytium_e2000.cQuoted 9 lines
hw/arm/phytium_e2000.c line 307
Quoted 7 lines
hw/arm/phytium_e2000.c new file +7
-0+static void phytium_pi_init (MachineState *ms) +{ +PhytiumE2000State *s =PHYTIUM_PI (ms); +int i; + +if (kvm_enabled ()) { +error_report ("phytium-pi: KVM is not supported" );Why is it relevant?
Quoted 4 lines
This is because the machine relies on heterogeneous named FTC310/FTC664 TCG CPU models and Arm KVM generally requires the host CPU model. KVM is rejected explicitly instead of failing later during vCPU initialization.
Hmm OK. Cc'ing Pierrick to add to our list of things to think about for heterogenous emulation. I'd rather have this handled in a generic way, not per-machine. Hopefully TypeInfo::is_available will be sufficient to not expose the machine if KVM is not available. No need to think about that now.
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
hw/arm/phytium_e2000.c new file +3
-0+exit (1 ); + } +}
Re: [PATCH 02/33] hw/arm: Add basic Phytium Pi machine
Quoted 35 lines · Philippe Mathieu-Daudé
Quoted 34 lines · Bin Meng
Hi Philippe,
Quoted 29 lines · Philippe Mathieu-Daudé
Quoted 18 lines · Bin Meng
Add the base topology for the Phytium Pi board built around the E2000Q SoC, with two FTC310 and two FTC664 CPUs, RAM, GICv3/ITS, and PL011 UARTs.
Describe the CPUs as three non-uniform clusters matching the vendor Linux device tree. Preserve the board CPU slot order so firmware MPIDR
0x200maps to QEMU CPU index 2.Signed-off-by Bin Meng <[email protected]>---
hw/arm/Kconfig | 8 + hw/arm/meson.build | 1 + hw/arm/phytium_e2000.c | 406 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 415 insertions(+)create mode 100644
hw/arm/phytium_e2000.chw/arm/phytium_e2000.c line 307
Quoted 7 lines
hw/arm/phytium_e2000.c new file +7
-0+static void phytium_pi_init (MachineState *ms) +{ +PhytiumE2000State *s =PHYTIUM_PI (ms); +int i; + +if (kvm_enabled ()) { +error_report ("phytium-pi: KVM is not supported" );Why is it relevant?
Quoted 4 lines
Quoted 4 lines
This is because the machine relies on heterogeneous named FTC310/FTC664 TCG CPU models and Arm KVM generally requires the host CPU model. KVM is rejected explicitly instead of failing later during vCPU initialization.
We have several other hardware accelerators for other platforms. It is right to be checking KVM specifically, or should we have general check that only passes for TCG/QTest ?
Quoted 5 lines
Hmm OK. Cc'ing Pierrick to add to our list of things to think about for heterogenous emulation. I'd rather have this handled in a generic way, not per-machine. Hopefully
TypeInfo::is_availablewill be sufficient to not expose the machine if KVM is not available. No need to think about that now.
We need to use QAPI MachineInfo / MachineClass to report to mgmt apps whether a machine is capable of using hardware acceleration or not in response to "query-machines".
Currently if a target supports HW accel, then apps assume that all machines in that target can use acceleration. This was a convenient short cut assumption, but this new machine suggests we can no make do with that assumption, and need to explicitly report it per-machine.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Re: [PATCH 02/33] hw/arm: Add basic Phytium Pi machine
Quoted 8 lines · Daniel P. Berrangé
We need to use QAPI MachineInfo / MachineClass to report to mgmt apps whether a machine is capable of using hardware acceleration or not in response to "query-machines".
Currently if a target supports HW accel, then apps assume that all machines in that target can use acceleration. This was a convenient short cut assumption, but this new machine suggests we can no make do with that assumption, and need to explicitly report it per-machine.
That assumption has never been true for Arm; this new machine type is no different to any of our existing boards in that regard. Support for KVM etc is only present for the 'virt' machine type and one or two others. Most of the rest don't work with KVM because they create a specific CPU type (not 'host' or 'max') and that won't work with KVM, or (as with sbsa-ref) because they want EL3 support and KVM doesn't provide that.
I suspect it's probably not a valid assumption for non-x86 architectures more generally.
thanks
-- PMM
Re: [PATCH 02/33] hw/arm: Add basic Phytium Pi machine
Quoted 10 lines · Peter Maydell
Quoted 8 lines · Daniel P. Berrangé
We need to use QAPI MachineInfo / MachineClass to report to mgmt apps whether a machine is capable of using hardware acceleration or not in response to "query-machines".
Currently if a target supports HW accel, then apps assume that all machines in that target can use acceleration. This was a convenient short cut assumption, but this new machine suggests we can no make do with that assumption, and need to explicitly report it per-machine.
Quoted 7 lines
That assumption has never been true for Arm; this new machine type is no different to any of our existing boards in that regard. Support for KVM etc is only present for the 'virt' machine type and one or two others. Most of the rest don't work with KVM because they create a specific CPU type (not 'host' or 'max') and that won't work with KVM, or (as with sbsa-ref) because they want EL3 support and KVM doesn't provide that.
Oh, then the problem is already way worse than I realized which really makes we think we should consider exposing whether machines can use HW acceleration or not.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Re: [PATCH 02/33] hw/arm: Add basic Phytium Pi machine
Quoted 20 lines · Daniel P. Berrangé
Quoted 10 lines · Peter Maydell
Quoted 8 lines · Daniel P. Berrangé
We need to use QAPI MachineInfo / MachineClass to report to mgmt apps whether a machine is capable of using hardware acceleration or not in response to "query-machines".
Currently if a target supports HW accel, then apps assume that all machines in that target can use acceleration. This was a convenient short cut assumption, but this new machine suggests we can no make do with that assumption, and need to explicitly report it per-machine.
Quoted 7 lines
That assumption has never been true for Arm; this new machine type is no different to any of our existing boards in that regard. Support for KVM etc is only present for the 'virt' machine type and one or two others. Most of the rest don't work with KVM because they create a specific CPU type (not 'host' or 'max') and that won't work with KVM, or (as with sbsa-ref) because they want EL3 support and KVM doesn't provide that.
Quoted 3 lines
Oh, then the problem is already way worse than I realized which really makes we think we should consider exposing whether machines can use HW acceleration or not.
It also depends on the options to the machine, so for instance this should always work with any of the hw accelerators:
qemu-system-aarch64 -M virt -cpu host
but this wants nested virt, so only works with a hw accel that supports that and a host kernel that has the KVM side support:
qemu-system-aarch64 -M virt,virtualization=on -cpu host
and this wants EL3, which won't work in any hw accelerator
qemu-system-aarch64 -M virt,secure=on -cpu host
Similarly the interrupt controller choice matters, so this:
qemu-system-aarch64 -M virt,gic-version=2 -cpu host
may or may not work depending on whether the host CPU has the GICv2 back-compat support; and this:
qemu-system-aarch64 -M virt,gic-version=x-5 -cpu host
is currently TCG-only. (But also it's experimental so you kind of know you're off-piste here ;-))
If you try the things that won't work with -enable-kvm then they should wind up causing QEMU to exit with a hopefully more or less informative error message, but I don't think we have any mechanism for introspection of the form "if I try this particular set of QEMU options is it going to work?" short of actually trying.
-- PMM
Re: [PATCH 02/33] hw/arm: Add basic Phytium Pi machine
Quoted 42 lines · Peter Maydell
Quoted 20 lines · Daniel P. Berrangé
Quoted 10 lines · Peter Maydell
Quoted 8 lines · Daniel P. Berrangé
We need to use QAPI MachineInfo / MachineClass to report to mgmt apps whether a machine is capable of using hardware acceleration or not in response to "query-machines".
Currently if a target supports HW accel, then apps assume that all machines in that target can use acceleration. This was a convenient short cut assumption, but this new machine suggests we can no make do with that assumption, and need to explicitly report it per-machine.
Quoted 7 lines
That assumption has never been true for Arm; this new machine type is no different to any of our existing boards in that regard. Support for KVM etc is only present for the 'virt' machine type and one or two others. Most of the rest don't work with KVM because they create a specific CPU type (not 'host' or 'max') and that won't work with KVM, or (as with sbsa-ref) because they want EL3 support and KVM doesn't provide that.
Quoted 3 lines
Oh, then the problem is already way worse than I realized which really makes we think we should consider exposing whether machines can use HW acceleration or not.
It also depends on the options to the machine, so for instance this should always work with any of the hw accelerators:
qemu-system-aarch64 -M virt -cpu host
but this wants nested virt, so only works with a hw accel that supports that and a host kernel that has the KVM side support:
qemu-system-aarch64 -M virt,virtualization=on -cpu host
and this wants EL3, which won't work in any hw accelerator
qemu-system-aarch64 -M virt,secure=on -cpu hostSimilarly the interrupt controller choice matters, so this:
qemu-system-aarch64 -M virt,gic-version=2 -cpu host
may or may not work depending on whether the host CPU has the GICv2 back-compat support; and this:
qemu-system-aarch64 -M virt,gic-version=x-5 -cpu host
is currently TCG-only. (But also it's experimental so you kind of know you're off-piste here ;-))
Quoted 5 lines
If you try the things that won't work with -enable-kvm then they should wind up causing QEMU to exit with a hopefully more or less informative error message, but I don't think we have any mechanism for introspection of the form "if I try this particular set of QEMU options is it going to work?" short of actually trying.
I recall some discussion with Markus / Paolo when brainstorming declarative dynamic machines, we'd need another MachinePhase iterating on all selected types to instantiate and check whether they can be instantiated, and returning impossible config error; way before a property is evaluated on an instance at Realize time.
Here IMO accelerators should report whether a CPU model class requested is accelerable or not (then later we can double check with features updated on the model instances).
The machine deciding is a shortcut, not scalable and hard to maintain.
Re: [PATCH 02/33] hw/arm: Add basic Phytium Pi machine
Quoted 49 lines · Philippe Mathieu-Daudé
Quoted 42 lines · Peter Maydell
Quoted 20 lines · Daniel P. Berrangé
Quoted 10 lines · Peter Maydell
Quoted 8 lines · Daniel P. Berrangé
We need to use QAPI MachineInfo / MachineClass to report to mgmt apps whether a machine is capable of using hardware acceleration or not in response to "query-machines".
Currently if a target supports HW accel, then apps assume that all machines in that target can use acceleration. This was a convenient short cut assumption, but this new machine suggests we can no make do with that assumption, and need to explicitly report it per-machine.
Quoted 7 lines
That assumption has never been true for Arm; this new machine type is no different to any of our existing boards in that regard. Support for KVM etc is only present for the 'virt' machine type and one or two others. Most of the rest don't work with KVM because they create a specific CPU type (not 'host' or 'max') and that won't work with KVM, or (as with sbsa-ref) because they want EL3 support and KVM doesn't provide that.
Quoted 3 lines
Oh, then the problem is already way worse than I realized which really makes we think we should consider exposing whether machines can use HW acceleration or not.
It also depends on the options to the machine, so for instance this should always work with any of the hw accelerators:
qemu-system-aarch64 -M virt -cpu host
but this wants nested virt, so only works with a hw accel that supports that and a host kernel that has the KVM side support:
qemu-system-aarch64 -M virt,virtualization=on -cpu host
and this wants EL3, which won't work in any hw accelerator
qemu-system-aarch64 -M virt,secure=on -cpu hostSimilarly the interrupt controller choice matters, so this:
qemu-system-aarch64 -M virt,gic-version=2 -cpu host
may or may not work depending on whether the host CPU has the GICv2 back-compat support; and this:
qemu-system-aarch64 -M virt,gic-version=x-5 -cpu host
is currently TCG-only. (But also it's experimental so you kind of know you're off-piste here ;-))Quoted 5 lines
If you try the things that won't work with -enable-kvm then they should wind up causing QEMU to exit with a hopefully more or less informative error message, but I don't think we have any mechanism for introspection of the form "if I try this particular set of QEMU options is it going to work?" short of actually trying.
Quoted 5 lines
I recall some discussion with Markus / Paolo when brainstorming declarative dynamic machines, we'd need another MachinePhase iterating on all selected types to instantiate and check whether they can be instantiated, and returning impossible config error; way before a property is evaluated on an instance at Realize time.
Mmm, yes, that is getting into quite alot of work for probably not enough benefit.
Quoted 4 lines
Here IMO accelerators should report whether a CPU model class requested is accelerable or not (then later we can double check with features updated on the model instances).
The machine deciding is a shortcut, not scalable and hard to maintain.
Yeah, I think you're right - the machine does look like a facade around the CPU for accelerator runnability. So it probably better fits the QMP commands for querying CPU runnability.
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com ~~ https://hachyderm.io/@berrange :| |: https://libvirt.org ~~ https://entangle-photo.org :| |: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
Re: [PATCH 02/33] hw/arm: Add basic Phytium Pi machine
In reply to Philippe Mathieu-DaudéQuoted 41 lines · Philippe Mathieu-Daudé
Quoted 34 lines · Bin Meng
Hi Philippe,
Quoted 20 lines · Philippe Mathieu-Daudé
Quoted 16 lines · Bin Meng
Add the base topology for the Phytium Pi board built around the E2000Q SoC, with two FTC310 and two FTC664 CPUs, RAM, GICv3/ITS, and PL011 UARTs.
Describe the CPUs as three non-uniform clusters matching the vendor Linux device tree. Preserve the board CPU slot order so firmware MPIDR
0x200maps to QEMU CPU index 2.Signed-off-by Bin Meng <[email protected]>---
hw/arm/Kconfig | 8 + hw/arm/meson.build | 1 + hw/arm/phytium_e2000.c | 406 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 415 insertions(+)create mode 100644
hw/arm/phytium_e2000.cQuoted 9 lines
hw/arm/phytium_e2000.c line 307
Quoted 7 lines
hw/arm/phytium_e2000.c new file +7
-0+static void phytium_pi_init (MachineState *ms) +{ +PhytiumE2000State *s =PHYTIUM_PI (ms); +int i; + +if (kvm_enabled ()) { +error_report ("phytium-pi: KVM is not supported" );Why is it relevant?
Quoted 4 lines
This is because the machine relies on heterogeneous named FTC310/FTC664 TCG CPU models and Arm KVM generally requires the host CPU model. KVM is rejected explicitly instead of failing later during vCPU initialization.
Quoted 5 lines
Hmm OK. Cc'ing Pierrick to add to our list of things to think about for heterogenous emulation. I'd rather have this handled in a generic way, not per-machine. Hopefully
TypeInfo::is_availablewill be sufficient to not expose the machine if KVM is not available. No need to think about that now.
Explicitly checking for KVM is something we do already in the sbsa-ref board. But I think you should only need to do that if your board type accepts arbitrary CPU types rather than hardwiring the CPU type.
-- PMM
PATCH 3/33 hw/arm: phytium: Add Phytium E2000 PCIe host
In reply to Bin MengAdd the E2000 GPEX host with ECAM, PIO, and 32-bit and 64-bit MMIO windows. Connect MSI through the ITS and route the four INTx outputs to GIC SPI 4 through 7.
The vendor device tree masks out the slot number and maps each interrupt pin directly to the corresponding SPI. Override the GPEX root-bus IRQ mapper so it selects an output solely by pin. Standard PCI-to-PCI bridge swizzling remains unchanged.
Expose the SoC-specific PCIe port and PHY control apertures as low-priority unimplemented regions. Firmware programs these windows before enumerating ECAM, but their state does not affect the generic host bridge.
---
hw/arm/Kconfig | 3 ++ hw/arm/phytium_e2000.c | 118 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+)
hw/arm/Kconfig +3 -0
@@ -130,7 +130,10 @@ config PHYTIUM_E2000 bool default y depends on TCG && AARCH64 + imply PCI_DEVICES select ARM_GIC + select PCI_EXPRESS + select PCI_EXPRESS_GENERIC_BRIDGE select PL011 select UNIMP
hw/arm/phytium_e2000.c +118 -0
166 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH 4/33 hw/sd: Add Synopsys DesignWare MCI controller
In reply to Bin MengThe Synopsys DesignWare Mobile Storage Host predates SDHCI and uses a distinct MCI programming interface. It is integrated by Samsung Exynos, Rockchip, HiSilicon, and Altera/Intel SoCFPGA platforms, among others.
Add a reusable controller model based on the DesignWare Mobile Storage Host 2.40a databook. Cover command and response handling, PIO FIFO aliases, reset and interrupt semantics, card state, and the standard 32-bit internal descriptor DMA engine. Also support the later 64-bit descriptor layout used by vendor variants.
Expose class hooks and immutable configuration fields so vendor extensions can reuse the common implementation.
---
MAINTAINERS | 2 + hw/sd/Kconfig | 5 + hw/sd/dw_mci.c | 1382 ++++++++++++++++++++++++++++++++++++++++ hw/sd/meson.build | 1 + include/hw/sd/dw_mci.h | 74 +++ 5 files changed, 1464 insertions(+) create mode 100644 hw/sd/dw_mci.c create mode 100644 include/hw/sd/dw_mci.h
MAINTAINERS +2 -0
@@ -2411,8 +2411,10 @@ M: Philippe Mathieu-Daudé <[email protected]> M: Bin Meng <[email protected]> L: [email protected] S: Odd Fixes +F: include/hw/sd/dw_mci.h F: include/hw/sd/sd* F: hw/sd/core.c +F: hw/sd/dw_mci.c F: hw/sd/sd* F: hw/sd/ssi-sd.c F: tests/qtest/fuzz-sdcard-test.c
hw/sd/Kconfig +5 -0
@@ -10,6 +10,11 @@ config SSI_SD config SD bool +config DW_MCI + bool + select REGISTER + select SD + config SDHCI bool select SD
hw/sd/dw_mci.c new file +1382 -0
1,382 lines not on this page · raw message
hw/sd/meson.build +1 -0
@@ -1,5 +1,6 @@ system_ss.add(when: 'CONFIG_PL181', if_true: files('pl181.c')) system_ss.add(when: 'CONFIG_SD', if_true: files('sd.c', 'core.c')) +system_ss.add(when: 'CONFIG_DW_MCI', if_true: files('dw_mci.c')) system_ss.add(when: 'CONFIG_SDHCI', if_true: files('sdhci.c')) system_ss.add(when: 'CONFIG_SDHCI_PCI', if_true: files('sdhci-pci.c')) system_ss.add(when: 'CONFIG_SSI_SD', if_true: files('ssi-sd.c'))
include/hw/sd/dw_mci.h new file +74 -0
74 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH 04/33] hw/sd: Add Synopsys DesignWare MCI controller
Hi Bin,
Quoted 17 lines · Bin Meng
The Synopsys DesignWare Mobile Storage Host predates SDHCI and uses a distinct MCI programming interface. It is integrated by Samsung Exynos, Rockchip, HiSilicon, and Altera/Intel SoCFPGA platforms, among others.
Add a reusable controller model based on the DesignWare Mobile Storage Host 2.40a databook. Cover command and response handling, PIO FIFO aliases, reset and interrupt semantics, card state, and the standard 32-bit internal descriptor DMA engine. Also support the later 64-bit descriptor layout used by vendor variants.
Expose class hooks and immutable configuration fields so vendor extensions can reuse the common implementation.
Signed-off-by Bin Meng <[email protected]>---
Quoted 8 lines
MAINTAINERS | 2 + hw/sd/Kconfig | 5 + hw/sd/dw_mci.c | 1382 ++++++++++++++++++++++++++++++++++++++++ hw/sd/meson.build | 1 + include/hw/sd/dw_mci.h | 74 +++ 5 files changed, 1464 insertions(+)create mode 100644
hw/sd/dw_mci.c
create mode 100644include/hw/sd/dw_mci.h
Please enable scripts/git.orderfile to ease review.
Quoted 19 lines
hw/sd/dw_mci.c new file +17
-0+REG32(ENABLE_SHIFT, 0x110) +static const VMStateDescription dw_mci_vmsd = { + .name =TYPE_DW_MCI , + .version_id =1 , + .minimum_version_id =1 , + .post_load = dw_mci_post_load, + .fields = (const VMStateField []) { +VMSTATE_UINT32_ARRAY (regs, DwMciState,DW_MCI_REG_COUNT ), +VMSTATE_UINT8_ARRAY (fifo, DwMciState,DW_MCI_FIFO_MAX_BYTES ), +VMSTATE_UINT32 (fifo_head, DwMciState), +VMSTATE_UINT32 (fifo_len, DwMciState), +VMSTATE_UINT32 (transfer_remaining, DwMciState), +VMSTATE_UINT64 (idmac_desc_addr, DwMciState), +VMSTATE_BOOL (transfer_active, DwMciState), +VMSTATE_BOOL (transfer_write, DwMciState), +VMSTATE_BOOL (transfer_send_stop, DwMciState), +VMSTATE_BOOL (idmac_suspended, DwMciState),
hw/sd/dw_mci.c
Quoted 10 lines
hw/sd/dw_mci.c new file +8
-0+ VMSTATE_BOOL(idmac_fatal, DwMciState), + VMSTATE_BOOL(card_inserted, DwMciState), + VMSTATE_BOOL(card_readonly, DwMciState), +VMSTATE_END_OF_LIST () + }, +}; +#define DW_MCI_MMIO_SIZE 0x1000 +#define DW_MCI_REG_COUNT (DW_MCI_MMIO_SIZE / sizeof(uint32_t))
At a glance, less than 70 registers are addressed but you map and allocate more than 1000, which end being migrated.
Maybe we can start with fewer (96?) registers, still mapping the whole 4K region?
Quoted 31 lines
include/hw/sd/dw_mci.h new file +31
-0+#define DW_MCI_FIFO_MAX_WORDS 2048 +#define DW_MCI_FIFO_MAX_BYTES (DW_MCI_FIFO_MAX_WORDS * sizeof(uint32_t)) + +struct DwMciState { +SysBusDevice parent_obj; + +MemoryRegion iomem; +SDBus sdbus; +qemu_irq irq; + +uint32_t regs[DW_MCI_REG_COUNT ]; +RegisterInfo regs_info[DW_MCI_REG_COUNT ]; + +uint8_t fifo[DW_MCI_FIFO_MAX_BYTES ]; +uint32_t fifo_head; +uint32_t fifo_len; +uint32_t transfer_remaining; +uint64_t idmac_desc_addr; +bool transfer_active; +bool transfer_write; +bool transfer_send_stop; +bool idmac_suspended; +bool idmac_fatal; +bool card_inserted; +bool card_readonly; + +uint32_t verid; +uint32_t hcon; +uint32_t data_offset; +uint32_t fifo_depth; +};
Re: [PATCH 04/33] hw/sd: Add Synopsys DesignWare MCI controller
Hi Philippe,
Quoted 29 lines · Philippe Mathieu-Daudé
Hi Bin,
Quoted 17 lines · Bin Meng
The Synopsys DesignWare Mobile Storage Host predates SDHCI and uses a distinct MCI programming interface. It is integrated by Samsung Exynos, Rockchip, HiSilicon, and Altera/Intel SoCFPGA platforms, among others.
Add a reusable controller model based on the DesignWare Mobile Storage Host 2.40a databook. Cover command and response handling, PIO FIFO aliases, reset and interrupt semantics, card state, and the standard 32-bit internal descriptor DMA engine. Also support the later 64-bit descriptor layout used by vendor variants.
Expose class hooks and immutable configuration fields so vendor extensions can reuse the common implementation.
Signed-off-by Bin Meng <[email protected]>---
Quoted 8 lines
MAINTAINERS | 2 + hw/sd/Kconfig | 5 + hw/sd/dw_mci.c | 1382 ++++++++++++++++++++++++++++++++++++++++ hw/sd/meson.build | 1 + include/hw/sd/dw_mci.h | 74 +++ 5 files changed, 1464 insertions(+)create mode 100644
hw/sd/dw_mci.c
create mode 100644include/hw/sd/dw_mci.h
Quoted 1 line
Please enable
scripts/git.orderfileto ease review.
Have done that for my local QEMU repo.
Quoted 29 lines
Quoted 27 lines
hw/sd/dw_mci.c new file +23
-0+REG32(ENABLE_SHIFT, 0x110) +static const VMStateDescription dw_mci_vmsd = { + .name =TYPE_DW_MCI , + .version_id =1 , + .minimum_version_id =1 , + .post_load = dw_mci_post_load, + .fields = (const VMStateField []) { +VMSTATE_UINT32_ARRAY (regs, DwMciState,DW_MCI_REG_COUNT ), +VMSTATE_UINT8_ARRAY (fifo, DwMciState,DW_MCI_FIFO_MAX_BYTES ), +VMSTATE_UINT32 (fifo_head, DwMciState), +VMSTATE_UINT32 (fifo_len, DwMciState), +VMSTATE_UINT32 (transfer_remaining, DwMciState), +VMSTATE_UINT64 (idmac_desc_addr, DwMciState), +VMSTATE_BOOL (transfer_active, DwMciState), +VMSTATE_BOOL (transfer_write, DwMciState), +VMSTATE_BOOL (transfer_send_stop, DwMciState), +VMSTATE_BOOL (idmac_suspended, DwMciState), +VMSTATE_BOOL (idmac_fatal, DwMciState), +VMSTATE_BOOL (card_inserted, DwMciState), +VMSTATE_BOOL (card_readonly, DwMciState), +VMSTATE_END_OF_LIST () + }, +};
Quoted 8 lines
include/hw/sd/dw_mci.h line 24
Quoted 2 lines
include/hw/sd/dw_mci.h new file +2
-0+#define DW_MCI_MMIO_SIZE 0x1000 +#define DW_MCI_REG_COUNT (DW_MCI_MMIO_SIZE / sizeof(uint32_t))At a glance, less than 70 registers are addressed but you map and allocate more than 1000, which end being migrated.
Maybe we can start with fewer (96?) registers, still mapping the whole 4K region?
Makes sense. Will fix in v2.
Quoted 24 lines
Quoted 24 lines
include/hw/sd/dw_mci.h new file +23
-0+#define DW_MCI_FIFO_MAX_WORDS 2048 +#define DW_MCI_FIFO_MAX_BYTES (DW_MCI_FIFO_MAX_WORDS * sizeof(uint32_t)) + +struct DwMciState { +SysBusDevice parent_obj; + +MemoryRegion iomem; +SDBus sdbus; +qemu_irq irq; + +uint32_t regs[DW_MCI_REG_COUNT ]; +RegisterInfo regs_info[DW_MCI_REG_COUNT ]; + +uint8_t fifo[DW_MCI_FIFO_MAX_BYTES ]; +uint32_t fifo_head; +uint32_t fifo_len; +uint32_t transfer_remaining; +uint64_t idmac_desc_addr; +bool transfer_active; +bool transfer_write; +bool transfer_send_stop; +bool idmac_suspended; +bool idmac_fatal;
Quoted 8 lines
include/hw/sd/dw_mci.h line 55
Quoted 8 lines
include/hw/sd/dw_mci.h new file +8
-0+bool card_inserted; +bool card_readonly; + +uint32_t verid; +uint32_t hcon; +uint32_t data_offset; +uint32_t fifo_depth; +};
Regards,
Bin
PATCH 5/33 hw/sd: Add Phytium E2000 MCI controller
In reply to Bin MengModel the E2000 SD/MMC controller as a subclass of the reusable DesignWare MCI implementation. Supply the E2000 hardware configuration, FIFO depth, data window, clock-ready behavior, and vendor divider register while inheriting the standard command and DMA paths.
---
hw/arm/Kconfig | 1 + hw/sd/meson.build | 1 + hw/sd/phytium_e2000_mci.c | 95 +++++++++++++++++++++++++++++++ include/hw/sd/phytium_e2000_mci.h | 21 +++++++ 4 files changed, 118 insertions(+) create mode 100644 hw/sd/phytium_e2000_mci.c create mode 100644 include/hw/sd/phytium_e2000_mci.h
hw/arm/Kconfig +1 -0
@@ -132,6 +132,7 @@ config PHYTIUM_E2000 depends on TCG && AARCH64 imply PCI_DEVICES select ARM_GIC + select DW_MCI select PCI_EXPRESS select PCI_EXPRESS_GENERIC_BRIDGE select PL011
hw/sd/meson.build +1 -0
@@ -6,6 +6,7 @@ system_ss.add(when: 'CONFIG_SDHCI_PCI', if_true: files('sdhci-pci.c')) system_ss.add(when: 'CONFIG_SSI_SD', if_true: files('ssi-sd.c')) system_ss.add(when: 'CONFIG_OMAP', if_true: files('omap_mmc.c')) +system_ss.add(when: 'CONFIG_PHYTIUM_E2000', if_true: files('phytium_e2000_mci.c')) system_ss.add(when: 'CONFIG_RASPI', if_true: files('bcm2835_sdhost.c')) 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'))
hw/sd/phytium_e2000_mci.c new file +95 -0
95 lines not on this page · raw message
include/hw/sd/phytium_e2000_mci.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* Phytium E2000 SD/MMC controller +* +* Copyright (c) 2026 Process Mission +* +* Author: +* Bin Meng <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_SD_PHYTIUM_E2000_MCI_H +#define HW_SD_PHYTIUM_E2000_MCI_H + +#include "hw/sd/dw_mci.h" +#include "qom/object.h" + +#define TYPE_PHYTIUM_E2000_MCI "phytium-e2000-mci" +OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000MciState, PHYTIUM_E2000_MCI) + +#endif
Signature · 1 line
2.53.0
PATCH 6/33 hw/arm: phytium: Connect Phytium E2000 MCI controllers
In reply to Bin MengInstantiate both E2000 MCI controllers at their low-peripheral addresses, route their interrupts to the GIC, and create an SD card on each exported bus. Map legacy IF_SD backends by controller index so firmware and Linux use the same board-visible media topology.
Keep the broad unimplemented aperture underneath the concrete devices and make SD the machine's default block interface.
---
hw/arm/Kconfig | 1 + hw/arm/phytium_e2000.c | 65 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+)
hw/arm/Kconfig +1 -0
@@ -136,6 +136,7 @@ config PHYTIUM_E2000 select PCI_EXPRESS select PCI_EXPRESS_GENERIC_BRIDGE select PL011 + select SD select UNIMP config REALVIEW
hw/arm/phytium_e2000.c +65 -0
113 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH 7/33 tests/qtest: Add Synopsys DesignWare MCI coverage
In reply to Bin MengExercise the reusable DesignWare MCI behavior through the Phytium Pi board integration. Cover register reset and interrupt handling, 64-bit IDMAC write/read and suspend/resume paths, and FIFO PIO transfers against an SD image.
---
MAINTAINERS | 1 + tests/qtest/dw_mci-test.c | 417 ++++++++++++++++++++++++++++++++++++++ tests/qtest/meson.build | 1 + 3 files changed, 419 insertions(+) create mode 100644 tests/qtest/dw_mci-test.c
MAINTAINERS +1 -0
@@ -2417,6 +2417,7 @@ F: hw/sd/core.c F: hw/sd/dw_mci.c F: hw/sd/sd* F: hw/sd/ssi-sd.c +F: tests/qtest/dw_mci-test.c F: tests/qtest/fuzz-sdcard-test.c F: tests/qtest/sdhci-test.c
tests/qtest/dw_mci-test.c new file +417 -0
417 lines not on this page · raw message
tests/qtest/meson.build +1 -0
@@ -279,6 +279,7 @@ qtests_aarch64 = \ config_all_devices.has_key('CONFIG_TPM_TIS_I2C') ? ['tpm-tis-i2c-test', 'tpm-tis-i2c-swtpm-test'] : []) + \ (config_all_devices.has_key('CONFIG_ASPEED_SOC') ? qtests_aspeed64 : []) + \ (config_all_devices.has_key('CONFIG_NPCM8XX') ? qtests_npcm8xx : []) + \ + (config_all_devices.has_key('CONFIG_PHYTIUM_E2000') ? ['dw_mci-test'] : []) + \ (config_all_devices.has_key('CONFIG_IOMMU_TESTDEV') and config_all_devices.has_key('CONFIG_ARM_VIRT') ? ['iommu-smmuv3-test'] : []) + \
Signature · 1 line
2.53.0
PATCH 8/33 hw/arm: phytium: Connect Phytium E2000 GEM controllers
In reply to Bin MengInstantiate all four standard Cadence GEM controllers described by the E2000 SoC device tree. The generic model implements the first 0x800 bytes of each 0x2000-byte E2000 aperture, so cover the complete window with a low-priority unimplemented region and map the Cadence registers on top. This accepts accesses to the SoC-specific clock and SerDes selectors without inventing their behavior.
Connect eight queue interrupts for GEM0 and four for GEM1 through GEM3, and configure the PCS, MDIO PHY address and 16360-byte jumbo limit expected by the SDK drivers.
---
hw/arm/Kconfig | 1 + hw/arm/phytium_e2000.c | 62 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
hw/arm/Kconfig +1 -0
@@ -132,6 +132,7 @@ config PHYTIUM_E2000 depends on TCG && AARCH64 imply PCI_DEVICES select ARM_GIC + select CADENCE select DW_MCI select PCI_EXPRESS select PCI_EXPRESS_GENERIC_BRIDGE
hw/arm/phytium_e2000.c +62 -0
114 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH 9/33 hw/misc: Add Phytium E2000 DDR status
In reply to Bin MengMove the E2000 DDR initialization and training compatibility window into a first-class registerinfo device. Keep ordinary aligned registers as persistent storage and implement the indirect selector/value interface used by the vendor PBF.
Return the expected initialization, PHY training, update, and BIST results, including the training-error range. This models the firmware contract without attempting a timing-accurate DDR PHY.
---
hw/misc/meson.build | 1 + hw/misc/phytium_e2000_ddr.c | 197 ++++++++++++++++++++++++++++ include/hw/misc/phytium_e2000_ddr.h | 23 ++++ 3 files changed, 221 insertions(+) create mode 100644 hw/misc/phytium_e2000_ddr.c create mode 100644 include/hw/misc/phytium_e2000_ddr.h
hw/misc/meson.build +1 -0
@@ -16,6 +16,7 @@ system_ss.add(when: 'CONFIG_PL310', if_true: files('arm_l2x0.c')) system_ss.add(when: 'CONFIG_INTEGRATOR_DEBUG', if_true: files('arm_integrator_debug.c')) system_ss.add(when: 'CONFIG_A9SCU', if_true: files('a9scu.c')) system_ss.add(when: 'CONFIG_ARM11SCU', if_true: files('arm11scu.c')) +system_ss.add(when: 'CONFIG_PHYTIUM_E2000', if_true: files('phytium_e2000_ddr.c')) system_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m_ras.c'))
hw/misc/phytium_e2000_ddr.c new file +197 -0
197 lines not on this page · raw message
include/hw/misc/phytium_e2000_ddr.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Phytium E2000 DDR training status +* +* Copyright (c) 2026 Process Mission +* +* Author: +* Bin Meng <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_MISC_PHYTIUM_E2000_DDR_H +#define HW_MISC_PHYTIUM_E2000_DDR_H + +#include "hw/core/sysbus.h" +#include "qom/object.h" + +#define TYPE_PHYTIUM_E2000_DDR "phytium-e2000-ddr" +OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000DDRState, PHYTIUM_E2000_DDR) + +#define PHYTIUM_E2000_DDR_MMIO_SIZE 0x400 + +#endif
Signature · 1 line
2.53.0
PATCH 10/33 hw/arm: phytium: Connect the Phytium E2000 DDR status
In reply to Bin MengInstantiate the E2000 DDR status device at 0x32b33000 and map it over the board-control placeholder. PBF and early U-Boot poll this selector window while firmware coordinates DRAM initialization from EL3.
---
hw/arm/phytium_e2000.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
hw/arm/phytium_e2000.c +20 -0
@@ -25,6 +25,7 @@#include "hw/core/qdev-properties.h" #include "hw/intc/arm_gicv3_common.h" #include "hw/intc/arm_gicv3_its_common.h" +#include "hw/misc/phytium_e2000_ddr.h" #include "hw/misc/unimp.h" #include "hw/net/cadence_gem.h" #include "hw/pci/pci.h"
@@ -48,6 +49,8 @@ OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000State, PHYTIUM_PI)#define PHYTIUM_E2000_NUM_UARTS 7#define PHYTIUM_E2000_NUM_GEMS 4 +#define PHYTIUM_E2000_DDR_STATUS_BASE 0x32b33000 +#define PHYTIUM_E2000_GTIMER_HZ 50000000enum {
@@ -445,6 +448,21 @@ static void phytium_e2000_create_mci(PhytiumE2000State *s, int index)phytium_e2000_attach_sd_card (DW_MCI (mci), index); } +static void phytium_e2000_create_ddr_status (PhytiumE2000State *s) +{ +DeviceState *dev =qdev_new (TYPE_PHYTIUM_E2000_DDR ); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); + +/* +* The selector window is embedded in the board-control aperture. It must +* override the placeholder because early U-Boot polls it while PBF is +* still coordinating DRAM initialization from EL3. +*/ +object_property_add_child (OBJECT (s),"ddr-status" ,OBJECT (dev)); +sysbus_realize_and_unref (sbd, &error_fatal); +sysbus_mmio_map_overlap (sbd,0 ,PHYTIUM_E2000_DDR_STATUS_BASE ,2 ); +} +static void phytium_e2000_create_unimplemented (void ) {/*
@@ -564,6 +582,8 @@ static void phytium_pi_init(MachineState *ms)phytium_e2000_create_cpus (s);phytium_e2000_create_gic (s); +phytium_e2000_create_ddr_status (s); +for (i =0 ; i <PHYTIUM_E2000_NUM_MCIS ; i++) {phytium_e2000_create_mci (s, i); }
Signature · 1 line
2.53.0
PATCH 11/33 hw/misc: Add Phytium E2000 MHU doorbell
In reply to Bin MengAdd a model for the E2000 AP OS MHU channel used by vendor firmware. Model its status, set and clear registers and complete nonzero notifications by updating the shared SCMI mailbox.
The device also provides the mailbox seeding helper required by the later PBR handoff. Board address mapping and SCP SRAM ownership are intentionally left to a following machine-integration commit.
---
hw/misc/meson.build | 1 + hw/misc/phytium_e2000_mhu.c | 185 ++++++++++++++++++++++++++++ include/hw/misc/phytium_e2000_mhu.h | 25 ++++ 3 files changed, 211 insertions(+) create mode 100644 hw/misc/phytium_e2000_mhu.c create mode 100644 include/hw/misc/phytium_e2000_mhu.h
hw/misc/meson.build +1 -0
@@ -17,6 +17,7 @@ system_ss.add(when: 'CONFIG_INTEGRATOR_DEBUG', if_true: files('arm_integrator_de system_ss.add(when: 'CONFIG_A9SCU', if_true: files('a9scu.c')) system_ss.add(when: 'CONFIG_ARM11SCU', if_true: files('arm11scu.c')) system_ss.add(when: 'CONFIG_PHYTIUM_E2000', if_true: files('phytium_e2000_ddr.c')) +system_ss.add(when: 'CONFIG_PHYTIUM_E2000', if_true: files('phytium_e2000_mhu.c')) system_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m_ras.c'))
hw/misc/phytium_e2000_mhu.c new file +185 -0
185 lines not on this page · raw message
include/hw/misc/phytium_e2000_mhu.h new file +25 -0
@@ -0,0 +1,25 @@ +/* +* Phytium E2000 MHU/SCMI doorbell +* +* Copyright (c) 2026 Process Mission +* +* Author: +* Bin Meng <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_MISC_PHYTIUM_E2000_MHU_H +#define HW_MISC_PHYTIUM_E2000_MHU_H + +#include "hw/core/sysbus.h" +#include "qom/object.h" + +#define TYPE_PHYTIUM_E2000_MHU "phytium-e2000-mhu" +OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000MHUState, PHYTIUM_E2000_MHU) + +#define PHYTIUM_E2000_MHU_MMIO_SIZE 0x1000 + +void phytium_e2000_mhu_seed_mailbox (void ); + +#endif
Signature · 1 line
2.53.0
PATCH 12/33 hw/arm: phytium: Connect the Phytium E2000 MHU
In reply to Bin MengAdd the E2000 SCP SRAM window used for SCMI messages and map the MHU doorbell into the board-control aperture.
---
hw/arm/phytium_e2000.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
hw/arm/phytium_e2000.c +34 -0
@@ -26,6 +26,7 @@#include "hw/intc/arm_gicv3_common.h" #include "hw/intc/arm_gicv3_its_common.h" #include "hw/misc/phytium_e2000_ddr.h" +#include "hw/misc/phytium_e2000_mhu.h" #include "hw/misc/unimp.h" #include "hw/net/cadence_gem.h" #include "hw/pci/pci.h"
@@ -49,6 +50,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000State, PHYTIUM_PI)#define PHYTIUM_E2000_NUM_UARTS 7#define PHYTIUM_E2000_NUM_GEMS 4 +#define PHYTIUM_E2000_MHU_BASE 0x32a00000 +#define PHYTIUM_E2000_SCP_SRAM_BASE 0x32a10000 +#define PHYTIUM_E2000_SCP_SRAM_SIZE 0x2000#define PHYTIUM_E2000_DDR_STATUS_BASE 0x32b33000#define PHYTIUM_E2000_GTIMER_HZ 50000000
@@ -90,6 +94,7 @@ struct PhytiumE2000State {DeviceState *gic;PhytiumE2000MciState *mci[PHYTIUM_E2000_NUM_MCIS ];CadenceGEMState *gem[PHYTIUM_E2000_NUM_GEMS ]; +MemoryRegion scp_sram;MemoryRegion ram_low;MemoryRegion ram_high; };
@@ -463,6 +468,33 @@ static void phytium_e2000_create_ddr_status(PhytiumE2000State *s)sysbus_mmio_map_overlap (sbd,0 ,PHYTIUM_E2000_DDR_STATUS_BASE ,2 ); } +static void phytium_e2000_create_scp_sram (PhytiumE2000State *s) +{ +/* +* PBF exchanges SCMI messages and platform parameters through this SCP +* SRAM window. Map writable RAM over the board-control placeholder before +* the MHU doorbell starts completing requests in it. +*/ +memory_region_init_ram (&s->scp_sram,NULL ,"phytium-e2000.scp-sram" , +PHYTIUM_E2000_SCP_SRAM_SIZE , &error_fatal); +memory_region_add_subregion_overlap (get_system_memory (), +PHYTIUM_E2000_SCP_SRAM_BASE , &s->scp_sram,1 ); +} + +static void phytium_e2000_create_mhu (PhytiumE2000State *s) +{ +DeviceState *dev =qdev_new (TYPE_PHYTIUM_E2000_MHU ); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); + +/* +* MHU is the notification side of the SCMI transport. The message body +* remains in SCP SRAM, so this device only owns the doorbell aperture. +*/ +object_property_add_child (OBJECT (s),"mhu" ,OBJECT (dev)); +sysbus_realize_and_unref (sbd, &error_fatal); +sysbus_mmio_map_overlap (sbd,0 ,PHYTIUM_E2000_MHU_BASE ,2 ); +} +static void phytium_e2000_create_unimplemented (void ) {/*
@@ -582,6 +614,8 @@ static void phytium_pi_init(MachineState *ms)phytium_e2000_create_cpus (s);phytium_e2000_create_gic (s); +phytium_e2000_create_scp_sram (s); +phytium_e2000_create_mhu (s);phytium_e2000_create_ddr_status (s);for (i =0 ; i <PHYTIUM_E2000_NUM_MCIS ; i++) {
Signature · 1 line
2.53.0
PATCH 13/33 hw/ssi: Add Phytium E2000 QSPI controller
In reply to Bin MengPhytium E2000Q integrates a QSPI controller which seems to be an in-house IP. This adds a model for it with command-port and direct-map paths, and exposes an SSI bus and chip-select output.
---
hw/ssi/Kconfig | 5 + hw/ssi/meson.build | 1 + hw/ssi/phytium_qspi.c | 398 ++++++++++++++++++++++++++++++++++ include/hw/ssi/phytium_qspi.h | 23 ++ 4 files changed, 427 insertions(+) create mode 100644 hw/ssi/phytium_qspi.c create mode 100644 include/hw/ssi/phytium_qspi.h
hw/ssi/Kconfig +5 -0
@@ -9,6 +9,11 @@ config SIFIVE_SPI config SSI bool +config PHYTIUM_E2000_QSPI + bool + select REGISTER + select SSI + config XILINX_SPI bool select SSI
hw/ssi/meson.build +1 -0
@@ -13,3 +13,4 @@ system_ss.add(when: 'CONFIG_IMX', if_true: files('imx_spi.c')) system_ss.add(when: 'CONFIG_IBEX', if_true: files('ibex_spi_host.c')) system_ss.add(when: 'CONFIG_BCM2835_SPI', if_true: files('bcm2835_spi.c')) system_ss.add(when: 'CONFIG_PNV_SPI', if_true: files('pnv_spi.c')) +system_ss.add(when: 'CONFIG_PHYTIUM_E2000_QSPI', if_true: files('phytium_qspi.c'))
hw/ssi/phytium_qspi.c new file +398 -0
398 lines not on this page · raw message
include/hw/ssi/phytium_qspi.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Phytium E2000 QSPI controller +* +* Copyright (c) 2026 Process Mission +* +* Author: +* Bin Meng <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_SSI_PHYTIUM_QSPI_H +#define HW_SSI_PHYTIUM_QSPI_H + +#include "hw/core/sysbus.h" + +#define TYPE_PHYTIUM_E2000_QSPI "phytium-e2000-qspi" +OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000QSPIState, PHYTIUM_E2000_QSPI) + +#define PHYTIUM_E2000_QSPI_REG_SIZE 0x1000 +#define PHYTIUM_E2000_QSPI_DIRECT_SIZE 0x10000000 + +#endif
Signature · 1 line
2.53.0
PATCH 14/33 hw/arm: phytium: Connect the Phytium E2000 QSPI controller
In reply to Bin MengInstantiate QSPI0 at its command and direct-map windows so accesses from E2000 firmware reach the controller model.
---
hw/arm/Kconfig | 1 + hw/arm/phytium_e2000.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+)
hw/arm/Kconfig +1 -0
@@ -136,6 +136,7 @@ config PHYTIUM_E2000 select DW_MCI select PCI_EXPRESS select PCI_EXPRESS_GENERIC_BRIDGE + select PHYTIUM_E2000_QSPI select PL011 select SD select UNIMP
hw/arm/phytium_e2000.c +20 -0
@@ -33,6 +33,7 @@#include "hw/pci-host/gpex.h" #include "hw/sd/phytium_e2000_mci.h" #include "hw/sd/sd.h" +#include "hw/ssi/phytium_qspi.h" #include "net/net.h" #include "qobject/qlist.h" #include "qom/object.h"
@@ -58,9 +59,11 @@ OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000State, PHYTIUM_PI)#define PHYTIUM_E2000_GTIMER_HZ 50000000enum { +PHYTIUM_E2000_QSPI_DIRECT ,PHYTIUM_E2000_LOW_PERIPH ,PHYTIUM_E2000_MCI0 ,PHYTIUM_E2000_MCI1 , +PHYTIUM_E2000_QSPI_REGS ,PHYTIUM_E2000_UART0 ,PHYTIUM_E2000_UART1 ,PHYTIUM_E2000_UART2 ,
@@ -92,6 +95,7 @@ struct PhytiumE2000State {MachineState parent;struct arm_boot_info bootinfo;DeviceState *gic; +DeviceState *qspi;PhytiumE2000MciState *mci[PHYTIUM_E2000_NUM_MCIS ];CadenceGEMState *gem[PHYTIUM_E2000_NUM_GEMS ];MemoryRegion scp_sram;
@@ -105,9 +109,11 @@ struct PhytiumE2000State {* handoff data and IACC is the fixed execution window for system firmware. */ static const MemMapEntry phytium_e2000_memmap[] = { + [PHYTIUM_E2000_QSPI_DIRECT ] = {0x00000000 ,0x10000000 }, [PHYTIUM_E2000_LOW_PERIPH ] = {0x28000000 ,0x00100000 }, [PHYTIUM_E2000_MCI0 ] = {0x28000000 ,0x00001000 }, [PHYTIUM_E2000_MCI1 ] = {0x28001000 ,0x00001000 }, + [PHYTIUM_E2000_QSPI_REGS ] = {0x28008000 ,0x00001000 }, [PHYTIUM_E2000_UART0 ] = {0x2800c000 ,0x00001000 }, [PHYTIUM_E2000_UART1 ] = {0x2800d000 ,0x00001000 }, [PHYTIUM_E2000_UART2 ] = {0x2800e000 ,0x00001000 },
@@ -453,6 +459,18 @@ static void phytium_e2000_create_mci(PhytiumE2000State *s, int index)phytium_e2000_attach_sd_card (DW_MCI (mci), index); } +static void phytium_e2000_create_qspi (PhytiumE2000State *s) +{ +DeviceState *controller =qdev_new (TYPE_PHYTIUM_E2000_QSPI ); + + s->qspi = controller; +sysbus_realize_and_unref (SYS_BUS_DEVICE (controller), &error_fatal); +sysbus_mmio_map_overlap (SYS_BUS_DEVICE (controller),0 , + phytium_e2000_memmap[PHYTIUM_E2000_QSPI_REGS ].base,2 ); +sysbus_mmio_map_overlap (SYS_BUS_DEVICE (controller),1 , + phytium_e2000_memmap[PHYTIUM_E2000_QSPI_DIRECT ].base,2 ); +} +static void phytium_e2000_create_ddr_status (PhytiumE2000State *s) {DeviceState *dev =qdev_new (TYPE_PHYTIUM_E2000_DDR );
@@ -611,6 +629,8 @@ static void phytium_pi_init(MachineState *ms)phytium_e2000_create_ram (s);phytium_e2000_create_unimplemented (); +phytium_e2000_create_qspi (s); +phytium_e2000_create_cpus (s);phytium_e2000_create_gic (s);
Signature · 1 line
2.53.0
PATCH 15/33 hw/misc: Add Phytium E2000 PBR model
In reply to Bin MengModel the E2000 Phytium Boot ROM as a standalone device. Parse the selected fip-all.bin medium and validate its PBF, TF-A FIP, and platform parameter records.
Use the common PBF parameter header to validate exact E2000 PLL, PCIe, DDR/MCU, and COMMON records, their declared sizes, and slot bounds. Stage the opaque records without interpreting service-specific payloads or selecting handoff addresses from their versions.
Locate the embedded TF-A FIP and memmap drivers from their data-structure relationships. Validate the documented vendor-private handoff relations instead of maintaining unexplained firmware-version address tables.
Expose the board strap as a PBR boot-mode property and derive the firmware-visible boot-media status inside the device. Stage IACC, relocate BL1, build the firmware handoff state, and release the primary CPU selected by the firmware. Keep status, boot SRAM, IACC, reset sequencing, and migration state inside the device so board code only supplies topology and the selected boot backend.
---
hw/misc/meson.build | 1 + hw/misc/phytium_e2000_pbr.c | 1221 +++++++++++++++++++++++++++ include/hw/misc/phytium_e2000_pbr.h | 55 ++ 3 files changed, 1277 insertions(+) create mode 100644 hw/misc/phytium_e2000_pbr.c create mode 100644 include/hw/misc/phytium_e2000_pbr.h
hw/misc/meson.build +1 -0
@@ -18,6 +18,7 @@ system_ss.add(when: 'CONFIG_A9SCU', if_true: files('a9scu.c')) system_ss.add(when: 'CONFIG_ARM11SCU', if_true: files('arm11scu.c')) system_ss.add(when: 'CONFIG_PHYTIUM_E2000', if_true: files('phytium_e2000_ddr.c')) system_ss.add(when: 'CONFIG_PHYTIUM_E2000', if_true: files('phytium_e2000_mhu.c')) +system_ss.add(when: 'CONFIG_PHYTIUM_E2000', if_true: files('phytium_e2000_pbr.c')) system_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m_ras.c'))
hw/misc/phytium_e2000_pbr.c new file +1221 -0
1,221 lines not on this page · raw message
include/hw/misc/phytium_e2000_pbr.h new file +55 -0
55 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH 16/33 hw/arm: phytium: Integrate the Phytium E2000 PBR
In reply to Bin MengInstantiate PBR in the Phytium Pi machine, map its status and boot memories, provide the heterogeneous MPIDR topology, and connect all CPU objects for reset-time handoff.
Use SD0 as the board firmware backend. Explicitly reject the unsupported -bios and pflash interfaces.
---
hw/arm/phytium_e2000.c | 97 +++++++++++++++++++++++++++++++++++++++--- 1 file changed, 92 insertions(+), 5 deletions(-)
hw/arm/phytium_e2000.c +92 -5
@@ -13,6 +13,7 @@#include "qemu/error-report.h" #include "qemu/units.h" #include "qapi/error.h" +#include "exec/cpu-common.h" #include "system/address-spaces.h" #include "system/kvm.h" #include "system/system.h"
@@ -20,6 +21,7 @@#include "hw/arm/boot.h" #include "hw/arm/bsa.h" #include "hw/arm/machines-qom.h" +#include "hw/block/flash.h" #include "hw/char/pl011.h" #include "hw/core/boards.h" #include "hw/core/qdev-properties.h"
@@ -27,6 +29,7 @@#include "hw/intc/arm_gicv3_its_common.h" #include "hw/misc/phytium_e2000_ddr.h" #include "hw/misc/phytium_e2000_mhu.h" +#include "hw/misc/phytium_e2000_pbr.h" #include "hw/misc/unimp.h" #include "hw/net/cadence_gem.h" #include "hw/pci/pci.h"
@@ -96,8 +99,10 @@ struct PhytiumE2000State {struct arm_boot_info bootinfo;DeviceState *gic;DeviceState *qspi; +PhytiumE2000PBRState *pbr;PhytiumE2000MciState *mci[PHYTIUM_E2000_NUM_MCIS ];CadenceGEMState *gem[PHYTIUM_E2000_NUM_GEMS ]; +CPUState *cpu[PHYTIUM_E2000_NUM_CPUS ];MemoryRegion scp_sram;MemoryRegion ram_low;MemoryRegion ram_high;
@@ -208,6 +213,17 @@ phytium_e2000_cpu_config[PHYTIUM_E2000_NUM_CPUS] = { }, }; +static uint64_t phytium_e2000_cpu_mp_affinity (unsigned int cpu) +{ +/* +* E2000Q exposes one core in each of the first two clusters and two cores +* in the third cluster. Firmware stores these MPIDRs in its parameter +* tables, so a linear CPU index is not a valid affinity value. +*/ +g_assert (cpu <ARRAY_SIZE (phytium_e2000_cpu_config)); +return phytium_e2000_cpu_config[cpu].mp_affinity; +} +static void phytium_e2000_create_its (PhytiumE2000State *s) {DeviceState *dev =qdev_new (its_class_name ());
@@ -410,6 +426,15 @@ static void phytium_e2000_create_pcie(PhytiumE2000State *s) } } +static void phytium_e2000_reject_legacy_firmware (MachineState *ms) +{ +if (ms->firmware ||drive_get (IF_PFLASH ,0 ,0 )) { +error_report ("phytium-pi: -bios and pflash firmware are not " +"supported; use an if=sd,index=0 image" ); +exit (1 ); + } +} +static BlockBackend *phytium_e2000_sd_blk (int index) {DriveInfo *dinfo =drive_get (IF_SD ,0 , index);
@@ -471,6 +496,47 @@ static void phytium_e2000_create_qspi(PhytiumE2000State *s) phytium_e2000_memmap[PHYTIUM_E2000_QSPI_DIRECT].base, 2); } +static bool phytium_e2000_create_pbr (PhytiumE2000State *s) +{ +MachineState *ms =MACHINE (s); +DeviceState *dev =qdev_new (TYPE_PHYTIUM_E2000_PBR ); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); +BlockBackend *boot_blk =NULL ; +uint64_t cpu_mpidrs[PHYTIUM_E2000_NUM_CPUS ]; +int i; + +if (!ms->kernel_filename) { + boot_blk =phytium_e2000_sd_blk (0 ); + } + +for (i =0 ; i < ms->smp.cpus; i++) { + cpu_mpidrs[i] =phytium_e2000_cpu_mp_affinity (i); + } + +qdev_prop_set_string (dev,"boot-mode" , +PHYTIUM_E2000_PBR_BOOT_MODE_SD0 ); +phytium_e2000_pbr_configure (PHYTIUM_E2000_PBR (dev), boot_blk, + phytium_e2000_memmap[ +PHYTIUM_E2000_RAM ].base, + ms->ram_size, cpu_mpidrs, ms->smp.cpus); + +/* +* PBR owns the status snapshot and both boot memories. The status block +* overlaps the broad board-control placeholder and therefore needs the +* higher mapping priority used by the previous status-only device. +*/ +object_property_add_child (OBJECT (s),"pbr" ,OBJECT (dev)); +sysbus_realize_and_unref (sbd, &error_fatal); +sysbus_mmio_map_overlap (sbd,0 ,PHYTIUM_E2000_PBR_STATUS_BASE ,2 ); +sysbus_mmio_map (sbd,1 , + phytium_e2000_memmap[PHYTIUM_E2000_BOOT_SRAM ].base); +sysbus_mmio_map (sbd,2 , + phytium_e2000_memmap[PHYTIUM_E2000_BOOT_IACC ].base); + s->pbr =PHYTIUM_E2000_PBR (dev); + +return phytium_e2000_pbr_firmware_loaded (s->pbr); +} +static void phytium_e2000_create_ddr_status (PhytiumE2000State *s) {DeviceState *dev =qdev_new (TYPE_PHYTIUM_E2000_DDR );
@@ -570,7 +636,8 @@ static void phytium_e2000_create_ram(PhytiumE2000State *s) phytium_e2000_memmap[PHYTIUM_E2000_RAM_HIGH].base, &s->ram_high); } -static void phytium_e2000_create_cpus (PhytiumE2000State *s) +static void phytium_e2000_create_cpus (PhytiumE2000State *s, +bool firmware_loaded) {MachineState *ms =MACHINE (s);const CPUArchIdList *possible_cpus;
@@ -587,18 +654,30 @@ static void phytium_e2000_create_cpus(PhytiumE2000State *s) &error_abort);object_property_set_int (cpuobj,"cntfrq" ,PHYTIUM_E2000_GTIMER_HZ , &error_abort); -if (object_property_find (cpuobj,"has_el3" )) { +if (!firmware_loaded &&object_property_find (cpuobj,"has_el3" )) {/* * The generic-loader U-Boot path starts after the EL3 firmware * stages that normally provide the Phytium SMC services. */ object_property_set_bool (cpuobj,"has_el3" , false, &error_abort); } +/* +* PBR releases only the primary MPIDR named in the firmware parameter +* header. Secondary CPUs remain powered off for later firmware or +* PSCI bring-up. +*/ +if (firmware_loaded && + i !=phytium_e2000_pbr_primary_cpu (s->pbr)) { +object_property_set_bool (cpuobj,"start-powered-off" , true, + &error_abort); + }object_property_set_link (cpuobj,"memory" ,OBJECT (get_system_memory ()), &error_abort); cs =CPU (cpuobj); cs->cpu_index = i;qdev_realize (DEVICE (cpuobj),NULL , &error_fatal); + s->cpu[i] = cs; +phytium_e2000_pbr_connect_cpu (s->pbr, i, cs);object_unref (cpuobj); } }
@@ -606,6 +685,7 @@ static void phytium_e2000_create_cpus(PhytiumE2000State *s)static void phytium_pi_init (MachineState *ms) {PhytiumE2000State *s =PHYTIUM_PI (ms); +bool firmware_loaded;int i;if (kvm_enabled ()) {
@@ -626,12 +706,15 @@ static void phytium_pi_init(MachineState *ms)exit (1 ); } +phytium_e2000_reject_legacy_firmware (ms); +phytium_e2000_create_ram (s);phytium_e2000_create_unimplemented ();phytium_e2000_create_qspi (s); + firmware_loaded =phytium_e2000_create_pbr (s); -phytium_e2000_create_cpus (s); +phytium_e2000_create_cpus (s, firmware_loaded);phytium_e2000_create_gic (s);phytium_e2000_create_scp_sram (s);
@@ -654,7 +737,7 @@ static void phytium_pi_init(MachineState *ms) s->bootinfo.board_id =-1 ; s->bootinfo.loader_start = phytium_e2000_memmap[PHYTIUM_E2000_RAM ].base; s->bootinfo.psci_conduit =QEMU_PSCI_CONDUIT_SMC ; - s->bootinfo.firmware_loaded = false; + s->bootinfo.firmware_loaded = firmware_loaded;arm_load_kernel (ARM_CPU (first_cpu), ms, &s->bootinfo); }
@@ -701,7 +784,11 @@ static void phytium_pi_class_init(ObjectClass *oc, const void *data) mc->valid_cpu_types = valid_cpu_types; mc->max_cpus =PHYTIUM_E2000_NUM_CPUS ; mc->default_cpus =PHYTIUM_E2000_NUM_CPUS ; - mc->default_ram_size =1 * GiB; +/* +* PBF/BL1 relocates to 0xf8c40000, which is outside a 1 GiB RAM window +* starting at 0x80000000. Two GiB is the minimum useful firmware default. +*/ + mc->default_ram_size =2 * GiB; mc->default_ram_id ="phytium-e2000.ram" ; mc->minimum_page_bits =12 ; mc->block_default_type =IF_SD ;
Signature · 1 line
2.53.0
PATCH 17/33 hw/arm: phytium: Add Phytium E2000 control region placeholders
In reply to Bin MengThe vendor PBF accesses clock, reset, platform, security, and chip control windows while bringing up the SoC.
Expose these windows as low-priority unimplemented regions. This keeps the firmware-visible address map observable and allows later device models to overlap individual windows without inventing register semantics.
---
hw/arm/phytium_e2000.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
hw/arm/phytium_e2000.c +35 -0
@@ -74,6 +74,8 @@ enum {PHYTIUM_E2000_UART4 ,PHYTIUM_E2000_UART5 ,PHYTIUM_E2000_UART6 , +PHYTIUM_E2000_CLK_CTRL , +PHYTIUM_E2000_SYSTEM_CTRL ,PHYTIUM_E2000_GIC_DIST ,PHYTIUM_E2000_GIC_ITS , PHYTIUM_E2000_GIC_REDIST,
@@ -85,6 +87,9 @@ enum {PHYTIUM_E2000_GEM1 ,PHYTIUM_E2000_GEM2 ,PHYTIUM_E2000_GEM3 , +PHYTIUM_E2000_PLATFORM_CTRL , +PHYTIUM_E2000_SECURITY_CTRL , +PHYTIUM_E2000_CHIP_CTRL ,PHYTIUM_E2000_BOOT_IACC ,PHYTIUM_E2000_PCIE_ECAM , PHYTIUM_E2000_PCIE_PIO,
@@ -126,6 +131,8 @@ static const MemMapEntry phytium_e2000_memmap[] = { [PHYTIUM_E2000_UART4] = { 0x28014000, 0x00001000 }, [PHYTIUM_E2000_UART5] = { 0x2802a000, 0x00001000 }, [PHYTIUM_E2000_UART6] = { 0x28032000, 0x00001000 }, + [PHYTIUM_E2000_CLK_CTRL] = { 0x28100000, 0x00001000 }, + [PHYTIUM_E2000_SYSTEM_CTRL] = { 0x30000000, 0x00001000 }, [PHYTIUM_E2000_GIC_DIST] = { 0x30800000, 0x00020000 }, [PHYTIUM_E2000_GIC_ITS] = { 0x30820000, 0x00020000 }, [PHYTIUM_E2000_GIC_REDIST] = { 0x30880000, 0x00080000 },
@@ -137,6 +144,9 @@ static const MemMapEntry phytium_e2000_memmap[] = { [PHYTIUM_E2000_GEM1] = { 0x3200e000, 0x00002000 }, [PHYTIUM_E2000_GEM2] = { 0x32010000, 0x00002000 }, [PHYTIUM_E2000_GEM3] = { 0x32012000, 0x00002000 }, + [PHYTIUM_E2000_PLATFORM_CTRL] = { 0x32e40000, 0x00010000 }, + [PHYTIUM_E2000_SECURITY_CTRL] = { 0x32f00000, 0x00001000 }, + [PHYTIUM_E2000_CHIP_CTRL] = { 0x33000000, 0x00010000 }, [PHYTIUM_E2000_BOOT_IACC] = { 0x38000000, 0x08000000 }, [PHYTIUM_E2000_PCIE_ECAM] = { 0x40000000, 0x10000000 }, [PHYTIUM_E2000_PCIE_PIO] = { 0x50000000, 0x00f00000 },
@@ -590,6 +600,19 @@ static void phytium_e2000_create_unimplemented(void)"phytium-e2000.low-peripheral" , phytium_e2000_memmap[PHYTIUM_E2000_LOW_PERIPH ].base, phytium_e2000_memmap[PHYTIUM_E2000_LOW_PERIPH].size); +/* +* PBF writes clock and reset controls as part of physical SoC bring-up. +* QEMU derives virtual clocks and reset state elsewhere, so retaining +* placeholder visibility is sufficient for these write-only setup paths. +*/ +create_unimplemented_device ( +"phytium-e2000.clock-control" , + phytium_e2000_memmap[PHYTIUM_E2000_CLK_CTRL ].base, + phytium_e2000_memmap[PHYTIUM_E2000_CLK_CTRL ].size); +create_unimplemented_device ( +"phytium-e2000.system-control" , + phytium_e2000_memmap[PHYTIUM_E2000_SYSTEM_CTRL ].base, + phytium_e2000_memmap[PHYTIUM_E2000_SYSTEM_CTRL ].size);/* * PBF programs SoC-specific PCIe PHY and port controls before U-Boot * enumerates ECAM. Their values do not affect the generic host bridge, so
@@ -607,6 +630,18 @@ static void phytium_e2000_create_unimplemented(void)"phytium-e2000.board-control" , phytium_e2000_memmap[PHYTIUM_E2000_BOARD_CTRL ].base, phytium_e2000_memmap[PHYTIUM_E2000_BOARD_CTRL].size); +create_unimplemented_device ( +"phytium-e2000.platform-control" , + phytium_e2000_memmap[PHYTIUM_E2000_PLATFORM_CTRL ].base, + phytium_e2000_memmap[PHYTIUM_E2000_PLATFORM_CTRL ].size); +create_unimplemented_device ( +"phytium-e2000.security-control" , + phytium_e2000_memmap[PHYTIUM_E2000_SECURITY_CTRL ].base, + phytium_e2000_memmap[PHYTIUM_E2000_SECURITY_CTRL ].size); +create_unimplemented_device ( +"phytium-e2000.chip-control" , + phytium_e2000_memmap[PHYTIUM_E2000_CHIP_CTRL ].base, + phytium_e2000_memmap[PHYTIUM_E2000_CHIP_CTRL ].size); }static void phytium_e2000_create_ram (PhytiumE2000State *s)
Signature · 1 line
2.53.0
PATCH 18/33 hw/misc: Support Phytium E2000 SCMI CPU power control
In reply to Bin MengThe E2000 MHU previously acknowledged every SCMI message without applying power-state changes. Consequently, BL31 reported successful PSCI CPU_ON calls while all secondary CPUs remained powered off.
Implement the power-domain requests and the Phytium PSOSTAT query used by the firmware. Follow the firmware-published runtime object graph, complete its SCP handoff, and reset each target CPU at the resident secondary entry published by BL1.
The secondary handoff is not described by the public PBF specifications. Scan BL1 for invariant control-flow, MPIDR, and PBR-root anchors while masking compiler-dependent branch displacements, then obtain the firmware-owned vector-slot address from the adjacent literal. Reject missing, ambiguous, unaligned, or null handoff records.
Pass the validated slot from PBR to MHU and dereference it for every CPU_ON request because firmware may publish the entry after boot and reuse the temporary BL1 image before Linux starts secondary CPUs.
With this change, booting from SDK firmware images can bring up all four cores successfully.
---
hw/arm/phytium_e2000.c | 18 ++ hw/misc/phytium_e2000_mhu.c | 384 ++++++++++++++++++++++++++-- hw/misc/phytium_e2000_pbr.c | 153 ++++++++++- include/hw/misc/phytium_e2000_mhu.h | 9 + include/hw/misc/phytium_e2000_pbr.h | 7 + 5 files changed, 543 insertions(+), 28 deletions(-)
hw/arm/phytium_e2000.c +18 -0
@@ -579,12 +579,30 @@ static void phytium_e2000_create_mhu(PhytiumE2000State *s) {DeviceState *dev =qdev_new (TYPE_PHYTIUM_E2000_MHU );SysBusDevice *sbd =SYS_BUS_DEVICE (dev); +int i;/* * MHU is the notification side of the SCMI transport. The message body * remains in SCP SRAM, so this device only owns the doorbell aperture. */ object_property_add_child (OBJECT (s),"mhu" ,OBJECT (dev)); +if (phytium_e2000_pbr_firmware_loaded (s->pbr)) { +/* +* PBR validates the firmware-specific BL1 handoff and owns all FIP +* interpretation. Pass only the resulting slot address to MHU; the +* transport must not parse firmware or assume a PBF build layout. +* Direct Linux boot has no firmware SCMI CPU_ON path and therefore +* intentionally leaves the slot unset. +*/ +phytium_e2000_mhu_set_secondary_vector_slot ( +PHYTIUM_E2000_MHU (dev), +phytium_e2000_pbr_secondary_vector_slot (s->pbr)); + } +for (i =0 ; i <MACHINE (s)->smp.cpus; i++) { +phytium_e2000_mhu_connect_cpu (PHYTIUM_E2000_MHU (dev), i, +phytium_e2000_cpu_mp_affinity (i), + s->cpu[i]); + }sysbus_realize_and_unref (sbd, &error_fatal);sysbus_mmio_map_overlap (sbd,0 ,PHYTIUM_E2000_MHU_BASE ,2 ); }
hw/misc/phytium_e2000_mhu.c +360 -24
453 lines not on this page · raw message
hw/misc/phytium_e2000_pbr.c +149 -4
196 lines not on this page · raw message
include/hw/misc/phytium_e2000_mhu.h +9 -0
@@ -12,14 +12,23 @@#ifndef HW_MISC_PHYTIUM_E2000_MHU_H #define HW_MISC_PHYTIUM_E2000_MHU_H +#include "hw/core/cpu.h" #include "hw/core/sysbus.h" +#include "hw/misc/phytium_e2000_pbr.h" #include "qom/object.h" #define TYPE_PHYTIUM_E2000_MHU "phytium-e2000-mhu" OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000MHUState, PHYTIUM_E2000_MHU)#define PHYTIUM_E2000_MHU_MMIO_SIZE 0x1000 +#define PHYTIUM_E2000_MHU_MAX_CPUS 4void phytium_e2000_mhu_seed_mailbox (void ); +void phytium_e2000_mhu_connect_cpu (PhytiumE2000MHUState *s, +unsigned int index,uint64_t mpidr, +CPUState *cpu); +/* Configure the PBR-validated, firmware-owned secondary-vector slot */ +void phytium_e2000_mhu_set_secondary_vector_slot (PhytiumE2000MHUState *s, +hwaddr slot);#endif
include/hw/misc/phytium_e2000_pbr.h +7 -0
@@ -35,6 +35,11 @@ OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000PBRState, PHYTIUM_E2000_PBR)#define PHYTIUM_E2000_PBR_BOOT_SRAM_SIZE 0x00100000#define PHYTIUM_E2000_PBR_IACC_SIZE 0x08000000#define PHYTIUM_E2000_PBR_MAX_CPUS 4 +#define PHYTIUM_E2000_PBR_ROOT \ + (PHYTIUM_E2000_PBR_BOOT_SRAM_BASE + 0x1000) +#define PHYTIUM_E2000_PBR_CPU_CONTROL \ + (PHYTIUM_E2000_PBR_BOOT_SRAM_BASE + 0x2000) +#define PHYTIUM_E2000_PBR_CPU_CONTROL_MAGIC 0xffaabbcc#define PHYTIUM_E2000_PBR_BOOT_MEDIA_QSPI 0x1#define PHYTIUM_E2000_PBR_BOOT_MEDIA_SD0 0x4
@@ -49,6 +54,8 @@ void phytium_e2000_pbr_configure(PhytiumE2000PBRState *s, unsigned int num_cpus);bool phytium_e2000_pbr_firmware_loaded (PhytiumE2000PBRState *s);int phytium_e2000_pbr_primary_cpu (PhytiumE2000PBRState *s); +/* Return the firmware-owned slot address, not its runtime entry value */ +hwaddr phytium_e2000_pbr_secondary_vector_slot (PhytiumE2000PBRState *s);void phytium_e2000_pbr_connect_cpu (PhytiumE2000PBRState *s,unsigned int index,CPUState *cpu);
Signature · 1 line
2.53.0
PATCH 19/33 hw/arm: phytium: Select the Phytium E2000 PBR boot medium
In reply to Bin MengIntroduce an abstract E2000 machine class and keep the Phytium Pi board strap fixed to SD0. Pass the selected backend and boot-mode property to the PBR device so firmware-visible boot-media state is owned by PBR rather than a user-settable machine option.
The class-level selection also provides the board-specific hook required by a later E2000Q COMe machine without allowing either board to change its physical boot strap.
---
hw/arm/phytium_e2000.c | 84 +++++++++++++++++++++++++++++++----------- 1 file changed, 62 insertions(+), 22 deletions(-)
hw/arm/phytium_e2000.c +62 -22
@@ -44,8 +44,12 @@#include "target/arm/cpu-qom.h" #include "target/arm/gtimer.h" +#define TYPE_PHYTIUM_E2000_MACHINE \ + MACHINE_TYPE_NAME("phytium-e2000-base") +OBJECT_DECLARE_TYPE (PhytiumE2000State, PhytiumE2000MachineClass, + PHYTIUM_E2000_MACHINE) +#define TYPE_PHYTIUM_PI MACHINE_TYPE_NAME("phytium-pi") -OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000State, PHYTIUM_PI)#define PHYTIUM_E2000_NUM_CPUS 4#define PHYTIUM_E2000_NUM_IRQS 256
@@ -100,7 +104,7 @@ enum { };struct PhytiumE2000State { -MachineState parent; +MachineState parent_obj;struct arm_boot_info bootinfo;DeviceState *gic;DeviceState *qspi;
@@ -113,6 +117,13 @@ struct PhytiumE2000State {MemoryRegion ram_high; }; +struct PhytiumE2000MachineClass { +MachineClass parent_class; + +const char *machine_name; +const char *pbr_boot_mode; +}; +/* * Keep the physical addresses used by the vendor firmware even before every * device behind them is modeled. In particular, boot SRAM carries PBR/PBF
@@ -436,11 +447,16 @@ static void phytium_e2000_create_pcie(PhytiumE2000State *s) } } -static void phytium_e2000_reject_legacy_firmware (MachineState *ms) +static void phytium_e2000_reject_legacy_firmware ( +MachineState *ms,PhytiumE2000MachineClass *pemc) {if (ms->firmware ||drive_get (IF_PFLASH ,0 ,0 )) { -error_report ("phytium-pi: -bios and pflash firmware are not " -"supported; use an if=sd,index=0 image" ); +error_report ("%s: -bios and pflash firmware are not supported; " +"use an if=%s,index=0 image" , + pemc->machine_name, + !strcmp (pemc->pbr_boot_mode, +PHYTIUM_E2000_PBR_BOOT_MODE_QSPI ) ? +"mtd" :"sd" );exit (1 ); } }
@@ -509,13 +525,17 @@ static void phytium_e2000_create_qspi(PhytiumE2000State *s)static bool phytium_e2000_create_pbr (PhytiumE2000State *s) {MachineState *ms =MACHINE (s); +PhytiumE2000MachineClass *pemc = +PHYTIUM_E2000_MACHINE_GET_CLASS (s);DeviceState *dev =qdev_new (TYPE_PHYTIUM_E2000_PBR );SysBusDevice *sbd =SYS_BUS_DEVICE (dev);BlockBackend *boot_blk =NULL ;uint64_t cpu_mpidrs[PHYTIUM_E2000_NUM_CPUS ];int i; -if (!ms->kernel_filename) { +if (!ms->kernel_filename && + !strcmp (pemc->pbr_boot_mode, +PHYTIUM_E2000_PBR_BOOT_MODE_SD0 )) { boot_blk =phytium_e2000_sd_blk (0 ); }
@@ -523,8 +543,7 @@ static bool phytium_e2000_create_pbr(PhytiumE2000State *s) cpu_mpidrs[i] =phytium_e2000_cpu_mp_affinity (i); } -qdev_prop_set_string (dev,"boot-mode" , -PHYTIUM_E2000_PBR_BOOT_MODE_SD0 ); +qdev_prop_set_string (dev,"boot-mode" , pemc->pbr_boot_mode); phytium_e2000_pbr_configure(PHYTIUM_E2000_PBR(dev), boot_blk, phytium_e2000_memmap[ PHYTIUM_E2000_RAM].base,
@@ -735,19 +754,21 @@ static void phytium_e2000_create_cpus(PhytiumE2000State *s, } } -static void phytium_pi_init (MachineState *ms) +static void phytium_e2000_init (MachineState *ms) { -PhytiumE2000State *s =PHYTIUM_PI (ms); +PhytiumE2000State *s =PHYTIUM_E2000_MACHINE (ms); +PhytiumE2000MachineClass *pemc = +PHYTIUM_E2000_MACHINE_GET_CLASS (ms);bool firmware_loaded;int i;if (kvm_enabled ()) { -error_report ("phytium-pi: KVM is not supported" ); +error_report ("%s: KVM is not supported" , pemc->machine_name);exit (1 ); }if (ms->smp.cpus >PHYTIUM_E2000_NUM_CPUS ) { -error_report ("phytium-pi supports at most %d CPUs" , +error_report ("%s supports at most %d CPUs" , pemc->machine_name,PHYTIUM_E2000_NUM_CPUS );exit (1 ); }
@@ -755,11 +776,11 @@ static void phytium_pi_init(MachineState *ms)if (ms->ram_size > phytium_e2000_memmap[PHYTIUM_E2000_RAM ].size + phytium_e2000_memmap[PHYTIUM_E2000_RAM_HIGH ].size) { -error_report ("phytium-pi supports at most 8 GiB RAM" ); +error_report ("%s supports at most 8 GiB RAM" , pemc->machine_name);exit (1 ); } -phytium_e2000_reject_legacy_firmware (ms); +phytium_e2000_reject_legacy_firmware (ms, pemc);phytium_e2000_create_ram (s);phytium_e2000_create_unimplemented ();
@@ -822,7 +843,7 @@ static const CPUArchIdList *phytium_e2000_possible_cpu_arch_ids(MachineState *msreturn ms->possible_cpus; } -static void phytium_pi_class_init (ObjectClass *oc,const void *data) +static void phytium_e2000_class_init (ObjectClass *oc,const void *data) {MachineClass *mc =MACHINE_CLASS (oc);static const char *const valid_cpu_types[] = {
@@ -831,8 +852,7 @@ static void phytium_pi_class_init(ObjectClass *oc, const void *data) NULL, }; - mc->init = phytium_pi_init; - mc->desc ="Phytium Pi board (Phytium E2000Q)" ; + mc->init = phytium_e2000_init; mc->default_cpu_type =ARM_CPU_TYPE_NAME ("phytium-ftc664" ); mc->valid_cpu_types = valid_cpu_types; mc->max_cpus =PHYTIUM_E2000_NUM_CPUS ;
@@ -844,22 +864,42 @@ static void phytium_pi_class_init(ObjectClass *oc, const void *data) mc->default_ram_size =2 * GiB; mc->default_ram_id ="phytium-e2000.ram" ; mc->minimum_page_bits =12 ; - mc->block_default_type =IF_SD ; mc->no_cdrom =1 ; mc->possible_cpu_arch_ids = phytium_e2000_possible_cpu_arch_ids; } +static void phytium_pi_class_init (ObjectClass *oc,const void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); +PhytiumE2000MachineClass *pemc = +PHYTIUM_E2000_MACHINE_CLASS (oc); + + mc->desc ="Phytium Pi board (Phytium E2000Q)" ; + mc->block_default_type =IF_SD ; + pemc->machine_name ="phytium-pi" ; + pemc->pbr_boot_mode =PHYTIUM_E2000_PBR_BOOT_MODE_SD0 ; +} + +static const TypeInfo phytium_e2000_base_info = { + .name =TYPE_PHYTIUM_E2000_MACHINE , + .parent =TYPE_MACHINE , + .abstract = true, + .class_init = phytium_e2000_class_init, + .class_size =sizeof (PhytiumE2000MachineClass), + .instance_size =sizeof (PhytiumE2000State), +}; +static const TypeInfo phytium_pi_info = { .name =TYPE_PHYTIUM_PI , - .parent =TYPE_MACHINE , + .parent =TYPE_PHYTIUM_E2000_MACHINE , .class_init = phytium_pi_class_init, - .instance_size =sizeof (PhytiumE2000State), .interfaces = aarch64_machine_interfaces, }; -static void phytium_pi_machine_init (void ) +static void phytium_e2000_machine_init (void ) { +type_register_static (&phytium_e2000_base_info);type_register_static (&phytium_pi_info); } -type_init (phytium_pi_machine_init); +type_init (phytium_e2000_machine_init);
Signature · 1 line
2.53.0
PATCH 20/33 hw/arm: phytium: Connect the Phytium E2000 I2C controller
In reply to Bin MengInstantiate DesignWare-compatible I2C controller in the shared E2000 machine initialization and wire its documented interrupt.
Leave board-specific I2C slave devices unmodeled.
---
hw/arm/Kconfig | 1 + hw/arm/phytium_e2000.c | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+)
hw/arm/Kconfig +1 -0
@@ -133,6 +133,7 @@ config PHYTIUM_E2000 imply PCI_DEVICES select ARM_GIC select CADENCE + select DESIGNWARE_I2C select DW_MCI select PCI_EXPRESS select PCI_EXPRESS_GENERIC_BRIDGE
hw/arm/phytium_e2000.c +19 -0
@@ -27,6 +27,7 @@#include "hw/core/qdev-properties.h" #include "hw/intc/arm_gicv3_common.h" #include "hw/intc/arm_gicv3_its_common.h" +#include "hw/i2c/designware_i2c.h" #include "hw/misc/phytium_e2000_ddr.h" #include "hw/misc/phytium_e2000_mhu.h" #include "hw/misc/phytium_e2000_pbr.h"
@@ -78,6 +79,7 @@ enum {PHYTIUM_E2000_UART4 ,PHYTIUM_E2000_UART5 ,PHYTIUM_E2000_UART6 , +PHYTIUM_E2000_I2C ,PHYTIUM_E2000_CLK_CTRL ,PHYTIUM_E2000_SYSTEM_CTRL , PHYTIUM_E2000_GIC_DIST,
@@ -141,6 +143,7 @@ static const MemMapEntry phytium_e2000_memmap[] = { [PHYTIUM_E2000_UART3] = { 0x2800f000, 0x00001000 }, [PHYTIUM_E2000_UART4] = { 0x28014000, 0x00001000 }, [PHYTIUM_E2000_UART5] = { 0x2802a000, 0x00001000 }, + [PHYTIUM_E2000_I2C] = { 0x28030000, 0x00001000 }, [PHYTIUM_E2000_UART6] = { 0x28032000, 0x00001000 }, [PHYTIUM_E2000_CLK_CTRL] = { 0x28100000, 0x00001000 }, [PHYTIUM_E2000_SYSTEM_CTRL] = { 0x30000000, 0x00001000 },
@@ -182,6 +185,8 @@ static const int phytium_e2000_uart_irqmap[] = { [6] = 107, }; +static const int phytium_e2000_i2c_irq =106 ; +static const uint8_t phytium_e2000_gem_num_queues[] = {8 ,4 ,4 ,4 };static const int phytium_e2000_gem_irqmap[PHYTIUM_E2000_NUM_GEMS ]
@@ -328,6 +333,19 @@ static void phytium_e2000_create_uart(PhytiumE2000State *s, int index) qdev_get_gpio_in(s->gic, phytium_e2000_uart_irqmap[index])); } +static void phytium_e2000_create_i2c (PhytiumE2000State *s) +{ +DeviceState *dev =qdev_new (TYPE_DESIGNWARE_I2C ); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); + +object_property_add_child (OBJECT (s),"i2c" ,OBJECT (dev)); +sysbus_realize_and_unref (sbd, &error_fatal); +sysbus_mmio_map_overlap (sbd,0 , + phytium_e2000_memmap[PHYTIUM_E2000_I2C ].base,1 ); +sysbus_connect_irq (sbd,0 , +qdev_get_gpio_in (s->gic, phytium_e2000_i2c_irq)); +} +static void phytium_e2000_create_gem (PhytiumE2000State *s,int index) {DeviceState *dev =qdev_new (TYPE_CADENCE_GEM );
@@ -801,6 +819,7 @@ static void phytium_e2000_init(MachineState *ms)for (i =0 ; i <PHYTIUM_E2000_NUM_UARTS ; i++) {phytium_e2000_create_uart (s, i); } +phytium_e2000_create_i2c (s);for (i =0 ; i <PHYTIUM_E2000_NUM_GEMS ; i++) {phytium_e2000_create_gem (s, i); }
Signature · 1 line
2.53.0
PATCH 21/33 hw/arm: phytium: Add Phytium E2000 xHCI controllers
In reply to Bin MengInstantiate two sysbus xHCI controllers at the documented addresses and wire their single interrupts to the GIC. Match the platform quirk by disabling streams and expose one paired USB 2.0/3.0 root port per controller.
---
hw/arm/Kconfig | 1 + hw/arm/phytium_e2000.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+)
hw/arm/Kconfig +1 -0
@@ -141,6 +141,7 @@ config PHYTIUM_E2000 select PL011 select SD select UNIMP + select USB_XHCI_SYSBUS config REALVIEW bool
hw/arm/phytium_e2000.c +34 -0
@@ -38,6 +38,7 @@#include "hw/sd/phytium_e2000_mci.h" #include "hw/sd/sd.h" #include "hw/ssi/phytium_qspi.h" +#include "hw/usb/xhci.h" #include "net/net.h" #include "qobject/qlist.h" #include "qom/object.h"
@@ -57,6 +58,7 @@ OBJECT_DECLARE_TYPE(PhytiumE2000State, PhytiumE2000MachineClass,#define PHYTIUM_E2000_NUM_MCIS 2#define PHYTIUM_E2000_NUM_UARTS 7 +#define PHYTIUM_E2000_NUM_XHCIS 2#define PHYTIUM_E2000_NUM_GEMS 4#define PHYTIUM_E2000_MHU_BASE 0x32a00000
@@ -89,6 +91,8 @@ enum {PHYTIUM_E2000_PCIE_CTRL ,PHYTIUM_E2000_PCIE_PHY_CTRL ,PHYTIUM_E2000_BOARD_CTRL , +PHYTIUM_E2000_XHCI0 , +PHYTIUM_E2000_XHCI1 ,PHYTIUM_E2000_GEM0 ,PHYTIUM_E2000_GEM1 , PHYTIUM_E2000_GEM2,
@@ -154,6 +158,8 @@ static const MemMapEntry phytium_e2000_memmap[] = { [PHYTIUM_E2000_PCIE_CTRL] = { 0x31000000, 0x00200000 }, [PHYTIUM_E2000_PCIE_PHY_CTRL] = { 0x31500000, 0x00001000 }, [PHYTIUM_E2000_BOARD_CTRL] = { 0x31800000, 0x01400000 }, + [PHYTIUM_E2000_XHCI0] = { 0x31a08000, 0x00018000 }, + [PHYTIUM_E2000_XHCI1] = { 0x31a28000, 0x00018000 }, [PHYTIUM_E2000_GEM0] = { 0x3200c000, 0x00002000 }, [PHYTIUM_E2000_GEM1] = { 0x3200e000, 0x00002000 }, [PHYTIUM_E2000_GEM2] = { 0x32010000, 0x00002000 },
@@ -187,6 +193,11 @@ static const int phytium_e2000_uart_irqmap[] = {static const int phytium_e2000_i2c_irq =106 ; +static const int phytium_e2000_xhci_irqmap[] = { + [0 ] =16 , + [1 ] =17 , +}; +static const uint8_t phytium_e2000_gem_num_queues[] = {8 ,4 ,4 ,4 };static const int phytium_e2000_gem_irqmap[PHYTIUM_E2000_NUM_GEMS ]
@@ -383,6 +394,26 @@ static void phytium_e2000_create_gem(PhytiumE2000State *s, int index) } } +static void phytium_e2000_create_xhci (PhytiumE2000State *s,int index) +{ +int map_idx =PHYTIUM_E2000_XHCI0 + index; +DeviceState *dev =qdev_new (TYPE_XHCI_SYSBUS ); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); + g_autofree char *name = g_strdup_printf("xhci%d", index); + +object_property_add_child (OBJECT (s), name,OBJECT (dev)); +qdev_prop_set_uint32 (dev,"intrs" ,1 ); +qdev_prop_set_uint32 (dev,"slots" ,XHCI_MAXSLOTS ); +qdev_prop_set_uint32 (dev,"p2" ,1 ); +qdev_prop_set_uint32 (dev,"p3" ,1 ); +qdev_prop_set_bit (dev,"streams" , false); +sysbus_realize_and_unref (sbd, &error_fatal); +sysbus_mmio_map_overlap ( + sbd,0 , phytium_e2000_memmap[map_idx].base,2 ); +sysbus_connect_irq (sbd,0 , +qdev_get_gpio_in (s->gic, phytium_e2000_xhci_irqmap[index])); +} +/* The vendor DT maps root-bus INTx solely by pin */ static int phytium_e2000_pcie_map_irq (PCIDevice *pdev,int pin) {
@@ -820,6 +851,9 @@ static void phytium_e2000_init(MachineState *ms)phytium_e2000_create_uart (s, i); }phytium_e2000_create_i2c (s); +for (i =0 ; i <PHYTIUM_E2000_NUM_XHCIS ; i++) { +phytium_e2000_create_xhci (s, i); + }for (i =0 ; i <PHYTIUM_E2000_NUM_GEMS ; i++) {phytium_e2000_create_gem (s, i); }
Signature · 1 line
2.53.0
PATCH 22/33 hw/misc: Model the Phytium E2000 random generator
In reply to Bin MengImplement the polled control, mode, status, data, and reseed registers for the E2000 hardware RNG. Use the guest random source for data and preserve deterministic replay.
---
hw/misc/meson.build | 1 + hw/misc/phytium_e2000_rng.c | 182 ++++++++++++++++++++++++++++ include/hw/misc/phytium_e2000_rng.h | 23 ++++ 3 files changed, 206 insertions(+) create mode 100644 hw/misc/phytium_e2000_rng.c create mode 100644 include/hw/misc/phytium_e2000_rng.h
hw/misc/meson.build +1 -0
@@ -19,6 +19,7 @@ system_ss.add(when: 'CONFIG_ARM11SCU', if_true: files('arm11scu.c')) system_ss.add(when: 'CONFIG_PHYTIUM_E2000', if_true: files('phytium_e2000_ddr.c')) system_ss.add(when: 'CONFIG_PHYTIUM_E2000', if_true: files('phytium_e2000_mhu.c')) system_ss.add(when: 'CONFIG_PHYTIUM_E2000', if_true: files('phytium_e2000_pbr.c')) +system_ss.add(when: 'CONFIG_PHYTIUM_E2000', if_true: files('phytium_e2000_rng.c')) system_ss.add(when: 'CONFIG_ARM_V7M', if_true: files('armv7m_ras.c'))
hw/misc/phytium_e2000_rng.c new file +182 -0
182 lines not on this page · raw message
include/hw/misc/phytium_e2000_rng.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* Phytium E2000 random number generator +* +* Copyright (c) 2026 Process Mission +* +* Author: +* Bin Meng <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0-or-later +*/ + +#ifndef HW_MISC_PHYTIUM_E2000_RNG_H +#define HW_MISC_PHYTIUM_E2000_RNG_H + +#include "hw/core/sysbus.h" +#include "qom/object.h" + +#define TYPE_PHYTIUM_E2000_RNG "phytium-e2000-rng" +OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000RNGState, PHYTIUM_E2000_RNG) + +#define PHYTIUM_E2000_RNG_MMIO_SIZE 0x1000 + +#endif
Signature · 1 line
2.53.0
PATCH 23/33 hw/arm: phytium: Connect the Phytium E2000 random generator
In reply to Bin MengInstantiate the RNG in the shared E2000 machine initialization and map it over the placeholder.
---
hw/arm/phytium_e2000.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
hw/arm/phytium_e2000.c +15 -0
@@ -31,6 +31,7 @@#include "hw/misc/phytium_e2000_ddr.h" #include "hw/misc/phytium_e2000_mhu.h" #include "hw/misc/phytium_e2000_pbr.h" +#include "hw/misc/phytium_e2000_rng.h" #include "hw/misc/unimp.h" #include "hw/net/cadence_gem.h" #include "hw/pci/pci.h"
@@ -97,6 +98,7 @@ enum {PHYTIUM_E2000_GEM1 ,PHYTIUM_E2000_GEM2 ,PHYTIUM_E2000_GEM3 , +PHYTIUM_E2000_RNG_REGS ,PHYTIUM_E2000_PLATFORM_CTRL ,PHYTIUM_E2000_SECURITY_CTRL , PHYTIUM_E2000_CHIP_CTRL,
@@ -164,6 +166,7 @@ static const MemMapEntry phytium_e2000_memmap[] = { [PHYTIUM_E2000_GEM1] = { 0x3200e000, 0x00002000 }, [PHYTIUM_E2000_GEM2] = { 0x32010000, 0x00002000 }, [PHYTIUM_E2000_GEM3] = { 0x32012000, 0x00002000 }, + [PHYTIUM_E2000_RNG_REGS] = { 0x32a36000, 0x00001000 }, [PHYTIUM_E2000_PLATFORM_CTRL] = { 0x32e40000, 0x00010000 }, [PHYTIUM_E2000_SECURITY_CTRL] = { 0x32f00000, 0x00001000 }, [PHYTIUM_E2000_CHIP_CTRL] = { 0x33000000, 0x00010000 },
@@ -630,6 +633,17 @@ static void phytium_e2000_create_ddr_status(PhytiumE2000State *s)sysbus_mmio_map_overlap (sbd,0 ,PHYTIUM_E2000_DDR_STATUS_BASE ,2 ); } +static void phytium_e2000_create_rng (PhytiumE2000State *s) +{ +DeviceState *dev =qdev_new (TYPE_PHYTIUM_E2000_RNG ); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); + +object_property_add_child (OBJECT (s),"rng" ,OBJECT (dev)); +sysbus_realize_and_unref (sbd, &error_fatal); +sysbus_mmio_map_overlap (sbd,0 , + phytium_e2000_memmap[PHYTIUM_E2000_RNG_REGS ].base,2 ); +} +static void phytium_e2000_create_scp_sram (PhytiumE2000State *s) {/*
@@ -842,6 +856,7 @@ static void phytium_e2000_init(MachineState *ms)phytium_e2000_create_scp_sram (s);phytium_e2000_create_mhu (s); +phytium_e2000_create_rng (s);phytium_e2000_create_ddr_status (s);for (i =0 ; i <PHYTIUM_E2000_NUM_MCIS ; i++) {
Signature · 1 line
2.53.0
PATCH 24/33 hw/arm: phytium: Support Phytium E2000 direct Linux boot
In reply to Bin MengAllow the Phytium Pi machine to boot a Linux Image directly through the generic Arm loader. Require the matching SDK phytiumpi_firefly.dtb whenever -kernel is used.
---
hw/arm/phytium_e2000.c | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
hw/arm/phytium_e2000.c +65 -0
@@ -15,6 +15,7 @@#include "qapi/error.h" #include "exec/cpu-common.h" #include "system/address-spaces.h" +#include "system/device_tree.h" #include "system/kvm.h" #include "system/system.h" #include "exec/hwaddr.h"
@@ -129,6 +130,7 @@ struct PhytiumE2000MachineClass {MachineClass parent_class;const char *machine_name; +const char *direct_boot_dtb;const char *pbr_boot_mode; };
@@ -771,6 +773,61 @@ static void phytium_e2000_create_ram(PhytiumE2000State *s) phytium_e2000_memmap[PHYTIUM_E2000_RAM_HIGH].base, &s->ram_high); } +static void phytium_e2000_add_memory_node (void *fdt,hwaddr base, +uint64_t size) +{ +uint32_t acells; +uint32_t scells; + g_autofree char *name = g_strdup_printf("/memory@%" HWADDR_PRIx, base); + + acells =qemu_fdt_getprop_cell (fdt,"/" ,"#address-cells" , +NULL , &error_fatal); + scells =qemu_fdt_getprop_cell (fdt,"/" ,"#size-cells" , +NULL , &error_fatal); + +qemu_fdt_add_subnode (fdt, name); +qemu_fdt_setprop_string (fdt, name,"device_type" ,"memory" ); +qemu_fdt_setprop_sized_cells (fdt, name,"reg" , + acells, base, scells, size); +} + +static void phytium_e2000_modify_dtb (const struct arm_boot_info *info, +void *fdt) +{ +uint64_t low_size = +MIN (info->ram_size, phytium_e2000_memmap[PHYTIUM_E2000_RAM ].size); +uint64_t high_size = info->ram_size - low_size; +g_auto (GStrv) memory_nodes =NULL ; +Error *err =NULL ; +int i; + +if (!high_size) { +return ; + } + +/* +* arm_load_dtb() normally describes RAM as one range beginning at +* loader_start. E2000 RAM above 2 GiB is instead mapped at 0x2000000000, +* beyond the PCIe aperture. Replace the generic range so Linux never +* treats the intervening address-space hole as RAM. +*/ + memory_nodes =qemu_fdt_node_unit_path (fdt,"memory" , &err); +if (err) { +error_report_err (err); +exit (1 ); + } +for (i =0 ; memory_nodes[i]; i++) { +if (g_str_has_prefix (memory_nodes[i],"/memory" )) { +qemu_fdt_nop_node (fdt, memory_nodes[i]); + } + } + +phytium_e2000_add_memory_node ( + fdt, phytium_e2000_memmap[PHYTIUM_E2000_RAM ].base, low_size); +phytium_e2000_add_memory_node ( + fdt, phytium_e2000_memmap[PHYTIUM_E2000_RAM_HIGH ].base, high_size); +} +static void phytium_e2000_create_cpus (PhytiumE2000State *s,bool firmware_loaded) {
@@ -830,6 +887,12 @@ static void phytium_e2000_init(MachineState *ms)exit (1 ); } +if (ms->kernel_filename && !ms->dtb) { +error_report ("%s: direct Linux boot requires the SDK %s via -dtb" , + pemc->machine_name, pemc->direct_boot_dtb); +exit (1 ); + } +if (ms->smp.cpus >PHYTIUM_E2000_NUM_CPUS ) {error_report ("%s supports at most %d CPUs" , pemc->machine_name,PHYTIUM_E2000_NUM_CPUS );
@@ -880,6 +943,7 @@ static void phytium_e2000_init(MachineState *ms) s->bootinfo.loader_start = phytium_e2000_memmap[PHYTIUM_E2000_RAM ].base; s->bootinfo.psci_conduit =QEMU_PSCI_CONDUIT_SMC ; s->bootinfo.firmware_loaded = firmware_loaded; + s->bootinfo.modify_dtb = phytium_e2000_modify_dtb;arm_load_kernel (ARM_CPU (first_cpu), ms, &s->bootinfo); }
@@ -945,6 +1009,7 @@ static void phytium_pi_class_init(ObjectClass *oc, const void *data) mc->desc ="Phytium Pi board (Phytium E2000Q)" ; mc->block_default_type =IF_SD ; pemc->machine_name ="phytium-pi" ; + pemc->direct_boot_dtb ="phytiumpi_firefly.dtb" ; pemc->pbr_boot_mode =PHYTIUM_E2000_PBR_BOOT_MODE_SD0 ; }
Signature · 1 line
2.53.0
PATCH 25/33 hw/arm: phytium: Add Phytium E2000Q COMe machine
In reply to Bin MengAdd the Phytium E2000Q COMe board as a second child of the shared E2000 machine class. Keep Phytium Pi fixed to SD0, while COMe selects QSPI0 firmware and requires its own DTB for direct Linux boot.
Instantiate the same E2000Q SoC controllers for both boards.
---
hw/arm/phytium_e2000.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
hw/arm/phytium_e2000.c +22 -1
@@ -53,7 +53,8 @@OBJECT_DECLARE_TYPE (PhytiumE2000State, PhytiumE2000MachineClass, PHYTIUM_E2000_MACHINE) -#define TYPE_PHYTIUM_PI MACHINE_TYPE_NAME("phytium-pi") +#define TYPE_PHYTIUM_PI MACHINE_TYPE_NAME("phytium-pi") +#define TYPE_PHYTIUM_E2000_COME MACHINE_TYPE_NAME("phytium-e2000-come")#define PHYTIUM_E2000_NUM_CPUS 4#define PHYTIUM_E2000_NUM_IRQS 256
@@ -1013,6 +1014,18 @@ static void phytium_pi_class_init(ObjectClass *oc, const void *data) pemc->pbr_boot_mode =PHYTIUM_E2000_PBR_BOOT_MODE_SD0 ; } +static void phytium_e2000_come_class_init (ObjectClass *oc,const void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); +PhytiumE2000MachineClass *pemc = +PHYTIUM_E2000_MACHINE_CLASS (oc); + + mc->desc ="Phytium E2000Q COMe Development Board" ; + pemc->machine_name ="phytium-e2000-come" ; + pemc->direct_boot_dtb ="e2000q-come-board.dtb" ; + pemc->pbr_boot_mode =PHYTIUM_E2000_PBR_BOOT_MODE_QSPI ; +} +static const TypeInfo phytium_e2000_base_info = { .name =TYPE_PHYTIUM_E2000_MACHINE , .parent =TYPE_MACHINE ,
@@ -1029,10 +1042,18 @@ static const TypeInfo phytium_pi_info = { .interfaces = aarch64_machine_interfaces, }; +static const TypeInfo phytium_e2000_come_info = { + .name =TYPE_PHYTIUM_E2000_COME , + .parent =TYPE_PHYTIUM_E2000_MACHINE , + .class_init = phytium_e2000_come_class_init, + .interfaces = aarch64_machine_interfaces, +}; +static void phytium_e2000_machine_init (void ) {type_register_static (&phytium_e2000_base_info);type_register_static (&phytium_pi_info); +type_register_static (&phytium_e2000_come_info); }type_init (phytium_e2000_machine_init);
Signature · 1 line
2.53.0
PATCH 26/33 hw/block: m25p80: Add GigaDevice GD25Q128 flash
In reply to Bin MengAdd the 128-Mbit GigaDevice GD25Q128 SPI NOR flash with JEDEC ID 0xc84018, 64 KiB sectors, and 4 KiB erase support.
The Phytium E2000Q COMe board uses this device for its QSPI boot flash.
---
hw/block/m25p80.c | 1 + 1 file changed, 1 insertion(+)
hw/block/m25p80.c +1 -0
@@ -207,6 +207,7 @@ static const FlashPartInfo known_devices[] = {/* GigaDevice */ { INFO("gd25q32", 0xc84016, 0, 64 << 10, 64, ER_4K) }, { INFO("gd25q64", 0xc84017, 0, 64 << 10, 128, ER_4K) }, + { INFO("gd25q128", 0xc84018, 0, 64 << 10, 256, ER_4K) },/* Intel/Numonyx -- xxxs33b */ { INFO("160s33b", 0x898911, 0, 64 << 10, 32, 0) },
Signature · 1 line
2.53.0
PATCH 27/33 hw/arm: phytium: Connect the Phytium E2000Q COMe QSPI flash
In reply to Bin MengAttach the board GD25Q128 to QSPI0 chip select zero and expose an MTD backend for COMe firmware storage.
Describe the flash model in the COMe machine class so the shared E2000 SoC still instantiates QSPI0 while Phytium Pi does not acquire a board-level SPI flash.
---
hw/arm/Kconfig | 1 + hw/arm/phytium_e2000.c | 37 +++++++++++++++++++++++++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-)
hw/arm/Kconfig +1 -0
@@ -140,6 +140,7 @@ config PHYTIUM_E2000 select PHYTIUM_E2000_QSPI select PL011 select SD + select SSI_M25P80 select UNIMP select USB_XHCI_SYSBUS
hw/arm/phytium_e2000.c +33 -4
@@ -40,6 +40,7 @@#include "hw/sd/phytium_e2000_mci.h" #include "hw/sd/sd.h" #include "hw/ssi/phytium_qspi.h" +#include "hw/ssi/ssi.h" #include "hw/usb/xhci.h" #include "net/net.h" #include "qobject/qlist.h"
@@ -118,6 +119,7 @@ struct PhytiumE2000State {struct arm_boot_info bootinfo;DeviceState *gic;DeviceState *qspi; +DeviceState *qspi_flash;PhytiumE2000PBRState *pbr;PhytiumE2000MciState *mci[PHYTIUM_E2000_NUM_MCIS ];CadenceGEMState *gem[PHYTIUM_E2000_NUM_GEMS ];
@@ -133,6 +135,7 @@ struct PhytiumE2000MachineClass {const char *machine_name;const char *direct_boot_dtb;const char *pbr_boot_mode; +const char *qspi_flash_model; };/*
@@ -577,6 +580,25 @@ static void phytium_e2000_create_qspi(PhytiumE2000State *s) phytium_e2000_memmap[PHYTIUM_E2000_QSPI_DIRECT].base, 2); } +static void phytium_e2000_attach_qspi_flash (PhytiumE2000State *s, +const char *model) +{ +DeviceState *flash =qdev_new (model); +DriveInfo *dinfo =drive_get (IF_MTD ,0 ,0 ); +qemu_irq flash_cs; + +if (dinfo) { +qdev_prop_set_drive_err (flash,"drive" ,blk_by_legacy_dinfo (dinfo), + &error_fatal); + } + + s->qspi_flash = flash; +qdev_realize_and_unref (flash,qdev_get_child_bus (s->qspi,"spi" ), + &error_fatal); + flash_cs =qdev_get_gpio_in_named (flash,SSI_GPIO_CS ,0 ); +qdev_connect_gpio_out_named (s->qspi,"cs" ,0 , flash_cs); +} +static bool phytium_e2000_create_pbr (PhytiumE2000State *s) {MachineState *ms =MACHINE (s);
@@ -588,10 +610,13 @@ static bool phytium_e2000_create_pbr(PhytiumE2000State *s)uint64_t cpu_mpidrs[PHYTIUM_E2000_NUM_CPUS ];int i; -if (!ms->kernel_filename && - !strcmp (pemc->pbr_boot_mode, -PHYTIUM_E2000_PBR_BOOT_MODE_SD0 )) { - boot_blk =phytium_e2000_sd_blk (0 ); +if (!ms->kernel_filename) { +if (!strcmp (pemc->pbr_boot_mode, +PHYTIUM_E2000_PBR_BOOT_MODE_QSPI )) { + boot_blk =m25p80_get_blk (s->qspi_flash); + }else { + boot_blk =phytium_e2000_sd_blk (0 ); + } }for (i =0 ; i < ms->smp.cpus; i++) {
@@ -913,6 +938,9 @@ static void phytium_e2000_init(MachineState *ms)phytium_e2000_create_unimplemented ();phytium_e2000_create_qspi (s); +if (pemc->qspi_flash_model) { +phytium_e2000_attach_qspi_flash (s, pemc->qspi_flash_model); + } firmware_loaded =phytium_e2000_create_pbr (s);phytium_e2000_create_cpus (s, firmware_loaded);
@@ -1024,6 +1052,7 @@ static void phytium_e2000_come_class_init(ObjectClass *oc, const void *data) pemc->machine_name ="phytium-e2000-come" ; pemc->direct_boot_dtb ="e2000q-come-board.dtb" ; pemc->pbr_boot_mode =PHYTIUM_E2000_PBR_BOOT_MODE_QSPI ; + pemc->qspi_flash_model ="gd25q128" ; }static const TypeInfo phytium_e2000_base_info = {
Signature · 1 line
2.53.0
PATCH 28/33 hw/arm: phytium: Add Phytium E2000 AHCI controllers
In reply to Bin MengAdd the two single-port sysbus AHCI controllers integrated in the E2000 SoC and route their interrupts to the GIC. Both boards expose the fixed controller blocks, but Phytium Pi does not wire either controller to a SATA disk and therefore rejects an IDE backend.
The physical COMe board wires its boot SSD to the second controller. Attach its SATA backend to AHCI1 so that U-Boot and Linux observe the same controller order as on hardware.
---
hw/arm/Kconfig | 3 +++ hw/arm/phytium_e2000.c | 54 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+)
hw/arm/Kconfig +3 -0
@@ -131,10 +131,13 @@ config PHYTIUM_E2000 default y depends on TCG && AARCH64 imply PCI_DEVICES + select AHCI_SYSBUS select ARM_GIC select CADENCE select DESIGNWARE_I2C select DW_MCI + select IDE_BUS + select IDE_DEV select PCI_EXPRESS select PCI_EXPRESS_GENERIC_BRIDGE select PHYTIUM_E2000_QSPI
hw/arm/phytium_e2000.c +54 -0
132 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH 29/33 hw/arm: Add Phytium E2000 Linux SCMI channel
In reply to Bin MengThe E2000 model only serviced the private PBF mailbox channel. The vendor Linux driver uses a separate shared-memory channel and therefore timed out before it could discover any SCMI protocols.
Model the Linux MHU doorbells and Base protocol while leaving Performance and Sensor unadvertised until their platform data can be represented faithfully. Document the limitation.
---
hw/arm/phytium_e2000.c | 4 + hw/misc/phytium_e2000_mhu.c | 457 +++++++++++++++++++++++++++++------- 2 files changed, 381 insertions(+), 80 deletions(-)
hw/arm/phytium_e2000.c +4 -0
@@ -232,6 +232,8 @@ static const int phytium_e2000_gem_irqmap[PHYTIUM_E2000_NUM_GEMS] [3] = { 68, 69, 70, 71 }, }; +static const int phytium_e2000_mhu_irq =22 ; +static const int phytium_e2000_pcie_irqmap[PCI_NUM_PINS ] = { [0 ] =4 , [1 ] =5 ,
@@ -756,6 +758,8 @@ static void phytium_e2000_create_mhu(PhytiumE2000State *s) }sysbus_realize_and_unref (sbd, &error_fatal);sysbus_mmio_map_overlap (sbd,0 ,PHYTIUM_E2000_MHU_BASE ,2 ); +sysbus_connect_irq (sbd,0 , +qdev_get_gpio_in (s->gic, phytium_e2000_mhu_irq)); }static void phytium_e2000_create_unimplemented (void )
hw/misc/phytium_e2000_mhu.c +377 -80
581 lines not on this page · raw message
Signature · 1 line
2.53.0
PATCH 30/33 hw/arm: phytium: Connect the Phytium E2000 SMMUv3
In reply to Bin MengThe vendor device tree routes PCIe DMA through an Arm SMMUv3, but its MMIO range currently reaches an unimplemented placeholder. Linux therefore reports that the IOMMU has no translation support.
Attach the generic SMMUv3 model to the GPEX root bus with the documented interrupt wiring and document stage-1 DMA translation support.
---
hw/arm/Kconfig | 1 + hw/arm/phytium_e2000.c | 39 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-)
hw/arm/Kconfig +1 -0
@@ -133,6 +133,7 @@ config PHYTIUM_E2000 imply PCI_DEVICES select AHCI_SYSBUS select ARM_GIC + select ARM_SMMUV3 select CADENCE select DESIGNWARE_I2C select DW_MCI
hw/arm/phytium_e2000.c +37 -2
@@ -22,6 +22,7 @@#include "hw/arm/boot.h" #include "hw/arm/bsa.h" #include "hw/arm/machines-qom.h" +#include "hw/arm/smmuv3.h" #include "hw/block/flash.h" #include "hw/char/pl011.h" #include "hw/core/boards.h"
@@ -69,6 +70,7 @@ OBJECT_DECLARE_TYPE(PhytiumE2000State, PhytiumE2000MachineClass,#define PHYTIUM_E2000_NUM_SATA_PORTS 1#define PHYTIUM_E2000_SATA_BOOT_AHCI 1#define PHYTIUM_E2000_NUM_GEMS 4 +#define PHYTIUM_E2000_NUM_SMMU_IRQS 4#define PHYTIUM_E2000_MHU_BASE 0x32a00000#define PHYTIUM_E2000_SCP_SRAM_BASE 0x32a10000
@@ -212,6 +214,14 @@ static const int phytium_e2000_uart_irqmap[] = {static const int phytium_e2000_i2c_irq =106 ; +/* Keep the architectural SMMUv3 output order aligned with the vendor DT */ +static const int phytium_e2000_smmu_irqmap[] = { + [SMMU_IRQ_EVTQ ] =240 , + [SMMU_IRQ_PRIQ ] =239 , + [SMMU_IRQ_CMD_SYNC ] =236 , + [SMMU_IRQ_GERROR ] =242 , +}; +static const int phytium_e2000_xhci_irqmap[] = { [0 ] =16 , [1 ] =17 ,
@@ -472,7 +482,7 @@ static int phytium_e2000_pcie_map_irq(PCIDevice *pdev, int pin)return pin; } -static void phytium_e2000_create_pcie (PhytiumE2000State *s) +static PCIBus *phytium_e2000_create_pcie (PhytiumE2000State *s) {DeviceState *dev =qdev_new (TYPE_GPEX_HOST );SysBusDevice *sbd =SYS_BUS_DEVICE (dev);
@@ -546,6 +556,29 @@ static void phytium_e2000_create_pcie(PhytiumE2000State *s) qdev_get_gpio_in(s->gic, phytium_e2000_pcie_irqmap[i]));gpex_set_irq_num (GPEX_HOST (dev), i, phytium_e2000_pcie_irqmap[i]); } + +return PCI_HOST_BRIDGE (dev)->bus; +} + +static void phytium_e2000_create_smmu (PhytiumE2000State *s,PCIBus *bus) +{ +DeviceState *dev =qdev_new (TYPE_ARM_SMMUV3 ); +SysBusDevice *sbd =SYS_BUS_DEVICE (dev); +int i; + +object_property_add_child (OBJECT (s),"smmu" ,OBJECT (dev)); +object_property_set_link (OBJECT (dev),"primary-bus" ,OBJECT (bus), + &error_abort); +object_property_set_link (OBJECT (dev),"memory" , +OBJECT (get_system_memory ()), &error_abort); +sysbus_realize_and_unref (sbd, &error_fatal); +sysbus_mmio_map_overlap (sbd,0 , + phytium_e2000_memmap[PHYTIUM_E2000_SYSTEM_CTRL ].base,2 ); + +for (i =0 ; i <PHYTIUM_E2000_NUM_SMMU_IRQS ; i++) { +sysbus_connect_irq (sbd, i, +qdev_get_gpio_in (s->gic, phytium_e2000_smmu_irqmap[i])); + } } static void phytium_e2000_reject_legacy_firmware(
@@ -951,6 +984,7 @@ static void phytium_e2000_init(MachineState *ms)PhytiumE2000MachineClass *pemc =PHYTIUM_E2000_MACHINE_GET_CLASS (ms);bool firmware_loaded; +PCIBus *pcie_bus;int i;if (kvm_enabled ()) {
@@ -1020,7 +1054,8 @@ static void phytium_e2000_init(MachineState *ms)phytium_e2000_create_gem (s, i); } -phytium_e2000_create_pcie (s); + pcie_bus =phytium_e2000_create_pcie (s); +phytium_e2000_create_smmu (s, pcie_bus); s->bootinfo.ram_size = ms->ram_size; s->bootinfo.board_id =-1 ;
Signature · 1 line
2.53.0
PATCH 31/33 docs/system/arm: Document Phytium E2000 machines
In reply to Bin MengDocument the shared E2000Q SoC model and the Phytium Pi and COMe board variants in one file. Keep common PBR, CPU, device, direct-boot, and limitation details together while separating the SD0 and QSPI-to-SATA workflows.
---
docs/system/arm/phytium_e2000.rst | 412 ++++++++++++++++++++++++++++++ docs/system/target-arm.rst | 1 + 2 files changed, 413 insertions(+) create mode 100644 docs/system/arm/phytium_e2000.rst
docs/system/arm/phytium_e2000.rst new file +412 -0
@@ -0,0 +1,412 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Phytium E2000Q machines (``phytium-pi``, ``phytium-e2000-come``) +================================================================ + +Overview +-------- + +QEMU models two boards built around the heterogeneous Phytium E2000Q SoC: + +.. list-table:: E2000Q machine variants + :header-rows: 1 + :widths: 20 20 20 20 20 + + * - Machine + - Firmware medium + - Linux storage + - SDK DTB + - Direct kernel + * - ``phytium-pi`` + - SD0 + - SD0 + - ``phytiumpi_firefly.dtb`` + - ``Image.gz`` + * - ``phytium-e2000-come`` + - QSPI0 + - AHCI1 SATA + - ``e2000q-come-board.dtb`` + - ``Image`` + +Both machines are intended for Linux and firmware images produced by the +Phytium Buildroot SDK. Phytium Pi has no board-attached SATA boot disk. The +COMe board attaches a GD25Q128 SPI NOR flash to QSPI0 and a SATA disk to +AHCI1. + +The Phytium firmware stack has three conceptual layers. The on-chip Phytium +Boot ROM (PBR) establishes the root of trust and prepares the early handoff, +Processor Base Firmware (PBF) initializes the processor, and System Firmware +(SFW) provides later firmware services and the bootloader. QEMU does not +execute the internal ROM. It recreates the PBR handoff state, reads a +``fip-all.bin`` image from byte zero of the board's selected firmware medium, +starts the PBF payload at EL3, and lets PBF hand off through the SFW stages to +U-Boot in the same image. + +The SFW flow loads BL31, whose resident EL3 runtime services handle the +Phytium private SMCs issued by U-Boot and Linux. QEMU does not intercept these +calls on the firmware boot path. + +The boot strap is fixed board wiring. Phytium Pi reports SD0 through the PBR +handoff while COMe reports QSPI0. Firmware may persist its environment or DDR +training data to the selected backend, so use a writable image or ``-snapshot``. + +The machines do not generate a device tree. Direct Linux boot with ``-kernel`` +requires the corresponding SDK DTB listed above through ``-dtb``. A later +Linux boot performed by firmware likewise requires the matching board DTB in +the guest-visible boot environment. + +PBR device ownership +-------------------- + +Firmware boot is implemented by the ``phytium-e2000-pbr`` device. The machine +model creates the QSPI and SD topology, maps the PBR status window, boot SRAM, +and IACC, fixes the device's ``boot-mode`` property from the board strap, and +connects the selected backend and CPU topology. It does not parse or stage +the firmware itself. ``boot-mode`` belongs to the PBR device and is not +exposed as a user-settable machine property. + +The PBR device reads only the selected board medium. It validates the outer +image extent, the embedded TF-A FIP, the primary MPIDR, and the +platform-parameter records. It then stages the complete computed image extent +at IACC ``0x38000000``, relocates PBF/BL1 to ``0xf8c40000``, constructs the +boot SRAM handoff, and releases the primary CPU named by the image. + +The public PBF interface defines a common 16-byte header containing magic, +version, size, and a reserved word for PLL, PCIe, DDR, and COMMON service +parameters. The E2000 firmware profile supplies their private container and +handoff placement: + +* PLL: FIP offset ``0xf5000`` to SCP SRAM ``0x32a10c00``, magic + ``0x54460020`` +* DDR/MCU (Memory Controller Unit): FIP offset ``0xf5300`` to SCP SRAM + ``0x32a10d00``, magic ``0x54460024`` +* PCIe: FIP offset ``0xf5100`` to SCP SRAM ``0x32a10e00``, magic + ``0x54460021`` +* COMMON: FIP offset ``0xf5200`` to SCP SRAM ``0x32a10f00``, magic + ``0x54460013`` + +In this PBF terminology, MCU means Memory Controller Unit. The record supplies +DDR controller configuration, DIMM/SPD data, and training parameters. + +The PBR device validates each exact E2000 magic, declared size, source bounds, +and the ``0x100``-byte destination-slot bound. It copies the declared record +without interpreting its service-specific payload and clears the remainder +of the destination slot. Parameter versions belong to their individual PBF +services and do not select a PBR handoff or TF-A object layout. In particular, +QEMU does not generate DDR/SPD data, rewrite the DDR/MCU record version, or +force DDR training controls. + +PBF embeds TF-A v2.3 FIP and memmap I/O drivers plus its platform I/O policy +table. The PBR device locates these from their TF-A data-structure +relationships and constructs the boot-SRAM state that registration and +``dev_open`` would have produced. This permits different PBF builds, +including two builds carrying version 4 DDR/MCU parameter records, to relocate +their I/O objects independently of the record version. + +Some remaining handoff details are private to the vendor PBR/PBF contract +rather than a published TF-A or hardware ABI. In particular, the fixed +boot-SRAM parameter graph and the placement of the FIP driver's runtime state +were reconstructed from the early PBF accesses and callback disassembly in +the 2 GiB and 4 GiB Phytium Pi SDK firmware samples and the COMe SDK firmware +sample. The implementation documents these evidence boundaries next to the +relevant code and rejects firmware whose surrounding TF-A structures do not +match. + +The device also owns reset, migration, and cleanup for this state. Its status +registers and firmware/primary-CPU state have explicit VMState, while the +device-owned boot SRAM and IACC RAM regions are migrated as RAMBlocks. A reset +restages the immutable input image and restores the handoff and primary entry. +This is a behavioral model of the ROM contract, not an Arm instruction-level +implementation of the on-chip PBR. + +CPU topology +------------ + +The E2000Q is heterogeneous. QEMU models the three non-uniform CPU clusters +described by the SDK Linux device tree: + +* cluster 0 contains one FTC664 core at MPIDR affinity ``0x0`` +* cluster 1 contains one FTC664 core at MPIDR affinity ``0x100`` +* cluster 2 contains two FTC310 cores at MPIDR affinities ``0x200`` and + ``0x201`` + +The corresponding QEMU CPU slot order is ``0x0``, ``0x100``, ``0x200``, +``0x201``. Firmware images that select primary affinity ``0x200`` therefore +release QEMU CPU index 2. CPU types are assigned by the board and must not be +replaced with a homogeneous ``-cpu`` model. + +The FTC310 and FTC664 TCG models use a Cortex-A72 execution base. Their +Phytium MIDR values, architectural instruction-feature fields, AArch32 +floating-point feature fields, and VIPT/PIPT I-cache policy match the values +observed on the physical E2000Q board. This is an architectural compatibility +model, not a performance or cache-capacity model. + +Supported devices +----------------- + +Both machines currently support: + +* two FTC664 and two FTC310 AArch64 CPU slots in three clusters +* RAM starting at ``0x80000000``, with 2 GiB by default and up to 8 GiB +* PBR-owned boot SRAM and IACC RAM used by the vendor firmware stack +* a GICv3 interrupt controller with ITS +* seven PL011 UARTs +* the DesignWare-compatible I2C controller +* the E2000 hardware random number generator +* two USB 3.0 xHCI host controllers +* two one-port sysbus AHCI controllers +* two SD/MMC controllers +* a GPEX PCIe host bridge with MSI support through the ITS and stage-1 DMA + translation through an Arm SMMUv3; PCIe endpoints such as network devices + must be added explicitly with ``-device`` +* a QSPI0 controller with a direct-mapped read window +* PBR, DDR, and MHU/SCMI compatibility behavior needed by the vendor + firmware, plus the SCMI Base protocol used by Linux + +Board wiring differs as follows: + +* Phytium Pi uses SD0 for firmware and its root filesystem and has no attached + QSPI flash or SATA boot disk +* COMe uses the GD25Q128 on QSPI0 for firmware and the AHCI1 SATA disk for + Linux + +Firmware boot +------------- + +Passing firmware through ``-bios`` or a pflash drive is not supported. Use +the board's fixed SD0 or QSPI0 medium as described below. + +Phytium Pi SD boot +~~~~~~~~~~~~~~~~~~ + +Build the complete SD image from the Phytium-maintained Buildroot release. No +separate ``make phytium_defconfig`` step is needed because +``merge_config.sh`` consumes the base defconfig directly: + +.. code-block:: shell + + $ git clone https://gitee.com/phytium_embedded/phytium-linux-buildroot.git + $ cd phytium-linux-buildroot + $ git checkout phytium-linux-buildroot_v2.4 + + $ ./support/kconfig/merge_config.sh \ + configs/phytium_defconfig \ + configs/phytiumpi_sdcard.config + $ make + +The resulting complete image is ``output/images/sdcard.img``. The SD-card +fragment selects the vendor 4 GiB firmware, builds ``fitImage`` from the +Buildroot kernel and Phytium Pi DTB, and packages those files together with +``rootfs.ext2``. Use this image directly rather than assembling its components +by hand. + +The vendor-generated SD layout reserves the first 64 MiB outside the root +filesystem: + +.. list-table:: Phytium Pi SD image layout + :header-rows: 1 + :widths: 25 20 55 + + * - Start + - Reserved size + - Content + * - ``0x00000000`` + - 4 MiB + - ``fip-all.bin`` firmware region + * - ``0x00400000`` + - 60 MiB + - U-Boot FIT image + * - ``0x04000000`` + - remaining image + - first partition, containing the ext4 root filesystem + +The default Phytium Pi SDK U-Boot environment reads the FIT from SD block +``0x2000`` (byte offset 4 MiB) and boots with ``root=/dev/mmcblk0p1``. The +first partition must therefore start at byte offset 64 MiB. A DOS partition +table may replace FIP sector zero, matching the vendor image recipe; the PBR +data used by the model begins at later fixed offsets in the firmware region. + +The SDK v2.4 image recipe declares the root partition as 16 GiB even when the +generated ``sdcard.img`` is shorter. Linux consequently reports that +``mmcblk0p1`` extends beyond the end of the device and truncates the reported +partition size. This warning is expected and does not prevent the contained +ext4 filesystem from mounting. + +UART1 carries the U-Boot and Linux console. The following command boots a +complete raw SD image without injecting U-Boot commands. ``-snapshot`` keeps +the source image unchanged when firmware writes its environment or DDR +training data: + +The following examples use images generated by Buildroot:: + + IMAGES=/path/to/buildroot/output/images + +.. code-block:: shell + + $ qemu-system-aarch64 \ + -machine phytium-pi \ + -smp 4 -m 4G \ + -display none -monitor none \ + -serial file:pbr-uart0.log \ + -serial stdio \ + -nic user \ + -snapshot \ + -drive file="$IMAGES/sdcard.img",if=sd,index=0,format=raw + +The explicit 4 GiB RAM size matches the firmware selected by +``phytiumpi_sdcard.config``. The verified flow with a version 4 DDR/MCU +parameter record completes PBF and DDR initialization, enters OP-TEE and +U-Boot, reads the FIT from SD, starts Linux on all four modeled CPUs, detects +SD0 as ``mmcblk0``, mounts partition 1, and reaches the login prompt without +serial or monitor input. +The SDK root filesystem uses a normal ``getty`` rather than an automatic +login, so entering a shell requires an interactive UART1 chardev. + +COMe QSPI-to-SATA boot +~~~~~~~~~~~~~~~~~~~~~~ + +This is the preferred COMe boot flow when a matching E2000Q +``fip-all.bin`` is available. The FIP container must begin at byte zero of a +raw QSPI image. + +Build the standard SATA disk image from the Phytium-maintained Buildroot +release: + +.. code-block:: shell + + $ git clone https://gitee.com/phytium_embedded/phytium-linux-buildroot.git + $ cd phytium-linux-buildroot + $ git checkout phytium-linux-buildroot_v2.4 + + $ make phytium_defconfig + $ make + +The resulting ``$SDK/disk.img`` has a GPT partition table. Its first partition +is a 400 MiB FAT filesystem containing ``Image``, the DTBs, and GRUB. Its +second partition contains the ext4 root filesystem. Attach this image directly +to AHCI1; no host-side repartitioning or file copying is required. + +Create a disposable 16 MiB GD25Q128 image in the erased state and copy the +FIP to byte zero: + +.. code-block:: shell + + $ export FIP=/path/to/sdk/fip-all.bin + $ export QSPI=/path/to/e2000q-gd25q128.bin + + $ dd if=/dev/zero bs=1M count=16 | tr '\000' '\377' > "$QSPI" + $ dd if="$FIP" of="$QSPI" conv=notrunc + +UART1 carries the interactive U-Boot console. UART0 is written to a separate +log so that early firmware output remains available. ``-snapshot`` keeps the +input images unchanged when firmware writes training data, its environment, +or the root filesystem: + +.. code-block:: shell + + $ qemu-system-aarch64 \ + -machine phytium-e2000-come \ + -smp 4 -m 2G \ + -display none -monitor none \ + -serial file:pbr-uart0.log \ + -serial stdio \ + -nic user \ + -snapshot \ + -drive file="$QSPI",if=mtd,index=0,format=raw \ + -drive file="$IMAGES/disk.img",if=ide,index=0,format=raw + +With the SDK firmware, the verified flow preserves the version 5 DDR/MCU +parameter record, identifies 2 GiB DDR4/X16, completes software training, data +BIST, and address BIST, detects the GD25Q128, reports ``boot media is qspi!``, +and enumerates the SATA disk as ``scsi 0`` through AHCI1. + +The U-Boot default environment may not match the layout of the Buildroot +``disk.img``. Press any key during the autoboot countdown to reach the +``E2000#`` prompt, then enter the following commands to load the raw arm64 +kernel and COMe DTB from the FAT partition and boot without an initrd: + +.. code-block:: shell + + setenv bootargs 'console=ttyAMA1,115200 root=/dev/sda2 rootwait rw cma=256M' + fatload scsi 0:1 0x90100000 Image + fatload scsi 0:1 0x90000000 e2000q-come-board.dtb + booti 0x90100000 - 0x90000000 + +The verified flow starts Linux on all four modeled CPUs, mounts ``sda2``, and +reaches the Buildroot login prompt on UART1. + +Direct Linux boot fallback +-------------------------- + +Use QEMU's direct ``-kernel`` interface only as a fallback when the Buildroot +SDK does not provide matching EDK2 or U-Boot source code and no usable vendor +FIP flow is available. This path bypasses PBR, PBF, SFW, and U-Boot. It +requires the board-specific SDK kernel and matching DTB listed in the overview; +omitting ``-dtb`` is an error. + +Starting the vendor U-Boot binary directly with ``-kernel`` is not supported. +That would bypass BL31 and leave the bootloader without the Phytium private +SMC services normally provided by the resident EL3 firmware. + +The following commands boot the SDK kernel with its initramfs and do not +require a disk image. + +Phytium Pi direct boot +~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: shell + + $ qemu-system-aarch64 \ + -machine phytium-pi \ + -smp 4 \ + -display none -monitor none \ + -serial null \ + -serial stdio \ + -nic user \ + -kernel "$IMAGES/Image.gz" \ + -dtb "$IMAGES/phytiumpi_firefly.dtb" \ + -initrd "$IMAGES/rootfs.cpio.gz" \ + -append 'console=ttyAMA1,115200 earlycon=pl011,mmio32,0x2800d000 rdinit=/init' + +COMe direct boot +~~~~~~~~~~~~~~~~ + +.. code-block:: shell + + $ qemu-system-aarch64 \ + -machine phytium-e2000-come \ + -smp 4 \ + -display none -monitor none \ + -serial null \ + -serial stdio \ + -nic user \ + -kernel "$IMAGES/Image" \ + -dtb "$IMAGES/e2000q-come-board.dtb" \ + -initrd "$IMAGES/rootfs.cpio.gz" \ + -append 'console=ttyAMA1,115200 earlycon=pl011,mmio32,0x2800d000 rdinit=/init' + +QEMU applies the normal Arm direct-boot fixups to the supplied SDK DTB, but +does not synthesize a replacement hardware description. + +Known limitations +----------------- + +The machines are functional models for the tested firmware and direct Linux +boot paths, not complete models of the physical development boards. + +* QEMU models the PBR handoff behavior needed by the tested ``fip-all.bin`` + image, not ROM instruction execution, authentication, or the complete + on-chip root of trust. +* The boot SRAM object graph and SFW callback addresses are limited to the + inspected firmware samples. Those samples carry version 4 or version 5 + DDR/MCU parameter records. +* FTC310 and FTC664 cache capacities and microarchitectural performance are + not modeled. Only the evidenced architected identities and I-cache policy + differ between the TCG CPU types. +* Standalone vendor U-Boot with ``-kernel`` is not supported; use a matching + ``fip-all.bin`` so BL31 provides the platform SMC services. +* Non-boot-critical peripherals remain unimplemented, so guest probe failures + are expected. The Phytium Pi ES8336 audio codec is not modeled. +* The Linux SCMI transport implements the Base protocol only. Performance and + Sensor protocols are not modeled, so SCMI CPU-frequency and temperature + interfaces are unavailable.
docs/system/target-arm.rst +1 -0
@@ -95,6 +95,7 @@ Board-specific documentation arm/mcimx7d-sabre arm/imx8m arm/orangepi + arm/phytium_e2000 arm/raspi arm/collie arm/sx1
Signature · 1 line
2.53.0
PATCH 32/33 tests/functional/aarch64: Add Phytium Pi boot tests
In reply to Bin MengThe Phytium Pi machine supports both the board firmware flow from SD and direct Linux boot. Exercise both paths with an SDK image bundle so firmware handoff and kernel loading regressions are caught.
Verify U-Boot, PBF relocation, the Linux handoff, and login for the firmware path. The Linux test loads the bundled kernel, DTB, and initramfs and waits for the same login prompt.
---
tests/functional/aarch64/meson.build | 2 + tests/functional/aarch64/test_phytium_pi.py | 77 +++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tests/functional/aarch64/test_phytium_pi.py
tests/functional/aarch64/meson.build +2 -0
@@ -7,6 +7,7 @@ test_aarch64_timeouts = { 'device_passthrough' : 720, 'imx8mm_evk' : 240, 'imx8mp_evk' : 240, + 'phytium_pi' : 600, 'raspi4' : 480, 'reverse_debug' : 180, 'rme_virt' : 1200,
@@ -39,6 +40,7 @@ tests_aarch64_system_thorough = [ 'imx8mp_evk', 'kvm', 'multiprocess', + 'phytium_pi', 'raspi3', 'raspi4', 'replay',
tests/functional/aarch64/test_phytium_pi.py new file +77 -0
77 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH 32/33] tests/functional/aarch64: Add Phytium Pi boot tests
Quoted 63 lines · Bin Meng
The Phytium Pi machine supports both the board firmware flow from SD and direct Linux boot. Exercise both paths with an SDK image bundle so firmware handoff and kernel loading regressions are caught.
Verify U-Boot, PBF relocation, the Linux handoff, and login for the firmware path. The Linux test loads the bundled kernel, DTB, and initramfs and waits for the same login prompt.
Signed-off-by Bin Meng <[email protected]>---
tests/functional/aarch64/meson.build | 2 + tests/functional/aarch64/test_phytium_pi.py | 77 +++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tests/functional/aarch64/test_phytium_pi.pytests/functional/aarch64/meson.build +2
-0@@ -7,6 +7,7 @@ test_aarch64_timeouts = { 'device_passthrough' : 720, 'imx8mm_evk' : 240, 'imx8mp_evk' : 240, + 'phytium_pi' : 600, 'raspi4' : 480, 'reverse_debug' : 180, 'rme_virt' : 1200,@@ -39,6 +40,7 @@ tests_aarch64_system_thorough = [ 'imx8mp_evk', 'kvm', 'multiprocess', + 'phytium_pi', 'raspi3', 'raspi4', 'replay',tests/functional/aarch64/test_phytium_pi.py new file +21
-0@@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +# +# Functional tests for the Phytium Pi machine +# +# Copyright (c) 2026 Process Mission +# +# Author: +# Bin Meng <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0-or-later + +from qemu_test import Asset, LinuxKernelTest +from qemu_test import skipBigDataTest, skipIfMissingCommands + + +class PhytiumPiMachine(LinuxKernelTest): + + ASSET_BUILDROOT = Asset( + ('https://github.com/processmission/qemu-machine-images/releases/' + 'download/v1.0.0/aarch64-phytium-pi-v1.0.0.tar.zst'), +
Quoted 1 line
'
5219d52b862e1245b12f79ba72e9a6144f5e0cf1a50061f8fda2db0aeeb92428')
Nice ;-)
I've been looking into something similar to make it easy to set up github projects that can build and host test assets:
https://github.com/stsquad/buildroot-asset
although my builds seem to take quite a bit longer that yours.
I wonder if there is a way to have a common repository set up but in a way that the forks can just build their own images. Either that or a core repository which everyone just forks adds their device and merges.
Anyway, test looks sane:
Quoted 56 lines
tests/functional/aarch64/test_phytium_pi.py new file +56
-0+ + def _prepare_images(self): + self.set_machine('phytium-pi') + + archive_path = self.uncompress( + self.ASSET_BUILDROOT, + target='aarch64-phytium-pi-v1.0.0.tar', + format='zstd') + self.archive_extract(archive_path, format='tar') + + self.vm.set_console(console_index=1) + self.vm.add_args('-smp', '4', + '-m', '4G', + '-display', 'none', + '-nic', 'none', + '-no-reboot') + + @skipIfMissingCommands('zstd') + @skipBigDataTest() + def test_firmware_boot(self): + self._prepare_images() + sdcard = self.scratch_file('images', 'sdcard.img') + + self.vm.add_args( + '-snapshot', + '-drive', f'file={sdcard},format=raw,if=sd,index=0') + self.vm.launch() + + self.wait_for_console_pattern('U-Boot 2022.01') + self.wait_for_console_pattern('PBF relocate done') + self.wait_for_console_pattern('Starting kernel ...') + self.wait_for_console_pattern('Phytium login:') + + @skipIfMissingCommands('zstd') + @skipBigDataTest() + def test_linux_boot(self): + self._prepare_images() + kernel = self.scratch_file('images', 'Image.gz') + dtb = self.scratch_file('images', 'phytiumpi_firefly.dtb') + initrd = self.scratch_file('images', 'rootfs.cpio.gz') + + self.vm.add_args( + '-kernel', kernel, + '-dtb', dtb, + '-initrd', initrd, + '-append', 'console=ttyAMA1,115200 ' + 'earlycon=pl011,mmio32,0x2800d000 rdinit=/init') + self.vm.launch() + + self.wait_for_console_pattern('Booting Linux on physical CPU') + self.wait_for_console_pattern('Machine model: Phytium Pi Board') + self.wait_for_console_pattern('Phytium login:') + + +if __name__ == '__main__': + LinuxKernelTest.main()
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Re: [PATCH 32/33] tests/functional/aarch64: Add Phytium Pi boot tests
Hi Alex,
Quoted 70 lines · Alex Bennée
Quoted 63 lines · Bin Meng
The Phytium Pi machine supports both the board firmware flow from SD and direct Linux boot. Exercise both paths with an SDK image bundle so firmware handoff and kernel loading regressions are caught.
Verify U-Boot, PBF relocation, the Linux handoff, and login for the firmware path. The Linux test loads the bundled kernel, DTB, and initramfs and waits for the same login prompt.
Signed-off-by Bin Meng <[email protected]>---
tests/functional/aarch64/meson.build | 2 + tests/functional/aarch64/test_phytium_pi.py | 77 +++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tests/functional/aarch64/test_phytium_pi.pytests/functional/aarch64/meson.build +2
-0@@ -7,6 +7,7 @@ test_aarch64_timeouts = { 'device_passthrough' : 720, 'imx8mm_evk' : 240, 'imx8mp_evk' : 240, + 'phytium_pi' : 600, 'raspi4' : 480, 'reverse_debug' : 180, 'rme_virt' : 1200,@@ -39,6 +40,7 @@ tests_aarch64_system_thorough = [ 'imx8mp_evk', 'kvm', 'multiprocess', + 'phytium_pi', 'raspi3', 'raspi4', 'replay',tests/functional/aarch64/test_phytium_pi.py new file +21
-0@@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +# +# Functional tests for the Phytium Pi machine +# +# Copyright (c) 2026 Process Mission +# +# Author: +# Bin Meng <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0-or-later + +from qemu_test import Asset, LinuxKernelTest +from qemu_test import skipBigDataTest, skipIfMissingCommands + + +class PhytiumPiMachine(LinuxKernelTest): + + ASSET_BUILDROOT = Asset( + ('https://github.com/processmission/qemu-machine-images/releases/' + 'download/v1.0.0/aarch64-phytium-pi-v1.0.0.tar.zst'), +Quoted 1 line
'
5219d52b862e1245b12f79ba72e9a6144f5e0cf1a50061f8fda2db0aeeb92428')Nice ;-)
Quoted 4 lines
I've been looking into something similar to make it easy to set up github projects that can build and host test assets:
This is actually very close to what I have been doing with
https://github.com/processmission/qemu-machine-images. It is intended to be a common repository for QEMU machine test assets.
Each machine has a small description under:
machine/<architecture>/<machine>/
It selects the independently built components, required images and machine-specific QEMU launcher. The container builders, packaging, checksums, release manifest and GitHub Actions workflow are shared. The workflow also distinguishes between the main repository and forks. A fork can build selected machines and upload run-scoped Actions artifacts without publishing a release. It can optionally publish its own development prerelease, while the main repository publishes frozen, versioned assets.
Quoted 2 lines
although my builds seem to take quite a bit longer that yours.
Yeah, as I only built the minimal busybox-based buildroot configuration, which is enough for QEMU boot testing :)
Quoted 4 lines
I wonder if there is a way to have a common repository set up but in a way that the forks can just build their own images. Either that or a core repository which everyone just forks adds their device and merges.
So perhaps qemu-machine-images could serve as a starting point for the common repository you describe. I would be happy to accept machine definitions from other contributors and make the add-a-machine workflow simpler.
Your buildroot-asset project also has useful ideas, particularly including enough Buildroot configuration and source metadata to reproduce an image manually. It would be good to align the two efforts instead of growing separate repositories for each maintainer or board.
Quoted 4 lines
Anyway, test looks sane:
Reviewed-by Alex Bennée <[email protected]>
Thanks for the review!
Quoted 51 lines
Quoted 51 lines
tests/functional/aarch64/test_phytium_pi.py new file +50
-0+ + def _prepare_images(self): + self.set_machine('phytium-pi') + + archive_path = self.uncompress( + self.ASSET_BUILDROOT, + target='aarch64-phytium-pi-v1.0.0.tar', + format='zstd') + self.archive_extract(archive_path, format='tar') + + self.vm.set_console(console_index=1) + self.vm.add_args('-smp', '4', + '-m', '4G', + '-display', 'none', + '-nic', 'none', + '-no-reboot') + + @skipIfMissingCommands('zstd') + @skipBigDataTest() + def test_firmware_boot(self): + self._prepare_images() + sdcard = self.scratch_file('images', 'sdcard.img') + + self.vm.add_args( + '-snapshot', + '-drive', f'file={sdcard},format=raw,if=sd,index=0') + self.vm.launch() + + self.wait_for_console_pattern('U-Boot 2022.01') + self.wait_for_console_pattern('PBF relocate done') + self.wait_for_console_pattern('Starting kernel ...') + self.wait_for_console_pattern('Phytium login:') + + @skipIfMissingCommands('zstd') + @skipBigDataTest() + def test_linux_boot(self): + self._prepare_images() + kernel = self.scratch_file('images', 'Image.gz') + dtb = self.scratch_file('images', 'phytiumpi_firefly.dtb') + initrd = self.scratch_file('images', 'rootfs.cpio.gz') + + self.vm.add_args( + '-kernel', kernel, + '-dtb', dtb, + '-initrd', initrd, + '-append', 'console=ttyAMA1,115200 ' + 'earlycon=pl011,mmio32,0x2800d000 rdinit=/init') + self.vm.launch() + + self.wait_for_console_pattern('Booting Linux on physical CPU')
Quoted 8 lines
tests/functional/aarch64/test_phytium_pi.py line 77
Quoted 6 lines
tests/functional/aarch64/test_phytium_pi.py new file +6
-0+ self.wait_for_console_pattern('Machine model: Phytium Pi Board') + self.wait_for_console_pattern('Phytium login:') + + +if __name__ == '__main__': + LinuxKernelTest.main()--
Regards,
Bin
Re: [PATCH 32/33] tests/functional/aarch64: Add Phytium Pi boot tests
Quoted 111 lines · Bin Meng
Hi Alex,
Quoted 70 lines · Alex Bennée
Quoted 63 lines · Bin Meng
The Phytium Pi machine supports both the board firmware flow from SD and direct Linux boot. Exercise both paths with an SDK image bundle so firmware handoff and kernel loading regressions are caught.
Verify U-Boot, PBF relocation, the Linux handoff, and login for the firmware path. The Linux test loads the bundled kernel, DTB, and initramfs and waits for the same login prompt.
Signed-off-by Bin Meng <[email protected]>---
tests/functional/aarch64/meson.build | 2 + tests/functional/aarch64/test_phytium_pi.py | 77 +++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 tests/functional/aarch64/test_phytium_pi.pytests/functional/aarch64/meson.build +2
-0@@ -7,6 +7,7 @@ test_aarch64_timeouts = { 'device_passthrough' : 720, 'imx8mm_evk' : 240, 'imx8mp_evk' : 240, + 'phytium_pi' : 600, 'raspi4' : 480, 'reverse_debug' : 180, 'rme_virt' : 1200,@@ -39,6 +40,7 @@ tests_aarch64_system_thorough = [ 'imx8mp_evk', 'kvm', 'multiprocess', + 'phytium_pi', 'raspi3', 'raspi4', 'replay',tests/functional/aarch64/test_phytium_pi.py new file +21
-0@@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +# +# Functional tests for the Phytium Pi machine +# +# Copyright (c) 2026 Process Mission +# +# Author: +# Bin Meng <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0-or-later + +from qemu_test import Asset, LinuxKernelTest +from qemu_test import skipBigDataTest, skipIfMissingCommands + + +class PhytiumPiMachine(LinuxKernelTest): + + ASSET_BUILDROOT = Asset( + ('https://github.com/processmission/qemu-machine-images/releases/' + 'download/v1.0.0/aarch64-phytium-pi-v1.0.0.tar.zst'), +Quoted 1 line
'
5219d52b862e1245b12f79ba72e9a6144f5e0cf1a50061f8fda2db0aeeb92428')Nice ;-)
Quoted 4 lines
I've been looking into something similar to make it easy to set up github projects that can build and host test assets:
This is actually very close to what I have been doing with
https://github.com/processmission/qemu-machine-images. It is intended to be a common repository for QEMU machine test assets.Each machine has a small description under:
machine/<architecture>/<machine>/
It selects the independently built components, required images and machine-specific QEMU launcher. The container builders, packaging, checksums, release manifest and GitHub Actions workflow are shared. The workflow also distinguishes between the main repository and forks. A fork can build selected machines and upload run-scoped Actions artifacts without publishing a release. It can optionally publish its own development prerelease, while the main repository publishes frozen, versioned assets.
Quoted 2 lines
although my builds seem to take quite a bit longer that yours.
Yeah, as I only built the minimal busybox-based buildroot configuration, which is enough for QEMU boot testing :)
Quoted 4 lines
I wonder if there is a way to have a common repository set up but in a way that the forks can just build their own images. Either that or a core repository which everyone just forks adds their device and merges.
So perhaps qemu-machine-images could serve as a starting point for the common repository you describe. I would be happy to accept machine definitions from other contributors and make the add-a-machine workflow simpler.
Quoted 4 lines
Your buildroot-asset project also has useful ideas, particularly including enough Buildroot configuration and source metadata to reproduce an image manually. It would be good to align the two efforts instead of growing separate repositories for each maintainer or board.
I agree.
Let me see if I can port my vkmark test image to your repo and add the metadata export to the image type.
Quoted 70 lines
Quoted 5 lines
Anyway, test looks sane:
Reviewed-by Alex Bennée <[email protected]>Thanks for the review!
Quoted 51 lines
Quoted 51 lines
tests/functional/aarch64/test_phytium_pi.py new file +50
-0+ + def _prepare_images(self): + self.set_machine('phytium-pi') + + archive_path = self.uncompress( + self.ASSET_BUILDROOT, + target='aarch64-phytium-pi-v1.0.0.tar', + format='zstd') + self.archive_extract(archive_path, format='tar') + + self.vm.set_console(console_index=1) + self.vm.add_args('-smp', '4', + '-m', '4G', + '-display', 'none', + '-nic', 'none', + '-no-reboot') + + @skipIfMissingCommands('zstd') + @skipBigDataTest() + def test_firmware_boot(self): + self._prepare_images() + sdcard = self.scratch_file('images', 'sdcard.img') + + self.vm.add_args( + '-snapshot', + '-drive', f'file={sdcard},format=raw,if=sd,index=0') + self.vm.launch() + + self.wait_for_console_pattern('U-Boot 2022.01') + self.wait_for_console_pattern('PBF relocate done') + self.wait_for_console_pattern('Starting kernel ...') + self.wait_for_console_pattern('Phytium login:') + + @skipIfMissingCommands('zstd') + @skipBigDataTest() + def test_linux_boot(self): + self._prepare_images() + kernel = self.scratch_file('images', 'Image.gz') + dtb = self.scratch_file('images', 'phytiumpi_firefly.dtb') + initrd = self.scratch_file('images', 'rootfs.cpio.gz') + + self.vm.add_args( + '-kernel', kernel, + '-dtb', dtb, + '-initrd', initrd, + '-append', 'console=ttyAMA1,115200 ' + 'earlycon=pl011,mmio32,0x2800d000 rdinit=/init') + self.vm.launch() + + self.wait_for_console_pattern('Booting Linux on physical CPU')Quoted 8 lines
tests/functional/aarch64/test_phytium_pi.py line 77
Quoted 6 lines
tests/functional/aarch64/test_phytium_pi.py new file +6
-0+ self.wait_for_console_pattern('Machine model: Phytium Pi Board') + self.wait_for_console_pattern('Phytium login:') + + +if __name__ == '__main__': + LinuxKernelTest.main()--
Regards,
Bin
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
PATCH 33/33 MAINTAINERS: Add Phytium E2000Q machines
In reply to Bin MengThe Phytium Pi and E2000Q COMe series adds board and SoC models, documentation, and boot tests. Group them under one entry so changes reach the machine maintainer and the ARM list.
Cover the machine, misc, SD wrapper, SSI, documentation, and functional test files introduced by the series.
---
MAINTAINERS | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
MAINTAINERS +14 -0
@@ -1011,6 +1011,20 @@ F: roms/vbootrom F: docs/system/arm/nuvoton.rst F: tests/functional/arm/test_quanta_gsj.py +Phytium E2000Q machines +M: Bin Meng <[email protected]> +L: [email protected] +S: Maintained +F: docs/system/arm/phytium_e2000.rst +F: hw/arm/phytium* +F: hw/misc/phytium* +F: hw/sd/phytium* +F: hw/ssi/phytium* +F: include/hw/misc/phytium* +F: include/hw/sd/phytium* +F: include/hw/ssi/phytium* +F: tests/functional/aarch64/test_phytium_pi.py + Raspberry Pi M: Peter Maydell <[email protected]> R: Philippe Mathieu-Daudé <[email protected]>
Signature · 1 line
2.53.0
Re: [PATCH 33/33] MAINTAINERS: Add Phytium E2000Q machines
Quoted 7 lines · Bin Meng
The Phytium Pi and E2000Q COMe series adds board and SoC models, documentation, and boot tests. Group them under one entry so changes reach the machine maintainer and the ARM list.
Cover the machine, misc, SD wrapper, SSI, documentation, and functional test files introduced by the series.
Quoted 6 lines
Signed-off-by Bin Meng <[email protected]>---
MAINTAINERS | 14 ++++++++++++++ 1 file changed, 14 insertions(+)