diff mbox series

[v2,16/29] dt-bindings:iio:dac:ti,dac082s085 yaml conversion

Message ID 20201031134110.724233-17-jic23@kernel.org (mailing list archive)
State New, archived
Headers show
Series dt-bindings:iio: Another set of yaml conversions. | expand

Commit Message

Jonathan Cameron Oct. 31, 2020, 1:40 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Fairly simple conversion with the exception of the XOR between
spi-cpha and spi-cpol.

Is there a better way to specify that?

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Lukas Wunner <lukas@wunner.de>
---
v2:
* Family typo
* Put back the reference regulator in example.
* Added checking of XOR of spi-cpha and spi-cpol
  (dropped Rob Herrings Reviewed-by due to this change)
  
 .../bindings/iio/dac/ti,dac082s085.yaml       | 79 +++++++++++++++++++
 .../bindings/iio/dac/ti-dac082s085.txt        | 34 --------
 2 files changed, 79 insertions(+), 34 deletions(-)

Comments

Lukas Wunner Oct. 31, 2020, 4:58 p.m. UTC | #1
On Sat, Oct 31, 2020 at 01:40:57PM +0000, Jonathan Cameron wrote:
> +  spi-cpha: true
> +  spi-cpol:
> +    description:
> +      Should be either spi-cpha, or spi-cpol but not both.

Do the YAML files follow RFC 2119 terminology?  If so, this is a
"must", not a "should".  (As it was in the txt file.)


> +required:
> +  - compatible
> +  - reg
> +  - vref-supply

This is missing "spi-cpha xor spi-cpol", not sure if it can be
specified here using the xor YAML trick.

Thanks,

Lukas
Jonathan Cameron Oct. 31, 2020, 6:11 p.m. UTC | #2
On Sat, 31 Oct 2020 17:58:36 +0100
Lukas Wunner <lukas@wunner.de> wrote:

> On Sat, Oct 31, 2020 at 01:40:57PM +0000, Jonathan Cameron wrote:
> > +  spi-cpha: true
> > +  spi-cpol:
> > +    description:
> > +      Should be either spi-cpha, or spi-cpol but not both.  
> 
> Do the YAML files follow RFC 2119 terminology?  If so, this is a
> "must", not a "should".  (As it was in the txt file.)

I'll fix that whilst applying if it is all we have outstanding.
This is an information comment only as the actual enforcement is
below.


> 
> 
> > +required:
> > +  - compatible
> > +  - reg
> > +  - vref-supply  
> 
> This is missing "spi-cpha xor spi-cpol", not sure if it can be
> specified here using the xor YAML trick.

It has to be specified in a separate block as far as I can tell.
That is done further down the file.  I've tested all the combinations
and xor is enforced.

+allOf:
+  - $ref: '#/definitions/cpolXORcpha'
+
+definitions:
+  cpolXORcpha:
+    not:
+      required: [spi-cpha, spi-cpol]
+    oneOf:
+      - required:
+          - spi-cpha
+      - required:
+          - spi-cpol
+

> 
> Thanks,
> 
> Lukas
Rob Herring (Arm) Nov. 3, 2020, 2:21 a.m. UTC | #3
On Sat, Oct 31, 2020 at 01:40:57PM +0000, Jonathan Cameron wrote:
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> 
> Fairly simple conversion with the exception of the XOR between
> spi-cpha and spi-cpol.
> 
> Is there a better way to specify that?
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Lukas Wunner <lukas@wunner.de>
> ---
> v2:
> * Family typo
> * Put back the reference regulator in example.
> * Added checking of XOR of spi-cpha and spi-cpol
>   (dropped Rob Herrings Reviewed-by due to this change)
>   
>  .../bindings/iio/dac/ti,dac082s085.yaml       | 79 +++++++++++++++++++
>  .../bindings/iio/dac/ti-dac082s085.txt        | 34 --------
>  2 files changed, 79 insertions(+), 34 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml b/Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml
> new file mode 100644
> index 000000000000..192b314c99d1
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml
> @@ -0,0 +1,79 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/dac/ti,dac082s085.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Texas Instruments DAC082s085 and similar DACs
> +
> +description:
> +  A family of Texas Instruments 8/10/12-bit 2/4-channel DACs
> +
> +maintainers:
> +  - Lukas Wunner <lukas@wunner.de>
> +
> +properties:
> +  compatible:
> +    enum:
> +      - ti,dac082s085
> +      - ti,dac102s085
> +      - ti,dac122s085
> +      - ti,dac084s085
> +      - ti,dac104s085
> +      - ti,dac124s085
> +
> +  reg:
> +    maxItems: 1
> +
> +  spi-cpha: true
> +  spi-cpol:
> +    description:
> +      Should be either spi-cpha, or spi-cpol but not both.
> +
> +  vref-supply:
> +    description: Needed to provide output scaling.
> +
> +  spi-max-frequency: true
> +
> +required:
> +  - compatible
> +  - reg
> +  - vref-supply
> +
> +additionalProperties: false
> +
> +allOf:
> +  - $ref: '#/definitions/cpolXORcpha'
> +
> +definitions:
> +  cpolXORcpha:

No need for a definition. Just put the below in the allOf entry.

> +    not:
> +      required: [spi-cpha, spi-cpol]
> +    oneOf:
> +      - required:
> +          - spi-cpha
> +      - required:
> +          - spi-cpol
> +
> +examples:
> +  - |
> +    vref_2v5_reg: regulator-vref {
> +        compatible = "regulator-fixed";
> +        regulator-name = "2v5";
> +        regulator-min-microvolt = <2500000>;
> +        regulator-max-microvolt = <2500000>;
> +        regulator-always-on;
> +    };
> +    spi {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        dac@0 {
> +            compatible = "ti,dac082s085";
> +            reg = <0>;
> +            spi-max-frequency = <40000000>;
> +            spi-cpol;
> +            vref-supply = <&vref_2v5_reg>;
> +        };
> +    };
> +...
> diff --git a/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt b/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt
> deleted file mode 100644
> index 9cb0e10df704..000000000000
> --- a/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt
> +++ /dev/null
> @@ -1,34 +0,0 @@
> -Texas Instruments 8/10/12-bit 2/4-channel DAC driver
> -
> -Required properties:
> - - compatible:		Must be one of:
> -			"ti,dac082s085"
> -			"ti,dac102s085"
> -			"ti,dac122s085"
> -			"ti,dac084s085"
> -			"ti,dac104s085"
> -			"ti,dac124s085"
> - - reg: 		Chip select number.
> - - spi-cpha, spi-cpol:	SPI mode (0,1) or (1,0) must be used, so specify
> -			either spi-cpha or spi-cpol (but not both).
> - - vref-supply: 	Phandle to the external reference voltage supply.
> -
> -For other required and optional properties of SPI slave nodes please refer to
> -../../spi/spi-bus.txt.
> -
> -Example:
> -	vref_2v5_reg: regulator-vref {
> -		compatible = "regulator-fixed";
> -		regulator-name = "2v5";
> -		regulator-min-microvolt = <2500000>;
> -		regulator-max-microvolt = <2500000>;
> -		regulator-always-on;
> -	};
> -
> -	dac@0 {
> -		compatible = "ti,dac082s085";
> -		reg = <0>;
> -		spi-max-frequency = <40000000>;
> -		spi-cpol;
> -		vref-supply = <&vref_2v5_reg>;
> -	};
> -- 
> 2.28.0
>
Jonathan Cameron Nov. 8, 2020, 4:34 p.m. UTC | #4
On Mon, 2 Nov 2020 20:21:08 -0600
Rob Herring <robh@kernel.org> wrote:

> On Sat, Oct 31, 2020 at 01:40:57PM +0000, Jonathan Cameron wrote:
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > 
> > Fairly simple conversion with the exception of the XOR between
> > spi-cpha and spi-cpol.
> > 
> > Is there a better way to specify that?
> > 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Lukas Wunner <lukas@wunner.de>
> > ---
> > v2:
> > * Family typo
> > * Put back the reference regulator in example.
> > * Added checking of XOR of spi-cpha and spi-cpol
> >   (dropped Rob Herrings Reviewed-by due to this change)
> >   
> >  .../bindings/iio/dac/ti,dac082s085.yaml       | 79 +++++++++++++++++++
> >  .../bindings/iio/dac/ti-dac082s085.txt        | 34 --------
> >  2 files changed, 79 insertions(+), 34 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml b/Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml
> > new file mode 100644
> > index 000000000000..192b314c99d1
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml
> > @@ -0,0 +1,79 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/iio/dac/ti,dac082s085.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: Texas Instruments DAC082s085 and similar DACs
> > +
> > +description:
> > +  A family of Texas Instruments 8/10/12-bit 2/4-channel DACs
> > +
> > +maintainers:
> > +  - Lukas Wunner <lukas@wunner.de>
> > +
> > +properties:
> > +  compatible:
> > +    enum:
> > +      - ti,dac082s085
> > +      - ti,dac102s085
> > +      - ti,dac122s085
> > +      - ti,dac084s085
> > +      - ti,dac104s085
> > +      - ti,dac124s085
> > +
> > +  reg:
> > +    maxItems: 1
> > +
> > +  spi-cpha: true
> > +  spi-cpol:
> > +    description:
> > +      Should be either spi-cpha, or spi-cpol but not both.
> > +
> > +  vref-supply:
> > +    description: Needed to provide output scaling.
> > +
> > +  spi-max-frequency: true
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - vref-supply
> > +
> > +additionalProperties: false
> > +
> > +allOf:
> > +  - $ref: '#/definitions/cpolXORcpha'
> > +
> > +definitions:
> > +  cpolXORcpha:  
> 
> No need for a definition. Just put the below in the allOf entry.

I can't figure out the syntax to do that.
If I put it directly there I get, 

... iio/dac/ti,dac082s085.yaml: allOf:0: 'not' is not one of ['$ref', 'if', 'then', 'else']

The use of $ref was the only way I could find to get around this.
What other option is there?  My Yaml is still largely cut and paste
based so not sure I fully understand the restrictions that are applied.

Thanks,

Jonathan



> 
> > +    not:
> > +      required: [spi-cpha, spi-cpol]
> > +    oneOf:
> > +      - required:
> > +          - spi-cpha
> > +      - required:
> > +          - spi-cpol
> > +
> > +examples:
> > +  - |
> > +    vref_2v5_reg: regulator-vref {
> > +        compatible = "regulator-fixed";
> > +        regulator-name = "2v5";
> > +        regulator-min-microvolt = <2500000>;
> > +        regulator-max-microvolt = <2500000>;
> > +        regulator-always-on;
> > +    };
> > +    spi {
> > +        #address-cells = <1>;
> > +        #size-cells = <0>;
> > +
> > +        dac@0 {
> > +            compatible = "ti,dac082s085";
> > +            reg = <0>;
> > +            spi-max-frequency = <40000000>;
> > +            spi-cpol;
> > +            vref-supply = <&vref_2v5_reg>;
> > +        };
> > +    };
> > +...
> > diff --git a/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt b/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt
> > deleted file mode 100644
> > index 9cb0e10df704..000000000000
> > --- a/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt
> > +++ /dev/null
> > @@ -1,34 +0,0 @@
> > -Texas Instruments 8/10/12-bit 2/4-channel DAC driver
> > -
> > -Required properties:
> > - - compatible:		Must be one of:
> > -			"ti,dac082s085"
> > -			"ti,dac102s085"
> > -			"ti,dac122s085"
> > -			"ti,dac084s085"
> > -			"ti,dac104s085"
> > -			"ti,dac124s085"
> > - - reg: 		Chip select number.
> > - - spi-cpha, spi-cpol:	SPI mode (0,1) or (1,0) must be used, so specify
> > -			either spi-cpha or spi-cpol (but not both).
> > - - vref-supply: 	Phandle to the external reference voltage supply.
> > -
> > -For other required and optional properties of SPI slave nodes please refer to
> > -../../spi/spi-bus.txt.
> > -
> > -Example:
> > -	vref_2v5_reg: regulator-vref {
> > -		compatible = "regulator-fixed";
> > -		regulator-name = "2v5";
> > -		regulator-min-microvolt = <2500000>;
> > -		regulator-max-microvolt = <2500000>;
> > -		regulator-always-on;
> > -	};
> > -
> > -	dac@0 {
> > -		compatible = "ti,dac082s085";
> > -		reg = <0>;
> > -		spi-max-frequency = <40000000>;
> > -		spi-cpol;
> > -		vref-supply = <&vref_2v5_reg>;
> > -	};
> > -- 
> > 2.28.0
> >
Jonathan Cameron March 14, 2021, 7:07 p.m. UTC | #5
On Sun, 8 Nov 2020 16:34:51 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> On Mon, 2 Nov 2020 20:21:08 -0600
> Rob Herring <robh@kernel.org> wrote:
> 
> > On Sat, Oct 31, 2020 at 01:40:57PM +0000, Jonathan Cameron wrote:  
> > > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > > 
> > > Fairly simple conversion with the exception of the XOR between
> > > spi-cpha and spi-cpol.
> > > 
> > > Is there a better way to specify that?
> > > 
> > > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > > Cc: Lukas Wunner <lukas@wunner.de>
> > > ---
> > > v2:
> > > * Family typo
> > > * Put back the reference regulator in example.
> > > * Added checking of XOR of spi-cpha and spi-cpol
> > >   (dropped Rob Herrings Reviewed-by due to this change)
> > >   
> > >  .../bindings/iio/dac/ti,dac082s085.yaml       | 79 +++++++++++++++++++
> > >  .../bindings/iio/dac/ti-dac082s085.txt        | 34 --------
> > >  2 files changed, 79 insertions(+), 34 deletions(-)
> > > 
> > > diff --git a/Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml b/Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml
> > > new file mode 100644
> > > index 000000000000..192b314c99d1
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml
> > > @@ -0,0 +1,79 @@
> > > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > > +%YAML 1.2
> > > +---
> > > +$id: http://devicetree.org/schemas/iio/dac/ti,dac082s085.yaml#
> > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > +
> > > +title: Texas Instruments DAC082s085 and similar DACs
> > > +
> > > +description:
> > > +  A family of Texas Instruments 8/10/12-bit 2/4-channel DACs
> > > +
> > > +maintainers:
> > > +  - Lukas Wunner <lukas@wunner.de>
> > > +
> > > +properties:
> > > +  compatible:
> > > +    enum:
> > > +      - ti,dac082s085
> > > +      - ti,dac102s085
> > > +      - ti,dac122s085
> > > +      - ti,dac084s085
> > > +      - ti,dac104s085
> > > +      - ti,dac124s085
> > > +
> > > +  reg:
> > > +    maxItems: 1
> > > +
> > > +  spi-cpha: true
> > > +  spi-cpol:
> > > +    description:
> > > +      Should be either spi-cpha, or spi-cpol but not both.
> > > +
> > > +  vref-supply:
> > > +    description: Needed to provide output scaling.
> > > +
> > > +  spi-max-frequency: true
> > > +
> > > +required:
> > > +  - compatible
> > > +  - reg
> > > +  - vref-supply
> > > +
> > > +additionalProperties: false
> > > +
> > > +allOf:
> > > +  - $ref: '#/definitions/cpolXORcpha'
> > > +
> > > +definitions:
> > > +  cpolXORcpha:    
> > 
> > No need for a definition. Just put the below in the allOf entry.  
> 
> I can't figure out the syntax to do that.
> If I put it directly there I get, 
> 
> ... iio/dac/ti,dac082s085.yaml: allOf:0: 'not' is not one of ['$ref', 'if', 'then', 'else']
> 
> The use of $ref was the only way I could find to get around this.
> What other option is there?  My Yaml is still largely cut and paste
> based so not sure I fully understand the restrictions that are applied.

Hi Rob,

I've had another go at playing with the syntax but still can't find a way around the above
issue if I try to get rid of the definitions block as you suggest.

Any pointers on the syntax very much appreciated!

Thanks

Jonathan

> 
> Thanks,
> 
> Jonathan
> 
> 
> 
> >   
> > > +    not:
> > > +      required: [spi-cpha, spi-cpol]
> > > +    oneOf:
> > > +      - required:
> > > +          - spi-cpha
> > > +      - required:
> > > +          - spi-cpol
> > > +
> > > +examples:
> > > +  - |
> > > +    vref_2v5_reg: regulator-vref {
> > > +        compatible = "regulator-fixed";
> > > +        regulator-name = "2v5";
> > > +        regulator-min-microvolt = <2500000>;
> > > +        regulator-max-microvolt = <2500000>;
> > > +        regulator-always-on;
> > > +    };
> > > +    spi {
> > > +        #address-cells = <1>;
> > > +        #size-cells = <0>;
> > > +
> > > +        dac@0 {
> > > +            compatible = "ti,dac082s085";
> > > +            reg = <0>;
> > > +            spi-max-frequency = <40000000>;
> > > +            spi-cpol;
> > > +            vref-supply = <&vref_2v5_reg>;
> > > +        };
> > > +    };
> > > +...
> > > diff --git a/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt b/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt
> > > deleted file mode 100644
> > > index 9cb0e10df704..000000000000
> > > --- a/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt
> > > +++ /dev/null
> > > @@ -1,34 +0,0 @@
> > > -Texas Instruments 8/10/12-bit 2/4-channel DAC driver
> > > -
> > > -Required properties:
> > > - - compatible:		Must be one of:
> > > -			"ti,dac082s085"
> > > -			"ti,dac102s085"
> > > -			"ti,dac122s085"
> > > -			"ti,dac084s085"
> > > -			"ti,dac104s085"
> > > -			"ti,dac124s085"
> > > - - reg: 		Chip select number.
> > > - - spi-cpha, spi-cpol:	SPI mode (0,1) or (1,0) must be used, so specify
> > > -			either spi-cpha or spi-cpol (but not both).
> > > - - vref-supply: 	Phandle to the external reference voltage supply.
> > > -
> > > -For other required and optional properties of SPI slave nodes please refer to
> > > -../../spi/spi-bus.txt.
> > > -
> > > -Example:
> > > -	vref_2v5_reg: regulator-vref {
> > > -		compatible = "regulator-fixed";
> > > -		regulator-name = "2v5";
> > > -		regulator-min-microvolt = <2500000>;
> > > -		regulator-max-microvolt = <2500000>;
> > > -		regulator-always-on;
> > > -	};
> > > -
> > > -	dac@0 {
> > > -		compatible = "ti,dac082s085";
> > > -		reg = <0>;
> > > -		spi-max-frequency = <40000000>;
> > > -		spi-cpol;
> > > -		vref-supply = <&vref_2v5_reg>;
> > > -	};
> > > -- 
> > > 2.28.0
> > >     
>
Jonathan Cameron March 14, 2021, 7:23 p.m. UTC | #6
On Sun, 14 Mar 2021 19:07:54 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> On Sun, 8 Nov 2020 16:34:51 +0000
> Jonathan Cameron <jic23@kernel.org> wrote:
> 
> > On Mon, 2 Nov 2020 20:21:08 -0600
> > Rob Herring <robh@kernel.org> wrote:
> >   
> > > On Sat, Oct 31, 2020 at 01:40:57PM +0000, Jonathan Cameron wrote:    
> > > > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > > > 
> > > > Fairly simple conversion with the exception of the XOR between
> > > > spi-cpha and spi-cpol.
> > > > 
> > > > Is there a better way to specify that?
> > > > 
> > > > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > > > Cc: Lukas Wunner <lukas@wunner.de>
> > > > ---
> > > > v2:
> > > > * Family typo
> > > > * Put back the reference regulator in example.
> > > > * Added checking of XOR of spi-cpha and spi-cpol
> > > >   (dropped Rob Herrings Reviewed-by due to this change)
> > > >   
> > > >  .../bindings/iio/dac/ti,dac082s085.yaml       | 79 +++++++++++++++++++
> > > >  .../bindings/iio/dac/ti-dac082s085.txt        | 34 --------
> > > >  2 files changed, 79 insertions(+), 34 deletions(-)
> > > > 
> > > > diff --git a/Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml b/Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml
> > > > new file mode 100644
> > > > index 000000000000..192b314c99d1
> > > > --- /dev/null
> > > > +++ b/Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml
> > > > @@ -0,0 +1,79 @@
> > > > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > > > +%YAML 1.2
> > > > +---
> > > > +$id: http://devicetree.org/schemas/iio/dac/ti,dac082s085.yaml#
> > > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > > +
> > > > +title: Texas Instruments DAC082s085 and similar DACs
> > > > +
> > > > +description:
> > > > +  A family of Texas Instruments 8/10/12-bit 2/4-channel DACs
> > > > +
> > > > +maintainers:
> > > > +  - Lukas Wunner <lukas@wunner.de>
> > > > +
> > > > +properties:
> > > > +  compatible:
> > > > +    enum:
> > > > +      - ti,dac082s085
> > > > +      - ti,dac102s085
> > > > +      - ti,dac122s085
> > > > +      - ti,dac084s085
> > > > +      - ti,dac104s085
> > > > +      - ti,dac124s085
> > > > +
> > > > +  reg:
> > > > +    maxItems: 1
> > > > +
> > > > +  spi-cpha: true
> > > > +  spi-cpol:
> > > > +    description:
> > > > +      Should be either spi-cpha, or spi-cpol but not both.
> > > > +
> > > > +  vref-supply:
> > > > +    description: Needed to provide output scaling.
> > > > +
> > > > +  spi-max-frequency: true
> > > > +
> > > > +required:
> > > > +  - compatible
> > > > +  - reg
> > > > +  - vref-supply
> > > > +
> > > > +additionalProperties: false
> > > > +
> > > > +allOf:
> > > > +  - $ref: '#/definitions/cpolXORcpha'
> > > > +
> > > > +definitions:
> > > > +  cpolXORcpha:      
> > > 
> > > No need for a definition. Just put the below in the allOf entry.    
> > 
> > I can't figure out the syntax to do that.
> > If I put it directly there I get, 
> > 
> > ... iio/dac/ti,dac082s085.yaml: allOf:0: 'not' is not one of ['$ref', 'if', 'then', 'else']
> > 
> > The use of $ref was the only way I could find to get around this.
> > What other option is there?  My Yaml is still largely cut and paste
> > based so not sure I fully understand the restrictions that are applied.  
> 
> Hi Rob,
> 
> I've had another go at playing with the syntax but still can't find a way around the above
> issue if I try to get rid of the definitions block as you suggest.
> 
> Any pointers on the syntax very much appreciated!

Little more digging.  So that restriction is coming from base.yaml

Not sure if the following 'fix' is fine though.. :)

diff --git a/meta-schemas/base.yaml b/meta-schemas/base.yaml
index a63e1ec18b2a..6d38ed1be3d2 100644
--- a/meta-schemas/base.yaml
+++ b/meta-schemas/base.yaml
@@ -39,6 +39,7 @@ properties:
           - if
           - then
           - else
+          - not
   anyOf: true
   oneOf: true
   definitions: true

> 
> Thanks
> 
> Jonathan
> 
> > 
> > Thanks,
> > 
> > Jonathan
> > 
> > 
> >   
> > >     
> > > > +    not:
> > > > +      required: [spi-cpha, spi-cpol]
> > > > +    oneOf:
> > > > +      - required:
> > > > +          - spi-cpha
> > > > +      - required:
> > > > +          - spi-cpol
> > > > +
> > > > +examples:
> > > > +  - |
> > > > +    vref_2v5_reg: regulator-vref {
> > > > +        compatible = "regulator-fixed";
> > > > +        regulator-name = "2v5";
> > > > +        regulator-min-microvolt = <2500000>;
> > > > +        regulator-max-microvolt = <2500000>;
> > > > +        regulator-always-on;
> > > > +    };
> > > > +    spi {
> > > > +        #address-cells = <1>;
> > > > +        #size-cells = <0>;
> > > > +
> > > > +        dac@0 {
> > > > +            compatible = "ti,dac082s085";
> > > > +            reg = <0>;
> > > > +            spi-max-frequency = <40000000>;
> > > > +            spi-cpol;
> > > > +            vref-supply = <&vref_2v5_reg>;
> > > > +        };
> > > > +    };
> > > > +...
> > > > diff --git a/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt b/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt
> > > > deleted file mode 100644
> > > > index 9cb0e10df704..000000000000
> > > > --- a/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt
> > > > +++ /dev/null
> > > > @@ -1,34 +0,0 @@
> > > > -Texas Instruments 8/10/12-bit 2/4-channel DAC driver
> > > > -
> > > > -Required properties:
> > > > - - compatible:		Must be one of:
> > > > -			"ti,dac082s085"
> > > > -			"ti,dac102s085"
> > > > -			"ti,dac122s085"
> > > > -			"ti,dac084s085"
> > > > -			"ti,dac104s085"
> > > > -			"ti,dac124s085"
> > > > - - reg: 		Chip select number.
> > > > - - spi-cpha, spi-cpol:	SPI mode (0,1) or (1,0) must be used, so specify
> > > > -			either spi-cpha or spi-cpol (but not both).
> > > > - - vref-supply: 	Phandle to the external reference voltage supply.
> > > > -
> > > > -For other required and optional properties of SPI slave nodes please refer to
> > > > -../../spi/spi-bus.txt.
> > > > -
> > > > -Example:
> > > > -	vref_2v5_reg: regulator-vref {
> > > > -		compatible = "regulator-fixed";
> > > > -		regulator-name = "2v5";
> > > > -		regulator-min-microvolt = <2500000>;
> > > > -		regulator-max-microvolt = <2500000>;
> > > > -		regulator-always-on;
> > > > -	};
> > > > -
> > > > -	dac@0 {
> > > > -		compatible = "ti,dac082s085";
> > > > -		reg = <0>;
> > > > -		spi-max-frequency = <40000000>;
> > > > -		spi-cpol;
> > > > -		vref-supply = <&vref_2v5_reg>;
> > > > -	};
> > > > -- 
> > > > 2.28.0
> > > >       
> >   
>
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml b/Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml
new file mode 100644
index 000000000000..192b314c99d1
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml
@@ -0,0 +1,79 @@ 
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/dac/ti,dac082s085.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Texas Instruments DAC082s085 and similar DACs
+
+description:
+  A family of Texas Instruments 8/10/12-bit 2/4-channel DACs
+
+maintainers:
+  - Lukas Wunner <lukas@wunner.de>
+
+properties:
+  compatible:
+    enum:
+      - ti,dac082s085
+      - ti,dac102s085
+      - ti,dac122s085
+      - ti,dac084s085
+      - ti,dac104s085
+      - ti,dac124s085
+
+  reg:
+    maxItems: 1
+
+  spi-cpha: true
+  spi-cpol:
+    description:
+      Should be either spi-cpha, or spi-cpol but not both.
+
+  vref-supply:
+    description: Needed to provide output scaling.
+
+  spi-max-frequency: true
+
+required:
+  - compatible
+  - reg
+  - vref-supply
+
+additionalProperties: false
+
+allOf:
+  - $ref: '#/definitions/cpolXORcpha'
+
+definitions:
+  cpolXORcpha:
+    not:
+      required: [spi-cpha, spi-cpol]
+    oneOf:
+      - required:
+          - spi-cpha
+      - required:
+          - spi-cpol
+
+examples:
+  - |
+    vref_2v5_reg: regulator-vref {
+        compatible = "regulator-fixed";
+        regulator-name = "2v5";
+        regulator-min-microvolt = <2500000>;
+        regulator-max-microvolt = <2500000>;
+        regulator-always-on;
+    };
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        dac@0 {
+            compatible = "ti,dac082s085";
+            reg = <0>;
+            spi-max-frequency = <40000000>;
+            spi-cpol;
+            vref-supply = <&vref_2v5_reg>;
+        };
+    };
+...
diff --git a/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt b/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt
deleted file mode 100644
index 9cb0e10df704..000000000000
--- a/Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt
+++ /dev/null
@@ -1,34 +0,0 @@ 
-Texas Instruments 8/10/12-bit 2/4-channel DAC driver
-
-Required properties:
- - compatible:		Must be one of:
-			"ti,dac082s085"
-			"ti,dac102s085"
-			"ti,dac122s085"
-			"ti,dac084s085"
-			"ti,dac104s085"
-			"ti,dac124s085"
- - reg: 		Chip select number.
- - spi-cpha, spi-cpol:	SPI mode (0,1) or (1,0) must be used, so specify
-			either spi-cpha or spi-cpol (but not both).
- - vref-supply: 	Phandle to the external reference voltage supply.
-
-For other required and optional properties of SPI slave nodes please refer to
-../../spi/spi-bus.txt.
-
-Example:
-	vref_2v5_reg: regulator-vref {
-		compatible = "regulator-fixed";
-		regulator-name = "2v5";
-		regulator-min-microvolt = <2500000>;
-		regulator-max-microvolt = <2500000>;
-		regulator-always-on;
-	};
-
-	dac@0 {
-		compatible = "ti,dac082s085";
-		reg = <0>;
-		spi-max-frequency = <40000000>;
-		spi-cpol;
-		vref-supply = <&vref_2v5_reg>;
-	};