Skip to content

Commit ba78ee0

Browse files
author
Boris Brezillon
committed
mtd: nand: Add an option to maximize the ECC strength
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>
1 parent 8283079 commit ba78ee0

3 files changed

Lines changed: 13 additions & 0 deletions

File tree

‎Documentation/devicetree/bindings/mtd/nand.txt‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ Optional NAND chip properties:
3535
- nand-ecc-step-size: integer representing the number of data bytes
3636
that are covered by a single ECC step.
3737

38+
- nand-ecc-maximize: boolean used to specify that you want to maximize ECC
39+
strength. The maximum ECC strength is both controller and
40+
chip dependent. The controller side has to select the ECC
41+
config providing the best strength and taking the OOB area
42+
size constraint into account.
43+
This is particularly useful when only the in-band area is
44+
used by the upper layers, and you want to make your NAND
45+
as reliable as possible.
46+
3847
The ECC strength and ECC step size properties define the correction capability
3948
of a controller. Together, they say a controller can correct "{strength} bit
4049
errors per {size} bytes".

‎drivers/mtd/nand/nand_base.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4272,6 +4272,9 @@ static int nand_dt_init(struct nand_chip *chip)
42724272
if (ecc_step > 0)
42734273
chip->ecc.size = ecc_step;
42744274

4275+
if (of_property_read_bool(dn, "nand-ecc-maximize"))
4276+
chip->ecc.options |= NAND_ECC_MAXIMIZE;
4277+
42754278
return 0;
42764279
}
42774280

‎include/linux/mtd/nand.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ enum nand_ecc_algo {
141141
* pages and you want to rely on the default implementation.
142142
*/
143143
#define NAND_ECC_GENERIC_ERASED_CHECK BIT(0)
144+
#define NAND_ECC_MAXIMIZE BIT(1)
144145

145146
/* Bit mask for flags passed to do_nand_read_ecc */
146147
#define NAND_GET_DEVICE 0x80

0 commit comments

Comments
 (0)