From: Bin Meng <bin.meng@processmission.com>
To: QEMU <qemu-devel@nongnu.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-arm@nongnu.org
Subject: [PATCH v2 26/32] hw/arm: phytium: Connect the Phytium E2000Q COMe QSPI flash
Date: Tue, 8 Sep 2026 18:41:35 +0800 [thread overview]
Message-ID: <20260908104159.1621764-27-bin.meng@processmission.com> (raw)
In-Reply-To: <20260908104159.1621764-1-bin.meng@processmission.com>
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.
Signed-off-by: Bin Meng <bin.meng@processmission.com>
---
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(-)
diff --git a/include/hw/arm/phytium_e2000.h b/include/hw/arm/phytium_e2000.h
index ee645ce530..baf9edd261 100644
--- a/include/hw/arm/phytium_e2000.h
+++ b/include/hw/arm/phytium_e2000.h
@@ -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
diff --git a/hw/arm/phytium_e2000.c b/hw/arm/phytium_e2000.c
index 33617e793a..4ded28814e 100644
--- a/hw/arm/phytium_e2000.c
+++ b/hw/arm/phytium_e2000.c
@@ -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);
diff --git a/hw/arm/phytium_e2000_machine.c b/hw/arm/phytium_e2000_machine.c
index c1944cb986..5ca2922e91 100644
--- a/hw/arm/phytium_e2000_machine.c
+++ b/hw/arm/phytium_e2000_machine.c
@@ -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 = {
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index 39a7f77611..988e8e0327 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -140,6 +140,7 @@ config PHYTIUM_E2000
select PHYTIUM_E2000_QSPI
select PL011
select SD
+ select SSI_M25P80
select UNIMP
select USB_XHCI_SYSBUS
--
2.53.0
next prev parent reply other threads:[~2026-09-08 10:43 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 10:41 [PATCH v2 00/32] hw/arm: Add Phytium E2000Q SoC and board support Bin Meng
2026-09-08 10:41 ` [PATCH v2 01/32] hw/arm: Add Phytium E2000 SoC and Phytium Pi machine Bin Meng
2026-09-08 10:41 ` [PATCH v2 02/32] hw/arm: phytium: Add Phytium E2000 PCIe host Bin Meng
2026-09-08 10:41 ` [PATCH v2 04/32] hw/sd: Add Phytium E2000 MCI controller Bin Meng
2026-09-08 10:41 ` [PATCH v2 05/32] hw/arm: phytium: Connect Phytium E2000 MCI controllers Bin Meng
2026-09-08 10:41 ` [PATCH v2 07/32] hw/arm: phytium: Connect Phytium E2000 GEM controllers Bin Meng
2026-09-08 10:41 ` [PATCH v2 08/32] hw/misc: Add Phytium E2000 DDR controller Bin Meng
2026-09-08 10:41 ` [PATCH v2 09/32] hw/arm: phytium: Connect the " Bin Meng
2026-09-08 10:41 ` [PATCH v2 10/32] hw/misc: Add Phytium E2000 MHU doorbell Bin Meng
2026-09-08 10:41 ` [PATCH v2 11/32] hw/arm: phytium: Connect the Phytium E2000 MHU Bin Meng
2026-09-08 10:41 ` [PATCH v2 12/32] hw/ssi: Add Phytium E2000 QSPI controller Bin Meng
2026-09-08 10:41 ` [PATCH v2 13/32] hw/arm: phytium: Connect the " Bin Meng
2026-09-08 10:41 ` [PATCH v2 14/32] hw/misc: Add Phytium E2000 PBR model Bin Meng
2026-09-08 10:41 ` [PATCH v2 15/32] hw/arm: phytium: Integrate the Phytium E2000 PBR Bin Meng
2026-09-08 10:41 ` [PATCH v2 16/32] hw/arm: phytium: Add Phytium E2000 control region placeholders Bin Meng
2026-09-08 10:41 ` [PATCH v2 17/32] hw/misc: Support Phytium E2000 SCMI CPU power control Bin Meng
2026-09-08 10:41 ` [PATCH v2 18/32] hw/arm: phytium: Select the Phytium E2000 PBR boot medium Bin Meng
2026-09-08 10:41 ` [PATCH v2 19/32] hw/arm: phytium: Connect the Phytium E2000 I2C controller Bin Meng
2026-09-08 10:41 ` [PATCH v2 20/32] hw/arm: phytium: Add Phytium E2000 xHCI controllers Bin Meng
2026-09-08 10:41 ` [PATCH v2 21/32] hw/misc: Model the Phytium E2000 random generator Bin Meng
2026-09-08 10:41 ` [PATCH v2 22/32] hw/arm: phytium: Connect " Bin Meng
2026-09-08 10:41 ` [PATCH v2 23/32] hw/arm: phytium: Support Phytium E2000 direct Linux boot Bin Meng
2026-09-08 10:41 ` [PATCH v2 24/32] hw/arm: phytium: Add Phytium E2000Q COMe machine Bin Meng
2026-09-08 10:41 ` Bin Meng [this message]
2026-09-08 10:41 ` [PATCH v2 27/32] hw/arm: phytium: Add Phytium E2000 AHCI controllers Bin Meng
2026-09-08 10:41 ` [PATCH v2 28/32] hw/arm: Add Phytium E2000 Linux SCMI channel Bin Meng
2026-09-08 10:41 ` [PATCH v2 29/32] hw/arm: phytium: Connect the Phytium E2000 SMMUv3 Bin Meng
2026-09-08 10:41 ` [PATCH v2 30/32] docs/system/arm: Document Phytium E2000 machines Bin Meng
2026-09-08 10:41 ` [PATCH v2 31/32] tests/functional/aarch64: Add Phytium Pi boot tests Bin Meng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260908104159.1621764-27-bin.meng@processmission.com \
--to=bin.meng@processmission.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox