summaryrefslogtreecommitdiffstats
path: root/board/emk/common/flash.c
diff options
context:
space:
mode:
authorwdenk <wdenk>2004-02-23 22:22:28 +0000
committerwdenk <wdenk>2004-02-23 22:22:28 +0000
commit63e73c9a8ed5b32d9c4067ffaad953e9a8fe8f0a (patch)
tree2f8915e0b3024c639748e930b56d60c0d8cf2d99 /board/emk/common/flash.c
parentcd0a9de68b03e5a54fd2a08f44be318e4397be01 (diff)
downloadu-boot-63e73c9a8ed5b32d9c4067ffaad953e9a8fe8f0a.tar.gz
u-boot-63e73c9a8ed5b32d9c4067ffaad953e9a8fe8f0a.tar.xz
u-boot-63e73c9a8ed5b32d9c4067ffaad953e9a8fe8f0a.zip
* Patches by Reinhard Meyer, 14 Feb 2004:
- update board/emk tree; use common flash driver - Corrected tested bits in machine check exception in cpu/mpc5xxx/traps.c [adapted for other PPC CPUs -- wd] - Added support for the M48T08 on the EVAL5200 board in rtc/mk48t59.c * Patch by Jon Diekema, 13 Feb 2004: Call show_boot_progress() whenever POST "FAILED" is printed. * Patch by Nishant Kamat, 13 Feb 2004: Add support for TI OMAP1610 H2 Board Fixes for cpu/arm926ejs/interrupt.c (based on Richard Woodruff's patch for arm925, 16 Oct 03) Fix for a timer bug in OMAP1610 Innovator Add support for CS0 (ROM)/CS3 (Flash) boot in OMAP1610 Innovator and H2 * Patches by Stephan Linz, 12 Feb 2004: - add support for NIOS timer with variable period preload counter value - prepare POST framework support for NIOS targets * Patch by Denis Peter, 11 Feb 2004: add POST support for the MIP405 board
Diffstat (limited to 'board/emk/common/flash.c')
-rw-r--r--board/emk/common/flash.c65
1 files changed, 52 insertions, 13 deletions
diff --git a/board/emk/common/flash.c b/board/emk/common/flash.c
index b2a21382e5..adfa9a0fb2 100644
--- a/board/emk/common/flash.c
+++ b/board/emk/common/flash.c
@@ -28,15 +28,33 @@
flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
-typedef unsigned char FLASH_PORT_WIDTH;
-typedef volatile unsigned char FLASH_PORT_WIDTHV;
-#define FLASH_ID_MASK 0xFF
+#if defined (CONFIG_TOP860)
+ typedef unsigned short FLASH_PORT_WIDTH;
+ typedef volatile unsigned short FLASH_PORT_WIDTHV;
+ #define FLASH_ID_MASK 0xFF
+
+ #define FPW FLASH_PORT_WIDTH
+ #define FPWV FLASH_PORT_WIDTHV
+
+ #define FLASH_CYCLE1 0x0555
+ #define FLASH_CYCLE2 0x02aa
+ #define FLASH_ID1 0
+ #define FLASH_ID2 1
+#endif
+
+#if defined (CONFIG_TOP5200)
+ typedef unsigned char FLASH_PORT_WIDTH;
+ typedef volatile unsigned char FLASH_PORT_WIDTHV;
+ #define FLASH_ID_MASK 0xFF
-#define FPW FLASH_PORT_WIDTH
-#define FPWV FLASH_PORT_WIDTHV
+ #define FPW FLASH_PORT_WIDTH
+ #define FPWV FLASH_PORT_WIDTHV
-#define FLASH_CYCLE1 0x0aaa
-#define FLASH_CYCLE2 0x0555
+ #define FLASH_CYCLE1 0x0aaa
+ #define FLASH_CYCLE2 0x0555
+ #define FLASH_ID1 0
+ #define FLASH_ID2 2
+#endif
/*-----------------------------------------------------------------------
* Functions
@@ -179,12 +197,33 @@ void flash_print_info (flash_info_t *info)
printf (" Sector Start Addresses:");
for (i=0; i<info->sector_count; ++i) {
+ ulong size;
+ int erased;
+ ulong *flash = (unsigned long *) info->start[i];
+
if ((i % 5) == 0) {
printf ("\n ");
}
- printf (" %08lX%s", info->start[i],
- info->protect[i] ? " (RO)" : " ");
+ /*
+ * Check if whole sector is erased
+ */
+ size =
+ (i != (info->sector_count - 1)) ?
+ (info->start[i + 1] - info->start[i]) >> 2 :
+ (info->start[0] + info->size - info->start[i]) >> 2;
+
+ for (
+ flash = (unsigned long *) info->start[i], erased = 1;
+ (flash != (unsigned long *) info->start[i] + size) && erased;
+ flash++
+ )
+ erased = *flash == ~0x0UL;
+
+ printf (" %08lX %s %s",
+ info->start[i],
+ erased ? "E": " ",
+ info->protect[i] ? "(RO)" : " ");
}
printf ("\n");
@@ -212,7 +251,7 @@ ulong flash_get_size (FPWV *addr, flash_info_t *info)
* This works for any bus width and any FLASH device width.
*/
udelay(100);
- switch (addr[0] & 0xff) {
+ switch (addr[FLASH_ID1] & 0xff) {
case (uchar)AMD_MANUFACT:
info->flash_id = FLASH_MAN_AMD;
@@ -225,7 +264,7 @@ ulong flash_get_size (FPWV *addr, flash_info_t *info)
#endif
default:
- printf ("unknown vendor=%x ", addr[0] & 0xff);
+ printf ("unknown vendor=%x ", addr[FLASH_ID1] & 0xff);
info->flash_id = FLASH_UNKNOWN;
info->sector_count = 0;
info->size = 0;
@@ -233,7 +272,7 @@ ulong flash_get_size (FPWV *addr, flash_info_t *info)
}
/* Check 16 bits or 32 bits of ID so work on 32 or 16 bit bus. */
- if (info->flash_id != FLASH_UNKNOWN) switch ((FPW)addr[2]) {
+ if (info->flash_id != FLASH_UNKNOWN) switch ((FPW)addr[FLASH_ID2]) {
case (FPW)AMD_ID_LV160B:
info->flash_id += FLASH_AM160B;
@@ -255,7 +294,7 @@ ulong flash_get_size (FPWV *addr, flash_info_t *info)
break;
default:
- printf ("unknown AMD device=%x ", (FPW)addr[2]);
+ printf ("unknown AMD device=%x ", (FPW)addr[FLASH_ID2]);
info->flash_id = FLASH_UNKNOWN;
info->sector_count = 0;
info->size = 0;