提交 f12a9473 编写于 作者: S Sneha Narnakaje 提交者: David Woodhouse

mtd: nand: DaVinci: Add 4-bit ECC support for large page NAND chips

This patch adds 4-bit ECC support for large page NAND chips using the new
ECC mode NAND_ECC_HW_OOB_FIRST.  The platform data from board-dm355-evm
has been adjusted to use this mode.

The patches have been verified on DM355 device with 2KiB-page Micron
devices using mtd-tests and JFFS2.  Error correction up to 4 bits has
also been verified using nandwrite/nanddump utilities.
Reviewed-by: NDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: NSneha Narnakaje <nsnehaprabha@ti.com>
Signed-off-by: NSandeep Paulraj <s-paulraj@ti.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Troy Kisky <troy.kisky@boundarydevices.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
上级 6e0cb135
...@@ -348,6 +348,12 @@ static int nand_davinci_correct_4bit(struct mtd_info *mtd, ...@@ -348,6 +348,12 @@ static int nand_davinci_correct_4bit(struct mtd_info *mtd,
if (!(syndrome[0] | syndrome[1] | syndrome[2] | syndrome[3])) if (!(syndrome[0] | syndrome[1] | syndrome[2] | syndrome[3]))
return 0; return 0;
/*
* Clear any previous address calculation by doing a dummy read of an
* error address register.
*/
davinci_nand_readl(info, NAND_ERR_ADD1_OFFSET);
/* Start address calculation, and wait for it to complete. /* Start address calculation, and wait for it to complete.
* We _could_ start reading more data while this is working, * We _could_ start reading more data while this is working,
* to speed up the overall page read. * to speed up the overall page read.
...@@ -359,8 +365,10 @@ static int nand_davinci_correct_4bit(struct mtd_info *mtd, ...@@ -359,8 +365,10 @@ static int nand_davinci_correct_4bit(struct mtd_info *mtd,
switch ((fsr >> 8) & 0x0f) { switch ((fsr >> 8) & 0x0f) {
case 0: /* no error, should not happen */ case 0: /* no error, should not happen */
davinci_nand_readl(info, NAND_ERR_ERRVAL1_OFFSET);
return 0; return 0;
case 1: /* five or more errors detected */ case 1: /* five or more errors detected */
davinci_nand_readl(info, NAND_ERR_ERRVAL1_OFFSET);
return -EIO; return -EIO;
case 2: /* error addresses computed */ case 2: /* error addresses computed */
case 3: case 3:
...@@ -500,6 +508,26 @@ static struct nand_ecclayout hwecc4_small __initconst = { ...@@ -500,6 +508,26 @@ static struct nand_ecclayout hwecc4_small __initconst = {
}, },
}; };
/* An ECC layout for using 4-bit ECC with large-page (2048bytes) flash,
* storing ten ECC bytes plus the manufacturer's bad block marker byte,
* and not overlapping the default BBT markers.
*/
static struct nand_ecclayout hwecc4_2048 __initconst = {
.eccbytes = 40,
.eccpos = {
/* at the end of spare sector */
24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
},
.oobfree = {
/* 2 bytes at offset 0 hold manufacturer badblock markers */
{.offset = 2, .length = 22, },
/* 5 bytes at offset 8 hold BBT markers */
/* 8 bytes at offset 16 hold JFFS2 clean markers */
},
};
static int __init nand_davinci_probe(struct platform_device *pdev) static int __init nand_davinci_probe(struct platform_device *pdev)
{ {
...@@ -690,15 +718,20 @@ static int __init nand_davinci_probe(struct platform_device *pdev) ...@@ -690,15 +718,20 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
info->mtd.oobsize - 16; info->mtd.oobsize - 16;
goto syndrome_done; goto syndrome_done;
} }
if (chunks == 4) {
info->ecclayout = hwecc4_2048;
info->chip.ecc.mode = NAND_ECC_HW_OOB_FIRST;
goto syndrome_done;
}
/* For large page chips we'll be wanting to use a /* 4KiB page chips are not yet supported. The eccpos from
* not-yet-implemented mode that reads OOB data * nand_ecclayout cannot hold 80 bytes and change to eccpos[]
* before reading the body of the page, to avoid * breaks userspace ioctl interface with mtd-utils. Once we
* the "infix OOB" model of NAND_ECC_HW_SYNDROME * resolve this issue, NAND_ECC_HW_OOB_FIRST mode can be used
* (and preserve manufacturer badblock markings). * for the 4KiB page chips.
*/ */
dev_warn(&pdev->dev, "no 4-bit ECC support yet " dev_warn(&pdev->dev, "no 4-bit ECC support yet "
"for large page NAND\n"); "for 4KiB-page NAND\n");
ret = -EIO; ret = -EIO;
goto err_scan; goto err_scan;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册