[U-Boot-Users] TQM823L flash recognition problem
Wolfgang Denk
wd at denx.de
Mon Jul 7 00:14:30 CEST 2008
In message <4868BD82.20407 at tqs.de> Jens Gehrlein wrote:
>
> Could you please change TQM823L.h:
>
> -#define CFG_FLASH_BANKS_LIST { CFG_FLASH_BASE }
> +#define CFG_FLASH_BANKS_LIST { CFG_FLASH_BASE, CFG_FLASH_BASE +
> 0x400000 }
Note that a proper patch (and without line wrapping) would have been
much more useful.
> There was a switch-over to use the CFI driver (see git history of file
> TQM823L.h). AFAIK the CFI driver needs a list with fix start addresses
> of each bank to start the CFI query on.
Thanks for pointing this out.
The big disadvantage of above code is that it requires a static
mapping of the second flash bank, i. e. it works only correctly for
fixed flash sizes. This may be not a big problem for the boards in
question here, but we use autoconfiguration everywhere else so this
doesn't fit in style.
The following patch tries to fix this in a more general way, but it
requires slight modification of the CFI driver to support this.
>From 53abac832029696e47fdd2bcc36a079419076b4a Mon Sep 17 00:00:00 2001
>From: Wolfgang Denk <wd at denx.de>
Date: Sun, 6 Jul 2008 23:54:34 +0200
Subject: [PATCH] TQM8xxL: fix support for second flash bank
When switching the TQM8xxL modules to use the CFI flash driver,
support for the second flash bank was broken. This gets fixed now.
One problem was that the CFI driver allows only for static initia-
lizers in the CFG_FLASH_BANKS_LIST definition, i. e. it did not allow
to map several flash banks contiguously if the bank sizes were not
known in advance, which kind of violates U-Boot's design philosophy.
Now we can refer to dynamically determined flash sizes and addresses.
Signed-off-by: Wolfgang Denk <wd at denx.de>
---
Note that the whole CFG_MAX_FLASH_BANKS_DETECT stuff is a big mess and
should be cleaned up, too, but that's another story. Any volunteers?
drivers/mtd/cfi_flash.c | 14 ++++++++------
include/configs/TQM823L.h | 2 +-
include/configs/TQM850L.h | 2 +-
include/configs/TQM855L.h | 2 +-
include/configs/TQM860L.h | 2 +-
include/configs/TQM862L.h | 2 +-
6 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index c0ea97b..1ed92b1 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -158,13 +158,13 @@ static uint flash_offset_cfi[2] = { FLASH_OFFSET_CFI, FLASH_OFFSET_CFI_ALT };
/* use CFG_MAX_FLASH_BANKS_DETECT if defined */
#ifdef CFG_MAX_FLASH_BANKS_DETECT
-static ulong bank_base[CFG_MAX_FLASH_BANKS_DETECT] = CFG_FLASH_BANKS_LIST;
-flash_info_t flash_info[CFG_MAX_FLASH_BANKS_DETECT]; /* FLASH chips info */
+# define CFI_MAX_FLASH_BANKS CFG_MAX_FLASH_BANKS_DETECT
#else
-static ulong bank_base[CFG_MAX_FLASH_BANKS] = CFG_FLASH_BANKS_LIST;
-flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* FLASH chips info */
+# define CFI_MAX_FLASH_BANKS CFG_MAX_FLASH_BANKS
#endif
+flash_info_t flash_info[CFI_MAX_FLASH_BANKS]; /* FLASH chips info */
+
/*
* Check if chip width is defined. If not, start detecting with 8bit.
*/
@@ -1909,12 +1909,14 @@ unsigned long flash_init (void)
char *s = getenv("unlock");
#endif
+#define BANK_BASE(i) (((unsigned long [CFI_MAX_FLASH_BANKS])CFG_FLASH_BANKS_LIST)[i])
+
/* Init: no FLASHes known */
for (i = 0; i < CFG_MAX_FLASH_BANKS; ++i) {
flash_info[i].flash_id = FLASH_UNKNOWN;
- if (!flash_detect_legacy (bank_base[i], i))
- flash_get_size (bank_base[i], i);
+ if (!flash_detect_legacy (BANK_BASE(i), i))
+ flash_get_size (BANK_BASE(i), i);
size += flash_info[i].size;
if (flash_info[i].flash_id == FLASH_UNKNOWN) {
#ifndef CFG_FLASH_QUIET_TEST
diff --git a/include/configs/TQM823L.h b/include/configs/TQM823L.h
index 100be7c..3871722 100644
--- a/include/configs/TQM823L.h
+++ b/include/configs/TQM823L.h
@@ -196,7 +196,7 @@
/* use CFI flash driver */
#define CFG_FLASH_CFI 1 /* Flash is CFI conformant */
#define CFG_FLASH_CFI_DRIVER 1 /* Use the common driver */
-#define CFG_FLASH_BANKS_LIST { CFG_FLASH_BASE }
+#define CFG_FLASH_BANKS_LIST { CFG_FLASH_BASE, CFG_FLASH_BASE+flash_info[0].size }
#define CFG_FLASH_EMPTY_INFO
#define CFG_FLASH_USE_BUFFER_WRITE 1
#define CFG_MAX_FLASH_BANKS 2 /* max number of memory banks */
diff --git a/include/configs/TQM850L.h b/include/configs/TQM850L.h
index 3097bc3..17afa89 100644
--- a/include/configs/TQM850L.h
+++ b/include/configs/TQM850L.h
@@ -183,7 +183,7 @@
/* use CFI flash driver */
#define CFG_FLASH_CFI 1 /* Flash is CFI conformant */
#define CFG_FLASH_CFI_DRIVER 1 /* Use the common driver */
-#define CFG_FLASH_BANKS_LIST { CFG_FLASH_BASE }
+#define CFG_FLASH_BANKS_LIST { CFG_FLASH_BASE, CFG_FLASH_BASE+flash_info[0].size }
#define CFG_FLASH_EMPTY_INFO
#define CFG_FLASH_USE_BUFFER_WRITE 1
#define CFG_MAX_FLASH_BANKS 2 /* max number of memory banks */
diff --git a/include/configs/TQM855L.h b/include/configs/TQM855L.h
index 8ca8906..73d6583 100644
--- a/include/configs/TQM855L.h
+++ b/include/configs/TQM855L.h
@@ -187,7 +187,7 @@
/* use CFI flash driver */
#define CFG_FLASH_CFI 1 /* Flash is CFI conformant */
#define CFG_FLASH_CFI_DRIVER 1 /* Use the common driver */
-#define CFG_FLASH_BANKS_LIST { CFG_FLASH_BASE }
+#define CFG_FLASH_BANKS_LIST { CFG_FLASH_BASE, CFG_FLASH_BASE+flash_info[0].size }
#define CFG_FLASH_EMPTY_INFO
#define CFG_FLASH_USE_BUFFER_WRITE 1
#define CFG_MAX_FLASH_BANKS 2 /* max number of memory banks */
diff --git a/include/configs/TQM860L.h b/include/configs/TQM860L.h
index f66aace..576e3e2 100644
--- a/include/configs/TQM860L.h
+++ b/include/configs/TQM860L.h
@@ -190,7 +190,7 @@
/* use CFI flash driver */
#define CFG_FLASH_CFI 1 /* Flash is CFI conformant */
#define CFG_FLASH_CFI_DRIVER 1 /* Use the common driver */
-#define CFG_FLASH_BANKS_LIST { CFG_FLASH_BASE }
+#define CFG_FLASH_BANKS_LIST { CFG_FLASH_BASE, CFG_FLASH_BASE+flash_info[0].size }
#define CFG_FLASH_EMPTY_INFO
#define CFG_FLASH_USE_BUFFER_WRITE 1
#define CFG_MAX_FLASH_BANKS 2 /* max number of memory banks */
diff --git a/include/configs/TQM862L.h b/include/configs/TQM862L.h
index 7813a20..6d2f91b 100644
--- a/include/configs/TQM862L.h
+++ b/include/configs/TQM862L.h
@@ -190,7 +190,7 @@
/* use CFI flash driver */
#define CFG_FLASH_CFI 1 /* Flash is CFI conformant */
#define CFG_FLASH_CFI_DRIVER 1 /* Use the common driver */
-#define CFG_FLASH_BANKS_LIST { CFG_FLASH_BASE }
+#define CFG_FLASH_BANKS_LIST { CFG_FLASH_BASE, CFG_FLASH_BASE+flash_info[0].size }
#define CFG_FLASH_EMPTY_INFO
#define CFG_FLASH_USE_BUFFER_WRITE 1
#define CFG_MAX_FLASH_BANKS 2 /* max number of memory banks */
--
1.5.4.2
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It's not an optical illusion, it just looks like one. -- Phil White
More information about the U-Boot
mailing list