lantiq: kernel: xway-nand: Move ECC engine setting to new DT binding
authorDaniel Kestrel <kestrel1974@t-online.de>
Sat, 7 Aug 2021 07:28:24 +0000 (09:28 +0200)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 2 Oct 2021 14:45:33 +0000 (16:45 +0200)
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>
13 files changed:
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/ar9_bt_homehub-v3a.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/danube_bt_homehub-v2b.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz3370-rev2-hynix.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz3370-rev2-micron.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz3390.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7362sl.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7412.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_avm_fritz7430.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_bt_homehub-v5a.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_lantiq_easy80920-nand.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_zyxel_p-2812hnu-f1.dts
target/linux/lantiq/files/arch/mips/boot/dts/lantiq/vr9_zyxel_p-2812hnu-f3.dts
target/linux/lantiq/patches-5.4/0019-MTD-nand-support-new-dt-bindings.patch [new file with mode: 0644]

index 61a39f9955215619f1ccc9e2f56d42ae34323c9c..71b32b62f5ab1c52a77df7422ef1bec583c97417 100644 (file)
                pinctrl-0 = <&nand_pins>, <&nand_cs1_pins>;
                pinctrl-names = "default";
 
+               nand-use-soft-ecc-engine;
+
                partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
index 0147b3ffd1deca63a7263a0acdbec3146809a294..85536b0082a579ee7eee601a0e3fc63752ec6782 100644 (file)
                pinctrl-0 = <&nand_pins>, <&nand_cs1_pins>;
                pinctrl-names = "default";
 
+               nand-use-soft-ecc-engine;
+
                partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
index e1d0851dab0cdfa5478dc9664a6b856c1d5f7c91..d1bbd0532a056d5124fad740da7d75b2f82b72de 100644 (file)
@@ -14,7 +14,7 @@
                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>;
 
index 2a98a12acb00c756594a23f592aad16df7e96abf..16cf76cef34398140b7d2a9ac5a84425bc265ac0 100644 (file)
@@ -6,7 +6,7 @@
 };
 
 &localbus {
-       flash@1 {
+       flash1: flash@1 {
                compatible = "lantiq,nand-xway";
                bank-width = <2>;
                reg = <1 0x0 0x2000000>;
@@ -14,7 +14,7 @@
                pinctrl-0 = <&nand_pins>, <&nand_cs1_pins>;
                pinctrl-names = "default";
 
-               nand-ecc-mode = "on-die";
+               nand-ecc-engine = <&flash1>;
 
                partitions {
                        compatible = "fixed-partitions";
index c4b92f9f910b9a7030f4ba7aedf71a8ff9bf9160..17be2729f93841cbaab609482dce8f2c0a07f0de 100644 (file)
 };
 
 &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";
index b1423e5dea4cc10665c9d8b4a61d627417ba4451..4d86bf5542d611e8dbe35d671faf6b400797514d 100644 (file)
@@ -46,7 +46,7 @@
 };
 
 &localbus {
-       flash@1 {
+       flash1: flash@1 {
                compatible = "lantiq,nand-xway";
                lantiq,cs1 = <1>;
                bank-width = <1>;
@@ -55,7 +55,7 @@
                pinctrl-0 = <&nand_pins>, <&nand_cs1_pins>;
                pinctrl-names = "default";
 
-               nand-ecc-mode = "on-die";
+               nand-ecc-engine = <&flash1>;
 
                partitions {
                        compatible = "fixed-partitions";
index a9d20915ea3c42a3cc5fcd4a221af6c04d8d9632..11f318db5de710df67ce83209eccd099f8eb1344 100644 (file)
@@ -91,6 +91,8 @@
                pinctrl-0 = <&nand_pins>, <&nand_cs1_pins>;
                pinctrl-names = "default";
 
+               nand-use-soft-ecc-engine;
+
                partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
index 3be20e1ff048c8a187005633aad774a15c2d882a..7bc64b76e7c860fe2c75e38b5f3e692133c23dbc 100644 (file)
                pinctrl-0 = <&nand_pins>, <&nand_cs1_pins>;
                pinctrl-names = "default";
 
+               nand-use-soft-ecc-engine;
+
                partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
index e24ee787f1312191d32bf9d21c8a6eacea81116d..76cf69335b917ba79af34e1968e1c98bf098e64e 100644 (file)
                nand-on-flash-bbt;
                nand-ecc-strength = <3>;
                nand-ecc-step-size = <256>;
+               nand-use-soft-ecc-engine;
 
                partitions {
                        compatible = "fixed-partitions";
index 475d5a59d7503e5107b88ea8bb91425ce676b3f6..82f72022c99ba2f0bf052583297387ae74033745 100644 (file)
@@ -19,6 +19,8 @@
                pinctrl-0 = <&nand_pins>;
                pinctrl-names = "default";
 
+               nand-use-soft-ecc-engine;
+
                partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
index 0e029d1995665d565e498025776ca6f83c18aa76..4a7f63b177c4a8d9e18479dfb8967fc68a4c4cf5 100644 (file)
@@ -30,6 +30,8 @@
                pinctrl-0 = <&nand_pins>, <&nand_cs1_pins>;
                pinctrl-names = "default";
 
+               nand-use-soft-ecc-engine;
+
                partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
index 12280241a59379f5f9668bee752c5442e44745f2..376cdaeb61ebcce117d50842994aa31355a16245 100644 (file)
@@ -51,6 +51,8 @@
                #address-cells = <1>;
                #size-cells = <1>;
 
+               nand-use-soft-ecc-engine;
+
                partition@0 {
                        label = "kernel";
                        reg = <0x0 0x200000>;
diff --git a/target/linux/lantiq/patches-5.4/0019-MTD-nand-support-new-dt-bindings.patch b/target/linux/lantiq/patches-5.4/0019-MTD-nand-support-new-dt-bindings.patch
new file mode 100644 (file)
index 0000000..b4aa5b9
--- /dev/null
@@ -0,0 +1,28 @@
+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]))