diff mbox series

[v2,1/2] dt-bindings: mtd: partitions: Add binding for Sercomm parser

Message ID 0450d781-c506-c28e-a0e5-435bee16721f@gmail.com
State Changes Requested
Headers show
Series [v2,1/2] dt-bindings: mtd: partitions: Add binding for Sercomm parser | expand

Commit Message

Mikhail Zhilkin April 30, 2022, 8:04 a.m. UTC
On 4/29/2022 11:22 PM, Krzysztof Kozlowski wrote:

>>>> 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?
>>> Not really, I don't understand why do you need it 
>> The main idea is keeping original Sercomm firmware behavior:
>>
>> 1. If dynamic partition map found then use offsets and mtd sizes stored
>> in partition map. It's provided by "sercomm,sc-partitions" compatible.
>>
>> 2. If dynamic partition map doesn't exist or broken then default values
>> (from dts) are used. It's provided by "fixed-partitions" compatible.
> Then you need to adjust fixed-partitions for such case. See syscon case
> (all over the tree and Documentation/devicetree/bindings/mfd/syscon.yaml).

Thanks! Here's what I got (neither errors nor warnings). I also updated
the parser itself by adding the vendor prefix and tested on a real device. 

 .../mtd/partitions/fixed-partitions.yaml      | 61 ++++++++++++++++++-
 1 file changed, 59 insertions(+), 2 deletions(-)

Comments

Krzysztof Kozlowski April 30, 2022, 2:35 p.m. UTC | #1
On 30/04/2022 10:04, Mikhail Zhilkin wrote:
> 
> diff --git
> a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
> b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
> index ea4cace6a955..fa457d55559b 100644
> --- a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
> +++ b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
> @@ -17,9 +17,29 @@ description: |
>  maintainers:
>    - Rafał Miłecki <rafal@milecki.pl>
>  
> +select:
> +  properties:
> +    compatible:
> +      contains:
> +        enum:
> +          - fixed-partitions
> +
> +  required:
> +    - compatible

With your approach you do not need this entire select. I pointed out to
you if you wanted to take the syscon approach.

> +
>  properties:
>    compatible:
> -    const: fixed-partitions
> +    anyOf:

oneOf

> +      - items:
> +          - enum:
> +              - sercomm,sc-partitions
> +
> +          - const: fixed-partitions
> +
> +      - contains:
> +          const: fixed-partitions
> +        minItems: 1
> +        maxItems: 2

This is also not needed if you do no take the syscon approach.

>  
>    "#address-cells": true
>  
> @@ -27,7 +47,18 @@ properties:
>  
>  patternProperties:
>    "@[0-9a-f]+$":
> -    $ref: "partition.yaml#"
> +    allOf:
> +      - $ref: "partition.yaml#"
> +      - if:
> +          properties:
> +            compatible:
> +              contains:
> +                const: sercomm,sc-partitions
> +        then:
> +          properties:
> +            sercomm,scpart-id:
> +              description: Partition id in Sercomm partition map
> +              $ref: /schemas/types.yaml#/definitions/uint32

I think we still did not clarify why do you need this ID which in all
your examples increments by one. The description basically is a copy of
property name, so it does not explain anything.

>  
>  required:
>    - "#address-cells"
> @@ -119,3 +150,29 @@ examples:
>              };
>          };
>      };

Blank line.

> +  - |
> +    partitions {
> +        compatible = "sercomm,sc-partitions", "fixed-partitions";
> +        #address-cells = <1>;
> +        #size-cells = <1>;
> +
> +        partition@0 {
> +            label = "u-boot";
> +            reg = <0x0 0x100000>;
> +            sercomm,scpart-id=<0>;

Missing spaces around =.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git
a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
index ea4cace6a955..fa457d55559b 100644
--- a/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
+++ b/Documentation/devicetree/bindings/mtd/partitions/fixed-partitions.yaml
@@ -17,9 +17,29 @@  description: |
 maintainers:
   - Rafał Miłecki <rafal@milecki.pl>
 
+select:
+  properties:
+    compatible:
+      contains:
+        enum:
+          - fixed-partitions
+
+  required:
+    - compatible
+
 properties:
   compatible:
-    const: fixed-partitions
+    anyOf:
+      - items:
+          - enum:
+              - sercomm,sc-partitions
+
+          - const: fixed-partitions
+
+      - contains:
+          const: fixed-partitions
+        minItems: 1
+        maxItems: 2
 
   "#address-cells": true
 
@@ -27,7 +47,18 @@  properties:
 
 patternProperties:
   "@[0-9a-f]+$":
-    $ref: "partition.yaml#"
+    allOf:
+      - $ref: "partition.yaml#"
+      - if:
+          properties:
+            compatible:
+              contains:
+                const: sercomm,sc-partitions
+        then:
+          properties:
+            sercomm,scpart-id:
+              description: Partition id in Sercomm partition map
+              $ref: /schemas/types.yaml#/definitions/uint32
 
 required:
   - "#address-cells"
@@ -119,3 +150,29 @@  examples:
             };
         };
     };
+  - |
+    partitions {
+        compatible = "sercomm,sc-partitions", "fixed-partitions";
+        #address-cells = <1>;
+        #size-cells = <1>;
+
+        partition@0 {
+            label = "u-boot";
+            reg = <0x0 0x100000>;
+            sercomm,scpart-id=<0>;
+            read-only;
+        };
+
+        partition@100000 {
+            label = "dynamic partition map";
+            reg = <0x100000 0x100000>;
+            sercomm,scpart-id = <1>;
+        };
+
+        partition@200000 {
+            label = "Factory";
+            reg = <0x200000 0x100000>;
+            sercomm,scpart-id = <2>;
+            read-only;
+        };
+    };