]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
nand_spl: store ecc data on the stack
authorScott Wood <scottwood@freescale.com>
Wed, 11 Jan 2012 21:41:01 +0000 (15:41 -0600)
committerScott Wood <scottwood@freescale.com>
Thu, 26 Jan 2012 22:09:06 +0000 (16:09 -0600)
Adapt the following patch from spl to nand_spl:

  Author: Stefano Babic <sbabic@denx.de>
  Date:   Thu Dec 15 10:55:37 2011 +0100

      nand_spl_simple: store ecc data on the stack

      Currently nand_spl_simple puts it's temp data at 0x10000 offset in SDRAM
      which is likely to contain already loaded data.
      The patch saves the oob data and the ecc on the stack replacing
      the fixed address in RAM.

Signed-off-by: Stefano Babic <sbabic@denx.de>
CC: Ilya Yanok <yanok@emcraft.com>
CC: Scott Wood <scottwood@freescale.com>
CC: Tom Rini <tom.rini@gmail.com>
CC: Simon Schwarz <simonschwarzcor@googlemail.com>
CC: Wolfgang Denk <wd@denx.de>
Signed-off-by: Scott Wood <scottwood@freescale.com>
While nand_spl is on its way out, in favor of spl, there are still
many boards using it, and conversions are gradual.  This allows us
to get rid of CONFIG_SYS_NAND_ECCSTEPS and CONFIG_SYS_NAND_ECCTOTAL now,
which would otherwise be likely to linger unreferenced after a conversion.

It also eliminates a temporary error in the hawkboard_nand build, since
the spl version of the patch removed ECCSTEPS/TOTAL from hawkboard.h, but
the spl conversion is pending (and may be merged via a different tree).

Signed-off-by: Scott Wood <scottwood@freescale.com>
include/configs/PMC440.h
include/configs/acadia.h
include/configs/bamboo.h
include/configs/cam_enc_4xx.h
include/configs/canyonlands.h
include/configs/kilauea.h
include/configs/qi_lb60.h
include/configs/sequoia.h
include/configs/smdk6400.h
include/configs/tam3517-common.h
nand_spl/nand_boot.c

index ed47a87820f0a461b84a334547ffac95dd449f69..b82095454ca74a93c6d2da190ba34ec9c2408d24 100644 (file)
 
 #define CONFIG_SYS_NAND_ECCSIZE        256
 #define CONFIG_SYS_NAND_ECCBYTES       3
 
 #define CONFIG_SYS_NAND_ECCSIZE        256
 #define CONFIG_SYS_NAND_ECCBYTES       3
-#define CONFIG_SYS_NAND_ECCSTEPS       (CONFIG_SYS_NAND_PAGE_SIZE / CONFIG_SYS_NAND_ECCSIZE)
 #define CONFIG_SYS_NAND_OOBSIZE        16
 #define CONFIG_SYS_NAND_OOBSIZE        16
-#define CONFIG_SYS_NAND_ECCTOTAL       (CONFIG_SYS_NAND_ECCBYTES * CONFIG_SYS_NAND_ECCSTEPS)
 #define CONFIG_SYS_NAND_ECCPOS         {0, 1, 2, 3, 6, 7}
 #endif
 
 #define CONFIG_SYS_NAND_ECCPOS         {0, 1, 2, 3, 6, 7}
 #endif
 
index 5573dc7a32f73a9397efac5e97e927a2b9837988..8c447ca951a00ac5c47c94adcedeb311c476a88a 100644 (file)
 
 #define CONFIG_SYS_NAND_ECCSIZE        256
 #define CONFIG_SYS_NAND_ECCBYTES       3
 
 #define CONFIG_SYS_NAND_ECCSIZE        256
 #define CONFIG_SYS_NAND_ECCBYTES       3
-#define CONFIG_SYS_NAND_ECCSTEPS       (CONFIG_SYS_NAND_PAGE_SIZE / CONFIG_SYS_NAND_ECCSIZE)
 #define CONFIG_SYS_NAND_OOBSIZE        16
 #define CONFIG_SYS_NAND_OOBSIZE        16
-#define CONFIG_SYS_NAND_ECCTOTAL       (CONFIG_SYS_NAND_ECCBYTES * CONFIG_SYS_NAND_ECCSTEPS)
 #define CONFIG_SYS_NAND_ECCPOS         {0, 1, 2, 3, 6, 7}
 
 #ifdef CONFIG_ENV_IS_IN_NAND
 #define CONFIG_SYS_NAND_ECCPOS         {0, 1, 2, 3, 6, 7}
 
 #ifdef CONFIG_ENV_IS_IN_NAND
index 7b66fc092a73a316539ace3e3aa6720766074c0f..506a558f14e5bf0262bb50818837072304d00799 100644 (file)
 
 #define CONFIG_SYS_NAND_ECCSIZE        256
 #define CONFIG_SYS_NAND_ECCBYTES       3
 
 #define CONFIG_SYS_NAND_ECCSIZE        256
 #define CONFIG_SYS_NAND_ECCBYTES       3
-#define CONFIG_SYS_NAND_ECCSTEPS       (CONFIG_SYS_NAND_PAGE_SIZE / CONFIG_SYS_NAND_ECCSIZE)
 #define CONFIG_SYS_NAND_OOBSIZE        16
 #define CONFIG_SYS_NAND_OOBSIZE        16
-#define CONFIG_SYS_NAND_ECCTOTAL       (CONFIG_SYS_NAND_ECCBYTES * CONFIG_SYS_NAND_ECCSTEPS)
 #define CONFIG_SYS_NAND_ECCPOS         {0, 1, 2, 3, 6, 7}
 
 #ifdef CONFIG_ENV_IS_IN_NAND
 #define CONFIG_SYS_NAND_ECCPOS         {0, 1, 2, 3, 6, 7}
 
 #ifdef CONFIG_ENV_IS_IN_NAND
index 86f74df28e7ca1d5c00ee537bc87ebe25e91f787..5d9672fbc812d1c13331f9a3250f5360aec1329d 100644 (file)
 #define CONFIG_SYS_NAND_ECCBYTES       10
 #define CONFIG_SYS_NAND_OOBSIZE                64
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
 #define CONFIG_SYS_NAND_ECCBYTES       10
 #define CONFIG_SYS_NAND_OOBSIZE                64
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
-#define CONFIG_SYS_NAND_ECCSTEPS       (CONFIG_SYS_NAND_PAGE_SIZE /     \
-                                        CONFIG_SYS_NAND_ECCSIZE)
-#define CONFIG_SYS_NAND_ECCTOTAL       (40)
 
 /*
  * RBL searches from Block n (n = 1..24)
 
 /*
  * RBL searches from Block n (n = 1..24)
index 8c03582c8ddc149249eb3e67a6827b3ad62c5f82..acb127c1d1227a166da8a01d0d45d922ec7ceabe 100644 (file)
 
 #define CONFIG_SYS_NAND_ECCSIZE        256
 #define CONFIG_SYS_NAND_ECCBYTES       3
 
 #define CONFIG_SYS_NAND_ECCSIZE        256
 #define CONFIG_SYS_NAND_ECCBYTES       3
-#define CONFIG_SYS_NAND_ECCSTEPS       (CONFIG_SYS_NAND_PAGE_SIZE / CONFIG_SYS_NAND_ECCSIZE)
 #define CONFIG_SYS_NAND_OOBSIZE        64
 #define CONFIG_SYS_NAND_OOBSIZE        64
-#define CONFIG_SYS_NAND_ECCTOTAL       (CONFIG_SYS_NAND_ECCBYTES * CONFIG_SYS_NAND_ECCSTEPS)
 #define CONFIG_SYS_NAND_ECCPOS         {40, 41, 42, 43, 44, 45, 46, 47, \
                                 48, 49, 50, 51, 52, 53, 54, 55, \
                                 56, 57, 58, 59, 60, 61, 62, 63}
 #define CONFIG_SYS_NAND_ECCPOS         {40, 41, 42, 43, 44, 45, 46, 47, \
                                 48, 49, 50, 51, 52, 53, 54, 55, \
                                 56, 57, 58, 59, 60, 61, 62, 63}
index e66aadf97e0c9c41908689937c0ab64fd6837579..621dbb8fa67fe74c7e06d4db187d2bd3f0aaec17 100644 (file)
 
 #define CONFIG_SYS_NAND_ECCSIZE        256
 #define CONFIG_SYS_NAND_ECCBYTES       3
 
 #define CONFIG_SYS_NAND_ECCSIZE        256
 #define CONFIG_SYS_NAND_ECCBYTES       3
-#define CONFIG_SYS_NAND_ECCSTEPS       (CONFIG_SYS_NAND_PAGE_SIZE / CONFIG_SYS_NAND_ECCSIZE)
 #define CONFIG_SYS_NAND_OOBSIZE        16
 #define CONFIG_SYS_NAND_OOBSIZE        16
-#define CONFIG_SYS_NAND_ECCTOTAL       (CONFIG_SYS_NAND_ECCBYTES * CONFIG_SYS_NAND_ECCSTEPS)
 #define CONFIG_SYS_NAND_ECCPOS         {0, 1, 2, 3, 6, 7}
 
 #ifdef CONFIG_ENV_IS_IN_NAND
 #define CONFIG_SYS_NAND_ECCPOS         {0, 1, 2, 3, 6, 7}
 
 #ifdef CONFIG_ENV_IS_IN_NAND
index f2e605a9b8b48609c8f3ab90ab3f513b0d002226..ebd8223d6f4de77152e1e29a5436e8200172689e 100644 (file)
 #define CONFIG_SYS_NAND_ECC_POS                (6 * NANONOTE_NAND_SIZE)
 #define CONFIG_SYS_NAND_ECCSIZE                512
 #define CONFIG_SYS_NAND_ECCBYTES       9
 #define CONFIG_SYS_NAND_ECC_POS                (6 * NANONOTE_NAND_SIZE)
 #define CONFIG_SYS_NAND_ECCSIZE                512
 #define CONFIG_SYS_NAND_ECCBYTES       9
-#define CONFIG_SYS_NAND_ECCSTEPS       \
-       (CONFIG_SYS_NAND_PAGE_SIZE / CONFIG_SYS_NAND_ECCSIZE)
-#define CONFIG_SYS_NAND_ECCTOTAL       \
-       (CONFIG_SYS_NAND_ECCBYTES * CONFIG_SYS_NAND_ECCSTEPS)
 #define CONFIG_SYS_NAND_ECCPOS         \
                {12, 13, 14, 15, 16, 17, 18, 19,\
                20, 21, 22, 23, 24, 25, 26, 27, \
 #define CONFIG_SYS_NAND_ECCPOS         \
                {12, 13, 14, 15, 16, 17, 18, 19,\
                20, 21, 22, 23, 24, 25, 26, 27, \
index a406ca032ce9153d023a3199083ce255a8cf3b0d..8e6954e3aa774d036a08d5053a20e2563b2d43fb 100644 (file)
 
 #define CONFIG_SYS_NAND_ECCSIZE        256
 #define CONFIG_SYS_NAND_ECCBYTES       3
 
 #define CONFIG_SYS_NAND_ECCSIZE        256
 #define CONFIG_SYS_NAND_ECCBYTES       3
-#define CONFIG_SYS_NAND_ECCSTEPS       (CONFIG_SYS_NAND_PAGE_SIZE / CONFIG_SYS_NAND_ECCSIZE)
 #define CONFIG_SYS_NAND_OOBSIZE        16
 #define CONFIG_SYS_NAND_OOBSIZE        16
-#define CONFIG_SYS_NAND_ECCTOTAL       (CONFIG_SYS_NAND_ECCBYTES * CONFIG_SYS_NAND_ECCSTEPS)
 #define CONFIG_SYS_NAND_ECCPOS         {0, 1, 2, 3, 6, 7}
 
 #ifdef CONFIG_ENV_IS_IN_NAND
 #define CONFIG_SYS_NAND_ECCPOS         {0, 1, 2, 3, 6, 7}
 
 #ifdef CONFIG_ENV_IS_IN_NAND
index 4d0b7b2d4d282687a692646669c880e5194e72d5..a2b9441050f4592771ad747319224590b27e9877 100644 (file)
 #define CONFIG_SYS_NAND_ECCSIZE        CONFIG_SYS_NAND_PAGE_SIZE
 /* Number of ECC bytes per OOB - S3C6400 calculates 4 bytes ECC in 1-bit mode */
 #define CONFIG_SYS_NAND_ECCBYTES       4
 #define CONFIG_SYS_NAND_ECCSIZE        CONFIG_SYS_NAND_PAGE_SIZE
 /* Number of ECC bytes per OOB - S3C6400 calculates 4 bytes ECC in 1-bit mode */
 #define CONFIG_SYS_NAND_ECCBYTES       4
-/* Number of ECC-blocks per NAND page */
-#define CONFIG_SYS_NAND_ECCSTEPS       (CONFIG_SYS_NAND_PAGE_SIZE / CONFIG_SYS_NAND_ECCSIZE)
 /* Size of a single OOB region */
 #define CONFIG_SYS_NAND_OOBSIZE        64
 /* Size of a single OOB region */
 #define CONFIG_SYS_NAND_OOBSIZE        64
-/* Number of ECC bytes per page */
-#define CONFIG_SYS_NAND_ECCTOTAL       (CONFIG_SYS_NAND_ECCBYTES * CONFIG_SYS_NAND_ECCSTEPS)
 /* ECC byte positions */
 #define CONFIG_SYS_NAND_ECCPOS         {40, 41, 42, 43, 44, 45, 46, 47, \
                                 48, 49, 50, 51, 52, 53, 54, 55, \
 /* ECC byte positions */
 #define CONFIG_SYS_NAND_ECCPOS         {40, 41, 42, 43, 44, 45, 46, 47, \
                                 48, 49, 50, 51, 52, 53, 54, 55, \
index 817d468a72c279e07d15b06892a0a09641f5776c..f4963ac07e88854a8c6ebef953a95fdf5fa7de68 100644 (file)
 #define CONFIG_SYS_NAND_ECCSIZE                256
 #define CONFIG_SYS_NAND_ECCBYTES       3
 
 #define CONFIG_SYS_NAND_ECCSIZE                256
 #define CONFIG_SYS_NAND_ECCBYTES       3
 
-#define CONFIG_SYS_NAND_ECCSTEPS       (CONFIG_SYS_NAND_PAGE_SIZE / \
-                                               CONFIG_SYS_NAND_ECCSIZE)
-#define CONFIG_SYS_NAND_ECCTOTAL       (CONFIG_SYS_NAND_ECCBYTES * \
-                                               CONFIG_SYS_NAND_ECCSTEPS)
-
 #define CONFIG_SYS_NAND_U_BOOT_START   CONFIG_SYS_TEXT_BASE
 
 #define CONFIG_SYS_NAND_U_BOOT_OFFS    0x80000
 #define CONFIG_SYS_NAND_U_BOOT_START   CONFIG_SYS_TEXT_BASE
 
 #define CONFIG_SYS_NAND_U_BOOT_OFFS    0x80000
index 2326962b20fca42c8f432a683ae01a7b2ed3772e..bfaabd3199c68321b05994c32feacbc0c6f6ee1c 100644 (file)
 
 static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS;
 
 
 static int nand_ecc_pos[] = CONFIG_SYS_NAND_ECCPOS;
 
+#define ECCSTEPS       (CONFIG_SYS_NAND_PAGE_SIZE / \
+                                       CONFIG_SYS_NAND_ECCSIZE)
+#define ECCTOTAL       (ECCSTEPS * CONFIG_SYS_NAND_ECCBYTES)
+
+
 #if (CONFIG_SYS_NAND_PAGE_SIZE <= 512)
 /*
  * NAND command for small page NAND devices (512)
 #if (CONFIG_SYS_NAND_PAGE_SIZE <= 512)
 /*
  * NAND command for small page NAND devices (512)
@@ -139,29 +144,21 @@ static int nand_is_bad_block(struct mtd_info *mtd, int block)
 static int nand_read_page(struct mtd_info *mtd, int block, int page, uchar *dst)
 {
        struct nand_chip *this = mtd->priv;
 static int nand_read_page(struct mtd_info *mtd, int block, int page, uchar *dst)
 {
        struct nand_chip *this = mtd->priv;
-       u_char *ecc_calc;
-       u_char *ecc_code;
-       u_char *oob_data;
+       u_char ecc_calc[ECCTOTAL];
+       u_char ecc_code[ECCTOTAL];
+       u_char oob_data[CONFIG_SYS_NAND_OOBSIZE];
        int i;
        int eccsize = CONFIG_SYS_NAND_ECCSIZE;
        int eccbytes = CONFIG_SYS_NAND_ECCBYTES;
        int i;
        int eccsize = CONFIG_SYS_NAND_ECCSIZE;
        int eccbytes = CONFIG_SYS_NAND_ECCBYTES;
-       int eccsteps = CONFIG_SYS_NAND_ECCSTEPS;
+       int eccsteps = ECCSTEPS;
        uint8_t *p = dst;
 
        uint8_t *p = dst;
 
-       /*
-        * No malloc available for now, just use some temporary locations
-        * in SDRAM
-        */
-       ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE + 0x10000);
-       ecc_code = ecc_calc + 0x100;
-       oob_data = ecc_calc + 0x200;
-
        nand_command(mtd, block, page, 0, NAND_CMD_READOOB);
        this->read_buf(mtd, oob_data, CONFIG_SYS_NAND_OOBSIZE);
        nand_command(mtd, block, page, 0, NAND_CMD_READ0);
 
        /* Pick the ECC bytes out of the oob data */
        nand_command(mtd, block, page, 0, NAND_CMD_READOOB);
        this->read_buf(mtd, oob_data, CONFIG_SYS_NAND_OOBSIZE);
        nand_command(mtd, block, page, 0, NAND_CMD_READ0);
 
        /* Pick the ECC bytes out of the oob data */
-       for (i = 0; i < CONFIG_SYS_NAND_ECCTOTAL; i++)
+       for (i = 0; i < ECCTOTAL; i++)
                ecc_code[i] = oob_data[nand_ecc_pos[i]];
 
 
                ecc_code[i] = oob_data[nand_ecc_pos[i]];
 
 
@@ -178,24 +175,17 @@ static int nand_read_page(struct mtd_info *mtd, int block, int page, uchar *dst)
 static int nand_read_page(struct mtd_info *mtd, int block, int page, uchar *dst)
 {
        struct nand_chip *this = mtd->priv;
 static int nand_read_page(struct mtd_info *mtd, int block, int page, uchar *dst)
 {
        struct nand_chip *this = mtd->priv;
-       u_char *ecc_calc;
-       u_char *ecc_code;
-       u_char *oob_data;
+       u_char ecc_calc[ECCTOTAL];
+       u_char ecc_code[ECCTOTAL];
+       u_char oob_data[CONFIG_SYS_NAND_OOBSIZE];
        int i;
        int eccsize = CONFIG_SYS_NAND_ECCSIZE;
        int eccbytes = CONFIG_SYS_NAND_ECCBYTES;
        int i;
        int eccsize = CONFIG_SYS_NAND_ECCSIZE;
        int eccbytes = CONFIG_SYS_NAND_ECCBYTES;
-       int eccsteps = CONFIG_SYS_NAND_ECCSTEPS;
+       int eccsteps = ECCSTEPS;
        uint8_t *p = dst;
 
        nand_command(mtd, block, page, 0, NAND_CMD_READ0);
 
        uint8_t *p = dst;
 
        nand_command(mtd, block, page, 0, NAND_CMD_READ0);
 
-       /* No malloc available for now, just use some temporary locations
-        * in SDRAM
-        */
-       ecc_calc = (u_char *)(CONFIG_SYS_SDRAM_BASE + 0x10000);
-       ecc_code = ecc_calc + 0x100;
-       oob_data = ecc_calc + 0x200;
-
        for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
                this->ecc.hwctl(mtd, NAND_ECC_READ);
                this->read_buf(mtd, p, eccsize);
        for (i = 0; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
                this->ecc.hwctl(mtd, NAND_ECC_READ);
                this->read_buf(mtd, p, eccsize);
@@ -204,10 +194,10 @@ static int nand_read_page(struct mtd_info *mtd, int block, int page, uchar *dst)
        this->read_buf(mtd, oob_data, CONFIG_SYS_NAND_OOBSIZE);
 
        /* Pick the ECC bytes out of the oob data */
        this->read_buf(mtd, oob_data, CONFIG_SYS_NAND_OOBSIZE);
 
        /* Pick the ECC bytes out of the oob data */
-       for (i = 0; i < CONFIG_SYS_NAND_ECCTOTAL; i++)
+       for (i = 0; i < ECCTOTAL; i++)
                ecc_code[i] = oob_data[nand_ecc_pos[i]];
 
                ecc_code[i] = oob_data[nand_ecc_pos[i]];
 
-       eccsteps = CONFIG_SYS_NAND_ECCSTEPS;
+       eccsteps = ECCSTEPS;
        p = dst;
 
        for (i = 0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {
        p = dst;
 
        for (i = 0 ; eccsteps; eccsteps--, i += eccbytes, p += eccsize) {