diff mbox series

dt-bindings: mtd: partitions: convert Broadcom's TRX to the json-schema

Message ID 20220216104126.31284-1-zajec5@gmail.com
State New
Headers show
Series dt-bindings: mtd: partitions: convert Broadcom's TRX to the json-schema | expand

Commit Message

Rafał Miłecki Feb. 16, 2022, 10:41 a.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

This helps validating DTS files.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 .../bindings/mtd/partitions/brcm,trx.txt      | 42 ---------------
 .../bindings/mtd/partitions/brcm,trx.yaml     | 51 +++++++++++++++++++
 2 files changed, 51 insertions(+), 42 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt
 create mode 100644 Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml

Comments

Rob Herring (Arm) Feb. 17, 2022, 3:59 a.m. UTC | #1
On Wed, 16 Feb 2022 11:41:26 +0100, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> This helps validating DTS files.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> ---
>  .../bindings/mtd/partitions/brcm,trx.txt      | 42 ---------------
>  .../bindings/mtd/partitions/brcm,trx.yaml     | 51 +++++++++++++++++++
>  2 files changed, 51 insertions(+), 42 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt
>  create mode 100644 Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml
> 

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:

dtschema/dtc warnings/errors:
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/linksys,ns-partitions.example.dt.yaml: partition@200000: compatible:0: 'brcm,trx' was expected
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/linksys,ns-partitions.example.dt.yaml: partition@200000: compatible: ['linksys,ns-firmware', 'brcm,trx'] is too long
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/linksys,ns-partitions.example.dt.yaml: partition@200000: 'reg' does not match any of the regexes: 'pinctrl-[0-9]+'
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/linksys,ns-partitions.example.dt.yaml: partition@1100000: compatible:0: 'brcm,trx' was expected
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/linksys,ns-partitions.example.dt.yaml: partition@1100000: compatible: ['linksys,ns-firmware', 'brcm,trx'] is too long
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/linksys,ns-partitions.example.dt.yaml: partition@1100000: 'reg' does not match any of the regexes: 'pinctrl-[0-9]+'
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.example.dt.yaml: firmware@100000: 'label', 'reg' do not match any of the regexes: 'pinctrl-[0-9]+'
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/nvmem-cells.example.dt.yaml: firmware@100000: 'label', 'reg' do not match any of the regexes: 'pinctrl-[0-9]+'
	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml

doc reference errors (make refcheckdocs):

See https://patchwork.ozlabs.org/patch/1593614

This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit.
Rafał Miłecki Feb. 17, 2022, 7:43 a.m. UTC | #2
Hi Rob,

On 17.02.2022 04:59, Rob Herring wrote:
> On Wed, 16 Feb 2022 11:41:26 +0100, Rafał Miłecki wrote:
>> From: Rafał Miłecki <rafal@milecki.pl>
>>
>> This helps validating DTS files.
>>
>> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
>> ---
>>   .../bindings/mtd/partitions/brcm,trx.txt      | 42 ---------------
>>   .../bindings/mtd/partitions/brcm,trx.yaml     | 51 +++++++++++++++++++
>>   2 files changed, 51 insertions(+), 42 deletions(-)
>>   delete mode 100644 Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt
>>   create mode 100644 Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml
>>
> 
> My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
> on your patch (DT_CHECKER_FLAGS is new in v5.13):
> 
> yamllint warnings/errors:
> 
> dtschema/dtc warnings/errors:
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/linksys,ns-partitions.example.dt.yaml: partition@200000: compatible:0: 'brcm,trx' was expected
> 	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml
> /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/linksys,ns-partitions.example.dt.yaml: partition@200000: compatible: ['linksys,ns-firmware', 'brcm,trx'] is too long
> 	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml

could you advise the best way to solve that?


1. compatible = "brcm,trx";

Most Broadcom 47xx devices have one firmware partition using TRX format.
So we want something like:

partition@200000 {
         compatible = "brcm,trx";
         label = "firmware";
         reg = <0x200000 0xf00000>;
};


2. compatible = "linksys,ns-firmware", "brcm,trx";

Linksys has two firmware partitions and operating system has to choose
the right one to proceed with (to parse for kernel & rootfs). They still
use TRX format though. So we want something like:

partition@200000 {
         compatible = "linksys,ns-firmware", "brcm,trx";
         reg = <0x200000 0xf00000>;
};

partition@1100000 {
         compatible = "linksys,ns-firmware", "brcm,trx";
         reg = <0x1100000 0xf00000>;
};


I thought of moving "linksys,ns-firmware" documentation to the
brcm,trx.yaml but its part of the compatible = "linksys,ns-partitions";
(parent node) so it doesn't fit there well.
Rob Herring (Arm) Feb. 23, 2022, 11:05 p.m. UTC | #3
On Thu, Feb 17, 2022 at 08:43:23AM +0100, Rafał Miłecki wrote:
> Hi Rob,
> 
> On 17.02.2022 04:59, Rob Herring wrote:
> > On Wed, 16 Feb 2022 11:41:26 +0100, Rafał Miłecki wrote:
> > > From: Rafał Miłecki <rafal@milecki.pl>
> > > 
> > > This helps validating DTS files.
> > > 
> > > Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
> > > ---
> > >   .../bindings/mtd/partitions/brcm,trx.txt      | 42 ---------------
> > >   .../bindings/mtd/partitions/brcm,trx.yaml     | 51 +++++++++++++++++++
> > >   2 files changed, 51 insertions(+), 42 deletions(-)
> > >   delete mode 100644 Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt
> > >   create mode 100644 Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml
> > > 
> > 
> > My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
> > on your patch (DT_CHECKER_FLAGS is new in v5.13):
> > 
> > yamllint warnings/errors:
> > 
> > dtschema/dtc warnings/errors:
> > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/linksys,ns-partitions.example.dt.yaml: partition@200000: compatible:0: 'brcm,trx' was expected
> > 	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml
> > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/linksys,ns-partitions.example.dt.yaml: partition@200000: compatible: ['linksys,ns-firmware', 'brcm,trx'] is too long
> > 	From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml
> 
> could you advise the best way to solve that?

You should move linksys,ns-firmware from linksys,ns-partitions.yaml to 
this schema. Then linksys,ns-partitions.yaml just has:

  "^partition@[0-9a-f]+$":
    $ref: "partition.yaml#"
    additionalProperties: true

That's not completely ideal because then undocumented properties are 
allowed. To fix that, you'd need:

  "^partition@[0-9a-f]+$":
    oneOf:
      - $ref: "partition.yaml#"
      - $ref: "brcm,trx.yaml#"
    unevaluatedProperties: false

I'm not 100% sure that will work.

Rob
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt b/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt
deleted file mode 100644
index c2175d3c82ec..000000000000
--- a/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.txt
+++ /dev/null
@@ -1,42 +0,0 @@ 
-Broadcom TRX Container Partition
-================================
-
-TRX is Broadcom's official firmware format for the BCM947xx boards. It's used by
-most of the vendors building devices based on Broadcom's BCM47xx SoCs and is
-supported by the CFE bootloader.
-
-Design of the TRX format is very minimalistic. Its header contains
-identification fields, CRC32 checksum and the locations of embedded partitions.
-Its purpose is to store a few partitions in a format that can be distributed as
-a standalone file and written in a flash memory.
-
-Container can hold up to 4 partitions. The first partition has to contain a
-device executable binary (e.g. a kernel) as it's what the CFE bootloader starts
-executing. Other partitions can be used for operating system purposes. This is
-useful for systems that keep kernel and rootfs separated.
-
-TRX doesn't enforce any strict partition boundaries or size limits. All
-partitions have to be less than the 4GiB max size limit.
-
-There are two existing/known TRX variants:
-1) v1 which contains 3 partitions
-2) v2 which contains 4 partitions
-
-There aren't separated compatible bindings for them as version can be trivialy
-detected by a software parsing TRX header.
-
-Required properties:
-- compatible : (required) must be "brcm,trx"
-
-Optional properties:
-
-- brcm,trx-magic: TRX magic, if it is different from the default magic
-		  0x30524448 as a u32.
-
-Example:
-
-flash@0 {
-	partitions {
-		compatible = "brcm,trx";
-	};
-};
diff --git a/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml b/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml
new file mode 100644
index 000000000000..ec871c9cf605
--- /dev/null
+++ b/Documentation/devicetree/bindings/mtd/partitions/brcm,trx.yaml
@@ -0,0 +1,51 @@ 
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mtd/partitions/brcm,trx.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Broadcom TRX Container Partition
+
+description: |
+  TRX is Broadcom's official firmware format for the BCM947xx boards. It's used
+  by most of the vendors building devices based on Broadcom's BCM47xx SoCs and
+  is supported by the CFE bootloader.
+
+  Design of the TRX format is very minimalistic. Its header contains
+  identification fields, CRC32 checksum and the locations of embedded
+  partitions. Its purpose is to store a few partitions in a format that can be
+  distributed as a standalone file and written in a flash memory.
+
+  Container can hold up to 4 partitions. The first partition has to contain a
+  device executable binary (e.g. a kernel) as it's what the CFE bootloader
+  starts executing. Other partitions can be used for operating system purposes.
+  This is useful for systems that keep kernel and rootfs separated.
+
+  TRX doesn't enforce any strict partition boundaries or size limits. All
+  partitions have to be less than the 4GiB max size limit.
+
+  There are two existing/known TRX variants:
+  1) v1 which contains 3 partitions
+  2) v2 which contains 4 partitions
+
+  There aren't separated compatible bindings for them as version can be trivialy
+  detected by a software parsing TRX header.
+
+maintainers:
+  - Rafał Miłecki <rafal@milecki.pl>
+
+properties:
+  compatible:
+    const: brcm,trx
+
+  brcm,trx-magic:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    description: TRX magic, if it is different from the default 0x30524448
+
+additionalProperties: false
+
+examples:
+  - |
+    partitions {
+        compatible = "brcm,trx";
+    };