According to Linux kernel DT schema nand-controller.yaml, using DT property
nand-ecc-algo=bch is the correct way for specifying BCH as ECC algorithm.

Signed-off-by: Pali Rohár <[email protected]>
---
 drivers/mtd/nand/raw/nand_base.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index f7616985d95e..e0c087f0ebaf 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -4598,6 +4598,12 @@ static int nand_dt_init(struct mtd_info *mtd, struct 
nand_chip *chip, ofnode nod
                        ecc_mode = NAND_ECC_SOFT_BCH;
        }
 
+       if (ecc_mode == NAND_ECC_SOFT) {
+               str = ofnode_read_string(node, "nand-ecc-algo");
+               if (str && !strcmp(str, "bch"))
+                       ecc_mode = NAND_ECC_SOFT_BCH;
+       }
+
        ecc_strength = ofnode_read_s32_default(node,
                                               "nand-ecc-strength", -1);
        ecc_step = ofnode_read_s32_default(node,
-- 
2.20.1

Reply via email to