When trying to add support for another device with Micron NAND chips,
it was discovered that the default setting in the kernel source does
not work with Micron Chips, since the device trees setting is
overwritten and hard coded by the kernel xway_nand driver. This was
the original reason for this PR.
A kernel patch sets the default ECC mode to soft without overwriting
the device tree settings and the device tree for devices using it
are updated with new parameters because the old ones are deprecated
by torvalds/linux@
533af69.
A patch for kernel 5.4 is provided to support the new settings
because kernel 5.4 does not support it.
Signed-off-by: Daniel Kestrel <kestrel1974@t-online.de>
pinctrl-0 = <&nand_pins>, <&nand_cs1_pins>;
pinctrl-names = "default";
+ nand-use-soft-ecc-engine;
+
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
pinctrl-0 = <&nand_pins>, <&nand_cs1_pins>;
pinctrl-names = "default";
+ nand-use-soft-ecc-engine;
+
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
pinctrl-0 = <&nand_pins>, <&nand_cs1_pins>;
pinctrl-names = "default";
- nand-ecc-mode = "soft";
+ nand-use-soft-ecc-engine;
nand-ecc-strength = <3>;
nand-ecc-step-size = <256>;
};
&localbus {
- flash@1 {
+ flash1: flash@1 {
compatible = "lantiq,nand-xway";
bank-width = <2>;
reg = <1 0x0 0x2000000>;
pinctrl-0 = <&nand_pins>, <&nand_cs1_pins>;
pinctrl-names = "default";
- nand-ecc-mode = "on-die";
+ nand-ecc-engine = <&flash1>;
partitions {
compatible = "fixed-partitions";
};
&localbus {
- flash@1 {
+ flash1: flash@1 {
compatible = "lantiq,nand-xway";
bank-width = <1>;
reg = <1 0x0 0x2000000>;
pinctrl-0 = <&nand_pins>;
pinctrl-names = "default";
- nand-ecc-mode = "on-die";
+ nand-ecc-engine = <&flash1>;
partitions {
compatible = "fixed-partitions";
};
&localbus {
- flash@1 {
+ flash1: flash@1 {
compatible = "lantiq,nand-xway";
lantiq,cs1 = <1>;
bank-width = <1>;
pinctrl-0 = <&nand_pins>, <&nand_cs1_pins>;
pinctrl-names = "default";
- nand-ecc-mode = "on-die";
+ nand-ecc-engine = <&flash1>;
partitions {
compatible = "fixed-partitions";
pinctrl-0 = <&nand_pins>, <&nand_cs1_pins>;
pinctrl-names = "default";
+ nand-use-soft-ecc-engine;
+
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
pinctrl-0 = <&nand_pins>, <&nand_cs1_pins>;
pinctrl-names = "default";
+ nand-use-soft-ecc-engine;
+
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
nand-on-flash-bbt;
nand-ecc-strength = <3>;
nand-ecc-step-size = <256>;
+ nand-use-soft-ecc-engine;
partitions {
compatible = "fixed-partitions";
pinctrl-0 = <&nand_pins>;
pinctrl-names = "default";
+ nand-use-soft-ecc-engine;
+
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
pinctrl-0 = <&nand_pins>, <&nand_cs1_pins>;
pinctrl-names = "default";
+ nand-use-soft-ecc-engine;
+
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#address-cells = <1>;
#size-cells = <1>;
+ nand-use-soft-ecc-engine;
+
partition@0 {
label = "kernel";
reg = <0x0 0x200000>;
--- /dev/null
+The nand-ecc-mode DT binding is depracated but the new bindings are
+not supported by kernel 5.4. Based on a fix in the kernel to not
+overwrite the DT ECC settings, the DT needs to be updated and moves
+to the new DT binding.
+Since the DT is shared between kernel 5.4 and 5.10, this patch is
+an interim solution to allow to use the new DT bindings in kernel 5.4.
+It should be removed when moving away from kernel 5.4.
+--- a/drivers/mtd/nand/raw/nand_base.c
++++ b/drivers/mtd/nand/raw/nand_base.c
+@@ -4851,10 +4851,17 @@ static int of_get_nand_ecc_mode(struct d
+ {
+ const char *pm;
+ int err, i;
++ struct device_node *eng_np;
+
+ err = of_property_read_string(np, "nand-ecc-mode", &pm);
+- if (err < 0)
++ if (err < 0) {
++ if (of_property_read_bool(np, "nand-use-soft-ecc-engine"))
++ return NAND_ECC_SOFT;
++ eng_np = of_parse_phandle(np, "nand-ecc-engine", 0);
++ if (eng_np && (eng_np == np))
++ return NAND_ECC_ON_DIE;
+ return err;
++ }
+
+ for (i = 0; i < ARRAY_SIZE(nand_ecc_modes); i++)
+ if (!strcasecmp(pm, nand_ecc_modes[i]))