Skip to contentSkip to conversation

dt-bindings: mtd: add binding for Linksys Northstar partitions

PATCH Applied Rafał Miłecki 3 participants 5 messages Mar 12, 2021 – Mar 28, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dt-bindings: mtd: add binding for Linksys Northstar partitions

From: Rafał Miłecki <[email protected]>

Linksys on Broadcom Northstar devices uses fixed flash layout with multiple firmware partitions.

---
 .../mtd/partitions/linksys,ns-partitions.yaml | 74 +++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/partitions/linksys,ns-partitions.yaml
Documentation/devicetree/bindings/mtd/partitions/linksys,ns-partitions.yaml new file +74 -0
new file mode 100644
index 000000000000..99249cdfbfb3
@@ -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 <[email protected]>
+
+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>;
+        };
+    };
Signature · 6 lines
2.26.2


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#1 lore raw

PATCH 2/2 mtd: parsers: ofpart: support Linksys Northstar partitions

From: Rafał Miłecki <[email protected]>

This allows extending ofpart parser with support for Linksys Northstar devices. That support uses recently added quirks mechanism.

---
 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
drivers/mtd/parsers/Kconfig +10 -0
index 0528855cf6c1..9babe678c41b 100644
@@ -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
drivers/mtd/parsers/Makefile +1 -0
index 2dfe9fb602de..2e98aa048278 100644
@@ -6,6 +6,7 @@ obj-$(CONFIG_MTD_CMDLINE_PARTS)		+= cmdlinepart.o
 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
drivers/mtd/parsers/ofpart_core.c +6 -0
index 2cef527dd976..0fd8d2a0db97 100644
@@ -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 bcm4908_partitions_quirks = {
 	.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)
@@ -167,6 +172,7 @@ static const struct of_device_id parse_ofpart_match_table[] = {
 	{ .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);
drivers/mtd/parsers/ofpart_linksys_ns.c new file +50 -0

50 lines not on this page · raw message

drivers/mtd/parsers/ofpart_linksys_ns.h new file +18 -0
new file mode 100644
index 000000000000..730c46812ebf
@@ -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
Signature · 1 line
2.26.2
maintainer Applied
#2 lore raw

Re: [PATCH 2/2] mtd: parsers: ofpart: support Linksys Northstar partitions

Quoted 6 lines · On Fri, 2021-03-12 at 13:49:19 UTC, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= wrote:

From: Rafał Miłecki <[email protected]>

This allows extending ofpart parser with support for Linksys Northstar devices. That support uses recently added quirks mechanism.

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

maintainer Reviewed-by on v1 1/2
#3 lore raw
In reply to Rafał Miłecki
Quoted 11 lines · Rafał Miłecki

From: Rafał Miłecki <[email protected]>

Linksys on Broadcom Northstar devices uses fixed flash layout with multiple firmware partitions.

---
 .../mtd/partitions/linksys,ns-partitions.yaml | 74 +++++++++++++++++++
 1 file changed, 74 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/partitions/linksys,ns-partitions.yaml

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

maintainer Applied
#4 lore raw
In reply to Rafał Miłecki
Quoted 7 lines · On Fri, 2021-03-12 at 13:49:18 UTC, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= wrote:

From: Rafał Miłecki <[email protected]>

Linksys on Broadcom Northstar devices uses fixed flash layout with multiple firmware partitions.

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel