qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Roy Franz <roy.franz@linaro.org>
To: qemu-devel@nongnu.org, kwolf@redhat.com, stefanha@redhat.com
Cc: Roy Franz <roy.franz@linaro.org>,
	peter.maydell@linaro.org, patches@linaro.org
Subject: [Qemu-devel] [PATCH 4/4 v4] block: Set proper device-width for vexpress flash
Date: Tue, 22 Oct 2013 09:35:56 -0700	[thread overview]
Message-ID: <1382459756-6853-5-git-send-email-roy.franz@linaro.org> (raw)
In-Reply-To: <1382459756-6853-1-git-send-email-roy.franz@linaro.org>

Create vexpress specific pflash registration
function which properly configures the device-width
of 16 bits (2 bytes) for the NOR flash on the
vexpress platform.  This change is required for
buffered flash writes to work properly.

Signed-off-by: Roy Franz <roy.franz@linaro.org>
---
 hw/arm/vexpress.c |   43 +++++++++++++++++++++++++++++++++----------
 1 file changed, 33 insertions(+), 10 deletions(-)

diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c
index f48de00..8eae73c 100644
--- a/hw/arm/vexpress.c
+++ b/hw/arm/vexpress.c
@@ -480,6 +480,35 @@ static void vexpress_modify_dtb(const struct arm_boot_info *info, void *fdt)
     }
 }
 
+
+/* Open code a private version of pflash registration since we
+ * need to set non-default device width for VExpress platform.
+ */
+static pflash_t *ve_pflash_cfi01_register(hwaddr base, const char *name,
+                                          BlockDriverState *bs)
+{
+    DeviceState *dev = qdev_create(NULL, "cfi.pflash01");
+
+    if (bs && qdev_prop_set_drive(dev, "drive", bs)) {
+        abort();
+    }
+
+    qdev_prop_set_uint32(dev, "num-blocks", VEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE);
+    qdev_prop_set_uint64(dev, "sector-length", VEXPRESS_FLASH_SECT_SIZE);
+    qdev_prop_set_uint8(dev, "width", 4);
+    qdev_prop_set_uint8(dev, "device-width", 2);
+    qdev_prop_set_uint8(dev, "big-endian", 0);
+    qdev_prop_set_uint16(dev, "id0", 0x00);
+    qdev_prop_set_uint16(dev, "id1", 0x89);
+    qdev_prop_set_uint16(dev, "id2", 0x00);
+    qdev_prop_set_uint16(dev, "id3", 0x18);
+    qdev_prop_set_string(dev, "name", name);
+    qdev_init_nofail(dev);
+
+    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
+    return OBJECT_CHECK(pflash_t, (dev), "cfi.pflash01");
+}
+
 static void vexpress_common_init(VEDBoardInfo *daughterboard,
                                  QEMUMachineInitArgs *args)
 {
@@ -561,11 +590,8 @@ static void vexpress_common_init(VEDBoardInfo *daughterboard,
     sysbus_create_simple("pl111", map[VE_CLCD], pic[14]);
 
     dinfo = drive_get_next(IF_PFLASH);
-    pflash0 = pflash_cfi01_register(map[VE_NORFLASH0], NULL, "vexpress.flash0",
-            VEXPRESS_FLASH_SIZE, dinfo ? dinfo->bdrv : NULL,
-            VEXPRESS_FLASH_SECT_SIZE,
-            VEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE, 4,
-            0x00, 0x89, 0x00, 0x18, 0);
+    pflash0 = ve_pflash_cfi01_register(map[VE_NORFLASH0], "vexpress.flash0",
+                                       dinfo ? dinfo->bdrv : NULL);
     if (!pflash0) {
         fprintf(stderr, "vexpress: error registering flash 0.\n");
         exit(1);
@@ -580,11 +606,8 @@ static void vexpress_common_init(VEDBoardInfo *daughterboard,
     }
 
     dinfo = drive_get_next(IF_PFLASH);
-    if (!pflash_cfi01_register(map[VE_NORFLASH1], NULL, "vexpress.flash1",
-            VEXPRESS_FLASH_SIZE, dinfo ? dinfo->bdrv : NULL,
-            VEXPRESS_FLASH_SECT_SIZE,
-            VEXPRESS_FLASH_SIZE / VEXPRESS_FLASH_SECT_SIZE, 4,
-            0x00, 0x89, 0x00, 0x18, 0)) {
+    if (!ve_pflash_cfi01_register(map[VE_NORFLASH1], "vexpress.flash1",
+                                  dinfo ? dinfo->bdrv : NULL)) {
         fprintf(stderr, "vexpress: error registering flash 1.\n");
         exit(1);
     }
-- 
1.7.10.4

  parent reply	other threads:[~2013-10-22 16:36 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-22 16:35 [Qemu-devel] [PATCH 0/4 v4] block, arm: Fix buffered flash writes on VExpress Roy Franz
2013-10-22 16:35 ` [Qemu-devel] [PATCH 1/4 v4] block: rename pflash_t member width to bank_width Roy Franz
2013-11-28 19:06   ` Peter Maydell
2013-10-22 16:35 ` [Qemu-devel] [PATCH 2/4 v5] block: Add device-width property to pflash_cfi01 Roy Franz
2013-11-28 19:03   ` Peter Maydell
2013-12-03 20:12     ` Roy Franz
2013-12-03 20:27       ` Peter Maydell
2013-12-03 20:36         ` Roy Franz
2013-10-22 16:35 ` [Qemu-devel] [PATCH 3/4 v4] block: return status for each device Roy Franz
2013-11-28 19:10   ` Peter Maydell
2013-12-03  2:27     ` Roy Franz
2013-10-22 16:35 ` Roy Franz [this message]
2013-11-28 19:12   ` [Qemu-devel] [PATCH 4/4 v4] block: Set proper device-width for vexpress flash Peter Maydell
2013-11-20  2:06 ` [Qemu-devel] [PATCH 0/4 v4] block, arm: Fix buffered flash writes on VExpress Roy Franz
2013-11-20  9:22 ` Stefan Hajnoczi
2013-11-20  9:27   ` Peter Maydell
2013-11-20 14:25     ` Stefan Hajnoczi

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=1382459756-6853-5-git-send-email-roy.franz@linaro.org \
    --to=roy.franz@linaro.org \
    --cc=kwolf@redhat.com \
    --cc=patches@linaro.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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;
as well as URLs for NNTP newsgroup(s).