Skip to contentSkip to conversation

dt-bindings: mtd: partitions: add binding for U-Boot bootloader

PATCH Applied Rafał Miłecki 3 participants 5 messages Jul 11, 2022 – Sep 19, 2022

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

PATCH 1/2 dt-bindings: mtd: partitions: add binding for U-Boot bootloader

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

Right now there is no (known) real reason for a custom binding for standard U-Boot partitions. Broadcom's U-Boot however requires extra handling - looking for environment variables subblocks. This commit adds Broadcom specific binding.

---
 .../bindings/mtd/partitions/u-boot.yaml       | 49 +++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/partitions/u-boot.yaml
Documentation/devicetree/bindings/mtd/partitions/u-boot.yaml new file +49 -0
new file mode 100644
index 000000000000..8a88e7d16524
@@ -0,0 +1,49 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mtd/partitions/u-boot.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: U-Boot bootloader partition
+
+description: |
+  U-Boot is a bootlodaer commonly used in embedded devices. It's almost always
+  located on some kind of flash device.
+
+  Device configuration is stored as a set of environment variables that are
+  located in a (usually standalone) block of data.
+
+maintainers:
+  - Rafał Miłecki <[email protected]>
+
+allOf:
+  - $ref: partition.yaml#
+
+properties:
+  compatible:
+    oneOf:
+      - const: brcm,u-boot
+        description: |
+          Broadcom stores environment variables inside a U-Boot partition. They
+          can be identified by a custom header with magic value.
+
+unevaluatedProperties: false
+
+examples:
+  - |
+    partitions {
+        compatible = "fixed-partitions";
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        partition@0 {
+            compatible = "brcm,u-boot";
+            reg = <0x0 0x100000>;
+            label = "u-boot";
+        };
+
+        partition@100000 {
+            reg = <0x100000 0x1ff00000>;
+            label = "firmware";
+        };
+    };
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/2 mtd: parsers: add Broadcom's U-Boot parser

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

Broadcom stores environment variables blocks inside U-Boot partition itself. This driver finds & registers them.

---
 drivers/mtd/parsers/Kconfig       | 10 ++++
 drivers/mtd/parsers/Makefile      |  1 +
 drivers/mtd/parsers/brcm_u-boot.c | 84 +++++++++++++++++++++++++++++++
 3 files changed, 95 insertions(+)
 create mode 100644 drivers/mtd/parsers/brcm_u-boot.c
drivers/mtd/parsers/Kconfig +10 -0
index b43df73927a0..81f2d0a795a6 100644
@@ -20,6 +20,16 @@ config MTD_BCM63XX_PARTS
 	  This provides partition parsing for BCM63xx devices with CFE
 	  bootloaders.
 
+config MTD_BRCM_U_BOOT
+	tristate "Broadcom's U-Boot partition parser"
+	depends on ARCH_BCM4908 || COMPILE_TEST
+	help
+	  Broadcom uses a custom way of storing U-Boot environment variables.
+	  They are placed inside U-Boot partition itself at unspecified offset.
+	  It's possible to locate them by looking for a custom header with a
+	  magic value. This driver does that and creates subpartitions for
+	  each found environment variables block.
+
 config MTD_CMDLINE_PARTS
 	tristate "Command line partition table parsing"
 	depends on MTD
drivers/mtd/parsers/Makefile +1 -0
index 2fcf0ab9e7da..23fa4de4016f 100644
@@ -2,6 +2,7 @@
 obj-$(CONFIG_MTD_AR7_PARTS)		+= ar7part.o
 obj-$(CONFIG_MTD_BCM47XX_PARTS)		+= bcm47xxpart.o
 obj-$(CONFIG_MTD_BCM63XX_PARTS)		+= bcm63xxpart.o
+obj-$(CONFIG_MTD_BRCM_U_BOOT)		+= brcm_u-boot.o
 obj-$(CONFIG_MTD_CMDLINE_PARTS)		+= cmdlinepart.o
 obj-$(CONFIG_MTD_OF_PARTS)		+= ofpart.o
 ofpart-y				+= ofpart_core.o
drivers/mtd/parsers/brcm_u-boot.c new file +84 -0

84 lines not on this page · raw message

Signature · 1 line
2.34.1
maintainer Applied
#2 lore raw

Re: [PATCH 2/2] mtd: parsers: add Broadcom's U-Boot parser

Quoted 6 lines · On Mon, 2022-07-11 at 15:30:41 UTC, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= wrote:

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

Broadcom stores environment variables blocks inside U-Boot partition itself. This driver finds & registers them.

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 7 lines · Rafał Miłecki

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

Right now there is no (known) real reason for a custom binding for standard U-Boot partitions. Broadcom's U-Boot however requires extra handling - looking for environment variables subblocks. This commit adds Broadcom specific binding.

Quoted 6 lines
---
 .../bindings/mtd/partitions/u-boot.yaml       | 49 +++++++++++++++++++
 1 file changed, 49 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mtd/partitions/u-boot.yaml
maintainer Applied
#4 lore raw
In reply to Rafał Miłecki
Quoted 9 lines · On Mon, 2022-07-11 at 15:30:40 UTC, =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= wrote:

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

Right now there is no (known) real reason for a custom binding for standard U-Boot partitions. Broadcom's U-Boot however requires extra handling - looking for environment variables subblocks. This commit adds Broadcom specific binding.

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

Miquel