kernel: backport 5.13 mtd partitioning changes
authorRafał Miłecki <rafal@milecki.pl>
Mon, 29 Mar 2021 06:16:17 +0000 (08:16 +0200)
committerRafał Miłecki <rafal@milecki.pl>
Thu, 8 Apr 2021 09:25:41 +0000 (11:25 +0200)
1. Use upstream accepted NVMEM patches
2. Minor fix for BCM4908 partitioning
3. Support for Linksys firmware partitions on Northstar

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
(cherry picked from commit 3fd0a4222b6efbfbdb560c5b13e899ecda627494)

17 files changed:
target/linux/ath79/patches-5.4/404-mtd-cybertan-trx-parser.patch
target/linux/bcm4908/config-5.4
target/linux/bcm53xx/config-5.4
target/linux/generic/backport-5.4/405-v5.13-mtd-parsers-ofpart-make-symbol-bcm4908_partitions_qu.patch [new file with mode: 0644]
target/linux/generic/backport-5.4/406-v5.13-0001-mtd-core-add-nvmem-cells-compatible-to-parse-mtd-as-.patch [new file with mode: 0644]
target/linux/generic/backport-5.4/406-v5.13-0002-dt-bindings-nvmem-drop-nodename-restriction.patch [new file with mode: 0644]
target/linux/generic/backport-5.4/406-v5.13-0003-dt-bindings-mtd-Document-use-of-nvmem-cells-compatib.patch [new file with mode: 0644]
target/linux/generic/backport-5.4/407-v5.13-0001-dt-bindings-mtd-add-binding-for-Linksys-Northstar-pa.patch [new file with mode: 0644]
target/linux/generic/backport-5.4/407-v5.13-0002-mtd-parsers-ofpart-support-Linksys-Northstar-partiti.patch [new file with mode: 0644]
target/linux/generic/pending-5.4/405-0001-mtd-core-add-nvmem-cells-compatible-to-parse-mtd-as-.patch [deleted file]
target/linux/generic/pending-5.4/405-0002-devicetree-nvmem-nvmem-drop-nodename-restriction.patch [deleted file]
target/linux/generic/pending-5.4/405-0003-dt-bindings-mtd-Document-use-of-nvmem-cells-compatib.patch [deleted file]
target/linux/generic/pending-5.4/435-mtd-add-routerbootpart-parser-config.patch
target/linux/ipq806x/patches-5.4/0031-mtd-add-SMEM-parser-for-QCOM-platforms.patch
target/linux/kirkwood/patches-5.4/202-linksys-find-active-root.patch
target/linux/lantiq/patches-5.4/0101-find_active_root.patch
target/linux/mvebu/patches-5.4/400-find_active_root.patch

index 59ee57d277b95877d95a3ac9bdd329da65f0b5f7..923589661ee04940ec18b7e302d72036b69893aa 100644 (file)
@@ -1,18 +1,18 @@
 --- a/drivers/mtd/parsers/Makefile
 +++ b/drivers/mtd/parsers/Makefile
-@@ -7,6 +7,7 @@ obj-$(CONFIG_MTD_MYLOADER_PARTS)               += myl
- obj-$(CONFIG_MTD_OF_PARTS)            += ofpart.o
+@@ -8,6 +8,7 @@ obj-$(CONFIG_MTD_OF_PARTS)             += ofpart.o
  ofpart-y                              += ofpart_core.o
  ofpart-$(CONFIG_MTD_OF_PARTS_BCM4908) += ofpart_bcm4908.o
+ ofpart-$(CONFIG_MTD_OF_PARTS_LINKSYS_NS)+= ofpart_linksys_ns.o
 +obj-$(CONFIG_MTD_PARSER_CYBERTAN)     += parser_cybertan.o
  obj-$(CONFIG_MTD_PARSER_IMAGETAG)     += parser_imagetag.o
  obj-$(CONFIG_MTD_AFS_PARTS)           += afs.o
  obj-$(CONFIG_MTD_PARSER_TRX)          += parser_trx.o
 --- a/drivers/mtd/parsers/Kconfig
 +++ b/drivers/mtd/parsers/Kconfig
-@@ -92,6 +92,14 @@ config MTD_OF_PARTS_BCM4908
-         that can have multiple "firmware" partitions. It takes care of
-         finding currently used one and backup ones.
+@@ -102,6 +102,14 @@ config MTD_OF_PARTS_LINKSYS_NS
+         two "firmware" partitions. Currently used firmware has to be detected
+         using CFE environment variable.
  
 +config MTD_PARSER_CYBERTAN
 +      tristate "Parser for Cybertan format partitions"
index 47529fc958326076c640065e83a4ee3b4dc1a38f..72ecdc0454b2b5944dc8cf1c8b28b6211a956ceb 100644 (file)
@@ -139,6 +139,7 @@ CONFIG_MTD_NAND_BRCMNAND=y
 CONFIG_MTD_NAND_CORE=y
 CONFIG_MTD_NAND_ECC_SW_HAMMING=y
 CONFIG_MTD_OF_PARTS_BCM4908=y
+# CONFIG_MTD_OF_PARTS_LINKSYS_NS is not set
 CONFIG_MTD_RAW_NAND=y
 CONFIG_MTD_SPLIT_CFE_BOOTFS=y
 # CONFIG_MTD_SPLIT_SQUASHFS_ROOT is not set
index 07a8f85aa05fa15b74c540fbc027235fa71302bd..f57bfd36b66ab2fdd2fde08091c24d4280397b5d 100644 (file)
@@ -258,6 +258,7 @@ CONFIG_MTD_BCM47XX_PARTS=y
 CONFIG_MTD_NAND_BRCMNAND=y
 CONFIG_MTD_NAND_CORE=y
 CONFIG_MTD_NAND_ECC_SW_HAMMING=y
+CONFIG_MTD_OF_PARTS_LINKSYS_NS=y
 CONFIG_MTD_PARSER_TRX=y
 CONFIG_MTD_RAW_NAND=y
 CONFIG_MTD_SPI_NOR=y
diff --git a/target/linux/generic/backport-5.4/405-v5.13-mtd-parsers-ofpart-make-symbol-bcm4908_partitions_qu.patch b/target/linux/generic/backport-5.4/405-v5.13-mtd-parsers-ofpart-make-symbol-bcm4908_partitions_qu.patch
new file mode 100644 (file)
index 0000000..f1b778a
--- /dev/null
@@ -0,0 +1,34 @@
+From b87b6d2d6f540e29c3f98e1572d64e560d73d6c1 Mon Sep 17 00:00:00 2001
+From: Wei Yongjun <weiyongjun1@huawei.com>
+Date: Thu, 4 Mar 2021 06:46:00 +0000
+Subject: [PATCH] mtd: parsers: ofpart: make symbol 'bcm4908_partitions_quirks'
+ static
+
+The sparse tool complains as follows:
+
+drivers/mtd/parsers/ofpart_core.c:25:32: warning:
+ symbol 'bcm4908_partitions_quirks' was not declared. Should it be static?
+
+This symbol is not used outside of ofpart_core.c, so this
+commit marks it static.
+
+Fixes: 457da931b608 ("mtd: parsers: ofpart: support BCM4908 fixed partitions")
+Reported-by: Hulk Robot <hulkci@huawei.com>
+Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
+Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Link: https://lore.kernel.org/linux-mtd/20210304064600.3279138-1-weiyongjun1@huawei.com
+---
+ drivers/mtd/parsers/ofpart_core.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/drivers/mtd/parsers/ofpart_core.c
++++ b/drivers/mtd/parsers/ofpart_core.c
+@@ -22,7 +22,7 @@ struct fixed_partitions_quirks {
+       int (*post_parse)(struct mtd_info *mtd, struct mtd_partition *parts, int nr_parts);
+ };
+-struct fixed_partitions_quirks bcm4908_partitions_quirks = {
++static struct fixed_partitions_quirks bcm4908_partitions_quirks = {
+       .post_parse = bcm4908_partitions_post_parse,
+ };
diff --git a/target/linux/generic/backport-5.4/406-v5.13-0001-mtd-core-add-nvmem-cells-compatible-to-parse-mtd-as-.patch b/target/linux/generic/backport-5.4/406-v5.13-0001-mtd-core-add-nvmem-cells-compatible-to-parse-mtd-as-.patch
new file mode 100644 (file)
index 0000000..ecea743
--- /dev/null
@@ -0,0 +1,40 @@
+From 658c4448bbbf02a143abf1b89d09a3337ebd3ba6 Mon Sep 17 00:00:00 2001
+From: Ansuel Smith <ansuelsmth@gmail.com>
+Date: Fri, 12 Mar 2021 07:28:19 +0100
+Subject: [PATCH] mtd: core: add nvmem-cells compatible to parse mtd as nvmem
+ cells
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Partitions that contains the nvmem-cells compatible will register
+their direct subonodes as nvmem cells and the node will be treated as a
+nvmem provider.
+
+Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+Tested-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Link: https://lore.kernel.org/linux-mtd/20210312062830.20548-1-ansuelsmth@gmail.com
+---
+ drivers/mtd/mtdcore.c | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/mtd/mtdcore.c
++++ b/drivers/mtd/mtdcore.c
+@@ -559,6 +559,7 @@ static int mtd_nvmem_reg_read(void *priv
+ static int mtd_nvmem_add(struct mtd_info *mtd)
+ {
++      struct device_node *node = mtd_get_of_node(mtd);
+       struct nvmem_config config = {};
+       config.id = -1;
+@@ -571,7 +572,7 @@ static int mtd_nvmem_add(struct mtd_info
+       config.stride = 1;
+       config.read_only = true;
+       config.root_only = true;
+-      config.no_of_node = true;
++      config.no_of_node = !of_device_is_compatible(node, "nvmem-cells");
+       config.priv = mtd;
+       mtd->nvmem = nvmem_register(&config);
diff --git a/target/linux/generic/backport-5.4/406-v5.13-0002-dt-bindings-nvmem-drop-nodename-restriction.patch b/target/linux/generic/backport-5.4/406-v5.13-0002-dt-bindings-nvmem-drop-nodename-restriction.patch
new file mode 100644 (file)
index 0000000..c0515bd
--- /dev/null
@@ -0,0 +1,28 @@
+From 52981a0fa9f7d68641e0e6bb584054c6d9eb2056 Mon Sep 17 00:00:00 2001
+From: Ansuel Smith <ansuelsmth@gmail.com>
+Date: Fri, 12 Mar 2021 07:28:20 +0100
+Subject: [PATCH] dt-bindings: nvmem: drop $nodename restriction
+
+Drop $nodename restriction as now mtd partition can also be used as
+nvmem provider.
+
+Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+Reviewed-by: Rob Herring <robh@kernel.org>
+Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Link: https://lore.kernel.org/linux-mtd/20210312062830.20548-2-ansuelsmth@gmail.com
+---
+ Documentation/devicetree/bindings/nvmem/nvmem.yaml | 3 ---
+ 1 file changed, 3 deletions(-)
+
+--- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
++++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
+@@ -20,9 +20,6 @@ description: |
+   storage device.
+ properties:
+-  $nodename:
+-    pattern: "^(eeprom|efuse|nvram)(@.*|-[0-9a-f])*$"
+-
+   "#address-cells":
+     const: 1
diff --git a/target/linux/generic/backport-5.4/406-v5.13-0003-dt-bindings-mtd-Document-use-of-nvmem-cells-compatib.patch b/target/linux/generic/backport-5.4/406-v5.13-0003-dt-bindings-mtd-Document-use-of-nvmem-cells-compatib.patch
new file mode 100644 (file)
index 0000000..552919f
--- /dev/null
@@ -0,0 +1,119 @@
+From ac42c46f983e4a9003a7bb91ad44a23ab7b8f534 Mon Sep 17 00:00:00 2001
+From: Ansuel Smith <ansuelsmth@gmail.com>
+Date: Fri, 12 Mar 2021 07:28:21 +0100
+Subject: [PATCH] dt-bindings: mtd: Document use of nvmem-cells compatible
+
+Document nvmem-cells compatible used to treat mtd partitions as a
+nvmem provider.
+
+Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+Reviewed-by: Rob Herring <robh@kernel.org>
+Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Link: https://lore.kernel.org/linux-mtd/20210312062830.20548-3-ansuelsmth@gmail.com
+---
+ .../bindings/mtd/partitions/nvmem-cells.yaml  | 99 +++++++++++++++++++
+ 1 file changed, 99 insertions(+)
+ create mode 100644 Documentation/devicetree/bindings/mtd/partitions/nvmem-cells.yaml
+
+--- /dev/null
++++ b/Documentation/devicetree/bindings/mtd/partitions/nvmem-cells.yaml
+@@ -0,0 +1,99 @@
++# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
++%YAML 1.2
++---
++$id: http://devicetree.org/schemas/mtd/partitions/nvmem-cells.yaml#
++$schema: http://devicetree.org/meta-schemas/core.yaml#
++
++title: Nvmem cells
++
++description: |
++  Any partition containing the compatible "nvmem-cells" will register as a
++  nvmem provider.
++  Each direct subnodes represents a nvmem cell following the nvmem binding.
++  Nvmem binding to declare nvmem-cells can be found in:
++  Documentation/devicetree/bindings/nvmem/nvmem.yaml
++
++maintainers:
++  - Ansuel Smith <ansuelsmth@gmail.com>
++
++allOf:
++  - $ref: /schemas/nvmem/nvmem.yaml#
++
++properties:
++  compatible:
++    const: nvmem-cells
++
++required:
++  - compatible
++
++additionalProperties: true
++
++examples:
++  - |
++    partitions {
++      compatible = "fixed-partitions";
++      #address-cells = <1>;
++      #size-cells = <1>;
++
++      /* ... */
++
++      };
++      art: art@1200000 {
++        compatible = "nvmem-cells";
++        reg = <0x1200000 0x0140000>;
++        label = "art";
++        read-only;
++        #address-cells = <1>;
++        #size-cells = <1>;
++
++        macaddr_gmac1: macaddr_gmac1@0 {
++          reg = <0x0 0x6>;
++        };
++
++        macaddr_gmac2: macaddr_gmac2@6 {
++          reg = <0x6 0x6>;
++        };
++
++        pre_cal_24g: pre_cal_24g@1000 {
++          reg = <0x1000 0x2f20>;
++        };
++
++        pre_cal_5g: pre_cal_5g@5000{
++          reg = <0x5000 0x2f20>;
++        };
++      };
++  - |
++    partitions {
++        compatible = "fixed-partitions";
++        #address-cells = <1>;
++        #size-cells = <1>;
++
++        partition@0 {
++            label = "bootloader";
++            reg = <0x000000 0x100000>;
++            read-only;
++        };
++
++        firmware@100000 {
++            compatible = "brcm,trx";
++            label = "firmware";
++            reg = <0x100000 0xe00000>;
++        };
++
++        calibration@f00000 {
++            compatible = "nvmem-cells";
++            label = "calibration";
++            reg = <0xf00000 0x100000>;
++            ranges = <0 0xf00000 0x100000>;
++            #address-cells = <1>;
++            #size-cells = <1>;
++
++            wifi0@0 {
++                reg = <0x000000 0x080000>;
++            };
++
++            wifi1@80000 {
++                reg = <0x080000 0x080000>;
++            };
++        };
++    };
diff --git a/target/linux/generic/backport-5.4/407-v5.13-0001-dt-bindings-mtd-add-binding-for-Linksys-Northstar-pa.patch b/target/linux/generic/backport-5.4/407-v5.13-0001-dt-bindings-mtd-add-binding-for-Linksys-Northstar-pa.patch
new file mode 100644 (file)
index 0000000..35a4afd
--- /dev/null
@@ -0,0 +1,98 @@
+From 2fa7294175c76e1ec568aa75c1891fd908728c8d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Fri, 12 Mar 2021 14:49:18 +0100
+Subject: [PATCH] dt-bindings: mtd: add binding for Linksys Northstar
+ partitions
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Linksys on Broadcom Northstar devices uses fixed flash layout with
+multiple firmware partitions.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Reviewed-by: Rob Herring <robh@kernel.org>
+Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Link: https://lore.kernel.org/linux-mtd/20210312134919.7767-1-zajec5@gmail.com
+---
+ .../mtd/partitions/linksys,ns-partitions.yaml | 74 +++++++++++++++++++
+ 1 file changed, 74 insertions(+)
+ create mode 100644 Documentation/devicetree/bindings/mtd/partitions/linksys,ns-partitions.yaml
+
+--- /dev/null
++++ b/Documentation/devicetree/bindings/mtd/partitions/linksys,ns-partitions.yaml
+@@ -0,0 +1,74 @@
++# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
++%YAML 1.2
++---
++$id: http://devicetree.org/schemas/mtd/partitions/linksys,ns-partitions.yaml#
++$schema: http://devicetree.org/meta-schemas/core.yaml#
++
++title: Linksys Northstar partitioning
++
++description: |
++  Linksys devices based on Broadcom Northstar architecture often use two
++  firmware partitions. One is used for regular booting, the other is treated as
++  fallback.
++
++  This binding allows defining all fixed partitions and marking those containing
++  firmware. System can use that information e.g. for booting or flashing
++  purposes.
++
++maintainers:
++  - Rafał Miłecki <rafal@milecki.pl>
++
++properties:
++  compatible:
++    const: linksys,ns-partitions
++
++  "#address-cells":
++    enum: [ 1, 2 ]
++
++  "#size-cells":
++    enum: [ 1, 2 ]
++
++patternProperties:
++  "^partition@[0-9a-f]+$":
++    $ref: "partition.yaml#"
++    properties:
++      compatible:
++        items:
++          - const: linksys,ns-firmware
++          - const: brcm,trx
++    unevaluatedProperties: false
++
++required:
++  - "#address-cells"
++  - "#size-cells"
++
++additionalProperties: false
++
++examples:
++  - |
++    partitions {
++        compatible = "linksys,ns-partitions";
++        #address-cells = <1>;
++        #size-cells = <1>;
++
++        partition@0 {
++            label = "boot";
++            reg = <0x0 0x100000>;
++            read-only;
++        };
++
++        partition@100000 {
++            label = "nvram";
++            reg = <0x100000 0x100000>;
++        };
++
++        partition@200000 {
++            compatible = "linksys,ns-firmware", "brcm,trx";
++            reg = <0x200000 0xf00000>;
++        };
++
++        partition@1100000 {
++            compatible = "linksys,ns-firmware", "brcm,trx";
++            reg = <0x1100000 0xf00000>;
++        };
++    };
diff --git a/target/linux/generic/backport-5.4/407-v5.13-0002-mtd-parsers-ofpart-support-Linksys-Northstar-partiti.patch b/target/linux/generic/backport-5.4/407-v5.13-0002-mtd-parsers-ofpart-support-Linksys-Northstar-partiti.patch
new file mode 100644 (file)
index 0000000..75eb939
--- /dev/null
@@ -0,0 +1,156 @@
+From 7134a2d026d942210b4d26d6059c9d979ca7866e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Fri, 12 Mar 2021 14:49:19 +0100
+Subject: [PATCH] mtd: parsers: ofpart: support Linksys Northstar partitions
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This allows extending ofpart parser with support for Linksys Northstar
+devices. That support uses recently added quirks mechanism.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
+Link: https://lore.kernel.org/linux-mtd/20210312134919.7767-2-zajec5@gmail.com
+---
+ drivers/mtd/parsers/Kconfig             | 10 +++++
+ drivers/mtd/parsers/Makefile            |  1 +
+ drivers/mtd/parsers/ofpart_core.c       |  6 +++
+ drivers/mtd/parsers/ofpart_linksys_ns.c | 50 +++++++++++++++++++++++++
+ drivers/mtd/parsers/ofpart_linksys_ns.h | 18 +++++++++
+ 5 files changed, 85 insertions(+)
+ create mode 100644 drivers/mtd/parsers/ofpart_linksys_ns.c
+ create mode 100644 drivers/mtd/parsers/ofpart_linksys_ns.h
+
+--- a/drivers/mtd/parsers/Kconfig
++++ b/drivers/mtd/parsers/Kconfig
+@@ -76,6 +76,16 @@ config MTD_OF_PARTS_BCM4908
+         that can have multiple "firmware" partitions. It takes care of
+         finding currently used one and backup ones.
++config MTD_OF_PARTS_LINKSYS_NS
++      bool "Linksys Northstar partitioning support"
++      depends on MTD_OF_PARTS && (ARCH_BCM_5301X || ARCH_BCM4908 || COMPILE_TEST)
++      default ARCH_BCM_5301X
++      help
++        This provides partitions parser for Linksys devices based on Broadcom
++        Northstar architecture. Linksys commonly uses fixed flash layout with
++        two "firmware" partitions. Currently used firmware has to be detected
++        using CFE environment variable.
++
+ config MTD_PARSER_IMAGETAG
+       tristate "Parser for BCM963XX Image Tag format partitions"
+       depends on BCM63XX || BMIPS_GENERIC || COMPILE_TEST
+--- a/drivers/mtd/parsers/Makefile
++++ b/drivers/mtd/parsers/Makefile
+@@ -6,6 +6,7 @@ obj-$(CONFIG_MTD_CMDLINE_PARTS)                += cmdl
+ obj-$(CONFIG_MTD_OF_PARTS)            += ofpart.o
+ ofpart-y                              += ofpart_core.o
+ ofpart-$(CONFIG_MTD_OF_PARTS_BCM4908) += ofpart_bcm4908.o
++ofpart-$(CONFIG_MTD_OF_PARTS_LINKSYS_NS)+= ofpart_linksys_ns.o
+ obj-$(CONFIG_MTD_PARSER_IMAGETAG)     += parser_imagetag.o
+ obj-$(CONFIG_MTD_AFS_PARTS)           += afs.o
+ obj-$(CONFIG_MTD_PARSER_TRX)          += parser_trx.o
+--- a/drivers/mtd/parsers/ofpart_core.c
++++ b/drivers/mtd/parsers/ofpart_core.c
+@@ -17,6 +17,7 @@
+ #include <linux/mtd/partitions.h>
+ #include "ofpart_bcm4908.h"
++#include "ofpart_linksys_ns.h"
+ struct fixed_partitions_quirks {
+       int (*post_parse)(struct mtd_info *mtd, struct mtd_partition *parts, int nr_parts);
+@@ -26,6 +27,10 @@ static struct fixed_partitions_quirks bc
+       .post_parse = bcm4908_partitions_post_parse,
+ };
++static struct fixed_partitions_quirks linksys_ns_partitions_quirks = {
++      .post_parse = linksys_ns_partitions_post_parse,
++};
++
+ static const struct of_device_id parse_ofpart_match_table[];
+ static bool node_has_compatible(struct device_node *pp)
+@@ -164,6 +169,7 @@ static const struct of_device_id parse_o
+       { .compatible = "fixed-partitions" },
+       /* Customized */
+       { .compatible = "brcm,bcm4908-partitions", .data = &bcm4908_partitions_quirks, },
++      { .compatible = "linksys,ns-partitions", .data = &linksys_ns_partitions_quirks, },
+       {},
+ };
+ MODULE_DEVICE_TABLE(of, parse_ofpart_match_table);
+--- /dev/null
++++ b/drivers/mtd/parsers/ofpart_linksys_ns.c
+@@ -0,0 +1,50 @@
++// SPDX-License-Identifier: GPL-2.0
++/*
++ * Copyright (C) 2021 Rafał Miłecki <rafal@milecki.pl>
++ */
++
++#include <linux/bcm47xx_nvram.h>
++#include <linux/mtd/mtd.h>
++#include <linux/mtd/partitions.h>
++
++#include "ofpart_linksys_ns.h"
++
++#define NVRAM_BOOT_PART               "bootpartition"
++
++static int ofpart_linksys_ns_bootpartition(void)
++{
++      char buf[4];
++      int bootpartition;
++
++      /* Check CFE environment variable */
++      if (bcm47xx_nvram_getenv(NVRAM_BOOT_PART, buf, sizeof(buf)) > 0) {
++              if (!kstrtoint(buf, 0, &bootpartition))
++                      return bootpartition;
++              pr_warn("Failed to parse %s value \"%s\"\n", NVRAM_BOOT_PART,
++                      buf);
++      } else {
++              pr_warn("Failed to get NVRAM \"%s\"\n", NVRAM_BOOT_PART);
++      }
++
++      return 0;
++}
++
++int linksys_ns_partitions_post_parse(struct mtd_info *mtd,
++                                   struct mtd_partition *parts,
++                                   int nr_parts)
++{
++      int bootpartition = ofpart_linksys_ns_bootpartition();
++      int trx_idx = 0;
++      int i;
++
++      for (i = 0; i < nr_parts; i++) {
++              if (of_device_is_compatible(parts[i].of_node, "linksys,ns-firmware")) {
++                      if (trx_idx++ == bootpartition)
++                              parts[i].name = "firmware";
++                      else
++                              parts[i].name = "backup";
++              }
++      }
++
++      return 0;
++}
+--- /dev/null
++++ b/drivers/mtd/parsers/ofpart_linksys_ns.h
+@@ -0,0 +1,18 @@
++/* SPDX-License-Identifier: GPL-2.0 */
++#ifndef __OFPART_LINKSYS_NS_H
++#define __OFPART_LINKSYS_NS_H
++
++#ifdef CONFIG_MTD_OF_PARTS_LINKSYS_NS
++int linksys_ns_partitions_post_parse(struct mtd_info *mtd,
++                                   struct mtd_partition *parts,
++                                   int nr_parts);
++#else
++static inline int linksys_ns_partitions_post_parse(struct mtd_info *mtd,
++                                                 struct mtd_partition *parts,
++                                                 int nr_parts)
++{
++      return -EOPNOTSUPP;
++}
++#endif
++
++#endif
diff --git a/target/linux/generic/pending-5.4/405-0001-mtd-core-add-nvmem-cells-compatible-to-parse-mtd-as-.patch b/target/linux/generic/pending-5.4/405-0001-mtd-core-add-nvmem-cells-compatible-to-parse-mtd-as-.patch
deleted file mode 100644 (file)
index 25801e4..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-From a5d83d6e2bc747b13f347962d4b335d70b23559b Mon Sep 17 00:00:00 2001
-From: Ansuel Smith <ansuelsmth@gmail.com>
-Date: Fri, 12 Mar 2021 07:28:19 +0100
-Subject: [PATCH] mtd: core: add nvmem-cells compatible to parse mtd as nvmem
- cells
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Partitions that contains the nvmem-cells compatible will register
-their direct subonodes as nvmem cells and the node will be treated as a
-nvmem provider.
-
-Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
-Tested-by: Rafał Miłecki <rafal@milecki.pl>
----
- drivers/mtd/mtdcore.c | 3 ++-
- 1 file changed, 2 insertions(+), 1 deletion(-)
-
---- a/drivers/mtd/mtdcore.c
-+++ b/drivers/mtd/mtdcore.c
-@@ -559,6 +559,7 @@ static int mtd_nvmem_reg_read(void *priv
- static int mtd_nvmem_add(struct mtd_info *mtd)
- {
-+      struct device_node *node = mtd_get_of_node(mtd);
-       struct nvmem_config config = {};
-       config.id = -1;
-@@ -571,7 +572,7 @@ static int mtd_nvmem_add(struct mtd_info
-       config.stride = 1;
-       config.read_only = true;
-       config.root_only = true;
--      config.no_of_node = true;
-+      config.no_of_node = !of_device_is_compatible(node, "nvmem-cells");
-       config.priv = mtd;
-       mtd->nvmem = nvmem_register(&config);
diff --git a/target/linux/generic/pending-5.4/405-0002-devicetree-nvmem-nvmem-drop-nodename-restriction.patch b/target/linux/generic/pending-5.4/405-0002-devicetree-nvmem-nvmem-drop-nodename-restriction.patch
deleted file mode 100644 (file)
index 14ea3f6..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-From 42645976c3289b03a12f1bd2bc131fd98fc27170 Mon Sep 17 00:00:00 2001
-From: Ansuel Smith <ansuelsmth@gmail.com>
-Date: Fri, 12 Mar 2021 07:28:20 +0100
-Subject: [PATCH] devicetree: nvmem: nvmem: drop $nodename restriction
-
-Drop $nodename restriction as now mtd partition can also be used as
-nvmem provider.
-
-Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
----
- Documentation/devicetree/bindings/nvmem/nvmem.yaml | 3 ---
- 1 file changed, 3 deletions(-)
-
---- a/Documentation/devicetree/bindings/nvmem/nvmem.yaml
-+++ b/Documentation/devicetree/bindings/nvmem/nvmem.yaml
-@@ -20,9 +20,6 @@ description: |
-   storage device.
- properties:
--  $nodename:
--    pattern: "^(eeprom|efuse|nvram)(@.*|-[0-9a-f])*$"
--
-   "#address-cells":
-     const: 1
diff --git a/target/linux/generic/pending-5.4/405-0003-dt-bindings-mtd-Document-use-of-nvmem-cells-compatib.patch b/target/linux/generic/pending-5.4/405-0003-dt-bindings-mtd-Document-use-of-nvmem-cells-compatib.patch
deleted file mode 100644 (file)
index 0eb4c63..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-From 377aa0135dc8489312edd3184d143ce3a89ff7ee Mon Sep 17 00:00:00 2001
-From: Ansuel Smith <ansuelsmth@gmail.com>
-Date: Fri, 12 Mar 2021 07:28:21 +0100
-Subject: [PATCH] dt-bindings: mtd: Document use of nvmem-cells compatible
-
-Document nvmem-cells compatible used to treat mtd partitions as a
-nvmem provider.
-
-Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
-Reviewed-by: Rob Herring <robh@kernel.org>
----
- .../bindings/mtd/partitions/nvmem-cells.yaml  | 99 +++++++++++++++++++
- 1 file changed, 99 insertions(+)
- create mode 100644 Documentation/devicetree/bindings/mtd/partitions/nvmem-cells.yaml
-
---- /dev/null
-+++ b/Documentation/devicetree/bindings/mtd/partitions/nvmem-cells.yaml
-@@ -0,0 +1,99 @@
-+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
-+%YAML 1.2
-+---
-+$id: http://devicetree.org/schemas/mtd/partitions/nvmem-cells.yaml#
-+$schema: http://devicetree.org/meta-schemas/core.yaml#
-+
-+title: Nvmem cells
-+
-+description: |
-+  Any partition containing the compatible "nvmem-cells" will register as a
-+  nvmem provider.
-+  Each direct subnodes represents a nvmem cell following the nvmem binding.
-+  Nvmem binding to declare nvmem-cells can be found in:
-+  Documentation/devicetree/bindings/nvmem/nvmem.yaml
-+
-+maintainers:
-+  - Ansuel Smith <ansuelsmth@gmail.com>
-+
-+allOf:
-+  - $ref: /schemas/nvmem/nvmem.yaml#
-+
-+properties:
-+  compatible:
-+    const: nvmem-cells
-+
-+required:
-+  - compatible
-+
-+additionalProperties: true
-+
-+examples:
-+  - |
-+    partitions {
-+      compatible = "fixed-partitions";
-+      #address-cells = <1>;
-+      #size-cells = <1>;
-+
-+      /* ... */
-+
-+      };
-+      art: art@1200000 {
-+        compatible = "nvmem-cells";
-+        reg = <0x1200000 0x0140000>;
-+        label = "art";
-+        read-only;
-+        #address-cells = <1>;
-+        #size-cells = <1>;
-+
-+        macaddr_gmac1: macaddr_gmac1@0 {
-+          reg = <0x0 0x6>;
-+        };
-+
-+        macaddr_gmac2: macaddr_gmac2@6 {
-+          reg = <0x6 0x6>;
-+        };
-+
-+        pre_cal_24g: pre_cal_24g@1000 {
-+          reg = <0x1000 0x2f20>;
-+        };
-+
-+        pre_cal_5g: pre_cal_5g@5000{
-+          reg = <0x5000 0x2f20>;
-+        };
-+      };
-+  - |
-+    partitions {
-+        compatible = "fixed-partitions";
-+        #address-cells = <1>;
-+        #size-cells = <1>;
-+
-+        partition@0 {
-+            label = "bootloader";
-+            reg = <0x000000 0x100000>;
-+            read-only;
-+        };
-+
-+        firmware@100000 {
-+            compatible = "brcm,trx";
-+            label = "firmware";
-+            reg = <0x100000 0xe00000>;
-+        };
-+
-+        calibration@f00000 {
-+            compatible = "nvmem-cells";
-+            label = "calibration";
-+            reg = <0xf00000 0x100000>;
-+            ranges = <0 0xf00000 0x100000>;
-+            #address-cells = <1>;
-+            #size-cells = <1>;
-+
-+            wifi0@0 {
-+                reg = <0x000000 0x080000>;
-+            };
-+
-+            wifi1@80000 {
-+                reg = <0x080000 0x080000>;
-+            };
-+        };
-+    };
index 7853cae3257e1ba5898b3fae4dd2885465e0681e..ab1e09a5f129d991b87e75fea8a2750becb8d987 100644 (file)
@@ -16,7 +16,7 @@ Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
 
 --- a/drivers/mtd/parsers/Kconfig
 +++ b/drivers/mtd/parsers/Kconfig
-@@ -185,3 +185,12 @@ config MTD_REDBOOT_PARTS_READONLY
+@@ -195,3 +195,12 @@ config MTD_REDBOOT_PARTS_READONLY
          'FIS directory' images, enable this option.
  
  endif # MTD_REDBOOT_PARTS
@@ -31,7 +31,7 @@ Signed-off-by: Thibaut VARÈNE <hacks@slashdirt.org>
 +       formatted DTS.
 --- a/drivers/mtd/parsers/Makefile
 +++ b/drivers/mtd/parsers/Makefile
-@@ -12,3 +12,4 @@ obj-$(CONFIG_MTD_AFS_PARTS)          += afs.o
+@@ -13,3 +13,4 @@ obj-$(CONFIG_MTD_AFS_PARTS)          += afs.o
  obj-$(CONFIG_MTD_PARSER_TRX)          += parser_trx.o
  obj-$(CONFIG_MTD_SHARPSL_PARTS)               += sharpslpart.o
  obj-$(CONFIG_MTD_REDBOOT_PARTS)               += redboot.o
index 0b54e0772e99f431e80004881ff31283e616ae31..6b7119b8e0c76e2254a5c838812576206f8d4127 100644 (file)
@@ -18,7 +18,7 @@ Signed-off-by: Ram Chandra Jangir <rjangi@codeaurora.org>
 
 --- a/drivers/mtd/parsers/Kconfig
 +++ b/drivers/mtd/parsers/Kconfig
-@@ -128,6 +128,13 @@ config MTD_PARSER_TRX
+@@ -138,6 +138,13 @@ config MTD_PARSER_TRX
          This driver will parse TRX header and report at least two partitions:
          kernel and rootfs.
  
@@ -34,7 +34,7 @@ Signed-off-by: Ram Chandra Jangir <rjangi@codeaurora.org>
        depends on MTD_NAND_SHARPSL || MTD_NAND_TMIO || COMPILE_TEST
 --- a/drivers/mtd/parsers/Makefile
 +++ b/drivers/mtd/parsers/Makefile
-@@ -10,6 +10,7 @@ ofpart-$(CONFIG_MTD_OF_PARTS_BCM4908)        +=
+@@ -11,6 +11,7 @@ ofpart-$(CONFIG_MTD_OF_PARTS_LINKSYS_NS)
  obj-$(CONFIG_MTD_PARSER_IMAGETAG)     += parser_imagetag.o
  obj-$(CONFIG_MTD_AFS_PARTS)           += afs.o
  obj-$(CONFIG_MTD_PARSER_TRX)          += parser_trx.o
index 3077e718c3075462e59676fb0d20f098d32d892c..016ec01112ce58e9012aa1891966699dc21f192b 100644 (file)
@@ -5,7 +5,7 @@ Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
 ---
 --- a/drivers/mtd/parsers/ofpart_core.c
 +++ b/drivers/mtd/parsers/ofpart_core.c
-@@ -33,6 +33,8 @@ static bool node_has_compatible(struct d
+@@ -38,6 +38,8 @@ static bool node_has_compatible(struct d
        return of_get_property(pp, "compatible", NULL);
  }
  
@@ -14,7 +14,7 @@ Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
  static int parse_fixed_partitions(struct mtd_info *master,
                                  const struct mtd_partition **pparts,
                                  struct mtd_part_parser_data *data)
-@@ -42,6 +44,7 @@ static int parse_fixed_partitions(struct
+@@ -47,6 +49,7 @@ static int parse_fixed_partitions(struct
        struct mtd_partition *parts;
        struct device_node *mtd_node;
        struct device_node *ofpart_node;
@@ -22,7 +22,7 @@ Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
        const char *partname;
        struct device_node *pp;
        int nr_parts, i, ret = 0;
-@@ -126,9 +129,15 @@ static int parse_fixed_partitions(struct
+@@ -131,9 +134,15 @@ static int parse_fixed_partitions(struct
                parts[i].size = of_read_number(reg + a_cells, s_cells);
                parts[i].of_node = pp;
  
@@ -41,7 +41,7 @@ Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
                parts[i].name = partname;
  
                if (of_get_property(pp, "read-only", &len))
-@@ -241,6 +250,18 @@ static int __init ofpart_parser_init(voi
+@@ -247,6 +256,18 @@ static int __init ofpart_parser_init(voi
        return 0;
  }
  
index 201cdd3f87fa6615da536a9b1766a6e0f4e3ece5..6e55ef9d7afaf30f4b9e6a1b72720b97ad669a27 100644 (file)
@@ -1,6 +1,6 @@
 --- a/drivers/mtd/parsers/ofpart_core.c
 +++ b/drivers/mtd/parsers/ofpart_core.c
-@@ -33,6 +33,38 @@ static bool node_has_compatible(struct d
+@@ -38,6 +38,38 @@ static bool node_has_compatible(struct d
        return of_get_property(pp, "compatible", NULL);
  }
  
@@ -39,7 +39,7 @@
  static int parse_fixed_partitions(struct mtd_info *master,
                                  const struct mtd_partition **pparts,
                                  struct mtd_part_parser_data *data)
-@@ -46,6 +78,8 @@ static int parse_fixed_partitions(struct
+@@ -51,6 +83,8 @@ static int parse_fixed_partitions(struct
        struct device_node *pp;
        int nr_parts, i, ret = 0;
        bool dedicated = true;
@@ -48,7 +48,7 @@
  
        /* Pull of_node from the master device node */
        mtd_node = mtd_get_of_node(master);
-@@ -88,7 +122,9 @@ static int parse_fixed_partitions(struct
+@@ -93,7 +127,9 @@ static int parse_fixed_partitions(struct
                return 0;
  
        parts = kcalloc(nr_parts, sizeof(*parts), GFP_KERNEL);
@@ -59,7 +59,7 @@
                return -ENOMEM;
  
        i = 0;
-@@ -137,6 +173,11 @@ static int parse_fixed_partitions(struct
+@@ -142,6 +178,11 @@ static int parse_fixed_partitions(struct
                if (of_get_property(pp, "lock", &len))
                        parts[i].mask_flags |= MTD_POWERUP_LOCK;
  
@@ -71,7 +71,7 @@
                i++;
        }
  
-@@ -146,6 +187,11 @@ static int parse_fixed_partitions(struct
+@@ -151,6 +192,11 @@ static int parse_fixed_partitions(struct
        if (quirks && quirks->post_parse)
                quirks->post_parse(master, parts, nr_parts);
  
@@ -83,7 +83,7 @@
        *pparts = parts;
        return nr_parts;
  
-@@ -156,6 +202,7 @@ ofpart_fail:
+@@ -161,6 +207,7 @@ ofpart_fail:
  ofpart_none:
        of_node_put(pp);
        kfree(parts);
index 6ac777a1d2efe1672e5a58674dcabc81ca590644..3bdb1eab8f0644069b6d536973a923f386d6a409 100644 (file)
@@ -5,7 +5,7 @@ Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
 
 --- a/drivers/mtd/parsers/ofpart_core.c
 +++ b/drivers/mtd/parsers/ofpart_core.c
-@@ -33,6 +33,8 @@ static bool node_has_compatible(struct d
+@@ -38,6 +38,8 @@ static bool node_has_compatible(struct d
        return of_get_property(pp, "compatible", NULL);
  }
  
@@ -14,7 +14,7 @@ Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
  static int parse_fixed_partitions(struct mtd_info *master,
                                  const struct mtd_partition **pparts,
                                  struct mtd_part_parser_data *data)
-@@ -43,6 +45,7 @@ static int parse_fixed_partitions(struct
+@@ -48,6 +50,7 @@ static int parse_fixed_partitions(struct
        struct device_node *mtd_node;
        struct device_node *ofpart_node;
        const char *partname;
@@ -22,7 +22,7 @@ Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
        struct device_node *pp;
        int nr_parts, i, ret = 0;
        bool dedicated = true;
-@@ -126,9 +129,13 @@ static int parse_fixed_partitions(struct
+@@ -131,9 +134,13 @@ static int parse_fixed_partitions(struct
                parts[i].size = of_read_number(reg + a_cells, s_cells);
                parts[i].of_node = pp;
  
@@ -39,7 +39,7 @@ Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
                parts[i].name = partname;
  
                if (of_get_property(pp, "read-only", &len))
-@@ -241,6 +248,18 @@ static int __init ofpart_parser_init(voi
+@@ -247,6 +254,18 @@ static int __init ofpart_parser_init(voi
        return 0;
  }