]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
mtd: move & update nand_ecclayout structure (plus board changes)
authorPrabhakar Kushwaha <prabhakar@freescale.com>
Fri, 4 Oct 2013 08:17:58 +0000 (13:47 +0530)
committerScott Wood <scottwood@freescale.com>
Thu, 21 Nov 2013 19:32:43 +0000 (13:32 -0600)
nand_ecclayout is present in mtd.h at Linux.
Move this structure to mtd.h to comply with Linux.

Also, increase the ecc placement locations to 640 to suport device having
writesize/oobsize of 8KB/640B. This means that the maximum oobsize has gone
up to 640 bytes and consequently the maximum ecc placement locations have
also gone up to 640.

Changes from Prabhabkar's version (squashed into one patch to preserve
bisectability):
 - Added _LARGE to MTD_MAX_*_ENTRIES

   This makes the names match current Linux source, and resolves
   a conflict between
   http://patchwork.ozlabs.org/patch/280488/
   and
   http://patchwork.ozlabs.org/patch/284513/

   The former was posted first and is closer to matching Linux, but
   unlike Linux it does not add _LARGE to the names.  The second adds
   _LARGE to one of the names, and depends on it in a subsequent patch
   (http://patchwork.ozlabs.org/patch/284512/).

 - Made max oobfree/eccpos configurable, and used this on tricorder,
   alpr, ASH405, T4160QDS, and T4240QDS (these boards failed to build
   for me without doing so, due to a size increase).

   On tricorder SPL, this saves 2576 bytes (and makes the SPL build
   again) versus the new default of 640 eccpos and 32 oobfree, and
   saves 336 bytes versus the old default of 128 eccpos and 8 oobfree.

Signed-off-by: Prabhakar Kushwaha <prabhakar@freescale.com>
CC: Vipin Kumar <vipin.kumar@st.com>
[scottwood@freescale.com: changes as described above]
Signed-off-by: Scott Wood <scottwood@freescale.com>
Cc: Thomas Weber <weber@corscience.de>
Cc: Matthias Fuchs <matthias.fuchs@esd-electronics.com>
Cc: Stefan Roese <sr@denx.de>
Cc: York Sun <yorksun@freescale.com>
Cc: Tom Rini <trini@ti.com>
Reviewed-by: Stefan Roese <sr@denx.de>
doc/README.nand
drivers/mtd/onenand/onenand_base.c
include/configs/ASH405.h
include/configs/MPC8572DS.h
include/configs/T4240QDS.h
include/configs/alpr.h
include/configs/tricorder.h
include/linux/mtd/mtd.h
include/mtd/mtd-abi.h

index 913e9b50b804535acf9adc5176cdaae4132e51a1..3a507b6c816cfe27509fccc34d3c39e24133a06d 100644 (file)
@@ -104,6 +104,16 @@ Configuration Options:
    CONFIG_SYS_MAX_NAND_DEVICE
       The maximum number of NAND devices you want to support.
 
+   CONFIG_SYS_NAND_MAX_ECCPOS
+      If specified, overrides the maximum number of ECC bytes
+      supported.  Useful for reducing image size, especially with SPL.
+      This must be at least 48 if nand_base.c is used.
+
+   CONFIG_SYS_NAND_MAX_OOBFREE
+      If specified, overrides the maximum number of free OOB regions
+      supported.  Useful for reducing image size, especially with SPL.
+      This must be at least 2 if nand_base.c is used.
+
    CONFIG_SYS_NAND_MAX_CHIPS
       The maximum number of NAND chips per device to be supported.
 
index 067f8ef184b59356f00f1e955a21ce863accd642..979e4af7c5fc73df42165fdb4b86034fb6cdc8c2 100644 (file)
@@ -761,7 +761,8 @@ static int onenand_transfer_auto_oob(struct mtd_info *mtd, uint8_t *buf,
        uint8_t *oob_buf = this->oob_buf;
 
        free = this->ecclayout->oobfree;
-       for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES && free->length; i++, free++) {
+       for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES_LARGE && free->length;
+            i++, free++) {
                if (readcol >= lastgap)
                        readcol += free->offset - lastgap;
                if (readend >= lastgap)
@@ -770,7 +771,8 @@ static int onenand_transfer_auto_oob(struct mtd_info *mtd, uint8_t *buf,
        }
        this->read_bufferram(mtd, 0, ONENAND_SPARERAM, oob_buf, 0, mtd->oobsize);
        free = this->ecclayout->oobfree;
-       for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES && free->length; i++, free++) {
+       for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES_LARGE && free->length;
+            i++, free++) {
                int free_end = free->offset + free->length;
                if (free->offset < readend && free_end > readcol) {
                        int st = max_t(int,free->offset,readcol);
@@ -1356,7 +1358,8 @@ static int onenand_fill_auto_oob(struct mtd_info *mtd, u_char *oob_buf,
        unsigned int i;
 
        free = this->ecclayout->oobfree;
-       for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES && free->length; i++, free++) {
+       for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES_LARGE && free->length;
+            i++, free++) {
                if (writecol >= lastgap)
                        writecol += free->offset - lastgap;
                if (writeend >= lastgap)
@@ -1364,7 +1367,8 @@ static int onenand_fill_auto_oob(struct mtd_info *mtd, u_char *oob_buf,
                lastgap = free->offset + free->length;
        }
        free = this->ecclayout->oobfree;
-       for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES && free->length; i++, free++) {
+       for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES_LARGE && free->length;
+            i++, free++) {
                int free_end = free->offset + free->length;
                if (free->offset < writeend && free_end > writecol) {
                        int st = max_t(int,free->offset,writecol);
@@ -2750,7 +2754,8 @@ int onenand_scan(struct mtd_info *mtd, int maxchips)
         * the out of band area
         */
        this->ecclayout->oobavail = 0;
-       for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES &&
+
+       for (i = 0; i < MTD_MAX_OOBFREE_ENTRIES_LARGE &&
            this->ecclayout->oobfree[i].length; i++)
                this->ecclayout->oobavail +=
                        this->ecclayout->oobfree[i].length;
index 9460be3b5987accd1e412c5f82dc8d0998186f57..2f5340723d99a1b628d03f81b8902c375dae4082 100644 (file)
 
 #define CONFIG_SYS_NAND_SKIP_BAD_DOT_I 1       /* ".i" read skips bad blocks   */
 #define CONFIG_SYS_NAND_QUIET          1
+#define CONFIG_SYS_NAND_MAX_OOBFREE    2
+#define CONFIG_SYS_NAND_MAX_ECCPOS     56
 
 /*-----------------------------------------------------------------------
  * PCI stuff
index c7511449eab7f08930e63dbf95f118b12a144d02..9ad94021e44a6fe418870e89f663b8ea84a6b158 100644 (file)
 #define CONFIG_CMD_NAND                1
 #define CONFIG_NAND_FSL_ELBC   1
 #define CONFIG_SYS_NAND_BLOCK_SIZE    (128 * 1024)
+#define CONFIG_SYS_NAND_MAX_OOBFREE    5
+#define CONFIG_SYS_NAND_MAX_ECCPOS     56
 
 /* NAND boot: 4K NAND loader config */
 #define CONFIG_SYS_NAND_SPL_SIZE       0x1000
index 3777ccb835d70fd8f83d620896ea927af2d58cd6..c96df54d99469dddee82478259915769a57e220e 100644 (file)
@@ -229,6 +229,8 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_CMD_NAND
 
 #define CONFIG_SYS_NAND_BLOCK_SIZE     (128 * 1024)
+#define CONFIG_SYS_NAND_MAX_OOBFREE    2
+#define CONFIG_SYS_NAND_MAX_ECCPOS     256
 
 #if defined(CONFIG_NAND)
 #define CONFIG_SYS_CSPR0_EXT           CONFIG_SYS_NAND_CSPR_EXT
index 2bf1986e3a7e445ec0f3b7c098bf42409fc59d3b..61fdebac3f6c672e9618c9292a119f80b6d61b3c 100644 (file)
 #define CONFIG_SYS_NAND_BASE_LIST      { CONFIG_SYS_NAND_BASE + 0, CONFIG_SYS_NAND_BASE + 2,   \
                                  CONFIG_SYS_NAND_BASE + 4, CONFIG_SYS_NAND_BASE + 6 }
 #define CONFIG_SYS_NAND_QUIET_TEST     1       /* don't warn upon unknown NAND flash   */
+#define CONFIG_SYS_NAND_MAX_OOBFREE    2
+#define CONFIG_SYS_NAND_MAX_ECCPOS     56
 
 /*-----------------------------------------------------------------------
  * External Bus Controller (EBC) Setup
index d57394e55016e7b5f3ec80628e049dc73bc0b49c..590eab7e483b73c26d5c0c07102fa88c5b6025ef 100644 (file)
                                                        /* devices */
 #define CONFIG_NAND_OMAP_BCH8
 #define CONFIG_BCH
+#define CONFIG_SYS_NAND_MAX_OOBFREE    2
+#define CONFIG_SYS_NAND_MAX_ECCPOS     56
 
 /* commands to include */
 #include <config_cmd_default.h>
index 6f44abdc16102d345e97845f17bc624e5c37eb44..a65b6815515f2e087baa4ad41b860e7b9ee38286 100644 (file)
@@ -96,6 +96,29 @@ struct mtd_oob_ops {
        uint8_t         *oobbuf;
 };
 
+#ifdef CONFIG_SYS_NAND_MAX_OOBFREE
+#define MTD_MAX_OOBFREE_ENTRIES_LARGE  CONFIG_SYS_NAND_MAX_OOBFREE
+#else
+#define MTD_MAX_OOBFREE_ENTRIES_LARGE  32
+#endif
+
+#ifdef CONFIG_SYS_NAND_MAX_ECCPOS
+#define MTD_MAX_ECCPOS_ENTRIES_LARGE   CONFIG_SYS_NAND_MAX_ECCPOS
+#else
+#define MTD_MAX_ECCPOS_ENTRIES_LARGE   640
+#endif
+
+/*
+ * ECC layout control structure. Exported to userspace for
+ * diagnosis and to allow creation of raw images
+ */
+struct nand_ecclayout {
+       uint32_t eccbytes;
+       uint32_t eccpos[MTD_MAX_ECCPOS_ENTRIES_LARGE];
+       uint32_t oobavail;
+       struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES_LARGE];
+};
+
 struct mtd_info {
        u_char type;
        u_int32_t flags;
index d51c1abd186328d9f862aba4febeabcc8fdf4eb1..ac3c29876048de8547e2b0fd514fe54085bcb2d3 100644 (file)
@@ -155,18 +155,6 @@ struct nand_oobfree {
        uint32_t length;
 };
 
-#define MTD_MAX_OOBFREE_ENTRIES        8
-/*
- * ECC layout control structure. Exported to userspace for
- * diagnosis and to allow creation of raw images
- */
-struct nand_ecclayout {
-       uint32_t eccbytes;
-       uint32_t eccpos[128];
-       uint32_t oobavail;
-       struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES];
-};
-
 /**
  * struct mtd_ecc_stats - error correction stats
  *