Skip to content

Commit 9efac6c

Browse files
Christophe Kerellomiquelraynal
authored andcommitted
mtd: rawnand: stm32_fmc2: fix broken ECC
Since commit d7157ff ("mtd: rawnand: Use the ECC framework user input parsing bits"), ECC are broken in FMC2 driver in case of nand-ecc-step-size and nand-ecc-strength are not set in the device tree. To avoid this issue, the default settings are now set in stm32_fmc2_nfc_attach_chip function. Signed-off-by: Christophe Kerello <christophe.kerello@st.com> Fixes: d7157ff ("mtd: rawnand: Use the ECC framework user input parsing bits") Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/1604064819-26861-1-git-send-email-christophe.kerello@st.com
1 parent 324f78d commit 9efac6c

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

drivers/mtd/nand/raw/stm32_fmc2_nand.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,6 +1708,13 @@ static int stm32_fmc2_nfc_attach_chip(struct nand_chip *chip)
17081708
return -EINVAL;
17091709
}
17101710

1711+
/* Default ECC settings in case they are not set in the device tree */
1712+
if (!chip->ecc.size)
1713+
chip->ecc.size = FMC2_ECC_STEP_SIZE;
1714+
1715+
if (!chip->ecc.strength)
1716+
chip->ecc.strength = FMC2_ECC_BCH8;
1717+
17111718
ret = nand_ecc_choose_conf(chip, &stm32_fmc2_nfc_ecc_caps,
17121719
mtd->oobsize - FMC2_BBM_LEN);
17131720
if (ret) {
@@ -1727,8 +1734,7 @@ static int stm32_fmc2_nfc_attach_chip(struct nand_chip *chip)
17271734

17281735
mtd_set_ooblayout(mtd, &stm32_fmc2_nfc_ooblayout_ops);
17291736

1730-
if (chip->options & NAND_BUSWIDTH_16)
1731-
stm32_fmc2_nfc_set_buswidth_16(nfc, true);
1737+
stm32_fmc2_nfc_setup(chip);
17321738

17331739
return 0;
17341740
}
@@ -1952,11 +1958,6 @@ static int stm32_fmc2_nfc_probe(struct platform_device *pdev)
19521958
chip->options |= NAND_BUSWIDTH_AUTO | NAND_NO_SUBPAGE_WRITE |
19531959
NAND_USES_DMA;
19541960

1955-
/* Default ECC settings */
1956-
chip->ecc.engine_type = NAND_ECC_ENGINE_TYPE_ON_HOST;
1957-
chip->ecc.size = FMC2_ECC_STEP_SIZE;
1958-
chip->ecc.strength = FMC2_ECC_BCH8;
1959-
19601961
/* Scan to find existence of the device */
19611962
ret = nand_scan(chip, nand->ncs);
19621963
if (ret)

0 commit comments

Comments
 (0)