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 ++-- scripts/config_whitelist.txt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c index ef571b4098f..53915ee69bf 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; diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index fc6fca8bb8f..51ee1f9eeb7 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -3307,6 +3307,7 @@ CONFIG_NAND_MPC5121_NFC CONFIG_NAND_MXC CONFIG_NAND_MXC_V1_1 CONFIG_NAND_MXS +CONFIG_NAND_MXS_BCH_LEGACY_GEO CONFIG_NAND_NDFC CONFIG_NAND_OMAP_ECCSCHEME CONFIG_NAND_OMAP_ELM -- cgit v1.2.3