Skip to contentSkip to conversation

hw/arm: Add Phytium E2000Q SoC and board support

PATCH In review Bin Meng 2 participants 34 messages Sep 8 – Sep 24 Arm/Amlogic Meson SoC support

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

v2 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 a reusable E2000Q SoC QOM device which owns Cortex-A72 CPU children and applies the FTC core configuration locally. Two board machines embed the SoC:

- 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 E2000Q SoC 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. Board machines retain RAM, firmware media, and storage backend attachment. 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.

Changes in v2:
- Use scripts/git.orderfile when generating the series
- Configure FTC cores as SoC-owned Cortex-A72 CPU children
- Keep Phytium CPU configuration out of the global ARM CPU list
- Explain why the Phytium machines are restricted to TCG
- Reduce the DesignWare MCI register migration state to 96 words

Bin Meng (32):
hw/arm: Add Phytium E2000 SoC and 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 controller
hw/arm: phytium: Connect the Phytium E2000 DDR controller 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                                 |   18 +
 docs/system/arm/phytium_e2000.rst           |  422 ++++++
 docs/system/target-arm.rst                  |    1 +
 include/hw/arm/phytium_e2000.h              |  120 ++
 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                      |   75 +
 include/hw/sd/phytium_e2000_mci.h           |   21 +
 include/hw/ssi/phytium_qspi.h               |   23 +
 hw/arm/phytium_e2000.c                      |  958 +++++++++++++
 hw/arm/phytium_e2000_machine.c              |  388 ++++++
 hw/block/m25p80.c                           |    1 +
 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/dw_mci.c                              | 1382 +++++++++++++++++++
 hw/sd/phytium_e2000_mci.c                   |   95 ++
 hw/ssi/phytium_qspi.c                       |  398 ++++++
 tests/qtest/dw_mci-test.c                   |  417 ++++++
 hw/arm/Kconfig                              |   22 +
 hw/arm/meson.build                          |    4 +
 hw/misc/meson.build                         |    4 +
 hw/sd/Kconfig                               |    5 +
 hw/sd/meson.build                           |    2 +
 hw/ssi/Kconfig                              |    5 +
 hw/ssi/meson.build                          |    1 +
 tests/functional/aarch64/meson.build        |    2 +
 tests/functional/aarch64/test_phytium_pi.py |   77 ++
 tests/qtest/meson.build                     |    1 +
 32 files changed, 7147 insertions(+)
 create mode 100644 docs/system/arm/phytium_e2000.rst
 create mode 100644 include/hw/arm/phytium_e2000.h
 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 hw/arm/phytium_e2000.c
 create mode 100644 hw/arm/phytium_e2000_machine.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 tests/qtest/dw_mci-test.c
 create mode 100644 tests/functional/aarch64/test_phytium_pi.py

---
base-commit: 35500e5c41aec76cde59befe750600dac7a9e37a
branch: phytium

Signature · 1 line
2.53.0
author
#1 lore raw

PATCH v2 1/32 hw/arm: Add Phytium E2000 SoC and Phytium Pi machine

Add a reusable E2000 SoC QOM device and the Phytium Pi board machine. The SoC owns the heterogeneous CPU complex, GICv3/ITS, PL011 UARTs, and the initial unimplemented register windows, while the machine owns RAM and embeds the SoC as a child.

Instantiate Cortex-A72 CPU objects inside the SoC and apply the FTC310 and FTC664 identity fields before realization. Add conservative RAZ/WI and NOP stubs for the E2000 system registers used by EL3 firmware. Keeping this configuration local avoids exposing SoC-specific CPU types through the global ARM CPU list.

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.

Reject KVM because the machine requires the heterogeneous FTC CPU configuration applied to the Cortex-A72 TCG cores. Its firmware path also depends on EL3 and Phytium-specific system registers that Arm KVM cannot provide.

---

Changes in v2:
- Split the board machine from a reusable E2000 SoC QOM device
- Make the SoC own its CPU, GIC, UART, and register-window children
- Configure FTC cores locally from the Cortex-A72 CPU type
- Explain why the machine is restricted to TCG

 include/hw/arm/phytium_e2000.h |  62 ++++++
 hw/arm/phytium_e2000.c         | 393 +++++++++++++++++++++++++++++++++
 hw/arm/phytium_e2000_machine.c | 171 ++++++++++++++
 hw/arm/Kconfig                 |   8 +
 hw/arm/meson.build             |   4 +
 5 files changed, 638 insertions(+)
 create mode 100644 include/hw/arm/phytium_e2000.h
 create mode 100644 hw/arm/phytium_e2000.c
 create mode 100644 hw/arm/phytium_e2000_machine.c
include/hw/arm/phytium_e2000.h new file +62 -0
new file mode 100644
index 0000000000..466481f629
@@ -0,0 +1,62 @@
+/*
+ * Phytium E2000 SoC model
+ *
+ * Copyright (c) 2026 Process Mission
+ *
+ * Author:
+ *   Bin Meng <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef HW_ARM_PHYTIUM_E2000_H
+#define HW_ARM_PHYTIUM_E2000_H
+
+#include "hw/arm/boot.h"
+#include "hw/core/sysbus.h"
+#include "target/arm/cpu.h"
+
+#define TYPE_PHYTIUM_E2000_SOC "phytium-e2000-soc"
+OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000SoCState, PHYTIUM_E2000_SOC)
+
+#define PHYTIUM_E2000_NUM_CPUS 4
+
+enum {
+    PHYTIUM_E2000_LOW_PERIPH,
+    PHYTIUM_E2000_UART0,
+    PHYTIUM_E2000_UART1,
+    PHYTIUM_E2000_UART2,
+    PHYTIUM_E2000_UART3,
+    PHYTIUM_E2000_UART4,
+    PHYTIUM_E2000_UART5,
+    PHYTIUM_E2000_UART6,
+    PHYTIUM_E2000_GIC_DIST,
+    PHYTIUM_E2000_GIC_ITS,
+    PHYTIUM_E2000_GIC_REDIST,
+    PHYTIUM_E2000_BOOT_SRAM,
+    PHYTIUM_E2000_BOARD_CTRL,
+    PHYTIUM_E2000_BOOT_IACC,
+    PHYTIUM_E2000_RAM,
+    PHYTIUM_E2000_RAM_HIGH,
+};
+
+extern const MemMapEntry phytium_e2000_memmap[];
+
+struct PhytiumE2000SoCState {
+    SysBusDevice parent_obj;
+
+    DeviceState *gic;
+    ARMCPU cpu[PHYTIUM_E2000_NUM_CPUS];
+    unsigned int num_cpus;
+};
+
+void phytium_e2000_soc_configure(PhytiumE2000SoCState *s,
+                                 unsigned int num_cpus);
+void phytium_e2000_soc_cpu_topology(unsigned int index,
+                                    uint64_t *mp_affinity,
+                                    int64_t *cluster_id,
+                                    int64_t *core_id);
+ARMCPU *phytium_e2000_soc_cpu(PhytiumE2000SoCState *s,
+                              unsigned int index);
+
+#endif
hw/arm/phytium_e2000.c new file +393 -0

393 lines not on this page · raw message

hw/arm/phytium_e2000_machine.c new file +171 -0

171 lines not on this page · raw message

hw/arm/Kconfig +8 -0
index eae06369b0..05676534c2 100644
@@ -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 +4 -0
index bcc068de04..85e5020e94 100644
@@ -10,6 +10,10 @@ 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',
+  'phytium_e2000_machine.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'))
Signature · 1 line
2.53.0
author
#2 lore raw

PATCH v2 2/32 hw/arm: phytium: Add Phytium E2000 PCIe host

In reply to Bin Meng

Add 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.

---

Changes in v2:
- Move the PCIe host into the E2000 SoC

 include/hw/arm/phytium_e2000.h |   6 ++
 hw/arm/phytium_e2000.c         | 111 +++++++++++++++++++++++++++++++++
 hw/arm/Kconfig                 |   3 +
 3 files changed, 120 insertions(+)
include/hw/arm/phytium_e2000.h +6 -0
index 466481f629..dcb6c46272 100644
@@ -34,9 +34,15 @@ enum {
     PHYTIUM_E2000_GIC_ITS,
     PHYTIUM_E2000_GIC_REDIST,
     PHYTIUM_E2000_BOOT_SRAM,
+    PHYTIUM_E2000_PCIE_CTRL,
+    PHYTIUM_E2000_PCIE_PHY_CTRL,
     PHYTIUM_E2000_BOARD_CTRL,
     PHYTIUM_E2000_BOOT_IACC,
+    PHYTIUM_E2000_PCIE_ECAM,
+    PHYTIUM_E2000_PCIE_PIO,
+    PHYTIUM_E2000_PCIE_MMIO,
     PHYTIUM_E2000_RAM,
+    PHYTIUM_E2000_PCIE_MMIO_HIGH,
     PHYTIUM_E2000_RAM_HIGH,
 };
 
hw/arm/phytium_e2000.c +111 -0

150 lines not on this page · raw message

hw/arm/Kconfig +3 -0
index 05676534c2..7bc85f4f9f 100644
@@ -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
 
Signature · 1 line
2.53.0
author
#3 lore raw

PATCH v2 3/32 hw/sd: Add Synopsys DesignWare MCI controller

In reply to 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. Keep the 4 KiB MMIO aperture while limiting register backing and migration state to 96 words; the FIFO window is maintained separately.

---

Changes in v2:
- Reduce register backing and migration state from 1024 to 96 words

 MAINTAINERS            |    2 +
 include/hw/sd/dw_mci.h |   75 +++
 hw/sd/dw_mci.c         | 1382 ++++++++++++++++++++++++++++++++++++++++
 hw/sd/Kconfig          |    5 +
 hw/sd/meson.build      |    1 +
 5 files changed, 1465 insertions(+)
 create mode 100644 include/hw/sd/dw_mci.h
 create mode 100644 hw/sd/dw_mci.c
MAINTAINERS +2 -0
index 7183babd6a..705a541b69 100644
@@ -2413,8 +2413,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
include/hw/sd/dw_mci.h new file +75 -0

75 lines not on this page · raw message

hw/sd/dw_mci.c new file +1382 -0

1,382 lines not on this page · raw message

hw/sd/Kconfig +5 -0
index c69bf24f8d..dc3ebefa52 100644
@@ -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/meson.build +1 -0
index ebf09e30a4..d7b97cdca4 100644
@@ -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'))
Signature · 1 line
2.53.0
author
#4 lore raw

PATCH v2 4/32 hw/sd: Add Phytium E2000 MCI controller

In reply to Bin Meng

Model 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.

---

(no changes since v1)

 include/hw/sd/phytium_e2000_mci.h | 21 +++++++
 hw/sd/phytium_e2000_mci.c         | 95 +++++++++++++++++++++++++++++++
 hw/arm/Kconfig                    |  1 +
 hw/sd/meson.build                 |  1 +
 4 files changed, 118 insertions(+)
 create mode 100644 include/hw/sd/phytium_e2000_mci.h
 create mode 100644 hw/sd/phytium_e2000_mci.c
include/hw/sd/phytium_e2000_mci.h new file +21 -0
new file mode 100644
index 0000000000..cc6fce06d0
@@ -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
hw/sd/phytium_e2000_mci.c new file +95 -0

95 lines not on this page · raw message

hw/arm/Kconfig +1 -0
index 7bc85f4f9f..84d0cefd81 100644
@@ -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
index d7b97cdca4..5792d0c923 100644
@@ -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'))
Signature · 1 line
2.53.0
author
#5 lore raw

PATCH v2 5/32 hw/arm: phytium: Connect Phytium E2000 MCI controllers

In reply to Bin Meng

Instantiate 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.

---

Changes in v2:
- Move MCI controllers into the SoC and attach cards in the machine

 include/hw/arm/phytium_e2000.h |  9 ++++++
 hw/arm/phytium_e2000.c         | 56 ++++++++++++++++++++++++++++++++++
 hw/arm/phytium_e2000_machine.c | 19 ++++++++++++
 hw/arm/Kconfig                 |  1 +
 4 files changed, 85 insertions(+)
include/hw/arm/phytium_e2000.h +9 -0
index dcb6c46272..e759d71746 100644
@@ -14,15 +14,20 @@
 
 #include "hw/arm/boot.h"
 #include "hw/core/sysbus.h"
+#include "hw/sd/phytium_e2000_mci.h"
+#include "qemu/typedefs.h"
 #include "target/arm/cpu.h"
 
 #define TYPE_PHYTIUM_E2000_SOC "phytium-e2000-soc"
 OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000SoCState, PHYTIUM_E2000_SOC)
 
 #define PHYTIUM_E2000_NUM_CPUS 4
+#define PHYTIUM_E2000_NUM_MCIS 2
 
 enum {
     PHYTIUM_E2000_LOW_PERIPH,
+    PHYTIUM_E2000_MCI0,
+    PHYTIUM_E2000_MCI1,
     PHYTIUM_E2000_UART0,
     PHYTIUM_E2000_UART1,
     PHYTIUM_E2000_UART2,
@@ -52,6 +57,7 @@ struct PhytiumE2000SoCState {
     SysBusDevice parent_obj;
 
     DeviceState *gic;
+    PhytiumE2000MciState *mci[PHYTIUM_E2000_NUM_MCIS];
     ARMCPU cpu[PHYTIUM_E2000_NUM_CPUS];
     unsigned int num_cpus;
 };
@@ -64,5 +70,8 @@ void phytium_e2000_soc_cpu_topology(unsigned int index,
                                     int64_t *core_id);
 ARMCPU *phytium_e2000_soc_cpu(PhytiumE2000SoCState *s,
                               unsigned int index);
+void phytium_e2000_soc_attach_sd_card(PhytiumE2000SoCState *s,
+                                      unsigned int index,
+                                      BlockBackend *blk);
 
 #endif
hw/arm/phytium_e2000.c +56 -0

92 lines not on this page · raw message

hw/arm/phytium_e2000_machine.c +19 -0
index 8a4f8d4275..7397c58a78 100644
@@ -14,6 +14,7 @@
 #include "qemu/units.h"
 #include "qapi/error.h"
 #include "system/address-spaces.h"
+#include "system/block-backend-global-state.h"
 #include "system/kvm.h"
 #include "exec/hwaddr.h"
 #include "hw/arm/boot.h"
@@ -35,6 +36,23 @@ struct PhytiumPiMachineState {
     MemoryRegion ram_high;
 };
 
+static BlockBackend *phytium_e2000_sd_blk(int index)
+{
+    DriveInfo *dinfo = drive_get(IF_SD, 0, index);
+
+    return dinfo ? blk_by_legacy_dinfo(dinfo) : NULL;
+}
+
+static void phytium_e2000_attach_sd_cards(PhytiumPiMachineState *s)
+{
+    int i;
+
+    for (i = 0; i < PHYTIUM_E2000_NUM_MCIS; i++) {
+        phytium_e2000_soc_attach_sd_card(
+            &s->soc, i, phytium_e2000_sd_blk(i));
+    }
+}
+
 static void phytium_e2000_create_ram(PhytiumPiMachineState *s)
 {
     MachineState *ms = MACHINE(s);
@@ -95,6 +113,7 @@ static void phytium_pi_init(MachineState *ms)
                             TYPE_PHYTIUM_E2000_SOC);
     phytium_e2000_soc_configure(&s->soc, ms->smp.cpus);
     sysbus_realize(SYS_BUS_DEVICE(&s->soc), &error_fatal);
+    phytium_e2000_attach_sd_cards(s);
 
     s->bootinfo.ram_size = ms->ram_size;
     s->bootinfo.board_id = -1;
hw/arm/Kconfig +1 -0
index 84d0cefd81..8b865e4e30 100644
@@ -136,6 +136,7 @@ config PHYTIUM_E2000
     select PCI_EXPRESS
     select PCI_EXPRESS_GENERIC_BRIDGE
     select PL011
+    select SD
     select UNIMP
 
 config REALVIEW
Signature · 1 line
2.53.0
author
#6 lore raw

PATCH v2 6/32 tests/qtest: Add Synopsys DesignWare MCI coverage

In reply to Bin Meng

Exercise 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.

---

Changes in v2:
- Follow the MCI device into the E2000 SoC QOM subtree

 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
index 705a541b69..d577cdbda5 100644
@@ -2419,6 +2419,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
 F: tests/qtest/xilinx-zynq-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
index c3593f7530..a7fc37e09d 100644
@@ -282,6 +282,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
author
#7 lore raw

PATCH v2 7/32 hw/arm: phytium: Connect Phytium E2000 GEM controllers

In reply to Bin Meng

Instantiate 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.

---

Changes in v2:
- Move GEM controllers and placeholder regions into the E2000 SoC

 include/hw/arm/phytium_e2000.h |  7 ++++
 hw/arm/phytium_e2000.c         | 59 ++++++++++++++++++++++++++++++++++
 hw/arm/Kconfig                 |  1 +
 3 files changed, 67 insertions(+)
include/hw/arm/phytium_e2000.h +7 -0
index e759d71746..a948c54f2c 100644
@@ -14,6 +14,7 @@
 
 #include "hw/arm/boot.h"
 #include "hw/core/sysbus.h"
+#include "hw/net/cadence_gem.h"
 #include "hw/sd/phytium_e2000_mci.h"
 #include "qemu/typedefs.h"
 #include "target/arm/cpu.h"
@@ -23,6 +24,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000SoCState, PHYTIUM_E2000_SOC)
 
 #define PHYTIUM_E2000_NUM_CPUS 4
 #define PHYTIUM_E2000_NUM_MCIS 2
+#define PHYTIUM_E2000_NUM_GEMS 4
 
 enum {
     PHYTIUM_E2000_LOW_PERIPH,
@@ -42,6 +44,10 @@ enum {
     PHYTIUM_E2000_PCIE_CTRL,
     PHYTIUM_E2000_PCIE_PHY_CTRL,
     PHYTIUM_E2000_BOARD_CTRL,
+    PHYTIUM_E2000_GEM0,
+    PHYTIUM_E2000_GEM1,
+    PHYTIUM_E2000_GEM2,
+    PHYTIUM_E2000_GEM3,
     PHYTIUM_E2000_BOOT_IACC,
     PHYTIUM_E2000_PCIE_ECAM,
     PHYTIUM_E2000_PCIE_PIO,
@@ -58,6 +64,7 @@ struct PhytiumE2000SoCState {
 
     DeviceState *gic;
     PhytiumE2000MciState *mci[PHYTIUM_E2000_NUM_MCIS];
+    CadenceGEMState *gem[PHYTIUM_E2000_NUM_GEMS];
     ARMCPU cpu[PHYTIUM_E2000_NUM_CPUS];
     unsigned int num_cpus;
 };
hw/arm/phytium_e2000.c +59 -0

92 lines not on this page · raw message

hw/arm/Kconfig +1 -0
index 8b865e4e30..d9759731f0 100644
@@ -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
Signature · 1 line
2.53.0
author
#8 lore raw

PATCH v2 8/32 hw/misc: Add Phytium E2000 DDR controller

In reply to Bin Meng

Model the E2000 DDR initialization and training compatibility window. 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.

---

(no changes since v1)

 include/hw/misc/phytium_e2000_ddr.h |  23 ++++
 hw/misc/phytium_e2000_ddr.c         | 197 ++++++++++++++++++++++++++++
 hw/misc/meson.build                 |   1 +
 3 files changed, 221 insertions(+)
 create mode 100644 include/hw/misc/phytium_e2000_ddr.h
 create mode 100644 hw/misc/phytium_e2000_ddr.c
include/hw/misc/phytium_e2000_ddr.h new file +23 -0
new file mode 100644
index 0000000000..91dc661106
@@ -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
hw/misc/phytium_e2000_ddr.c new file +197 -0

197 lines not on this page · raw message

hw/misc/meson.build +1 -0
index 9790afa104..dca5f67ca9 100644
@@ -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'))
 
Signature · 1 line
2.53.0
author
#9 lore raw

PATCH v2 9/32 hw/arm: phytium: Connect the Phytium E2000 DDR controller

In reply to Bin Meng

Instantiate the E2000 DDR controller device and map it over the board-control placeholder. PBF and early U-Boot poll this selector window while firmware coordinates DRAM initialization from EL3.

---

Changes in v2:
- Move the DDR status device into the E2000 SoC

 hw/arm/phytium_e2000.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
hw/arm/phytium_e2000.c +20 -0
index da8313d61f..9a0cc00c91 100644
@@ -21,6 +21,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"
@@ -39,6 +40,8 @@
 
 #define PHYTIUM_E2000_NUM_UARTS       7
 
+#define PHYTIUM_E2000_DDR_STATUS_BASE 0x32b33000
+
 #define PHYTIUM_E2000_GTIMER_HZ       50000000
 
 /*
@@ -462,6 +465,21 @@ static void phytium_e2000_create_mci(PhytiumE2000SoCState *s, int index)
         qdev_get_gpio_in(s->gic, phytium_e2000_mci_irqmap[index]));
 }
 
+static void phytium_e2000_create_ddr_status(PhytiumE2000SoCState *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(PhytiumE2000SoCState *s)
 {
     /*
@@ -584,6 +602,8 @@ static void phytium_e2000_soc_realize(DeviceState *dev, Error **errp)
     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
author
#10 lore raw

PATCH v2 10/32 hw/misc: Add Phytium E2000 MHU doorbell

In reply to Bin Meng

Add 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.

---

(no changes since v1)

 include/hw/misc/phytium_e2000_mhu.h |  25 ++++
 hw/misc/phytium_e2000_mhu.c         | 185 ++++++++++++++++++++++++++++
 hw/misc/meson.build                 |   1 +
 3 files changed, 211 insertions(+)
 create mode 100644 include/hw/misc/phytium_e2000_mhu.h
 create mode 100644 hw/misc/phytium_e2000_mhu.c
include/hw/misc/phytium_e2000_mhu.h new file +25 -0
new file mode 100644
index 0000000000..0527d6fe8d
@@ -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
hw/misc/phytium_e2000_mhu.c new file +185 -0

185 lines not on this page · raw message

hw/misc/meson.build +1 -0
index dca5f67ca9..149ec8e797 100644
@@ -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'))
 
Signature · 1 line
2.53.0
author
#11 lore raw

PATCH v2 11/32 hw/arm: phytium: Connect the Phytium E2000 MHU

In reply to Bin Meng

Add the E2000 SCP SRAM window used for SCMI messages and map the MHU doorbell into the board-control aperture.

---

Changes in v2:
- Move the MHU and SCP SRAM into the E2000 SoC

 include/hw/arm/phytium_e2000.h |  1 +
 hw/arm/phytium_e2000.c         | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)
include/hw/arm/phytium_e2000.h +1 -0
index a948c54f2c..40f91256a2 100644
@@ -66,6 +66,7 @@ struct PhytiumE2000SoCState {
     PhytiumE2000MciState *mci[PHYTIUM_E2000_NUM_MCIS];
     CadenceGEMState *gem[PHYTIUM_E2000_NUM_GEMS];
     ARMCPU cpu[PHYTIUM_E2000_NUM_CPUS];
+    MemoryRegion scp_sram;
     unsigned int num_cpus;
 };
 
hw/arm/phytium_e2000.c +34 -0
index 9a0cc00c91..95ebf3c87b 100644
@@ -22,6 +22,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"
@@ -40,6 +41,9 @@
 
 #define PHYTIUM_E2000_NUM_UARTS       7
 
+#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
@@ -480,6 +484,34 @@ static void phytium_e2000_create_ddr_status(PhytiumE2000SoCState *s)
     sysbus_mmio_map_overlap(sbd, 0, PHYTIUM_E2000_DDR_STATUS_BASE, 2);
 }
 
+static void phytium_e2000_create_scp_sram(PhytiumE2000SoCState *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, OBJECT(s),
+                           "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(PhytiumE2000SoCState *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(PhytiumE2000SoCState *s)
 {
     /*
@@ -602,6 +634,8 @@ static void phytium_e2000_soc_realize(DeviceState *dev, Error **errp)
     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
author
#12 lore raw

PATCH v2 12/32 hw/ssi: Add Phytium E2000 QSPI controller

In reply to Bin Meng

Phytium 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.

---

(no changes since v1)

 include/hw/ssi/phytium_qspi.h |  23 ++
 hw/ssi/phytium_qspi.c         | 398 ++++++++++++++++++++++++++++++++++
 hw/ssi/Kconfig                |   5 +
 hw/ssi/meson.build            |   1 +
 4 files changed, 427 insertions(+)
 create mode 100644 include/hw/ssi/phytium_qspi.h
 create mode 100644 hw/ssi/phytium_qspi.c
include/hw/ssi/phytium_qspi.h new file +23 -0
new file mode 100644
index 0000000000..c6534af16d
@@ -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
hw/ssi/phytium_qspi.c new file +398 -0

398 lines not on this page · raw message

hw/ssi/Kconfig +5 -0
index 1bd56463c1..202c81c5ac 100644
@@ -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
index 6afb1ea200..c76945ddf4 100644
@@ -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'))
Signature · 1 line
2.53.0
author
#13 lore raw

PATCH v2 13/32 hw/arm: phytium: Connect the Phytium E2000 QSPI controller

In reply to Bin Meng

Instantiate QSPI0 at its command and direct-map windows so accesses from E2000 firmware reach the controller model.

---

Changes in v2:
- Move the QSPI controller into the E2000 SoC
- Store the QSPI child with its concrete QOM state type

 include/hw/arm/phytium_e2000.h |  4 ++++
 hw/arm/phytium_e2000.c         | 15 +++++++++++++++
 hw/arm/Kconfig                 |  1 +
 3 files changed, 20 insertions(+)
include/hw/arm/phytium_e2000.h +4 -0
index 40f91256a2..92b39129ba 100644
@@ -16,6 +16,7 @@
 #include "hw/core/sysbus.h"
 #include "hw/net/cadence_gem.h"
 #include "hw/sd/phytium_e2000_mci.h"
+#include "hw/ssi/phytium_qspi.h"
 #include "qemu/typedefs.h"
 #include "target/arm/cpu.h"
 
@@ -27,9 +28,11 @@ OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000SoCState, PHYTIUM_E2000_SOC)
 #define PHYTIUM_E2000_NUM_GEMS 4
 
 enum {
+    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,
@@ -63,6 +66,7 @@ struct PhytiumE2000SoCState {
     SysBusDevice parent_obj;
 
     DeviceState *gic;
+    PhytiumE2000QSPIState *qspi;
     PhytiumE2000MciState *mci[PHYTIUM_E2000_NUM_MCIS];
     CadenceGEMState *gem[PHYTIUM_E2000_NUM_GEMS];
     ARMCPU cpu[PHYTIUM_E2000_NUM_CPUS];
hw/arm/phytium_e2000.c +15 -0
index 95ebf3c87b..3e30d112f7 100644
@@ -28,6 +28,7 @@
 #include "hw/pci/pci.h"
 #include "hw/pci-host/gpex.h"
 #include "hw/sd/sd.h"
+#include "hw/ssi/phytium_qspi.h"
 #include "net/net.h"
 #include "qobject/qlist.h"
 #include "qom/object.h"
@@ -54,9 +55,11 @@
  * handoff data and IACC is the fixed execution window for system firmware.
  */
 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 },
@@ -469,6 +472,17 @@ static void phytium_e2000_create_mci(PhytiumE2000SoCState *s, int index)
         qdev_get_gpio_in(s->gic, phytium_e2000_mci_irqmap[index]));
 }
 
+static void phytium_e2000_create_qspi(PhytiumE2000SoCState *s)
+{
+    s->qspi = PHYTIUM_E2000_QSPI(qdev_new(TYPE_PHYTIUM_E2000_QSPI));
+    object_property_add_child(OBJECT(s), "qspi", OBJECT(s->qspi));
+    sysbus_realize_and_unref(SYS_BUS_DEVICE(s->qspi), &error_fatal);
+    sysbus_mmio_map_overlap(SYS_BUS_DEVICE(s->qspi), 0,
+        phytium_e2000_memmap[PHYTIUM_E2000_QSPI_REGS].base, 2);
+    sysbus_mmio_map_overlap(SYS_BUS_DEVICE(s->qspi), 1,
+        phytium_e2000_memmap[PHYTIUM_E2000_QSPI_DIRECT].base, 2);
+}
+
 static void phytium_e2000_create_ddr_status(PhytiumE2000SoCState *s)
 {
     DeviceState *dev = qdev_new(TYPE_PHYTIUM_E2000_DDR);
@@ -631,6 +645,7 @@ static void phytium_e2000_soc_realize(DeviceState *dev, Error **errp)
     }
 
     phytium_e2000_create_unimplemented(s);
+    phytium_e2000_create_qspi(s);
     phytium_e2000_create_cpus(s);
     phytium_e2000_create_gic(s);
 
hw/arm/Kconfig +1 -0
index d9759731f0..e4111eaec2 100644
@@ -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
Signature · 1 line
2.53.0
author
#14 lore raw

PATCH v2 14/32 hw/misc: Add Phytium E2000 PBR model

In reply to Bin Meng

Model 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.

---

(no changes since v1)

 include/hw/misc/phytium_e2000_pbr.h |   55 ++
 hw/misc/phytium_e2000_pbr.c         | 1221 +++++++++++++++++++++++++++
 hw/misc/meson.build                 |    1 +
 3 files changed, 1277 insertions(+)
 create mode 100644 include/hw/misc/phytium_e2000_pbr.h
 create mode 100644 hw/misc/phytium_e2000_pbr.c
include/hw/misc/phytium_e2000_pbr.h new file +55 -0
new file mode 100644
index 0000000000..890d419254
@@ -0,0 +1,55 @@
+/*
+ * Phytium E2000 PBR (Phytium Boot ROM) model
+ *
+ * Copyright (c) 2026 Process Mission
+ *
+ * Author:
+ *   Bin Meng <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef HW_MISC_PHYTIUM_E2000_PBR_H
+#define HW_MISC_PHYTIUM_E2000_PBR_H
+
+#include "hw/core/sysbus.h"
+#include "qom/object.h"
+
+#define TYPE_PHYTIUM_E2000_PBR "phytium-e2000-pbr"
+OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000PBRState, PHYTIUM_E2000_PBR)
+
+/*
+ * These are E2000 physical addresses, not locations chosen by a particular
+ * PBF build. Keep them with the PBR device so that the machine memory map and
+ * the firmware parser do not grow independent copies of the same constants.
+ *
+ * The boot SRAM contains the handoff left by the on-chip PBR. IACC is the
+ * vendor-named boot-time execution window into which PBR places fip-all.bin.
+ * The status window is consumed by PBF as a snapshot of PBR-owned state.
+ */
+#define PHYTIUM_E2000_PBR_STATUS_BASE       0x32a11804
+#define PHYTIUM_E2000_PBR_BOOT_SRAM_BASE    0x30c00000
+#define PHYTIUM_E2000_PBR_IACC_BASE         0x38000000
+
+#define PHYTIUM_E2000_PBR_MMIO_SIZE         0x64
+#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_BOOT_MEDIA_QSPI   0x1
+#define PHYTIUM_E2000_PBR_BOOT_MEDIA_SD0    0x4
+
+#define PHYTIUM_E2000_PBR_BOOT_MODE_QSPI    "qspi"
+#define PHYTIUM_E2000_PBR_BOOT_MODE_SD0     "sd"
+
+void phytium_e2000_pbr_configure(PhytiumE2000PBRState *s,
+                                 BlockBackend *boot_blk,
+                                 hwaddr ram_base, uint64_t ram_size,
+                                 const uint64_t *cpu_mpidrs,
+                                 unsigned int num_cpus);
+bool phytium_e2000_pbr_firmware_loaded(PhytiumE2000PBRState *s);
+int phytium_e2000_pbr_primary_cpu(PhytiumE2000PBRState *s);
+void phytium_e2000_pbr_connect_cpu(PhytiumE2000PBRState *s,
+                                   unsigned int index, CPUState *cpu);
+
+#endif
hw/misc/phytium_e2000_pbr.c new file +1221 -0

1,221 lines not on this page · raw message

hw/misc/meson.build +1 -0
index 149ec8e797..8579004e88 100644
@@ -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'))
 
Signature · 1 line
2.53.0
author
#15 lore raw

PATCH v2 15/32 hw/arm: phytium: Integrate the Phytium E2000 PBR

In reply to Bin Meng

Instantiate PBR in the E2000 SoC, map its status and boot memories, provide the heterogeneous MPIDR topology, and connect all SoC-owned CPU objects for reset-time handoff.

Have the Phytium Pi machine select SD0 and pass its board backend into the SoC. Explicitly reject unsupported -bios and pflash interfaces.

---

Changes in v2:
- Connect PBR to the SoC-owned CPU children
- Let the machine configure the SoC-owned PBR backend

 include/hw/arm/phytium_e2000.h | 11 +++++
 hw/arm/phytium_e2000.c         | 74 +++++++++++++++++++++++++++++++++-
 hw/arm/phytium_e2000_machine.c | 26 ++++++++++--
 3 files changed, 107 insertions(+), 4 deletions(-)
include/hw/arm/phytium_e2000.h +11 -0
index 92b39129ba..6199bb7b5c 100644
@@ -14,6 +14,7 @@
 
 #include "hw/arm/boot.h"
 #include "hw/core/sysbus.h"
+#include "hw/misc/phytium_e2000_pbr.h"
 #include "hw/net/cadence_gem.h"
 #include "hw/sd/phytium_e2000_mci.h"
 #include "hw/ssi/phytium_qspi.h"
@@ -67,14 +68,23 @@ struct PhytiumE2000SoCState {
 
     DeviceState *gic;
     PhytiumE2000QSPIState *qspi;
+    PhytiumE2000PBRState *pbr;
     PhytiumE2000MciState *mci[PHYTIUM_E2000_NUM_MCIS];
     CadenceGEMState *gem[PHYTIUM_E2000_NUM_GEMS];
     ARMCPU cpu[PHYTIUM_E2000_NUM_CPUS];
     MemoryRegion scp_sram;
+
+    const char *pbr_boot_mode;
+    BlockBackend *boot_blk;
+    uint64_t ram_size;
     unsigned int num_cpus;
+    bool firmware_loaded;
 };
 
 void phytium_e2000_soc_configure(PhytiumE2000SoCState *s,
+                                 const char *pbr_boot_mode,
+                                 BlockBackend *boot_blk,
+                                 uint64_t ram_size,
                                  unsigned int num_cpus);
 void phytium_e2000_soc_cpu_topology(unsigned int index,
                                     uint64_t *mp_affinity,
@@ -82,6 +92,7 @@ void phytium_e2000_soc_cpu_topology(unsigned int index,
                                     int64_t *core_id);
 ARMCPU *phytium_e2000_soc_cpu(PhytiumE2000SoCState *s,
                               unsigned int index);
+bool phytium_e2000_soc_firmware_loaded(PhytiumE2000SoCState *s);
 void phytium_e2000_soc_attach_sd_card(PhytiumE2000SoCState *s,
                                       unsigned int index,
                                       BlockBackend *blk);
hw/arm/phytium_e2000.c +73 -1

129 lines not on this page · raw message

hw/arm/phytium_e2000_machine.c +23 -3
index 7397c58a78..3ab82c5fff 100644
@@ -53,6 +53,15 @@ static void phytium_e2000_attach_sd_cards(PhytiumPiMachineState *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 void phytium_e2000_create_ram(PhytiumPiMachineState *s)
 {
     MachineState *ms = MACHINE(s);
@@ -83,6 +92,8 @@ static void phytium_e2000_create_ram(PhytiumPiMachineState *s)
 static void phytium_pi_init(MachineState *ms)
 {
     PhytiumPiMachineState *s = PHYTIUM_PI(ms);
+    BlockBackend *boot_blk;
+    bool firmware_loaded;
 
     /*
      * KVM cannot provide the heterogeneous FTC CPU configuration applied to
@@ -107,20 +118,25 @@ static void phytium_pi_init(MachineState *ms)
         exit(1);
     }
 
+    phytium_e2000_reject_legacy_firmware(ms);
     phytium_e2000_create_ram(s);
+    boot_blk = ms->kernel_filename ? NULL : phytium_e2000_sd_blk(0);
 
     object_initialize_child(OBJECT(s), "soc", &s->soc,
                             TYPE_PHYTIUM_E2000_SOC);
-    phytium_e2000_soc_configure(&s->soc, ms->smp.cpus);
+    phytium_e2000_soc_configure(&s->soc,
+                                PHYTIUM_E2000_PBR_BOOT_MODE_SD0,
+                                boot_blk, ms->ram_size, ms->smp.cpus);
     sysbus_realize(SYS_BUS_DEVICE(&s->soc), &error_fatal);
     phytium_e2000_attach_sd_cards(s);
 
+    firmware_loaded = phytium_e2000_soc_firmware_loaded(&s->soc);
     s->bootinfo.ram_size = ms->ram_size;
     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(phytium_e2000_soc_cpu(&s->soc, 0), ms, &s->bootinfo);
 }
 
@@ -167,7 +183,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
author
#16 lore raw

PATCH v2 16/32 hw/arm: phytium: Add Phytium E2000 control region placeholders

In reply to Bin Meng

The 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.

---

Changes in v2:
- Make the E2000 SoC own its placeholder regions

 include/hw/arm/phytium_e2000.h |  5 +++++
 hw/arm/phytium_e2000.c         | 25 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+)
include/hw/arm/phytium_e2000.h +5 -0
index 6199bb7b5c..15aa1cddd1 100644
@@ -41,6 +41,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,
@@ -52,6 +54,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,
hw/arm/phytium_e2000.c +25 -0
index 6818d081b3..18d64aca69 100644
@@ -68,6 +68,8 @@ 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 },
@@ -79,6 +81,9 @@ 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 },
@@ -581,6 +586,17 @@ static void phytium_e2000_create_unimplemented(PhytiumE2000SoCState *s)
     phytium_e2000_create_unimplemented_region(
         s, "low-peripheral", "phytium-e2000.low-peripheral",
         PHYTIUM_E2000_LOW_PERIPH);
+    /*
+     * 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.
+     */
+    phytium_e2000_create_unimplemented_region(
+        s, "clock-control", "phytium-e2000.clock-control",
+        PHYTIUM_E2000_CLK_CTRL);
+    phytium_e2000_create_unimplemented_region(
+        s, "system-control", "phytium-e2000.system-control",
+        PHYTIUM_E2000_SYSTEM_CTRL);
     /*
      * PBF programs SoC-specific PCIe PHY and port controls before U-Boot
      * enumerates ECAM. Their values do not affect the generic host bridge, so
@@ -595,6 +611,15 @@ static void phytium_e2000_create_unimplemented(PhytiumE2000SoCState *s)
     phytium_e2000_create_unimplemented_region(
         s, "board-control", "phytium-e2000.board-control",
         PHYTIUM_E2000_BOARD_CTRL);
+    phytium_e2000_create_unimplemented_region(
+        s, "platform-control", "phytium-e2000.platform-control",
+        PHYTIUM_E2000_PLATFORM_CTRL);
+    phytium_e2000_create_unimplemented_region(
+        s, "security-control", "phytium-e2000.security-control",
+        PHYTIUM_E2000_SECURITY_CTRL);
+    phytium_e2000_create_unimplemented_region(
+        s, "chip-control", "phytium-e2000.chip-control",
+        PHYTIUM_E2000_CHIP_CTRL);
 }
 
 static void phytium_e2000_create_cpus(PhytiumE2000SoCState *s)
Signature · 1 line
2.53.0
author
#17 lore raw

PATCH v2 17/32 hw/misc: Support Phytium E2000 SCMI CPU power control

In reply to Bin Meng

The 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.

---

Changes in v2:
- Connect MHU to the SoC-owned CPU children
- Use the SoC CPU count when wiring SCMI power control

 include/hw/misc/phytium_e2000_mhu.h |   9 +
 include/hw/misc/phytium_e2000_pbr.h |   7 +
 hw/arm/phytium_e2000.c              |  18 ++
 hw/misc/phytium_e2000_mhu.c         | 384 ++++++++++++++++++++++++++--
 hw/misc/phytium_e2000_pbr.c         | 153 ++++++++++-
 5 files changed, 543 insertions(+), 28 deletions(-)
include/hw/misc/phytium_e2000_mhu.h +9 -0
index 0527d6fe8d..013f55a820 100644
@@ -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  4
 
 void 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
index 890d419254..03f055dcd0 100644
@@ -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);
 
hw/arm/phytium_e2000.c +18 -0
index 18d64aca69..e3fea5ada1 100644
@@ -566,12 +566,30 @@ static void phytium_e2000_create_mhu(PhytiumE2000SoCState *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 < s->num_cpus; i++) {
+        phytium_e2000_mhu_connect_cpu(PHYTIUM_E2000_MHU(dev), i,
+                                      phytium_e2000_cpu_mp_affinity(i),
+                                      CPU(&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

Signature · 1 line
2.53.0
author
#18 lore raw

PATCH v2 18/32 hw/arm: phytium: Select the Phytium E2000 PBR boot medium

In reply to Bin Meng

Introduce 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.

---

Changes in v2:
- Keep board boot straps and media policy in the machine layer

 hw/arm/phytium_e2000_machine.c | 89 +++++++++++++++++++++++++---------
 1 file changed, 65 insertions(+), 24 deletions(-)
hw/arm/phytium_e2000_machine.c +65 -24
index 3ab82c5fff..0337795f2d 100644
@@ -24,10 +24,14 @@
 #include "qom/object.h"
 #include "target/arm/cpu-qom.h"
 
+#define TYPE_PHYTIUM_E2000_MACHINE \
+    MACHINE_TYPE_NAME("phytium-e2000-base")
+OBJECT_DECLARE_TYPE(PhytiumE2000MachineState, PhytiumE2000MachineClass,
+                    PHYTIUM_E2000_MACHINE)
+
 #define TYPE_PHYTIUM_PI MACHINE_TYPE_NAME("phytium-pi")
-OBJECT_DECLARE_SIMPLE_TYPE(PhytiumPiMachineState, PHYTIUM_PI)
 
-struct PhytiumPiMachineState {
+struct PhytiumE2000MachineState {
     MachineState parent_obj;
 
     struct arm_boot_info bootinfo;
@@ -36,6 +40,13 @@ struct PhytiumPiMachineState {
     MemoryRegion ram_high;
 };
 
+struct PhytiumE2000MachineClass {
+    MachineClass parent_class;
+
+    const char *machine_name;
+    const char *pbr_boot_mode;
+};
+
 static BlockBackend *phytium_e2000_sd_blk(int index)
 {
     DriveInfo *dinfo = drive_get(IF_SD, 0, index);
@@ -43,7 +54,7 @@ static BlockBackend *phytium_e2000_sd_blk(int index)
     return dinfo ? blk_by_legacy_dinfo(dinfo) : NULL;
 }
 
-static void phytium_e2000_attach_sd_cards(PhytiumPiMachineState *s)
+static void phytium_e2000_attach_sd_cards(PhytiumE2000MachineState *s)
 {
     int i;
 
@@ -53,16 +64,21 @@ static void phytium_e2000_attach_sd_cards(PhytiumPiMachineState *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);
     }
 }
 
-static void phytium_e2000_create_ram(PhytiumPiMachineState *s)
+static void phytium_e2000_create_ram(PhytiumE2000MachineState *s)
 {
     MachineState *ms = MACHINE(s);
     uint64_t low_size =
@@ -89,9 +105,11 @@ static void phytium_e2000_create_ram(PhytiumPiMachineState *s)
         phytium_e2000_memmap[PHYTIUM_E2000_RAM_HIGH].base, &s->ram_high);
 }
 
-static void phytium_pi_init(MachineState *ms)
+static void phytium_e2000_init(MachineState *ms)
 {
-    PhytiumPiMachineState *s = PHYTIUM_PI(ms);
+    PhytiumE2000MachineState *s = PHYTIUM_E2000_MACHINE(ms);
+    PhytiumE2000MachineClass *pemc =
+        PHYTIUM_E2000_MACHINE_GET_CLASS(ms);
     BlockBackend *boot_blk;
     bool firmware_loaded;
 
@@ -101,12 +119,12 @@ static void phytium_pi_init(MachineState *ms)
      * Phytium-specific system registers that KVM cannot provide.
      */
     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);
     }
@@ -114,18 +132,22 @@ 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);
-    boot_blk = ms->kernel_filename ? NULL : phytium_e2000_sd_blk(0);
+    if (!ms->kernel_filename &&
+        !strcmp(pemc->pbr_boot_mode, PHYTIUM_E2000_PBR_BOOT_MODE_SD0)) {
+        boot_blk = phytium_e2000_sd_blk(0);
+    } else {
+        boot_blk = NULL;
+    }
 
     object_initialize_child(OBJECT(s), "soc", &s->soc,
                             TYPE_PHYTIUM_E2000_SOC);
-    phytium_e2000_soc_configure(&s->soc,
-                                PHYTIUM_E2000_PBR_BOOT_MODE_SD0,
+    phytium_e2000_soc_configure(&s->soc, pemc->pbr_boot_mode,
                                 boot_blk, ms->ram_size, ms->smp.cpus);
     sysbus_realize(SYS_BUS_DEVICE(&s->soc), &error_fatal);
     phytium_e2000_attach_sd_cards(s);
@@ -169,7 +191,7 @@ static const CPUArchIdList *phytium_e2000_possible_cpu_arch_ids(
     return 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[] = {
@@ -177,8 +199,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("cortex-a72");
     mc->valid_cpu_types = valid_cpu_types;
     mc->max_cpus = PHYTIUM_E2000_NUM_CPUS;
@@ -190,21 +211,41 @@ 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(PhytiumE2000MachineState),
+};
+
 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(PhytiumPiMachineState),
 };
 
-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
author
#19 lore raw

PATCH v2 19/32 hw/arm: phytium: Connect the Phytium E2000 I2C controller

In reply to Bin Meng

Instantiate the DesignWare-compatible I2C controller during E2000 SoC realization and wire its documented interrupt.

Leave board-specific I2C slave devices unmodeled.

---

Changes in v2:
- Move the I2C controller into the E2000 SoC

 include/hw/arm/phytium_e2000.h |  1 +
 hw/arm/phytium_e2000.c         | 18 ++++++++++++++++++
 hw/arm/Kconfig                 |  1 +
 3 files changed, 20 insertions(+)
include/hw/arm/phytium_e2000.h +1 -0
index 15aa1cddd1..228d1ecab0 100644
@@ -40,6 +40,7 @@ enum {
     PHYTIUM_E2000_UART3,
     PHYTIUM_E2000_UART4,
     PHYTIUM_E2000_UART5,
+    PHYTIUM_E2000_I2C,
     PHYTIUM_E2000_UART6,
     PHYTIUM_E2000_CLK_CTRL,
     PHYTIUM_E2000_SYSTEM_CTRL,
hw/arm/phytium_e2000.c +18 -0
index e3fea5ada1..c282de7088 100644
@@ -21,6 +21,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"
@@ -67,6 +68,7 @@ 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 },
@@ -108,6 +110,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
@@ -341,6 +345,19 @@ static void phytium_e2000_create_unimplemented_region(
                             phytium_e2000_memmap[map_idx].base, -1000);
 }
 
+static void phytium_e2000_create_i2c(PhytiumE2000SoCState *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(PhytiumE2000SoCState *s, int index)
 {
     DeviceState *dev = qdev_new(TYPE_CADENCE_GEM);
@@ -774,6 +791,7 @@ static void phytium_e2000_soc_realize(DeviceState *dev, Error **errp)
     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);
     }
hw/arm/Kconfig +1 -0
index e4111eaec2..a77a4c2a09 100644
@@ -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
Signature · 1 line
2.53.0
author
#20 lore raw

PATCH v2 20/32 hw/arm: phytium: Add Phytium E2000 xHCI controllers

In reply to Bin Meng

Instantiate 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.

---

Changes in v2:
- Move the xHCI controllers into the E2000 SoC

 include/hw/arm/phytium_e2000.h |  2 ++
 hw/arm/phytium_e2000.c         | 32 ++++++++++++++++++++++++++++++++
 hw/arm/Kconfig                 |  1 +
 3 files changed, 35 insertions(+)
include/hw/arm/phytium_e2000.h +2 -0
index 228d1ecab0..079f7298e9 100644
@@ -51,6 +51,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,
hw/arm/phytium_e2000.c +32 -0
index c282de7088..e74005289f 100644
@@ -31,6 +31,7 @@
 #include "hw/pci-host/gpex.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"
@@ -43,6 +44,7 @@
 #define PHYTIUM_E2000_NUM_IRQS        256
 
 #define PHYTIUM_E2000_NUM_UARTS       7
+#define PHYTIUM_E2000_NUM_XHCIS       2
 
 #define PHYTIUM_E2000_MHU_BASE        0x32a00000
 #define PHYTIUM_E2000_SCP_SRAM_BASE   0x32a10000
@@ -79,6 +81,8 @@ 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 },
@@ -112,6 +116,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
@@ -397,6 +406,26 @@ static void phytium_e2000_create_gem(PhytiumE2000SoCState *s, int index)
     }
 }
 
+static void phytium_e2000_create_xhci(PhytiumE2000SoCState *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)
 {
@@ -792,6 +821,9 @@ static void phytium_e2000_soc_realize(DeviceState *dev, Error **errp)
         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);
     }
hw/arm/Kconfig +1 -0
index a77a4c2a09..39a7f77611 100644
@@ -141,6 +141,7 @@ config PHYTIUM_E2000
     select PL011
     select SD
     select UNIMP
+    select USB_XHCI_SYSBUS
 
 config REALVIEW
     bool
Signature · 1 line
2.53.0
author
#21 lore raw

PATCH v2 21/32 hw/misc: Model the Phytium E2000 random generator

In reply to Bin Meng

Implement 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.

---

(no changes since v1)

 include/hw/misc/phytium_e2000_rng.h |  23 ++++
 hw/misc/phytium_e2000_rng.c         | 182 ++++++++++++++++++++++++++++
 hw/misc/meson.build                 |   1 +
 3 files changed, 206 insertions(+)
 create mode 100644 include/hw/misc/phytium_e2000_rng.h
 create mode 100644 hw/misc/phytium_e2000_rng.c
include/hw/misc/phytium_e2000_rng.h new file +23 -0
new file mode 100644
index 0000000000..d8c73e20a9
@@ -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
hw/misc/phytium_e2000_rng.c new file +182 -0

182 lines not on this page · raw message

hw/misc/meson.build +1 -0
index 8579004e88..60f36fa80a 100644
@@ -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'))
 
Signature · 1 line
2.53.0
author
#22 lore raw

PATCH v2 22/32 hw/arm: phytium: Connect the Phytium E2000 random generator

In reply to Bin Meng

Instantiate the RNG during E2000 SoC realization and map it over the placeholder.

---

Changes in v2:
- Move the random generator into the E2000 SoC

 include/hw/arm/phytium_e2000.h |  1 +
 hw/arm/phytium_e2000.c         | 14 ++++++++++++++
 2 files changed, 15 insertions(+)
include/hw/arm/phytium_e2000.h +1 -0
index 079f7298e9..ee645ce530 100644
@@ -57,6 +57,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,
hw/arm/phytium_e2000.c +14 -0
index e74005289f..33617e793a 100644
@@ -25,6 +25,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"
@@ -87,6 +88,7 @@ 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 },
@@ -594,6 +596,17 @@ static void phytium_e2000_create_ddr_status(PhytiumE2000SoCState *s)
     sysbus_mmio_map_overlap(sbd, 0, PHYTIUM_E2000_DDR_STATUS_BASE, 2);
 }
 
+static void phytium_e2000_create_rng(PhytiumE2000SoCState *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(PhytiumE2000SoCState *s)
 {
     /*
@@ -812,6 +825,7 @@ static void phytium_e2000_soc_realize(DeviceState *dev, Error **errp)
 
     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
author
#23 lore raw

PATCH v2 23/32 hw/arm: phytium: Support Phytium E2000 direct Linux boot

In reply to Bin Meng

Allow 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.

---

Changes in v2:
- Pass the SoC-owned primary ARMCPU to the boot loader

 hw/arm/phytium_e2000_machine.c | 65 ++++++++++++++++++++++++++++++++++
 1 file changed, 65 insertions(+)
hw/arm/phytium_e2000_machine.c +65 -0
index 0337795f2d..41bce8a64b 100644
@@ -15,6 +15,7 @@
 #include "qapi/error.h"
 #include "system/address-spaces.h"
 #include "system/block-backend-global-state.h"
+#include "system/device_tree.h"
 #include "system/kvm.h"
 #include "exec/hwaddr.h"
 #include "hw/arm/boot.h"
@@ -44,6 +45,7 @@ struct PhytiumE2000MachineClass {
     MachineClass parent_class;
 
     const char *machine_name;
+    const char *direct_boot_dtb;
     const char *pbr_boot_mode;
 };
 
@@ -105,6 +107,61 @@ static void phytium_e2000_create_ram(PhytiumE2000MachineState *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_init(MachineState *ms)
 {
     PhytiumE2000MachineState *s = PHYTIUM_E2000_MACHINE(ms);
@@ -123,6 +180,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);
@@ -159,6 +222,7 @@ static void phytium_e2000_init(MachineState *ms)
         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(phytium_e2000_soc_cpu(&s->soc, 0), ms, &s->bootinfo);
 }
 
@@ -224,6 +288,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
author
#24 lore raw

PATCH v2 24/32 hw/arm: phytium: Add Phytium E2000Q COMe machine

In reply to Bin Meng

Add 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.

---

(no changes since v1)

 hw/arm/phytium_e2000_machine.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)
hw/arm/phytium_e2000_machine.c +21 -1
index 41bce8a64b..c1944cb986 100644
@@ -30,7 +30,8 @@
 OBJECT_DECLARE_TYPE(PhytiumE2000MachineState, 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")
 
 struct PhytiumE2000MachineState {
     MachineState parent_obj;
@@ -292,6 +293,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,
@@ -307,10 +320,17 @@ static const TypeInfo phytium_pi_info = {
     .class_init = phytium_pi_class_init,
 };
 
+static const TypeInfo phytium_e2000_come_info = {
+    .name = TYPE_PHYTIUM_E2000_COME,
+    .parent = TYPE_PHYTIUM_E2000_MACHINE,
+    .class_init = phytium_e2000_come_class_init,
+};
+
 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
author
#25 lore raw

PATCH v2 25/32 hw/block: m25p80: Add GigaDevice GD25Q128 flash

In reply to Bin Meng

Add 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.

---

(no changes since v1)

 hw/block/m25p80.c | 1 +
 1 file changed, 1 insertion(+)
hw/block/m25p80.c +1 -0
index 545e0b5728..60a9b1f8d5 100644
@@ -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
author
#26 lore raw

PATCH v2 26/32 hw/arm: phytium: Connect the Phytium E2000Q COMe QSPI flash

In reply to Bin Meng

Attach 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.

---

Changes in v2:
- Keep QSPI flash ownership in the COMe machine
- Pass the board flash backend into the E2000 SoC
- Use the typed QSPI child through generic qdev interfaces

 include/hw/arm/phytium_e2000.h |  2 ++
 hw/arm/phytium_e2000.c         | 13 +++++++++++++
 hw/arm/phytium_e2000_machine.c | 33 +++++++++++++++++++++++++++++----
 hw/arm/Kconfig                 |  1 +
 4 files changed, 45 insertions(+), 4 deletions(-)
include/hw/arm/phytium_e2000.h +2 -0
index ee645ce530..baf9edd261 100644
@@ -105,5 +105,7 @@ bool phytium_e2000_soc_firmware_loaded(PhytiumE2000SoCState *s);
 void phytium_e2000_soc_attach_sd_card(PhytiumE2000SoCState *s,
                                       unsigned int index,
                                       BlockBackend *blk);
+void phytium_e2000_soc_attach_qspi_flash(PhytiumE2000SoCState *s,
+                                         DeviceState *flash);
 
 #endif
hw/arm/phytium_e2000.c +13 -0
index 33617e793a..4ded28814e 100644
@@ -32,6 +32,7 @@
 #include "hw/pci-host/gpex.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"
@@ -802,6 +803,18 @@ void phytium_e2000_soc_attach_sd_card(PhytiumE2000SoCState *s,
     qdev_realize_and_unref(card, bus, &error_fatal);
 }
 
+void phytium_e2000_soc_attach_qspi_flash(PhytiumE2000SoCState *s,
+                                         DeviceState *flash)
+{
+    qemu_irq flash_cs;
+
+    qdev_realize_and_unref(flash,
+                           qdev_get_child_bus(DEVICE(s->qspi), "spi"),
+                           &error_fatal);
+    flash_cs = qdev_get_gpio_in_named(flash, SSI_GPIO_CS, 0);
+    qdev_connect_gpio_out_named(DEVICE(s->qspi), "cs", 0, flash_cs);
+}
+
 static void phytium_e2000_soc_realize(DeviceState *dev, Error **errp)
 {
     PhytiumE2000SoCState *s = PHYTIUM_E2000_SOC(dev);
hw/arm/phytium_e2000_machine.c +29 -4
index c1944cb986..5ca2922e91 100644
@@ -22,6 +22,7 @@
 #include "hw/arm/bsa.h"
 #include "hw/arm/phytium_e2000.h"
 #include "hw/core/boards.h"
+#include "hw/core/qdev-properties.h"
 #include "qom/object.h"
 #include "target/arm/cpu-qom.h"
 
@@ -48,11 +49,13 @@ struct PhytiumE2000MachineClass {
     const char *machine_name;
     const char *direct_boot_dtb;
     const char *pbr_boot_mode;
+    const char *qspi_flash_model;
 };
 
-static BlockBackend *phytium_e2000_sd_blk(int index)
+static BlockBackend *phytium_e2000_drive_blk(BlockInterfaceType type,
+                                             int index)
 {
-    DriveInfo *dinfo = drive_get(IF_SD, 0, index);
+    DriveInfo *dinfo = drive_get(type, 0, index);
 
     return dinfo ? blk_by_legacy_dinfo(dinfo) : NULL;
 }
@@ -63,10 +66,24 @@ static void phytium_e2000_attach_sd_cards(PhytiumE2000MachineState *s)
 
     for (i = 0; i < PHYTIUM_E2000_NUM_MCIS; i++) {
         phytium_e2000_soc_attach_sd_card(
-            &s->soc, i, phytium_e2000_sd_blk(i));
+            &s->soc, i, phytium_e2000_drive_blk(IF_SD, i));
     }
 }
 
+static void phytium_e2000_attach_qspi_flash(
+    PhytiumE2000MachineState *s, const char *model)
+{
+    DeviceState *flash = qdev_new(model);
+    DriveInfo *dinfo = drive_get(IF_MTD, 0, 0);
+
+    object_property_add_child(OBJECT(s), "qspi-flash", OBJECT(flash));
+    if (dinfo) {
+        qdev_prop_set_drive_err(flash, "drive", blk_by_legacy_dinfo(dinfo),
+                                &error_fatal);
+    }
+    phytium_e2000_soc_attach_qspi_flash(&s->soc, flash);
+}
+
 static void phytium_e2000_reject_legacy_firmware(
     MachineState *ms, PhytiumE2000MachineClass *pemc)
 {
@@ -204,7 +221,11 @@ static void phytium_e2000_init(MachineState *ms)
     phytium_e2000_create_ram(s);
     if (!ms->kernel_filename &&
         !strcmp(pemc->pbr_boot_mode, PHYTIUM_E2000_PBR_BOOT_MODE_SD0)) {
-        boot_blk = phytium_e2000_sd_blk(0);
+        boot_blk = phytium_e2000_drive_blk(IF_SD, 0);
+    } else if (!ms->kernel_filename &&
+               !strcmp(pemc->pbr_boot_mode,
+                       PHYTIUM_E2000_PBR_BOOT_MODE_QSPI)) {
+        boot_blk = phytium_e2000_drive_blk(IF_MTD, 0);
     } else {
         boot_blk = NULL;
     }
@@ -215,6 +236,9 @@ static void phytium_e2000_init(MachineState *ms)
                                 boot_blk, ms->ram_size, ms->smp.cpus);
     sysbus_realize(SYS_BUS_DEVICE(&s->soc), &error_fatal);
     phytium_e2000_attach_sd_cards(s);
+    if (pemc->qspi_flash_model) {
+        phytium_e2000_attach_qspi_flash(s, pemc->qspi_flash_model);
+    }
 
     firmware_loaded = phytium_e2000_soc_firmware_loaded(&s->soc);
     s->bootinfo.ram_size = ms->ram_size;
@@ -303,6 +327,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 = {
hw/arm/Kconfig +1 -0
index 39a7f77611..988e8e0327 100644
@@ -140,6 +140,7 @@ config PHYTIUM_E2000
     select PHYTIUM_E2000_QSPI
     select PL011
     select SD
+    select SSI_M25P80
     select UNIMP
     select USB_XHCI_SYSBUS
 
Signature · 1 line
2.53.0
author
#27 lore raw

PATCH v2 27/32 hw/arm: phytium: Add Phytium E2000 AHCI controllers

In reply to Bin Meng

Add 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.

---

Changes in v2:
- Move AHCI controllers into the SoC and attach SATA in the machine

 include/hw/arm/phytium_e2000.h | 15 ++++++++++---
 hw/arm/phytium_e2000.c         | 39 ++++++++++++++++++++++++++++++++++
 hw/arm/phytium_e2000_machine.c | 27 +++++++++++++++++++++++
 hw/arm/Kconfig                 |  3 +++
 4 files changed, 81 insertions(+), 3 deletions(-)
include/hw/arm/phytium_e2000.h +12 -3
index baf9edd261..3d45a82811 100644
@@ -24,9 +24,12 @@
 #define TYPE_PHYTIUM_E2000_SOC "phytium-e2000-soc"
 OBJECT_DECLARE_SIMPLE_TYPE(PhytiumE2000SoCState, PHYTIUM_E2000_SOC)
 
-#define PHYTIUM_E2000_NUM_CPUS 4
-#define PHYTIUM_E2000_NUM_MCIS 2
-#define PHYTIUM_E2000_NUM_GEMS 4
+#define PHYTIUM_E2000_NUM_CPUS        4
+#define PHYTIUM_E2000_NUM_MCIS        2
+#define PHYTIUM_E2000_NUM_GEMS        4
+#define PHYTIUM_E2000_NUM_AHCIS       2
+#define PHYTIUM_E2000_NUM_SATA_PORTS  1
+#define PHYTIUM_E2000_SATA_BOOT_AHCI  1
 
 enum {
     PHYTIUM_E2000_QSPI_DIRECT,
@@ -53,10 +56,12 @@ enum {
     PHYTIUM_E2000_BOARD_CTRL,
     PHYTIUM_E2000_XHCI0,
     PHYTIUM_E2000_XHCI1,
+    PHYTIUM_E2000_AHCI0,
     PHYTIUM_E2000_GEM0,
     PHYTIUM_E2000_GEM1,
     PHYTIUM_E2000_GEM2,
     PHYTIUM_E2000_GEM3,
+    PHYTIUM_E2000_AHCI1,
     PHYTIUM_E2000_RNG_REGS,
     PHYTIUM_E2000_PLATFORM_CTRL,
     PHYTIUM_E2000_SECURITY_CTRL,
@@ -77,6 +82,7 @@ struct PhytiumE2000SoCState {
 
     DeviceState *gic;
     PhytiumE2000QSPIState *qspi;
+    DeviceState *ahci[PHYTIUM_E2000_NUM_AHCIS];
     PhytiumE2000PBRState *pbr;
     PhytiumE2000MciState *mci[PHYTIUM_E2000_NUM_MCIS];
     CadenceGEMState *gem[PHYTIUM_E2000_NUM_GEMS];
@@ -107,5 +113,8 @@ void phytium_e2000_soc_attach_sd_card(PhytiumE2000SoCState *s,
                                       BlockBackend *blk);
 void phytium_e2000_soc_attach_qspi_flash(PhytiumE2000SoCState *s,
                                          DeviceState *flash);
+void phytium_e2000_soc_attach_sata(PhytiumE2000SoCState *s,
+                                   unsigned int index,
+                                   DriveInfo **drives);
 
 #endif
hw/arm/phytium_e2000.c +39 -0
index 4ded28814e..bc3491ca27 100644
@@ -19,6 +19,8 @@
 #include "hw/arm/phytium_e2000.h"
 #include "hw/char/pl011.h"
 #include "hw/core/qdev-properties.h"
+#include "hw/ide/ahci-sysbus.h"
+#include "hw/ide/ide-bus.h"
 #include "hw/intc/arm_gicv3_common.h"
 #include "hw/intc/arm_gicv3_its_common.h"
 #include "hw/i2c/designware_i2c.h"
@@ -85,10 +87,12 @@ const MemMapEntry phytium_e2000_memmap[] = {
     [PHYTIUM_E2000_BOARD_CTRL] =     { 0x31800000, 0x01400000 },
     [PHYTIUM_E2000_XHCI0] =          { 0x31a08000, 0x00018000 },
     [PHYTIUM_E2000_XHCI1] =          { 0x31a28000, 0x00018000 },
+    [PHYTIUM_E2000_AHCI0] =          { 0x31a40000, 0x00001000 },
     [PHYTIUM_E2000_GEM0] =           { 0x3200c000, 0x00002000 },
     [PHYTIUM_E2000_GEM1] =           { 0x3200e000, 0x00002000 },
     [PHYTIUM_E2000_GEM2] =           { 0x32010000, 0x00002000 },
     [PHYTIUM_E2000_GEM3] =           { 0x32012000, 0x00002000 },
+    [PHYTIUM_E2000_AHCI1] =          { 0x32014000, 0x00001000 },
     [PHYTIUM_E2000_RNG_REGS] =       { 0x32a36000, 0x00001000 },
     [PHYTIUM_E2000_PLATFORM_CTRL] =  { 0x32e40000, 0x00010000 },
     [PHYTIUM_E2000_SECURITY_CTRL] =  { 0x32f00000, 0x00001000 },
@@ -124,6 +128,11 @@ static const int phytium_e2000_xhci_irqmap[] = {
     [1] = 17,
 };
 
+static const int phytium_e2000_ahci_irqmap[] = {
+    [0] = 42,
+    [1] = 43,
+};
+
 static const uint8_t phytium_e2000_gem_num_queues[] = { 8, 4, 4, 4 };
 
 static const int
@@ -409,6 +418,22 @@ static void phytium_e2000_create_gem(PhytiumE2000SoCState *s, int index)
     }
 }
 
+static void phytium_e2000_create_ahci(PhytiumE2000SoCState *s, int index)
+{
+    int map_idx = index ? PHYTIUM_E2000_AHCI1 : PHYTIUM_E2000_AHCI0;
+    DeviceState *dev = qdev_new(TYPE_SYSBUS_AHCI);
+    g_autofree char *name = g_strdup_printf("ahci%d", index);
+
+    s->ahci[index] = dev;
+    object_property_add_child(OBJECT(s), name, OBJECT(dev));
+    qdev_prop_set_uint32(dev, "num-ports", PHYTIUM_E2000_NUM_SATA_PORTS);
+    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
+    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0,
+        phytium_e2000_memmap[map_idx].base);
+    sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
+        qdev_get_gpio_in(s->gic, phytium_e2000_ahci_irqmap[index]));
+}
+
 static void phytium_e2000_create_xhci(PhytiumE2000SoCState *s, int index)
 {
     int map_idx = PHYTIUM_E2000_XHCI0 + index;
@@ -815,6 +840,17 @@ void phytium_e2000_soc_attach_qspi_flash(PhytiumE2000SoCState *s,
     qdev_connect_gpio_out_named(DEVICE(s->qspi), "cs", 0, flash_cs);
 }
 
+void phytium_e2000_soc_attach_sata(PhytiumE2000SoCState *s,
+                                   unsigned int index,
+                                   DriveInfo **drives)
+{
+    SysbusAHCIState *sysahci;
+
+    g_assert(index < ARRAY_SIZE(s->ahci));
+    sysahci = SYSBUS_AHCI(s->ahci[index]);
+    ahci_ide_create_devs(&sysahci->ahci, drives);
+}
+
 static void phytium_e2000_soc_realize(DeviceState *dev, Error **errp)
 {
     PhytiumE2000SoCState *s = PHYTIUM_E2000_SOC(dev);
@@ -851,6 +887,9 @@ static void phytium_e2000_soc_realize(DeviceState *dev, Error **errp)
     for (i = 0; i < PHYTIUM_E2000_NUM_XHCIS; i++) {
         phytium_e2000_create_xhci(s, i);
     }
+    for (i = 0; i < PHYTIUM_E2000_NUM_AHCIS; i++) {
+        phytium_e2000_create_ahci(s, i);
+    }
     for (i = 0; i < PHYTIUM_E2000_NUM_GEMS; i++) {
         phytium_e2000_create_gem(s, i);
     }
hw/arm/phytium_e2000_machine.c +27 -0
index 5ca2922e91..9c41403ba9 100644
@@ -23,6 +23,7 @@
 #include "hw/arm/phytium_e2000.h"
 #include "hw/core/boards.h"
 #include "hw/core/qdev-properties.h"
+#include "hw/ide/ide-bus.h"
 #include "qom/object.h"
 #include "target/arm/cpu-qom.h"
 
@@ -50,6 +51,7 @@ struct PhytiumE2000MachineClass {
     const char *direct_boot_dtb;
     const char *pbr_boot_mode;
     const char *qspi_flash_model;
+    bool has_sata_boot;
 };
 
 static BlockBackend *phytium_e2000_drive_blk(BlockInterfaceType type,
@@ -84,6 +86,19 @@ static void phytium_e2000_attach_qspi_flash(
     phytium_e2000_soc_attach_qspi_flash(&s->soc, flash);
 }
 
+static void phytium_e2000_attach_sata(PhytiumE2000MachineState *s)
+{
+    DriveInfo *hd[PHYTIUM_E2000_NUM_SATA_PORTS] = {};
+
+    /*
+     * The COMe boot disk is wired to the second fixed AHCI controller. U-Boot
+     * probes both controllers and exposes the only attached disk as scsi 0.
+     */
+    ide_drive_get(hd, ARRAY_SIZE(hd));
+    phytium_e2000_soc_attach_sata(&s->soc,
+                                  PHYTIUM_E2000_SATA_BOOT_AHCI, hd);
+}
+
 static void phytium_e2000_reject_legacy_firmware(
     MachineState *ms, PhytiumE2000MachineClass *pemc)
 {
@@ -217,6 +232,12 @@ static void phytium_e2000_init(MachineState *ms)
         exit(1);
     }
 
+    if (!pemc->has_sata_boot && drive_get_by_index(IF_IDE, 0)) {
+        error_report("%s does not expose a SATA boot disk; "
+                     "use if=sd,index=0", pemc->machine_name);
+        exit(1);
+    }
+
     phytium_e2000_reject_legacy_firmware(ms, pemc);
     phytium_e2000_create_ram(s);
     if (!ms->kernel_filename &&
@@ -239,6 +260,9 @@ static void phytium_e2000_init(MachineState *ms)
     if (pemc->qspi_flash_model) {
         phytium_e2000_attach_qspi_flash(s, pemc->qspi_flash_model);
     }
+    if (pemc->has_sata_boot) {
+        phytium_e2000_attach_sata(s);
+    }
 
     firmware_loaded = phytium_e2000_soc_firmware_loaded(&s->soc);
     s->bootinfo.ram_size = ms->ram_size;
@@ -315,6 +339,7 @@ static void phytium_pi_class_init(ObjectClass *oc, const void *data)
     pemc->machine_name = "phytium-pi";
     pemc->direct_boot_dtb = "phytiumpi_firefly.dtb";
     pemc->pbr_boot_mode = PHYTIUM_E2000_PBR_BOOT_MODE_SD0;
+    pemc->has_sata_boot = false;
 }
 
 static void phytium_e2000_come_class_init(ObjectClass *oc, const void *data)
@@ -324,10 +349,12 @@ static void phytium_e2000_come_class_init(ObjectClass *oc, const void *data)
         PHYTIUM_E2000_MACHINE_CLASS(oc);
 
     mc->desc = "Phytium E2000Q COMe Development Board";
+    mc->block_default_type = IF_IDE;
     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";
+    pemc->has_sata_boot = true;
 }
 
 static const TypeInfo phytium_e2000_base_info = {
hw/arm/Kconfig +3 -0
index 988e8e0327..9b6a1f1d5b 100644
@@ -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
Signature · 1 line
2.53.0
author
#28 lore raw

PATCH v2 28/32 hw/arm: Add Phytium E2000 Linux SCMI channel

In reply to Bin Meng

The 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.

---

Changes in v2:
- Keep the Linux SCMI channel inside the E2000 SoC

 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
index bc3491ca27..cb94318430 100644
@@ -143,6 +143,8 @@ phytium_e2000_gem_irqmap[PHYTIUM_E2000_NUM_GEMS][MAX_PRIORITY_QUEUES] = {
     [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,
@@ -677,6 +679,8 @@ static void phytium_e2000_create_mhu(PhytiumE2000SoCState *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(PhytiumE2000SoCState *s)
hw/misc/phytium_e2000_mhu.c +377 -80

581 lines not on this page · raw message

Signature · 1 line
2.53.0
author
#29 lore raw

PATCH v2 29/32 hw/arm: phytium: Connect the Phytium E2000 SMMUv3

In reply to Bin Meng

The 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.

---

Changes in v2:
- Move SMMUv3 into the E2000 SoC

 hw/arm/phytium_e2000.c | 39 +++++++++++++++++++++++++++++++++++++--
 hw/arm/Kconfig         |  1 +
 2 files changed, 38 insertions(+), 2 deletions(-)
hw/arm/phytium_e2000.c +37 -2
index cb94318430..b4ccf71d0c 100644
@@ -17,6 +17,7 @@
 #include "exec/hwaddr.h"
 #include "hw/arm/bsa.h"
 #include "hw/arm/phytium_e2000.h"
+#include "hw/arm/smmuv3.h"
 #include "hw/char/pl011.h"
 #include "hw/core/qdev-properties.h"
 #include "hw/ide/ahci-sysbus.h"
@@ -49,6 +50,7 @@
 
 #define PHYTIUM_E2000_NUM_UARTS       7
 #define PHYTIUM_E2000_NUM_XHCIS       2
+#define PHYTIUM_E2000_NUM_SMMU_IRQS   4
 
 #define PHYTIUM_E2000_MHU_BASE        0x32a00000
 #define PHYTIUM_E2000_SCP_SRAM_BASE   0x32a10000
@@ -123,6 +125,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,
@@ -462,7 +472,7 @@ static int phytium_e2000_pcie_map_irq(PCIDevice *pdev, int pin)
     return pin;
 }
 
-static void phytium_e2000_create_pcie(PhytiumE2000SoCState *s)
+static PCIBus *phytium_e2000_create_pcie(PhytiumE2000SoCState *s)
 {
     DeviceState *dev = qdev_new(TYPE_GPEX_HOST);
     SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
@@ -538,6 +548,29 @@ static void phytium_e2000_create_pcie(PhytiumE2000SoCState *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(PhytiumE2000SoCState *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_create_mci(PhytiumE2000SoCState *s, int index)
@@ -858,6 +891,7 @@ void phytium_e2000_soc_attach_sata(PhytiumE2000SoCState *s,
 static void phytium_e2000_soc_realize(DeviceState *dev, Error **errp)
 {
     PhytiumE2000SoCState *s = PHYTIUM_E2000_SOC(dev);
+    PCIBus *pcie_bus;
     int i;
 
     if (!s->num_cpus || s->num_cpus > PHYTIUM_E2000_NUM_CPUS) {
@@ -898,7 +932,8 @@ static void phytium_e2000_soc_realize(DeviceState *dev, Error **errp)
         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);
 }
 
 static void phytium_e2000_soc_class_init(ObjectClass *oc, const void *data)
hw/arm/Kconfig +1 -0
index 9b6a1f1d5b..f32ce34602 100644
@@ -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
Signature · 1 line
2.53.0
author
#30 lore raw

PATCH v2 30/32 docs/system/arm: Document Phytium E2000 machines

In reply to Bin Meng

Document 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.

---

Changes in v2:
- Describe the machine and SoC QOM split
- Describe the SoC-owned Cortex-A72 CPU configuration

 docs/system/arm/phytium_e2000.rst | 422 ++++++++++++++++++++++++++++++
 docs/system/target-arm.rst        |   1 +
 2 files changed, 423 insertions(+)
 create mode 100644 docs/system/arm/phytium_e2000.rst
docs/system/arm/phytium_e2000.rst new file +422 -0
new file mode 100644
index 0000000000..7253a4f60b
@@ -0,0 +1,422 @@
+.. 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``
+
+Each board machine embeds a ``phytium-e2000-soc`` QOM child. The SoC owns the
+CPUs, interrupt controller, and integrated peripheral controllers. The machine
+owns RAM and the boot configuration, and attaches the board-level SD card,
+QSPI flash, and SATA disk to buses exported by the SoC.
+
+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 board
+machine selects the boot strap and backend when configuring its E2000 SoC
+child. The SoC creates the QSPI and MCI controllers, maps the PBR status
+window, boot SRAM, and IACC, and connects the PBR to its CPU topology. Neither
+the machine nor the SoC parses or stages 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.
+
+All four slots instantiate SoC-owned Cortex-A72 TCG CPU objects. Before
+realizing each object, the SoC applies its FTC310 or FTC664 identity and the
+E2000 system registers used by firmware. The ``-cpu`` option therefore accepts
+only the Cortex-A72 execution base and cannot replace the heterogeneous slot
+assignments.
+
+The 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 configured core variants.
+* 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
index 260cd7e4d6..77c18b5f2e 100644
@@ -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
author
#31 lore raw

PATCH v2 31/32 tests/functional/aarch64: Add Phytium Pi boot tests

In reply to 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.

---

(no changes since v1)

 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
index f0881bed16..71bf45e4ea 100644
@@ -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
author
#32 lore raw

PATCH v2 32/32 MAINTAINERS: Add Phytium E2000Q machines

In reply to 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.

---

 MAINTAINERS | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
MAINTAINERS +15 -0
index d577cdbda5..6fb382eb06 100644
@@ -1012,6 +1012,21 @@ 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: include/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
#33 lore raw
In reply to Bin Meng
Quoted 133 lines · Bin Meng

The Phytium E2000Q is a heterogeneous Armv8 SoC with two FTC664 cores and two FTC310 cores. This series adds a reusable E2000Q SoC QOM device which owns Cortex-A72 CPU children and applies the FTC core configuration locally. Two board machines embed the SoC:

- 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 E2000Q SoC 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. Board machines retain RAM, firmware media, and storage backend attachment. 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.

Changes in v2:
- Use scripts/git.orderfile when generating the series
- Configure FTC cores as SoC-owned Cortex-A72 CPU children
- Keep Phytium CPU configuration out of the global ARM CPU list
- Explain why the Phytium machines are restricted to TCG
- Reduce the DesignWare MCI register migration state to 96 words

Bin Meng (32):
hw/arm: Add Phytium E2000 SoC and 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 controller
hw/arm: phytium: Connect the Phytium E2000 DDR controller 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                                 |   18 +
 docs/system/arm/phytium_e2000.rst           |  422 ++++++
 docs/system/target-arm.rst                  |    1 +
 include/hw/arm/phytium_e2000.h              |  120 ++
 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                      |   75 +
 include/hw/sd/phytium_e2000_mci.h           |   21 +
 include/hw/ssi/phytium_qspi.h               |   23 +
 hw/arm/phytium_e2000.c                      |  958 +++++++++++++
 hw/arm/phytium_e2000_machine.c              |  388 ++++++
 hw/block/m25p80.c                           |    1 +
 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/dw_mci.c                              | 1382 +++++++++++++++++++
 hw/sd/phytium_e2000_mci.c                   |   95 ++
 hw/ssi/phytium_qspi.c                       |  398 ++++++
 tests/qtest/dw_mci-test.c                   |  417 ++++++
 hw/arm/Kconfig                              |   22 +
 hw/arm/meson.build                          |    4 +
 hw/misc/meson.build                         |    4 +
 hw/sd/Kconfig                               |    5 +
 hw/sd/meson.build                           |    2 +
 hw/ssi/Kconfig                              |    5 +
 hw/ssi/meson.build                          |    1 +
 tests/functional/aarch64/meson.build        |    2 +
 tests/functional/aarch64/test_phytium_pi.py |   77 ++
 tests/qtest/meson.build                     |    1 +
 32 files changed, 7147 insertions(+)
 create mode 100644 docs/system/arm/phytium_e2000.rst
 create mode 100644 include/hw/arm/phytium_e2000.h
 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 hw/arm/phytium_e2000.c
 create mode 100644 hw/arm/phytium_e2000_machine.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 tests/qtest/dw_mci-test.c
 create mode 100644 tests/functional/aarch64/test_phytium_pi.py
Quoted 4 lines

---
base-commit: 35500e5c41aec76cde59befe750600dac7a9e37a
branch: phytium

Ping for review?