mtd: mxc_nand: generate nand_ecclayout for 8 bit ECC
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Tue Jun 23 10:59:05 PDT 2015
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=8eeb4c521a8047ea73da0d6eb2d87a7f60cdd99a
Commit: 8eeb4c521a8047ea73da0d6eb2d87a7f60cdd99a
Parent: c19900edff983cfa2ddb92830d59f8e9550fde4f
Author: Baruch Siach <baruch at tkos.co.il>
AuthorDate: Wed May 13 11:17:39 2015 +0300
Committer: Brian Norris <computersforpeace at gmail.com>
CommitDate: Wed May 20 21:32:18 2015 -0700
mtd: mxc_nand: generate nand_ecclayout for 8 bit ECC
Hardware 8 bit ECC requires a different nand_ecclayout. Instead of adding yet
another static struct nand_ecclayout, generate it in code.
Reviewed-by: Sascha Hauer <s.hauer at pengutronix.de>
Signed-off-by: Baruch Siach <baruch at tkos.co.il>
Acked-by: Uwe Kleine-König <u.kleine-koenig at pengutronix.de>
Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
drivers/mtd/nand/mxc_nand.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/mxc_nand.c b/drivers/mtd/nand/mxc_nand.c
index 260d77d5..2426db8 100644
--- a/drivers/mtd/nand/mxc_nand.c
+++ b/drivers/mtd/nand/mxc_nand.c
@@ -960,6 +960,23 @@ static int get_eccsize(struct mtd_info *mtd)
return 8;
}
+static void ecc_8bit_layout_4k(struct nand_ecclayout *layout)
+{
+ int i, j;
+
+ layout->eccbytes = 8*18;
+ for (i = 0; i < 8; i++)
+ for (j = 0; j < 18; j++)
+ layout->eccpos[i*18 + j] = i*26 + j + 7;
+
+ layout->oobfree[0].offset = 2;
+ layout->oobfree[0].length = 4;
+ for (i = 1; i < 8; i++) {
+ layout->oobfree[i].offset = i*26;
+ layout->oobfree[i].length = 7;
+ }
+}
+
static void preset_v1(struct mtd_info *mtd)
{
struct nand_chip *nand_chip = mtd->priv;
@@ -1636,8 +1653,11 @@ static int mxcnd_probe(struct platform_device *pdev)
if (mtd->writesize == 2048)
this->ecc.layout = host->devtype_data->ecclayout_2k;
- else if (mtd->writesize == 4096)
+ else if (mtd->writesize == 4096) {
this->ecc.layout = host->devtype_data->ecclayout_4k;
+ if (get_eccsize(mtd) == 8)
+ ecc_8bit_layout_4k(this->ecc.layout);
+ }
/*
* Experimentation shows that i.MX NFC can only handle up to 218 oob
More information about the linux-mtd-cvs
mailing list