
On 26.01.2023 02:14, William Zhang wrote:
On 01/21/2023 03:43 PM, Linus Walleij wrote:
For BRCMNAND with 1-bit BCH ECC (BCH-1) such as used on the D-Link DIR-885L and DIR-890L routers, we need to explicitly select the ECC like this in the device tree:
nand-ecc-algo = "bch"; nand-ecc-strength = <1>; nand-ecc-step-size = <512>;
This is handled by the Linux kernel but U-Boot core does not respect this. Fix it up by parsing the algorithm and preserve the behaviour using this property to select software BCH as far as possible.
For 1 bit HW ECC, the BRCMNAND driver only uses HAMMING ECC. The brcmnand_setup_dev function should take care of it with just these two properties in the device tress without any code changes: nand-ecc-strength = <1>; nand-ecc-step-size = <512>; unless these D-Link device has always been using software BCH-1 and wants to continue to use software BCH-1.
Please check arch/arm/boot/dts/bcm5301x-nand-cs0-bch1.dtsi https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch...
It's included by arch/arm/boot/dts/bcm47094-dlink-dir-885l.dts https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch...
I can confirm D-Link decided to use BCH-1 for some of its devices. I didn't expect it neither and that required fixing up brcmnand driver in Linux actually.
BTW, I didn't see this change from master branch of linux nand base driver. The "nand-ecc-algo" is only used by the ecc engine code(ecc.c) but this code is not in the u-boot obviously. Were you porting this from a different version of linux nand driver?
My original proposal for brcmnand looked like this: [PATCH 3/3] mtd: brcmnand: respect ECC algorithm set by NAND subsystem https://lore.kernel.org/lkml/1461324197-1333-3-git-send-email-zajec5@gmail.c...
It was reworked by Brian to a more backward compatible solution that got accepted: [PATCH] mtd: brcmnand: respect ECC algorithm set by the NAND subsystem https://lore.kernel.org/lkml/20160426055355.GA25981@localhost/ https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...