diff mbox

[v2] versatiblepb: add NOR flash support

Message ID 1334588567-25628-1-git-send-email-eric@eukrea.com
State New
Headers show

Commit Message

Eric Benard April 16, 2012, 3:02 p.m. UTC
- add support for the 64MB NOR CFI01 flash available at
0x34000000 on the versatilepb board
http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0225d/BBAJIHEC.html

- tested with barebox bootloader

Signed-off-by: Eric Bénard <eric@eukrea.com>
---
change since v1 :
 - remove hack to boot from NOR flash
 - fix checkpatch warnings
 
 hw/versatilepb.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

Comments

Peter Maydell April 20, 2012, 3:34 p.m. UTC | #1
On 16 April 2012 16:02, Eric Bénard <eric@eukrea.com> wrote:
> - add support for the 64MB NOR CFI01 flash available at
> 0x34000000 on the versatilepb board
> http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0225d/BBAJIHEC.html
>
> - tested with barebox bootloader
>
> Signed-off-by: Eric Bénard <eric@eukrea.com>

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>

-- PMM
diff mbox

Patch

diff --git a/hw/versatilepb.c b/hw/versatilepb.c
index 25afb1e..6f8a64d 100644
--- a/hw/versatilepb.c
+++ b/hw/versatilepb.c
@@ -16,6 +16,11 @@ 
 #include "boards.h"
 #include "blockdev.h"
 #include "exec-memory.h"
+#include "flash.h"
+
+#define VERSATILE_FLASH_ADDR 0x34000000
+#define VERSATILE_FLASH_SIZE (64 * 1024 * 1024)
+#define VERSATILE_FLASH_SECT_SIZE (256 * 1024)
 
 /* Primary interrupt controller.  */
 
@@ -180,6 +185,7 @@  static void versatile_init(ram_addr_t ram_size,
     NICInfo *nd;
     int n;
     int done_smc = 0;
+    DriveInfo *dinfo;
 
     if (!cpu_model)
         cpu_model = "arm926";
@@ -310,6 +316,16 @@  static void versatile_init(ram_addr_t ram_size,
     /*  0x101f2000 UART1.  */
     /*  0x101f3000 UART2.  */
     /* 0x101f4000 SSPI.  */
+    /* 0x34000000 NOR Flash */
+
+    dinfo = drive_get(IF_PFLASH, 0, 0);
+    if (!pflash_cfi01_register(VERSATILE_FLASH_ADDR, NULL, "versatile.flash",
+                          VERSATILE_FLASH_SIZE, dinfo ? dinfo->bdrv : NULL,
+                          VERSATILE_FLASH_SECT_SIZE,
+                          VERSATILE_FLASH_SIZE / VERSATILE_FLASH_SECT_SIZE,
+                          4, 0x0089, 0x0018, 0x0000, 0x0, 0)) {
+        fprintf(stderr, "qemu: Error registering flash memory.\n");
+    }
 
     versatile_binfo.ram_size = ram_size;
     versatile_binfo.kernel_filename = kernel_filename;