]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
mtd: nand: Add an option to maximize the ECC strength
authorBoris Brezillon <boris.brezillon@free-electrons.com>
Wed, 8 Jun 2016 15:04:22 +0000 (17:04 +0200)
committerBoris Brezillon <boris.brezillon@free-electrons.com>
Fri, 23 Sep 2016 07:35:16 +0000 (09:35 +0200)
The generic NAND DT bindings allows one to tweak the ECC strength and
step size to their need. It can be used to lower the ECC strength to
match a bootloader/firmware config, but might also be used to get a better
reliability.

In the latter case, the user might want to use the maximum ECC strength
without having to explicitly calculate the exact value (this value not
only depends on the OOB size, but also on the NAND controller, and can
be tricky to extract).

Add a generic 'nand-ecc-maximize' DT property and the associated
NAND_ECC_MAXIMIZE flag, to let ECC controller drivers select the best
ECC strength and step-size on their own.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Rob Herring <robh@kernel.org>
Documentation/devicetree/bindings/mtd/nand.txt
drivers/mtd/nand/nand_base.c
include/linux/mtd/nand.h

index 3733300de8dd949bd822154c469aabcc75b40520..b05601600083d91c17c649b8cc5603011628f2a3 100644 (file)
@@ -35,6 +35,15 @@ Optional NAND chip properties:
 - nand-ecc-step-size: integer representing the number of data bytes
                      that are covered by a single ECC step.
 
+- nand-ecc-maximize: boolean used to specify that you want to maximize ECC
+                    strength. The maximum ECC strength is both controller and
+                    chip dependent. The controller side has to select the ECC
+                    config providing the best strength and taking the OOB area
+                    size constraint into account.
+                    This is particularly useful when only the in-band area is
+                    used by the upper layers, and you want to make your NAND
+                    as reliable as possible.
+
 The ECC strength and ECC step size properties define the correction capability
 of a controller. Together, they say a controller can correct "{strength} bit
 errors per {size} bytes".
index f39775b057798f1ac9ab41bba1df36a5425fca9f..6669dfcf9e794e1d9727bb6e58097fdb5ac7e65a 100644 (file)
@@ -4272,6 +4272,9 @@ static int nand_dt_init(struct nand_chip *chip)
        if (ecc_step > 0)
                chip->ecc.size = ecc_step;
 
+       if (of_property_read_bool(dn, "nand-ecc-maximize"))
+               chip->ecc.options |= NAND_ECC_MAXIMIZE;
+
        return 0;
 }
 
index d3e3f8d033367d138336fd80f13614e57eadfaf5..331caf987b16c6d0d4704610d4460595473db4c7 100644 (file)
@@ -141,6 +141,7 @@ enum nand_ecc_algo {
  * pages and you want to rely on the default implementation.
  */
 #define NAND_ECC_GENERIC_ERASED_CHECK  BIT(0)
+#define NAND_ECC_MAXIMIZE              BIT(1)
 
 /* Bit mask for flags passed to do_nand_read_ecc */
 #define NAND_GET_DEVICE                0x80