All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Cédric Le Goater" <clg@kaod.org>
To: openbmc@lists.ozlabs.org
Subject: [PATCH qemu 03/12] ast2400: create SPI flash slaves
Date: Sun, 29 May 2016 23:19:56 +0200	[thread overview]
Message-ID: <1464556805-4340-4-git-send-email-clg@kaod.org> (raw)
In-Reply-To: <1464556805-4340-1-git-send-email-clg@kaod.org>

This patch creates a number of SPI flash slaves of the same type under
the SMC/FMC and under the SMC/SPI controllers. We use a "n25q256a"
flash module type for the BMC and a "mx25l25635e" for the host. These
types are common in the OpenPower ecosystem.

The segment addresses used for the memory mappings are the defaults
provided by the specs. They can be changed with the Segment Address
Register but this is not supported in the current implementation.

Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
 hw/arm/palmetto-bmc.c       |  3 +++
 hw/ssi/aspeed_smc.c         | 62 +++++++++++++++++++++++++++++++++++++++++++++
 include/hw/ssi/aspeed_smc.h |  3 +++
 3 files changed, 68 insertions(+)

diff --git a/hw/arm/palmetto-bmc.c b/hw/arm/palmetto-bmc.c
index 6367f978bc7b..c4099987d354 100644
--- a/hw/arm/palmetto-bmc.c
+++ b/hw/arm/palmetto-bmc.c
@@ -50,6 +50,9 @@ static void palmetto_bmc_init(MachineState *machine)
     object_property_set_bool(OBJECT(&bmc->soc), true, "realized",
                              &error_abort);
 
+    aspeed_smc_init_flashes(&bmc->soc.smc, "n25q256a");
+    aspeed_smc_init_flashes(&bmc->soc.spi, "mx25l25635e");
+
     palmetto_bmc_binfo.kernel_filename = machine->kernel_filename;
     palmetto_bmc_binfo.initrd_filename = machine->initrd_filename;
     palmetto_bmc_binfo.kernel_cmdline = machine->kernel_cmdline;
diff --git a/hw/ssi/aspeed_smc.c b/hw/ssi/aspeed_smc.c
index 43743628ba0c..4175356141e7 100644
--- a/hw/ssi/aspeed_smc.c
+++ b/hw/ssi/aspeed_smc.c
@@ -215,6 +215,8 @@ static int aspeed_smc_init(SysBusDevice *sbd)
                           name, ASPEED_SMC_R_MAX * 4);
     sysbus_init_mmio(sbd, &s->mmio);
 
+    s->flashes = g_new0(AspeedSMCFlashState *, s->num_cs);
+
     return 0;
 }
 
@@ -368,3 +370,63 @@ static void aspeed_smc_flash_register_types(void)
 }
 
 type_init(aspeed_smc_flash_register_types)
+
+/*
+ * Default segments mappings and size for each slave
+ */
+typedef struct AspeedSegments {
+    hwaddr addr;
+    uint32_t size;
+} AspeedSegments;
+
+/* unused */
+static const AspeedSegments aspeed_segment_legacy[] = {
+    { 0x14000000, 32 * 1024 * 1024 },
+};
+
+static const AspeedSegments aspeed_segment_fmc[] = {
+    { 0x20000000, 64 * 1024 * 1024 },
+    { 0x24000000, 32 * 1024 * 1024 },
+    { 0x26000000, 32 * 1024 * 1024 },
+    { 0x28000000, 32 * 1024 * 1024 },
+    { 0x2A000000, 32 * 1024 * 1024 }
+};
+
+static const AspeedSegments aspeed_segment_spi[] = {
+    { 0x30000000, 64 * 1024 * 1024 },
+};
+
+static const AspeedSegments *aspeed_segments[] = {
+    aspeed_segment_legacy, aspeed_segment_fmc, aspeed_segment_spi
+};
+
+void aspeed_smc_init_flashes(AspeedSMCState *s, const char *flashtype)
+{
+    int i ;
+    char name[32];
+
+    for (i = 0; i < s->num_cs; ++i) {
+        Object *new = object_new(TYPE_ASPEED_SMC_FLASH);
+        AspeedSMCFlashState *fl = ASPEED_SMC_FLASH(new);
+        qemu_irq cs_line;
+
+        s->flashes[i] = fl;
+
+        snprintf(name, sizeof(name), "aspeed.%s.%d",
+                 aspeed_smc_types[s->smc_type], i);
+
+        fl->id = i;
+        fl->controller = s;
+        fl->flash = ssi_create_slave(s->spi, flashtype);
+
+        cs_line = qdev_get_gpio_in_named(fl->flash, SSI_GPIO_CS, 0);
+        sysbus_connect_irq(SYS_BUS_DEVICE(s), i + 1, cs_line);
+
+        memory_region_init_io(&fl->mmio, new, &aspeed_smc_flash_ops, fl, name,
+                              aspeed_segments[s->smc_type][i].size);
+        sysbus_init_mmio(SYS_BUS_DEVICE(new), &fl->mmio);
+
+        sysbus_mmio_map(SYS_BUS_DEVICE(new), 0,
+                        aspeed_segments[s->smc_type][i].addr);
+    }
+}
diff --git a/include/hw/ssi/aspeed_smc.h b/include/hw/ssi/aspeed_smc.h
index 6cea1313eabd..1625dfb76a63 100644
--- a/include/hw/ssi/aspeed_smc.h
+++ b/include/hw/ssi/aspeed_smc.h
@@ -74,10 +74,13 @@ typedef struct AspeedSMCState {
     uint8_t r_conf;
     uint8_t r_ctrl0;
     uint8_t conf_enable_w0;
+
+    AspeedSMCFlashState **flashes;
 } AspeedSMCState;
 
 #define TYPE_ASPEED_SPI "aspeed.spi"
 #define ASPEED_SPI(obj) OBJECT_CHECK(AspeedSPIState, (obj), TYPE_ASPEED_SPI)
 
+extern void aspeed_smc_init_flashes(AspeedSMCState *s, const char *flashtype);
 
 #endif /* ASPEED_SMC_H */
-- 
2.1.4

  parent reply	other threads:[~2016-05-29 21:20 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-29 21:19 [PATCH qemu 00/12] SMC and network support Cédric Le Goater
2016-05-29 21:19 ` [PATCH qemu 01/12] ast2400: add SMC controllers (FMC and SPI) Cédric Le Goater
2016-06-07  2:08   ` Andrew Jeffery
2016-06-08 11:53     ` Cédric Le Goater
2016-05-29 21:19 ` [PATCH qemu 02/12] ast2400: add SPI flash slave object Cédric Le Goater
2016-06-07  5:34   ` Andrew Jeffery
2016-06-08 12:42     ` Cédric Le Goater
2016-05-29 21:19 ` Cédric Le Goater [this message]
2016-06-07  5:56   ` [PATCH qemu 03/12] ast2400: create SPI flash slaves Andrew Jeffery
2016-06-08 12:46     ` Cédric Le Goater
2016-05-29 21:19 ` [PATCH qemu 04/12] m25p80: add a get storage routine Cédric Le Goater
2016-05-29 21:19 ` [PATCH qemu 05/12] ast2400: handle SPI flash Command mode (read only) Cédric Le Goater
2016-06-07  6:04   ` Andrew Jeffery
2016-05-29 21:19 ` [PATCH qemu 06/12] ast2400: use contents of first SPI flash as a rom Cédric Le Goater
2016-06-07  6:24   ` Andrew Jeffery
2016-06-09 10:42     ` Cédric Le Goater
2016-05-29 21:20 ` [PATCH qemu 07/12] m25p80: add RDCR instruction for Macronix chip Cédric Le Goater
2016-05-29 21:20 ` [PATCH qemu 08/12] m25p80: add mx25l25635f chip Cédric Le Goater
2016-05-29 21:20 ` [PATCH qemu 09/12] ast2400: use a " Cédric Le Goater
2016-06-07  6:29   ` Andrew Jeffery
2016-05-29 21:20 ` [PATCH qemu 10/12] ast2400: add a BT device Cédric Le Goater
2016-06-07  7:15   ` Andrew Jeffery
2016-05-29 21:20 ` [PATCH qemu 11/12] net: add FTGMAC100 support Cédric Le Goater
2016-06-08  3:50   ` Andrew Jeffery
2016-05-29 21:20 ` [PATCH qemu 12/12] ast2400: add a FTGMAC100 nic Cédric Le Goater
2016-06-07  7:26   ` Andrew Jeffery
2016-06-23 17:00 ` [PATCH qemu 00/12] SMC and network support Cédric Le Goater
2016-06-24  7:06   ` Joel Stanley
2016-06-24  7:18     ` Cédric Le Goater
2016-06-27 16:09   ` Andrew Jeffery

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=1464556805-4340-4-git-send-email-clg@kaod.org \
    --to=clg@kaod.org \
    --cc=openbmc@lists.ozlabs.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.