[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [PATCH v5 8/9] ast2400: create SPI flash slaves
From: |
Cédric Le Goater |
Subject: |
[Qemu-arm] [PATCH v5 8/9] ast2400: create SPI flash slaves |
Date: |
Tue, 28 Jun 2016 20:24:29 +0200 |
A set of SPI flash slaves is attached under the flash controllers of
the palmetto platform. "n25q256a" flash modules are used for the BMC
and "mx25l25635e" for the host. These types are common in the
OpenPower ecosystem.
Signed-off-by: Cédric Le Goater <address@hidden>
---
Changes since v3 :
- moved memory mapping to platform initialization
Changes since v2 :
- moved the initialization of the flash modules under the palmetto
platform
hw/arm/palmetto-bmc.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/hw/arm/palmetto-bmc.c b/hw/arm/palmetto-bmc.c
index b8eed21348d8..54e29a865d88 100644
--- a/hw/arm/palmetto-bmc.c
+++ b/hw/arm/palmetto-bmc.c
@@ -18,6 +18,8 @@
#include "hw/arm/ast2400.h"
#include "hw/boards.h"
#include "qemu/log.h"
+#include "sysemu/block-backend.h"
+#include "sysemu/blockdev.h"
static struct arm_boot_info palmetto_bmc_binfo = {
.loader_start = AST2400_SDRAM_BASE,
@@ -30,6 +32,32 @@ typedef struct PalmettoBMCState {
MemoryRegion ram;
} PalmettoBMCState;
+static void palmetto_bmc_init_flashes(AspeedSMCState *s, const char *flashtype,
+ Error **errp)
+{
+ int i ;
+
+ for (i = 0; i < s->num_cs; ++i) {
+ AspeedSMCFlash *fl = &s->flashes[i];
+ DriveInfo *dinfo = drive_get_next(IF_MTD);
+ qemu_irq cs_line;
+
+ /*
+ * FIXME: check that we are not using a flash module exceeding
+ * the controller segment size
+ */
+ fl->flash = ssi_create_slave_no_init(s->spi, flashtype);
+ if (dinfo) {
+ qdev_prop_set_drive(fl->flash, "drive", blk_by_legacy_dinfo(dinfo),
+ errp);
+ }
+ qdev_init_nofail(fl->flash);
+
+ cs_line = qdev_get_gpio_in_named(fl->flash, SSI_GPIO_CS, 0);
+ sysbus_connect_irq(SYS_BUS_DEVICE(s), i + 1, cs_line);
+ }
+}
+
static void palmetto_bmc_init(MachineState *machine)
{
PalmettoBMCState *bmc;
@@ -49,6 +77,9 @@ static void palmetto_bmc_init(MachineState *machine)
object_property_set_bool(OBJECT(&bmc->soc), true, "realized",
&error_abort);
+ palmetto_bmc_init_flashes(&bmc->soc.smc, "n25q256a", &error_abort);
+ palmetto_bmc_init_flashes(&bmc->soc.spi, "mx25l25635e", &error_abort);
+
palmetto_bmc_binfo.kernel_filename = machine->kernel_filename;
palmetto_bmc_binfo.initrd_filename = machine->initrd_filename;
palmetto_bmc_binfo.kernel_cmdline = machine->kernel_cmdline;
--
2.1.4
- [Qemu-arm] [PATCH v5 0/9] ast2400: SMC controllers, Cédric Le Goater, 2016/06/28
- [Qemu-arm] [PATCH v5 1/9] ssi: change ssi_slave_init to be a realize ops, Cédric Le Goater, 2016/06/28
- [Qemu-arm] [PATCH v5 2/9] m25p80: do not put iovec on the stack, Cédric Le Goater, 2016/06/28
- [Qemu-arm] [PATCH v5 3/9] m25p80: avoid out of bounds accesses, Cédric Le Goater, 2016/06/28
- [Qemu-arm] [PATCH v5 4/9] m25p80: change cur_addr to 32 bit integer, Cédric Le Goater, 2016/06/28
- [Qemu-arm] [PATCH v5 5/9] m25p80: qdev-ify drive property, Cédric Le Goater, 2016/06/28
- [Qemu-arm] [PATCH v5 6/9] ast2400: add SMC controllers (FMC and SPI), Cédric Le Goater, 2016/06/28
- [Qemu-arm] [PATCH v5 7/9] ast2400: add SPI flash slaves, Cédric Le Goater, 2016/06/28
- [Qemu-arm] [PATCH v5 8/9] ast2400: create SPI flash slaves,
Cédric Le Goater <=
- [Qemu-arm] [PATCH v5 9/9] tests: add a m25p80 test, Cédric Le Goater, 2016/06/28