2022-04-10 02:10:51

by Mikhail Zhilkin

[permalink] [raw]
Subject: [PATCH v2 1/2] dt-bindings: mtd: partitions: Add binding for Sercomm parser


On 4/9/2022 9:04 PM, Mikhail Zhilkin wrote:
>>>>> +required:
>>>>> + - compatible
>>>> Missing reg.
>>> reg isn't required. Parser can read partition offsets and sizes from
>>> SC PART MAP table. Or do you mean something else?  All is ok
>>> without reg definition in "Example" (except the warns that reg property
>>> is missing).
>> reg might not be required for current implementation but it is required
>> by devicetree for every node with unit address. Do you expect here nodes
>> without unit addresses?
> Only "partitions" node has no unit address. All subnodes  have unit
> addresses and therefore have to have reg property. I've just realized
> that "fixed-partitions.yaml" is almost my case. It looks like I can
> copy'n'paste  "required" and "*properties".
> Do you mind if I don't reinvent the wheel and reuse this good
> practice?
>
> Here's what I got (no any warnings appears):


I'm sorry, Krzysztof & All. Here is the final one.

---
 .../mtd/partitions/sercomm,sc-partitions.yaml | 78 +++++++++++++++++++
 1 file changed, 78 insertions(+)
 create mode 100644
Documentation/devicetree/bindings/mtd/partitions/sercomm,sc-partitions.yaml

diff --git
a/Documentation/devicetree/bindings/mtd/partitions/sercomm,sc-partitions.yaml
b/Documentation/devicetree/bindings/mtd/partitions/sercomm,sc-partitions.yaml
new file mode 100644
index 000000000000..33172f0be92a
--- /dev/null
+++
b/Documentation/devicetree/bindings/mtd/partitions/sercomm,sc-partitions.yaml
@@ -0,0 +1,78 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id:
http://devicetree.org/schemas/mtd/partitions/sercomm,sc-partitions.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Sercomm Partitions
+
+description: |
+  Sercomm is one of hardware manufacturers providing SoCs used in home
routers.
+  The Sercomm partition map table contains information about non-standard
+  partition offsets and sizes (depending on the bad blocks presence and
their
+  locations). Partition map is used by many Sercomm-based Ralink
devices (e.g.
+  Beeline, Netgear).
+
+  The partition table should be a node named "partitions". Partitions
are then
+  defined as subnodes.
+
+maintainers:
+  - Mikhail Zhilkin <[email protected]>
+
+properties:
+  compatible:
+    const: sercomm,sc-partitions
+
+  "#address-cells": true
+
+  "#size-cells": true
+
+patternProperties:
+  "@[0-9a-f]+$":
+    $ref: "partition.yaml#"
+
+required:
+  - compatible
+  - "#address-cells"
+  - "#size-cells"
+
+additionalProperties: true
+
+examples:
+  - |
+    partitions {
+        compatible = "sercomm,sc-partitions";
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        partition@0 {
+            label = "u-boot";
+            reg = <0x0 0x100000>;
+            scpart-id = <0>;
+            read-only;
+        };
+
+        partition@100000 {
+            label = "dynamic partition map";
+            reg = <0x100000 0x100000>;
+            scpart-id = <1>;
+        };
+
+        factory: partition@200000 {
+            label = "Factory";
+            reg = <0x200000 0x100000>;
+            scpart-id = <2>;
+            read-only;
+
+            compatible = "nvmem-cells";
+            #address-cells = <1>;
+            #size-cells = <1>;
+
+            macaddr_factory_21000: macaddr@21000 {
+                reg = <0x21000 0x6>;
+            };
+        };
+
+        /* ... */
+
+    };
--


> Best regards,
> Mikhail


2022-04-12 11:58:24

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] dt-bindings: mtd: partitions: Add binding for Sercomm parser

On 09/04/2022 20:17, Mikhail Zhilkin wrote:
>
> On 4/9/2022 9:04 PM, Mikhail Zhilkin wrote:
>>>>>> +required:
>>>>>> + - compatible
>>>>> Missing reg.
>>>> reg isn't required. Parser can read partition offsets and sizes from
>>>> SC PART MAP table. Or do you mean something else?  All is ok
>>>> without reg definition in "Example" (except the warns that reg property
>>>> is missing).
>>> reg might not be required for current implementation but it is required
>>> by devicetree for every node with unit address. Do you expect here nodes
>>> without unit addresses?
>> Only "partitions" node has no unit address. All subnodes  have unit
>> addresses and therefore have to have reg property. I've just realized
>> that "fixed-partitions.yaml" is almost my case. It looks like I can
>> copy'n'paste  "required" and "*properties".
>> Do you mind if I don't reinvent the wheel and reuse this good
>> practice?
>>
>> Here's what I got (no any warnings appears):
>
>
> I'm sorry, Krzysztof & All. Here is the final one.

I am sorry, but you changed now a lot in the bindings and it looks
entirely different. Things previously being correct now are wrong, so
rather start from your old bindings...

>
> ---
>  .../mtd/partitions/sercomm,sc-partitions.yaml | 78 +++++++++++++++++++
>  1 file changed, 78 insertions(+)
>  create mode 100644
> Documentation/devicetree/bindings/mtd/partitions/sercomm,sc-partitions.yaml
>
> diff --git
> a/Documentation/devicetree/bindings/mtd/partitions/sercomm,sc-partitions.yaml
> b/Documentation/devicetree/bindings/mtd/partitions/sercomm,sc-partitions.yaml
> new file mode 100644
> index 000000000000..33172f0be92a
> --- /dev/null
> +++
> b/Documentation/devicetree/bindings/mtd/partitions/sercomm,sc-partitions.yaml
> @@ -0,0 +1,78 @@
> +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
> +%YAML 1.2
> +---
> +$id:
> http://devicetree.org/schemas/mtd/partitions/sercomm,sc-partitions.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Sercomm Partitions
> +
> +description: |
> +  Sercomm is one of hardware manufacturers providing SoCs used in home
> routers.
> +  The Sercomm partition map table contains information about non-standard
> +  partition offsets and sizes (depending on the bad blocks presence and
> their
> +  locations). Partition map is used by many Sercomm-based Ralink
> devices (e.g.
> +  Beeline, Netgear).
> +
> +  The partition table should be a node named "partitions". Partitions
> are then
> +  defined as subnodes.
> +
> +maintainers:
> +  - Mikhail Zhilkin <[email protected]>
> +
> +properties:
> +  compatible:
> +    const: sercomm,sc-partitions
> +
> +  "#address-cells": true
> +
> +  "#size-cells": true
> +
> +patternProperties:
> +  "@[0-9a-f]+$":
> +    $ref: "partition.yaml#"
> +
> +required:
> +  - compatible
> +  - "#address-cells"
> +  - "#size-cells"

Still missing reg.

> +
> +additionalProperties: true

This is wrong, why it became true?


Best regards,
Krzysztof

2022-05-01 07:03:22

by Mikhail Zhilkin

[permalink] [raw]
Subject: Re: [PATCH v2 1/2] dt-bindings: mtd: partitions: Add binding for Sercomm parser


Hi, Krzysztof,

On 4/10/2022 11:18 AM, Krzysztof Kozlowski wrote:
> I am sorry, but you changed now a lot in the bindings and it looks
> entirely different. Things previously being correct now are wrong, so
> rather start from your old bindings...


Looks like I'm a bit confused... I use dual "compatible" in my real dts
and I realized that:

1. Therefore I have to use  dual "compatible" in example too:

compatible = "sercomm,sc-partitions", "fixed-partitions";

2. When I'm trying to reuse "fixed-partitions" compatible from
fixed-partitions.yaml in my new .yaml I get "too long" errors.

Real dts:

Link:
https://github.com/openwrt/openwrt/blob/edcc1a9a734bb3fcdc9242025290d3f173e71b78/target/linux/ramips/dts/mt7621_beeline_smartbox-giga.dts#L79

So, I currently found another solution - to extend fixed-partitions.yaml
with "sercomm,sc-partitions". Is It ok from your side? Can I use this
code in v3?

diff --git
a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
index ea4cace6a955..9eebe39a57fb 100644
--- a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
+++ b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
@@ -19,7 +19,11 @@ maintainers:
 
 properties:
   compatible:
-    const: fixed-partitions
+    oneOf:
+      - const: fixed-partitions
+      - items:
+          - const: sercomm,sc-partitions
+          - const: fixed-partitions
 
   "#address-cells": true
 
@@ -27,7 +31,18 @@ properties:
 
 patternProperties:
   "@[0-9a-f]+$":
-    $ref: "partition.yaml#"
+    allOf:
+      - $ref: "partition.yaml#"
+      - if:
+          properties:
+            compatible:
+              contains:
+                const: sercomm,sc-partitions
+        then:
+          properties:
+            scpart-id:
+              description: Partition id in Sercomm partition map
+              $ref: /schemas/types.yaml#/definitions/uint32
 
 required:
   - "#address-cells"
@@ -119,3 +134,29 @@ examples:
             };
         };
     };
+  - |
+    partitions {
+        compatible = "sercomm,sc-partitions", "fixed-partitions";
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        partition@0 {
+            label = "u-boot";
+            reg = <0x0 0x100000>;
+            scpart-id=<0>;
+            read-only;
+        };
+
+        partition@100000 {
+            label = "dynamic partition map";
+            reg = <0x100000 0x100000>;
+            scpart-id = <1>;
+        };
+
+        partition@200000 {
+            label = "Factory";
+            reg = <0x200000 0x100000>;
+            scpart-id = <2>;
+            read-only;
+        };
+    };
--
2.25.1


>> +
>> +additionalProperties: true
> This is wrong, why it became true?

You're right. Got it


> Best regards,
> Krzysztof

--
Best regards,
Mikhail