mtd: nand: sunxi: Support ECC maximization
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Sat Oct 8 21:59:06 PDT 2016
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=4796d8655915b8dce265318542a40d920aad91a3
Commit: 4796d8655915b8dce265318542a40d920aad91a3
Parent: 8bbba48124f2ace8f8bf382539d7115f0f307eeb
Author: Boris Brezillon <boris.brezillon at free-electrons.com>
AuthorDate: Wed Jun 8 17:04:24 2016 +0200
Committer: Boris Brezillon <boris.brezillon at free-electrons.com>
CommitDate: Fri Sep 23 09:35:16 2016 +0200
mtd: nand: sunxi: Support ECC maximization
Setup the maximum ECC config when NAND_ECC_MAXIMIZE is set.
Signed-off-by: Boris Brezillon <boris.brezillon at free-electrons.com>
---
drivers/mtd/nand/sunxi_nand.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/mtd/nand/sunxi_nand.c b/drivers/mtd/nand/sunxi_nand.c
index 2032244..8b8470c 100644
--- a/drivers/mtd/nand/sunxi_nand.c
+++ b/drivers/mtd/nand/sunxi_nand.c
@@ -1787,6 +1787,35 @@ static int sunxi_nand_hw_common_ecc_ctrl_init(struct mtd_info *mtd,
int ret;
int i;
+ if (ecc->options & NAND_ECC_MAXIMIZE) {
+ int bytes;
+
+ ecc->size = 1024;
+ nsectors = mtd->writesize / ecc->size;
+
+ /* Reserve 2 bytes for the BBM */
+ bytes = (mtd->oobsize - 2) / nsectors;
+
+ /* 4 non-ECC bytes are added before each ECC bytes section */
+ bytes -= 4;
+
+ /* and bytes has to be even. */
+ if (bytes % 2)
+ bytes--;
+
+ ecc->strength = bytes * 8 / fls(8 * ecc->size);
+
+ for (i = 0; i < ARRAY_SIZE(strengths); i++) {
+ if (strengths[i] > ecc->strength)
+ break;
+ }
+
+ if (!i)
+ ecc->strength = 0;
+ else
+ ecc->strength = strengths[i - 1];
+ }
+
if (ecc->size != 512 && ecc->size != 1024)
return -EINVAL;
More information about the linux-mtd-cvs
mailing list