diff mbox series

[v2,2/3] dt-bindings: PCI: uniphier-ep: Clean up reg, clocks, resets, and their names using compatible string

Message ID 1649294553-17310-3-git-send-email-hayashi.kunihiko@socionext.com (mailing list archive)
State Superseded
Headers show
Series dt-bindings: PCI: uniphier: Fix endpoint descriptions | expand

Commit Message

Kunihiko Hayashi April 7, 2022, 1:22 a.m. UTC
Instead of "oneOf:" choices, use "allOf:" and "if:" to define reg, clocks,
resets, and their names that can be taken by the compatible string.

The order of their names doesn't change here.

Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
---
 .../pci/socionext,uniphier-pcie-ep.yaml       | 84 ++++++++++++-------
 1 file changed, 56 insertions(+), 28 deletions(-)

Comments

Rob Herring (Arm) April 12, 2022, 10:05 p.m. UTC | #1
On Thu, Apr 07, 2022 at 10:22:32AM +0900, Kunihiko Hayashi wrote:
> Instead of "oneOf:" choices, use "allOf:" and "if:" to define reg, clocks,
> resets, and their names that can be taken by the compatible string.
> 
> The order of their names doesn't change here.
> 
> Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
> ---
>  .../pci/socionext,uniphier-pcie-ep.yaml       | 84 ++++++++++++-------
>  1 file changed, 56 insertions(+), 28 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/pci/socionext,uniphier-pcie-ep.yaml b/Documentation/devicetree/bindings/pci/socionext,uniphier-pcie-ep.yaml
> index 437e61618d06..49a5b2ca266c 100644
> --- a/Documentation/devicetree/bindings/pci/socionext,uniphier-pcie-ep.yaml
> +++ b/Documentation/devicetree/bindings/pci/socionext,uniphier-pcie-ep.yaml
> @@ -15,9 +15,6 @@ description: |
>  maintainers:
>    - Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
>  
> -allOf:
> -  - $ref: /schemas/pci/snps,dw-pcie-ep.yaml#
> -
>  properties:
>    compatible:
>      enum:
> @@ -28,41 +25,19 @@ properties:
>      minItems: 4
>      maxItems: 5
>  
> -  reg-names:
> -    oneOf:
> -      - items:
> -          - const: dbi
> -          - const: dbi2
> -          - const: link
> -          - const: addr_space
> -      - items:
> -          - const: dbi
> -          - const: dbi2
> -          - const: link
> -          - const: addr_space
> -          - const: atu

This could be just:

      minItems: 4
      items:
        - const: dbi
        - const: dbi2
        - const: link
        - const: addr_space
        - const: atu

Then the if/then can have just 'minItems: 5' or 'maxItems: 4' for each 
case. I prefer the if/then schemas to be minimal.

> +  reg-names: true
>  
>    clocks:
>      minItems: 1
>      maxItems: 2
>  
> -  clock-names:
> -    oneOf:
> -      - items:              # for Pro5
> -          - const: gio
> -          - const: link
> -      - const: link         # for NX1
> +  clock-names: true
>  
>    resets:
>      minItems: 1
>      maxItems: 2
>  
> -  reset-names:
> -    oneOf:
> -      - items:              # for Pro5
> -          - const: gio
> -          - const: link
> -      - const: link         # for NX1
> +  reset-names: true
>  
>    num-ib-windows:
>      const: 16
> @@ -78,6 +53,59 @@ properties:
>    phy-names:
>      const: pcie-phy
>  
> +allOf:
> +  - $ref: /schemas/pci/snps,dw-pcie-ep.yaml#
> +  - if:
> +      properties:
> +        compatible:
> +          contains:
> +            const: socionext,uniphier-pro5-pcie-ep
> +    then:
> +      properties:
> +        reg:
> +          minItems: 4
> +          maxItems: 4
> +        reg-names:
> +          items:
> +            - const: dbi
> +            - const: dbi2
> +            - const: link
> +            - const: addr_space
> +        clocks:
> +          minItems: 2
> +          maxItems: 2
> +        clock-names:
> +          items:
> +            - const: gio
> +            - const: link
> +        resets:
> +          minItems: 2
> +          maxItems: 2
> +        reset-names:
> +          items:
> +            - const: gio
> +            - const: link
> +    else:
> +      properties:
> +        reg:
> +          minItems: 4
> +          maxItems: 5
> +        reg-names:
> +          items:
> +            - const: dbi
> +            - const: dbi2
> +            - const: link
> +            - const: addr_space
> +            - const: atu
> +        clocks:
> +          maxItems: 1
> +        clock-names:
> +          const: link
> +        resets:
> +          maxItems: 1
> +        reset-names:
> +          const: link
> +
>  required:
>    - compatible
>    - reg
> -- 
> 2.25.1
> 
>
Kunihiko Hayashi April 15, 2022, 12:55 a.m. UTC | #2
Hi Rob,

On 2022/04/13 7:05, Rob Herring wrote:
> On Thu, Apr 07, 2022 at 10:22:32AM +0900, Kunihiko Hayashi wrote:
>> Instead of "oneOf:" choices, use "allOf:" and "if:" to define reg,
> clocks,
>> resets, and their names that can be taken by the compatible string.
>>
>> The order of their names doesn't change here.
>>
>> Signed-off-by: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
>> ---
>>   .../pci/socionext,uniphier-pcie-ep.yaml       | 84 ++++++++++++-------
>>   1 file changed, 56 insertions(+), 28 deletions(-)
>>
>> diff --git
> a/Documentation/devicetree/bindings/pci/socionext,uniphier-pcie-ep.yaml
> b/Documentation/devicetree/bindings/pci/socionext,uniphier-pcie-ep.yaml
>> index 437e61618d06..49a5b2ca266c 100644
>> ---
> a/Documentation/devicetree/bindings/pci/socionext,uniphier-pcie-ep.yaml
>> +++
> b/Documentation/devicetree/bindings/pci/socionext,uniphier-pcie-ep.yaml
>> @@ -15,9 +15,6 @@ description: |
>>   maintainers:
>>     - Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
>>   
>> -allOf:
>> -  - $ref: /schemas/pci/snps,dw-pcie-ep.yaml#
>> -
>>   properties:
>>     compatible:
>>       enum:
>> @@ -28,41 +25,19 @@ properties:
>>       minItems: 4
>>       maxItems: 5
>>   
>> -  reg-names:
>> -    oneOf:
>> -      - items:
>> -          - const: dbi
>> -          - const: dbi2
>> -          - const: link
>> -          - const: addr_space
>> -      - items:
>> -          - const: dbi
>> -          - const: dbi2
>> -          - const: link
>> -          - const: addr_space
>> -          - const: atu
> 
> This could be just:
> 
>        minItems: 4
>        items:
>          - const: dbi
>          - const: dbi2
>          - const: link
>          - const: addr_space
>          - const: atu
> 
> Then the if/then can have just 'minItems: 5' or 'maxItems: 4' for each
> case. I prefer the if/then schemas to be minimal.

I've got it. It means writing a common description, and writing
only the constraints in if/then. I'll rewrite it next.

Thank you,

---
Best Regards
Kunihiko Hayashi
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/pci/socionext,uniphier-pcie-ep.yaml b/Documentation/devicetree/bindings/pci/socionext,uniphier-pcie-ep.yaml
index 437e61618d06..49a5b2ca266c 100644
--- a/Documentation/devicetree/bindings/pci/socionext,uniphier-pcie-ep.yaml
+++ b/Documentation/devicetree/bindings/pci/socionext,uniphier-pcie-ep.yaml
@@ -15,9 +15,6 @@  description: |
 maintainers:
   - Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
 
-allOf:
-  - $ref: /schemas/pci/snps,dw-pcie-ep.yaml#
-
 properties:
   compatible:
     enum:
@@ -28,41 +25,19 @@  properties:
     minItems: 4
     maxItems: 5
 
-  reg-names:
-    oneOf:
-      - items:
-          - const: dbi
-          - const: dbi2
-          - const: link
-          - const: addr_space
-      - items:
-          - const: dbi
-          - const: dbi2
-          - const: link
-          - const: addr_space
-          - const: atu
+  reg-names: true
 
   clocks:
     minItems: 1
     maxItems: 2
 
-  clock-names:
-    oneOf:
-      - items:              # for Pro5
-          - const: gio
-          - const: link
-      - const: link         # for NX1
+  clock-names: true
 
   resets:
     minItems: 1
     maxItems: 2
 
-  reset-names:
-    oneOf:
-      - items:              # for Pro5
-          - const: gio
-          - const: link
-      - const: link         # for NX1
+  reset-names: true
 
   num-ib-windows:
     const: 16
@@ -78,6 +53,59 @@  properties:
   phy-names:
     const: pcie-phy
 
+allOf:
+  - $ref: /schemas/pci/snps,dw-pcie-ep.yaml#
+  - if:
+      properties:
+        compatible:
+          contains:
+            const: socionext,uniphier-pro5-pcie-ep
+    then:
+      properties:
+        reg:
+          minItems: 4
+          maxItems: 4
+        reg-names:
+          items:
+            - const: dbi
+            - const: dbi2
+            - const: link
+            - const: addr_space
+        clocks:
+          minItems: 2
+          maxItems: 2
+        clock-names:
+          items:
+            - const: gio
+            - const: link
+        resets:
+          minItems: 2
+          maxItems: 2
+        reset-names:
+          items:
+            - const: gio
+            - const: link
+    else:
+      properties:
+        reg:
+          minItems: 4
+          maxItems: 5
+        reg-names:
+          items:
+            - const: dbi
+            - const: dbi2
+            - const: link
+            - const: addr_space
+            - const: atu
+        clocks:
+          maxItems: 1
+        clock-names:
+          const: link
+        resets:
+          maxItems: 1
+        reset-names:
+          const: link
+
 required:
   - compatible
   - reg