From 1fcfe88d75dc9f8b92726afead68d43544d3e7d6 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Thu, 20 Apr 2017 14:14:10 -0700 Subject: mtd: nand: mxs_nand: fix ECC strength calculation for old geometry The old geometry used to round down the ECC strength. This allows to compile a U-Boot which has the same ECC format used in current Linux kernels by adding this line to the board configuration header file: #define CONFIG_NAND_MXS_BCH_LEGACY_GEO Note that this leads to 14 bit ECC per 512 byte block, which requires 2149 bytes overall. The SoC's boot ROM is only able to handle pages up to 2112 bytes, hence this format cannot be used for the boot/flash configuration block (BCB/FCB). Note that upstream Linux can also calculate ECC using JEDEC/ONFI NAND chip parameters by using the fsl,use-minimum-ecc device tree property. Signed-off-by: Stefan Agner Acked-by: Brandon Shibley --- drivers/mtd/nand/mxs_nand.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers') diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c index ef571b4098..53915ee69b 100644 --- a/drivers/mtd/nand/mxs_nand.c +++ b/drivers/mtd/nand/mxs_nand.c @@ -257,8 +257,8 @@ static int mxs_nand_get_ecc_strength(struct mtd_info *mtd) #if defined(CONFIG_NAND_MXS_BCH_LEGACY_GEO) ecc_strength = ((page_oob_size - MXS_NAND_METADATA_SIZE) * 8) /(galois_field * mxs_nand_ecc_chunk_cnt(mtd->writesize)); - ecc_strength += ecc_strength & 1; - ecc_strength = min(ecc_strength, MXS_NAND_MAX_ECC_STRENGTH); + ecc_strength = round_down(ecc_strength, 2); + ecc_strength = min(ecc_strength, max_ecc_strength_supported); #endif } return 0; -- cgit v1.2.3