diff mbox series

[RFC,2/2] dt-bindings: pwm: Convert Samsung PWM bindings to json-schema

Message ID 20190909183436.9045-2-krzk@kernel.org
State Superseded
Headers show
Series [RFC,1/2] dt-bindings: pwm: Convert PWM bindings to json-schema | expand

Commit Message

Krzysztof Kozlowski Sept. 9, 2019, 6:34 p.m. UTC
Convert Samsung PWM (S3C, S5P and Exynos SoCs) bindings to DT schema
format using json-schema.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
---
 .../devicetree/bindings/pwm/pwm-samsung.txt   |  51 --------
 .../devicetree/bindings/pwm/pwm-samsung.yaml  | 111 ++++++++++++++++++
 2 files changed, 111 insertions(+), 51 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/pwm/pwm-samsung.txt
 create mode 100644 Documentation/devicetree/bindings/pwm/pwm-samsung.yaml

Comments

Rob Herring Sept. 13, 2019, 2:36 p.m. UTC | #1
On Mon, Sep 09, 2019 at 08:34:36PM +0200, Krzysztof Kozlowski wrote:
> Convert Samsung PWM (S3C, S5P and Exynos SoCs) bindings to DT schema
> format using json-schema.
> 
> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> ---
>  .../devicetree/bindings/pwm/pwm-samsung.txt   |  51 --------
>  .../devicetree/bindings/pwm/pwm-samsung.yaml  | 111 ++++++++++++++++++
>  2 files changed, 111 insertions(+), 51 deletions(-)
>  delete mode 100644 Documentation/devicetree/bindings/pwm/pwm-samsung.txt
>  create mode 100644 Documentation/devicetree/bindings/pwm/pwm-samsung.yaml


> diff --git a/Documentation/devicetree/bindings/pwm/pwm-samsung.yaml b/Documentation/devicetree/bindings/pwm/pwm-samsung.yaml
> new file mode 100644
> index 000000000000..90fb467bcdd5
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/pwm/pwm-samsung.yaml
> @@ -0,0 +1,111 @@
> +# SPDX-License-Identifier: GPL-2.0
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/pwm/pwm-samsung.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Samsung SoC PWM timers
> +
> +maintainers:
> +  - Thierry Reding <thierry.reding@gmail.com>
> +  - Krzysztof Kozlowski <krzk@kernel.org>
> +
> +description: |+
> +  Samsung SoCs contain PWM timer blocks which can be used for system clock source
> +  and clock event timers, as well as to drive SoC outputs with PWM signal. Each
> +  PWM timer block provides 5 PWM channels (not all of them can drive physical
> +  outputs - see SoC and board manual).
> +
> +  Be aware that the clocksource driver supports only uniprocessor systems.
> +
> +allOf:
> +  - $ref: pwm.yaml#
> +
> +properties:
> +  compatible:
> +    enum:
> +      - samsung,s3c2410-pwm             # 16-bit, S3C24xx
> +      - samsung,s3c6400-pwm             # 32-bit, S3C64xx
> +      - samsung,s5p6440-pwm             # 32-bit, S5P64x0
> +      - samsung,s5pc100-pwm             # 32-bit, S5PC100, S5PV210, Exynos4210 rev0 SoCs
> +      - samsung,exynos4210-pwm          # 32-bit, Exynos
> +
> +  reg:
> +    maxItems: 1
> +
> +  clocks:
> +    minItems: 1
> +    maxItems: 3
> +
> +  clock-names:
> +    description: |
> +      Should contain all following required clock names:
> +      - "timers" - PWM base clock used to generate PWM signals,
> +      and any subset of following optional clock names:
> +      - "pwm-tclk0" - first external PWM clock source,
> +      - "pwm-tclk1" - second external PWM clock source.
> +      Note that not all IP variants allow using all external clock sources.
> +      Refer to SoC documentation to learn which clock source configurations
> +      are available.
> +    oneOf:
> +      - items:
> +        - const: "timers"
> +      - items:
> +        - const: "timers"
> +        - const: "pwm-tclk0"
> +      - items:
> +        - const: "timers"
> +        - const: "pwm-tclk1"
> +      - items:
> +        - const: "timers"
> +        - const: "pwm-tclk0"
> +        - const: "pwm-tclk1"
> +
> +  interrupts:
> +    description:
> +      One interrupt per timer, starting at timer 0.
> +    minItems: 1
> +    maxItems: 5
> +
> +  "#pwm-cells":
> +    description:
> +      The only third cell flag supported by this binding
> +      is PWM_POLARITY_INVERTED.
> +    const: 3
> +
> +  samsung,pwm-outputs:
> +    description:
> +      A list of PWM channels used as PWM outputs on particular platform.
> +      It is an array of up to 5 elements being indices of PWM channels
> +      (from 0 to 4), the order does not matter.
> +    # TODO: Values should not repeat

uniqueItems: true

Though it looks like we have to enable that keyword. (As silently 
ignoring unknown keywords (such as typos) is 'feature' of json-schema, 
we explicitly list keywords we use.)

> +    allOf:
> +      - $ref: /schemas/types.yaml#/definitions/uint32-array
> +      # FIXME: min/max limit of items does not work
> +      - items:
> +          minItems: 1
> +          maxItems: 5
> +      - items:
> +          minimum: 0
> +          maximum: 4

I think you want:

minItems: 1
maxItems: 2
items:
  minimum: 0
  maximum: 4

> +
> +required:
> +  - clocks
> +  - clock-names
> +  - compatible
> +  - interrupts
> +  - "#pwm-cells"
> +  - reg
> +
> +examples:
> +  - |
> +    pwm@7f006000 {
> +      compatible = "samsung,s3c6400-pwm";
> +      reg = <0x7f006000 0x1000>;
> +      interrupt-parent = <&vic0>;
> +      interrupts = <23>, <24>, <25>, <27>, <28>;
> +      clocks = <&clock 67>;
> +      clock-names = "timers";
> +      samsung,pwm-outputs = <0>, <1>;
> +      #pwm-cells = <3>;
> +    };
> -- 
> 2.17.1
>
Krzysztof Kozlowski Sept. 18, 2019, 11:53 a.m. UTC | #2
On Fri, 13 Sep 2019 at 16:36, Rob Herring <robh@kernel.org> wrote:
>
> On Mon, Sep 09, 2019 at 08:34:36PM +0200, Krzysztof Kozlowski wrote:
> > Convert Samsung PWM (S3C, S5P and Exynos SoCs) bindings to DT schema
> > format using json-schema.
> >
> > Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
> > ---
> >  .../devicetree/bindings/pwm/pwm-samsung.txt   |  51 --------
> >  .../devicetree/bindings/pwm/pwm-samsung.yaml  | 111 ++++++++++++++++++
> >  2 files changed, 111 insertions(+), 51 deletions(-)
> >  delete mode 100644 Documentation/devicetree/bindings/pwm/pwm-samsung.txt
> >  create mode 100644 Documentation/devicetree/bindings/pwm/pwm-samsung.yaml
>
>
> > diff --git a/Documentation/devicetree/bindings/pwm/pwm-samsung.yaml b/Documentation/devicetree/bindings/pwm/pwm-samsung.yaml
> > new file mode 100644
> > index 000000000000..90fb467bcdd5
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/pwm/pwm-samsung.yaml
> > @@ -0,0 +1,111 @@
> > +# SPDX-License-Identifier: GPL-2.0
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/pwm/pwm-samsung.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Samsung SoC PWM timers
> > +
> > +maintainers:
> > +  - Thierry Reding <thierry.reding@gmail.com>
> > +  - Krzysztof Kozlowski <krzk@kernel.org>
> > +
> > +description: |+
> > +  Samsung SoCs contain PWM timer blocks which can be used for system clock source
> > +  and clock event timers, as well as to drive SoC outputs with PWM signal. Each
> > +  PWM timer block provides 5 PWM channels (not all of them can drive physical
> > +  outputs - see SoC and board manual).
> > +
> > +  Be aware that the clocksource driver supports only uniprocessor systems.
> > +
> > +allOf:
> > +  - $ref: pwm.yaml#
> > +
> > +properties:
> > +  compatible:
> > +    enum:
> > +      - samsung,s3c2410-pwm             # 16-bit, S3C24xx
> > +      - samsung,s3c6400-pwm             # 32-bit, S3C64xx
> > +      - samsung,s5p6440-pwm             # 32-bit, S5P64x0
> > +      - samsung,s5pc100-pwm             # 32-bit, S5PC100, S5PV210, Exynos4210 rev0 SoCs
> > +      - samsung,exynos4210-pwm          # 32-bit, Exynos
> > +
> > +  reg:
> > +    maxItems: 1
> > +
> > +  clocks:
> > +    minItems: 1
> > +    maxItems: 3
> > +
> > +  clock-names:
> > +    description: |
> > +      Should contain all following required clock names:
> > +      - "timers" - PWM base clock used to generate PWM signals,
> > +      and any subset of following optional clock names:
> > +      - "pwm-tclk0" - first external PWM clock source,
> > +      - "pwm-tclk1" - second external PWM clock source.
> > +      Note that not all IP variants allow using all external clock sources.
> > +      Refer to SoC documentation to learn which clock source configurations
> > +      are available.
> > +    oneOf:
> > +      - items:
> > +        - const: "timers"
> > +      - items:
> > +        - const: "timers"
> > +        - const: "pwm-tclk0"
> > +      - items:
> > +        - const: "timers"
> > +        - const: "pwm-tclk1"
> > +      - items:
> > +        - const: "timers"
> > +        - const: "pwm-tclk0"
> > +        - const: "pwm-tclk1"
> > +
> > +  interrupts:
> > +    description:
> > +      One interrupt per timer, starting at timer 0.
> > +    minItems: 1
> > +    maxItems: 5
> > +
> > +  "#pwm-cells":
> > +    description:
> > +      The only third cell flag supported by this binding
> > +      is PWM_POLARITY_INVERTED.
> > +    const: 3
> > +
> > +  samsung,pwm-outputs:
> > +    description:
> > +      A list of PWM channels used as PWM outputs on particular platform.
> > +      It is an array of up to 5 elements being indices of PWM channels
> > +      (from 0 to 4), the order does not matter.
> > +    # TODO: Values should not repeat
>
> uniqueItems: true
>
> Though it looks like we have to enable that keyword. (As silently
> ignoring unknown keywords (such as typos) is 'feature' of json-schema,
> we explicitly list keywords we use.)

This works fine.

>
> > +    allOf:
> > +      - $ref: /schemas/types.yaml#/definitions/uint32-array
> > +      # FIXME: min/max limit of items does not work
> > +      - items:
> > +          minItems: 1
> > +          maxItems: 5
> > +      - items:
> > +          minimum: 0
> > +          maximum: 4
>
> I think you want:
>
> minItems: 1
> maxItems: 2
> items:
>   minimum: 0
>   maximum: 4

This not. However I figured out it is not needed. Since these are
unique values from 0 to 4, then the size of array cannot be longer
than 5 or shorter than 1.

Best regards,
Krzysztof
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/pwm/pwm-samsung.txt b/Documentation/devicetree/bindings/pwm/pwm-samsung.txt
deleted file mode 100644
index 5538de9c2007..000000000000
--- a/Documentation/devicetree/bindings/pwm/pwm-samsung.txt
+++ /dev/null
@@ -1,51 +0,0 @@ 
-* Samsung PWM timers
-
-Samsung SoCs contain PWM timer blocks which can be used for system clock source
-and clock event timers, as well as to drive SoC outputs with PWM signal. Each
-PWM timer block provides 5 PWM channels (not all of them can drive physical
-outputs - see SoC and board manual).
-
-Be aware that the clocksource driver supports only uniprocessor systems.
-
-Required properties:
-- compatible : should be one of following:
-    samsung,s3c2410-pwm - for 16-bit timers present on S3C24xx SoCs
-    samsung,s3c6400-pwm - for 32-bit timers present on S3C64xx SoCs
-    samsung,s5p6440-pwm - for 32-bit timers present on S5P64x0 SoCs
-    samsung,s5pc100-pwm - for 32-bit timers present on S5PC100, S5PV210,
-			  Exynos4210 rev0 SoCs
-    samsung,exynos4210-pwm - for 32-bit timers present on Exynos4210,
-                          Exynos4x12, Exynos5250 and Exynos5420 SoCs
-- reg: base address and size of register area
-- interrupts: list of timer interrupts (one interrupt per timer, starting at
-  timer 0)
-- clock-names: should contain all following required clock names:
-    - "timers" - PWM base clock used to generate PWM signals,
-  and any subset of following optional clock names:
-    - "pwm-tclk0" - first external PWM clock source,
-    - "pwm-tclk1" - second external PWM clock source.
-  Note that not all IP variants allow using all external clock sources.
-  Refer to SoC documentation to learn which clock source configurations
-  are available.
-- clocks: should contain clock specifiers of all clocks, which input names
-  have been specified in clock-names property, in same order.
-- #pwm-cells: should be 3. See pwm.txt in this directory for a description of
-  the cells format. The only third cell flag supported by this binding is
-  PWM_POLARITY_INVERTED.
-
-Optional properties:
-- samsung,pwm-outputs: list of PWM channels used as PWM outputs on particular
-    platform - an array of up to 5 elements being indices of PWM channels
-    (from 0 to 4), the order does not matter.
-
-Example:
-	pwm@7f006000 {
-		compatible = "samsung,s3c6400-pwm";
-		reg = <0x7f006000 0x1000>;
-		interrupt-parent = <&vic0>;
-		interrupts = <23>, <24>, <25>, <27>, <28>;
-		clocks = <&clock 67>;
-		clock-names = "timers";
-		samsung,pwm-outputs = <0>, <1>;
-		#pwm-cells = <3>;
-	}
diff --git a/Documentation/devicetree/bindings/pwm/pwm-samsung.yaml b/Documentation/devicetree/bindings/pwm/pwm-samsung.yaml
new file mode 100644
index 000000000000..90fb467bcdd5
--- /dev/null
+++ b/Documentation/devicetree/bindings/pwm/pwm-samsung.yaml
@@ -0,0 +1,111 @@ 
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/pwm/pwm-samsung.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Samsung SoC PWM timers
+
+maintainers:
+  - Thierry Reding <thierry.reding@gmail.com>
+  - Krzysztof Kozlowski <krzk@kernel.org>
+
+description: |+
+  Samsung SoCs contain PWM timer blocks which can be used for system clock source
+  and clock event timers, as well as to drive SoC outputs with PWM signal. Each
+  PWM timer block provides 5 PWM channels (not all of them can drive physical
+  outputs - see SoC and board manual).
+
+  Be aware that the clocksource driver supports only uniprocessor systems.
+
+allOf:
+  - $ref: pwm.yaml#
+
+properties:
+  compatible:
+    enum:
+      - samsung,s3c2410-pwm             # 16-bit, S3C24xx
+      - samsung,s3c6400-pwm             # 32-bit, S3C64xx
+      - samsung,s5p6440-pwm             # 32-bit, S5P64x0
+      - samsung,s5pc100-pwm             # 32-bit, S5PC100, S5PV210, Exynos4210 rev0 SoCs
+      - samsung,exynos4210-pwm          # 32-bit, Exynos
+
+  reg:
+    maxItems: 1
+
+  clocks:
+    minItems: 1
+    maxItems: 3
+
+  clock-names:
+    description: |
+      Should contain all following required clock names:
+      - "timers" - PWM base clock used to generate PWM signals,
+      and any subset of following optional clock names:
+      - "pwm-tclk0" - first external PWM clock source,
+      - "pwm-tclk1" - second external PWM clock source.
+      Note that not all IP variants allow using all external clock sources.
+      Refer to SoC documentation to learn which clock source configurations
+      are available.
+    oneOf:
+      - items:
+        - const: "timers"
+      - items:
+        - const: "timers"
+        - const: "pwm-tclk0"
+      - items:
+        - const: "timers"
+        - const: "pwm-tclk1"
+      - items:
+        - const: "timers"
+        - const: "pwm-tclk0"
+        - const: "pwm-tclk1"
+
+  interrupts:
+    description:
+      One interrupt per timer, starting at timer 0.
+    minItems: 1
+    maxItems: 5
+
+  "#pwm-cells":
+    description:
+      The only third cell flag supported by this binding
+      is PWM_POLARITY_INVERTED.
+    const: 3
+
+  samsung,pwm-outputs:
+    description:
+      A list of PWM channels used as PWM outputs on particular platform.
+      It is an array of up to 5 elements being indices of PWM channels
+      (from 0 to 4), the order does not matter.
+    # TODO: Values should not repeat
+    allOf:
+      - $ref: /schemas/types.yaml#/definitions/uint32-array
+      # FIXME: min/max limit of items does not work
+      - items:
+          minItems: 1
+          maxItems: 5
+      - items:
+          minimum: 0
+          maximum: 4
+
+required:
+  - clocks
+  - clock-names
+  - compatible
+  - interrupts
+  - "#pwm-cells"
+  - reg
+
+examples:
+  - |
+    pwm@7f006000 {
+      compatible = "samsung,s3c6400-pwm";
+      reg = <0x7f006000 0x1000>;
+      interrupt-parent = <&vic0>;
+      interrupts = <23>, <24>, <25>, <27>, <28>;
+      clocks = <&clock 67>;
+      clock-names = "timers";
+      samsung,pwm-outputs = <0>, <1>;
+      #pwm-cells = <3>;
+    };