[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 11/12] hw/arm: Wire up BMC boot flash for npcm750-evb and quan
From: |
Havard Skinnemoen |
Subject: |
[PATCH v2 11/12] hw/arm: Wire up BMC boot flash for npcm750-evb and quanta-gsj |
Date: |
Thu, 11 Jun 2020 15:30:15 -0700 |
This allows these NPCM7xx-based boards to boot from a flash image, e.g.
one built with OpenBMC. For example like this:
IMAGE=${OPENBMC}/build/tmp/deploy/images/gsj/image-bmc
qemu-system-arm -machine quanta-gsj -nographic \
-bios ~/qemu/bootrom/npcm7xx_bootrom.bin \
-drive file=${IMAGE},if=mtd,bus=0,unit=0,format=raw,snapshot=on
Change-Id: I158a4d9952c0e90f2b1b7280443a7305b6ae57cf
Reviewed-by: Tyrone Ting <kfting@nuvoton.com>
Signed-off-by: Havard Skinnemoen <hskinnemoen@google.com>
---
hw/arm/npcm7xx_boards.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
index 86e18af2d7..1ec772fa59 100644
--- a/hw/arm/npcm7xx_boards.c
+++ b/hw/arm/npcm7xx_boards.c
@@ -18,6 +18,7 @@
#include "hw/arm/boot.h"
#include "hw/arm/npcm7xx.h"
#include "hw/core/cpu.h"
+#include "hw/qdev-properties.h"
#include "qapi/error.h"
#include "qemu/units.h"
@@ -40,6 +41,20 @@ static void npcm7xx_load_kernel(MachineState *machine,
NPCM7xxState *soc)
arm_load_kernel(&soc->cpu[0], machine, &npcm7xx_binfo);
}
+static void npcm7xx_connect_flash(NPCM7xxFIUState *fiu, int cs_no,
+ const char *flash_type, DriveInfo *dinfo) {
+ DeviceState *flash;
+ qemu_irq flash_cs;
+
+ flash = ssi_create_slave_no_init(fiu->spi, flash_type);
+ qdev_prop_set_drive(flash, "drive", blk_by_legacy_dinfo(dinfo),
+ &error_abort);
+ qdev_init_nofail(flash);
+
+ flash_cs = qdev_get_gpio_in_named(flash, SSI_GPIO_CS, 0);
+ sysbus_connect_irq(SYS_BUS_DEVICE(fiu), cs_no, flash_cs);
+}
+
static NPCM7xxState *npcm7xx_create_soc(MachineState *machine)
{
NPCM7xxMachineClass *nmc = NPCM7XX_MACHINE_GET_CLASS(machine);
@@ -57,18 +72,30 @@ static NPCM7xxState *npcm7xx_create_soc(MachineState
*machine)
static void npcm750_evb_init(MachineState *machine)
{
NPCM7xxState *soc;
+ DriveInfo *dinfo;
soc = npcm7xx_create_soc(machine);
+ dinfo = drive_get(IF_MTD, 0, 0);
+ if (dinfo) {
+ npcm7xx_connect_flash(&soc->fiu[0], 0, "w25q256", dinfo);
+ }
+
npcm7xx_load_kernel(machine, soc);
}
static void quanta_gsj_init(MachineState *machine)
{
NPCM7xxState *soc;
+ DriveInfo *dinfo;
soc = npcm7xx_create_soc(machine);
+ dinfo = drive_get(IF_MTD, 0, 0);
+ if (dinfo) {
+ npcm7xx_connect_flash(&soc->fiu[0], 0, "mx25l25635e", dinfo);
+ }
+
npcm7xx_load_kernel(machine, soc);
}
--
2.27.0.290.gba653c62da-goog
- [PATCH v2 06/12] hw/arm: Add two NPCM7xx-based machines, (continued)
- [PATCH v2 06/12] hw/arm: Add two NPCM7xx-based machines, Havard Skinnemoen, 2020/06/11
- [PATCH v2 05/12] hw/arm: Add NPCM730 and NPCM750 SoC models, Havard Skinnemoen, 2020/06/11
- [PATCH v2 08/12] hw/nvram: NPCM7xx OTP device model, Havard Skinnemoen, 2020/06/11
- [PATCH v2 07/12] hw/arm: Load -bios image as a boot ROM for npcm7xx, Havard Skinnemoen, 2020/06/11
- [PATCH v2 09/12] hw/mem: Stubbed out NPCM7xx Memory Controller model, Havard Skinnemoen, 2020/06/11
- [PATCH v2 10/12] hw/ssi: NPCM7xx Flash Interface Unit device model, Havard Skinnemoen, 2020/06/11
- [PATCH v2 11/12] hw/arm: Wire up BMC boot flash for npcm750-evb and quanta-gsj,
Havard Skinnemoen <=
- [PATCH v2 12/12] docs/system: Add Nuvoton machine documentation, Havard Skinnemoen, 2020/06/11
- Re: [PATCH v2 00/12] Add Nuvoton NPCM730/NPCM750 SoCs and two BMC machines, Cédric Le Goater, 2020/06/17