mtd: move & update nand_ecclayout structure (plus board changes)
PATCH v3 1/1 mtd: move & update nand_ecclayout structure (plus board changes)
From: Prabhakar Kushwaha <[email protected]>
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.
---
v3: fix some PPC boards as well
v2: add a fix for SPL size on tricorder, and squash patches together for bisectability
doc/README.nand | 10 ++++++++++ drivers/mtd/onenand/onenand_base.c | 15 ++++++++++----- include/configs/ASH405.h | 2 ++ include/configs/MPC8572DS.h | 2 ++ include/configs/T4240QDS.h | 2 ++ include/configs/alpr.h | 2 ++ include/configs/tricorder.h | 2 ++ include/linux/mtd/mtd.h | 23 +++++++++++++++++++++++ include/mtd/mtd-abi.h | 12 ------------ 9 files changed, 53 insertions(+), 17 deletions(-)
doc/README.nand +10 -0
@@ -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.
drivers/mtd/onenand/onenand_base.c +10 -5
@@ -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;
include/configs/ASH405.h +2 -0
@@ -143,6 +143,8 @@#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
include/configs/MPC8572DS.h +2 -0
@@ -322,6 +322,8 @@#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
include/configs/T4240QDS.h +2 -0
@@ -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
include/configs/alpr.h +2 -0
@@ -324,6 +324,8 @@#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
include/configs/tricorder.h +2 -0
@@ -140,6 +140,8 @@/* 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>
include/linux/mtd/mtd.h +23 -0
@@ -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;
include/mtd/mtd-abi.h +0 -12
@@ -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 *
Signature · 1 line
1.8.1.2
PATCH v3 1/1 mtd: move & update nand_ecclayout structure (plus board changes)
Hi Scott,
Quoted 33 lines · Scott Wood
From: Prabhakar Kushwaha <[email protected]>
nand_ecclayoutis present inmtd.hat Linux. Move this structure tomtd.hto 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_LARGEto MTD_MAX_*_ENTRIESThis 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
_LARGEto the names. The second adds_LARGEto 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.
Quoted 9 lines
Signed-off-by Prabhakar Kushwaha <[email protected]>CC Vipin Kumar <[email protected]>[scottwood at freescale.com: changes as described above]Signed-off-by Scott Wood <[email protected]>Cc Thomas Weber <[email protected]>Cc Matthias Fuchs <[email protected]>Cc Stefan Roese <[email protected]>Cc York Sun <[email protected]>Cc Tom Rini <[email protected]>
I don't have any affected board to test this on (maintained by myself), but this change looks reasonable. So:
Thanks,
Stefan
PATCH v3 1/1 mtd: move & update nand_ecclayout structure (plus board changes)
In reply to Scott WoodQuoted 32 lines · Scott Wood
From: Prabhakar Kushwaha <[email protected]>
nand_ecclayoutis present inmtd.hat Linux. Move this structure tomtd.hto 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_LARGEto MTD_MAX_*_ENTRIESThis 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
_LARGEto the names. The second adds_LARGEto 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.
[snip]
Quoted 57 lines
include/configs/ASH405.h +2
-0@@ -143,6 +143,8 @@#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 include/configs/MPC8572DS.h +2
-0@@ -322,6 +322,8 @@#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 0x1000include/configs/T4240QDS.h +2
-0@@ -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_EXTinclude/configs/alpr.h +2
-0@@ -324,6 +324,8 @@#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 include/configs/tricorder.h +0
-0
include/configs/tricorder.h line 147
Quoted 8 lines
include/configs/tricorder.h +2
-0@@ -140,6 +140,8 @@/* 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>
So, cam_enc_4xx (ARM) also fails to build with ELDK 5.2.1 (is fine with newer toolchains), so I dug into this patch to shrink things there. But looking above, are all of these right? It seems like generally we say OOBFREE=2, ECCPOS=56, except once you say OOBFREE=5 ECCPOS=56 and once OOBFREE=5 ECCPOS=256. Are these really right and just 'odd' due to the chip used?
Also, Heiko, what should these values be for cam_enc_4xx? Thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20131125/03c55063/attachment.pgp>
PATCH v3 1/1 mtd: move & update nand_ecclayout structure (plus board changes)
Quoted 6 lines · Tom Rini
So,
cam_enc_4xx(ARM) also fails to build with ELDK 5.2.1 (is fine with newer toolchains), so I dug into this patch to shrink things there. But looking above, are all of these right? It seems like generally we say OOBFREE=2, ECCPOS=56, except once you say OOBFREE=5 ECCPOS=56 and once OOBFREE=5 ECCPOS=256. Are these really right and just 'odd' due to the chip used?
2/56 is the minimum based on layouts in generic code (until such a time as we allow those to be configured out), but if a board enables a NAND driver that specifies a layout with larger arrays, the values need to be larger. If the values specified are too small, you'll get a compiler warning about too many elements in an array initializer.
Quoted 1 line
Also, Heiko, what should these values be for
cam_enc_4xx? Thanks!
It looks like 2/56 will work for that (davinci with CONFIG_SYS_NAND_PAGE_2K but not CONFIG_NAND_6BYTES_OOB_FREE_10BYTES_ECC). If I misread the ifdef flow, then the compiler will let you know.
CONFIG_NAND_6BYTES_OOB_FREE_10BYTES_ECC would require OOBFREE of at least 4, and CONFIG_SYS_NAND_PAGE_4K would require ECCPOS of at least 80.
-Scott