[PATCH] dt-bindings: mtd: Add a schema for binman

Simon Glass
2023-09-21T18:46:03Z

Binman[1] is a tool for creating firmware images. It allows you to
combine various binaries and place them in an output file.

Binman uses a DT schema to describe an image, in enough detail that
it can be automatically built from component parts, disassembled,
replaced, listed, etc.

Images are typically stored in flash, which is why this binding is
targeted at mtd. Previous discussion is at [2] [3].

[1] https://u-boot.readthedocs.io/en/stable/develop/package/binman.html
[2] https://lore.kernel.org/u-boot/20230821180220.2724080-3-sjg@chromium.org/
[3] https://www.spinics.net/lists/devicetree/msg626149.html

Signed-off-by: Simon Glass <sjg@chromium.org>
---

.../bindings/mtd/partitions/binman.yaml | 50 +++++++++++++++
.../bindings/mtd/partitions/binman/entry.yaml | 61 +++++++++++++++++++
.../bindings/mtd/partitions/partitions.yaml | 1 +
MAINTAINERS | 5 ++
4 files changed, 117 insertions(+)
create mode 100644 Documentation/devicetree/bindings/mtd/partitions/binman.yaml
create mode 100644 Documentation/devicetree/bindings/mtd/partitions/binman/entry.yaml

diff --git a/Documentation/devicetree/bindings/mtd/partitions/binman.yaml b/Documentation/devicetree/bindings/mtd/partitions/binman.yaml
new file mode 100644
index 00000000000000..c792d5a37b700a
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/partitions/binman.yaml
@@ -0,0 +1,50 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2023 Google LLC
+
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mtd/partitions/binman.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Binman firmware layout
+
+maintainers:
+ - Simon Glass <sjg@chromium.org>
+
+description: |
+ The binman node provides a layout for firmware, used when packaging firmware
+ from multiple projects. For now it just supports a very simple set of
+ features, as a starting point for discussion.
+
+ Documentation for Binman is available at:
+
+ https://u-boot.readthedocs.io/en/latest/develop/package/binman.html
+
+ with the current image-description format at:
+
+ https://u-boot.readthedocs.io/en/latest/develop/package/binman.html#image-description-format
+
+properties:
+ compatible:
+ const: u-boot,binman
+
+required:
+ - compatible
+
+additionalProperties: false
+
+examples:
+ - |
+ firmware {
+ binman {
+ compatible = "u-boot,binman";
+
+ u-boot {
+ size = <0xa0000>;
+ };
+
+ atf-bl31 {
+ offset = <0x100000>;
+ };
+ };
+ };
diff --git a/Documentation/devicetree/bindings/mtd/partitions/binman/entry.yaml b/Documentation/devicetree/bindings/mtd/partitions/binman/entry.yaml
new file mode 100644
index 00000000000000..8003eb4f1a994f
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/partitions/binman/entry.yaml
@@ -0,0 +1,61 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2023 Google LLC
+
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mtd/partitions/binman/entry.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Binman entry
+
+maintainers:
+ - Simon Glass <sjg@chromium.org>
+
+description: |
+ The entry node specifies a single entry in the firmware.
+
+ Entries have a specific type, such as "u-boot" or "atf-bl31". If the type
+ is missing, the name is used as the type.
+
+ Note: This definition is intended to be hierarchical, so that entries can
+ appear in other entries. Schema for that is TBD.
+
+properties:
+ $nodename:
+ pattern: "^[-a-z]+(-[0-9]+)?$"
+
+ type:
+ $ref: /schemas/types.yaml#/definitions/string
+
+ offset:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: |
+ Provides the offset of this entry from the start of its parent section.
+ If this is omitted, Binman will determine this by packing the enclosing
+ section according to alignment rules, etc.
+
+ size:
+ $ref: /schemas/types.yaml#/definitions/uint32
+ description: |
+ Provides the size of this entry in bytes. If this is omitted, Binman will
+ use the content size, along with any alignment information, to determine
+ the size of the entry.
+
+additionalProperties: false
+
+examples:
+ - |
+ firmware {
+ binman {
+ compatible = "u-boot,binman";
+
+ u-boot {
+ size = <0xa0000>;
+ };
+
+ second-area {
+ type = "atf-bl31";
+ offset = <0x100000>;
+ };
+ };
+ };
diff --git a/Documentation/devicetree/bindings/mtd/partitions/partitions.yaml b/Documentation/devicetree/bindings/mtd/partitions/partitions.yaml
index 1dda2c80747bd7..849fd15d085ccc 100644
--- a/Documentation/devicetree/bindings/mtd/partitions/partitions.yaml
+++ b/Documentation/devicetree/bindings/mtd/partitions/partitions.yaml
@@ -15,6 +15,7 @@ maintainers:

oneOf:
- $ref: arm,arm-firmware-suite.yaml
+ - $ref: binman.yaml
- $ref: brcm,bcm4908-partitions.yaml
- $ref: brcm,bcm947xx-cfe-partitions.yaml
- $ref: fixed-partitions.yaml
diff --git a/MAINTAINERS b/MAINTAINERS
index a4c30221eb305d..ebcbfb4292e8dc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3505,6 +3505,11 @@ F: Documentation/filesystems/bfs.rst
F: fs/bfs/
F: include/uapi/linux/bfs_fs.h

+BINMAN
+M: Simon Glass <sjg@chromium.org>
+S: Supported
+F: Documentation/devicetree/bindings/mtd/partitions/binman*
+
BITMAP API
M: Yury Norov <yury.norov@gmail.com>
R: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
2.42.0.515.g380fc7ccd1-goog