Skip to contentSkip to conversation

dt-bindings:iio:yaml conversions with xor condition

PATCH Superseded Jonathan Cameron 2 participants 6 messages Apr 1, 2021 – Apr 24, 2021

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jonathan Cameron

author maintainer
#0 lore raw

cover dt-bindings:iio:yaml conversions with xor condition

From: Jonathan Cameron <[email protected]>

These two binding conversions are left from last year because I couldn't figure out how to do the XOR between spi-cpha and spi-cpol without using a $ref. Rob suggested it should work by lifting the $ref block and putting it inline but that ran into a restriction the dt-schema that a oneOf is not allowed directly under an allOf.

Line 34 of schema/base.yaml
allOf:
items:
propertyNames:
enum:
- $ref
- if
- then
- else
anyOf: true

I was just about to send a pull request to relax that constraint when I realized that a top level oneOf was sufficient for this XoR condition because it rules out more than one of the options being true at the same time. Hence the simplified version given here constrains things correctly.

oneOf:
- required:
- spi-cpha
- required:
- spi-cpol

We don't need to also specify
not:
required: [spi-cpha, spi-cpol]
as done in earlier versions of these bindings.

One other minor change in patch 2 to make Should -> Must to avoid confusion.

Jonathan Cameron (2):
dt-bindings:iio:dac:ad5755: txt to yaml format conversion. dt-bindings:iio:dac:ti,dac082s085 yaml conversion

 .../devicetree/bindings/iio/dac/ad5755.txt    | 124 -------------
 .../bindings/iio/dac/adi,ad5755.yaml          | 171 ++++++++++++++++++
 .../bindings/iio/dac/ti,dac082s085.yaml       |  72 ++++++++
 .../bindings/iio/dac/ti-dac082s085.txt        |  34 ----
 4 files changed, 243 insertions(+), 158 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/dac/ad5755.txt
 create mode 100644 Documentation/devicetree/bindings/iio/dac/adi,ad5755.yaml
 create mode 100644 Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml
 delete mode 100644 Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt
Signature · 1 line
2.31.1
author maintainer
#1 lore raw

PATCH 1/2 dt-bindings:iio:dac:ad5755: txt to yaml format conversion.

From: Jonathan Cameron <[email protected]>

Straight forward conversion. Only fiddly bit is the XOR of spi-cpol and spi-cpha.

---
 .../devicetree/bindings/iio/dac/ad5755.txt    | 124 -------------
 .../bindings/iio/dac/adi,ad5755.yaml          | 171 ++++++++++++++++++
 2 files changed, 171 insertions(+), 124 deletions(-)
Documentation/devicetree/bindings/iio/dac/ad5755.txt deleted +0 -124
deleted file mode 100644
index 502e1e55adbd..000000000000
@@ -1,124 +0,0 @@
-* Analog Devices AD5755 IIO Multi-Channel DAC Linux Driver
-
-Required properties:
- - compatible: Has to contain one of the following:
-	adi,ad5755
-	adi,ad5755-1
-	adi,ad5757
-	adi,ad5735
-	adi,ad5737
-
- - reg: spi chip select number for the device
- - spi-cpha or spi-cpol: is the only modes that is supported
-
-Recommended properties:
- - spi-max-frequency: Definition as per
-		Documentation/devicetree/bindings/spi/spi-bus.txt
-
-Optional properties:
-See include/dt-bindings/iio/ad5755.h
- - adi,ext-dc-dc-compenstation-resistor: boolean set if the hardware have an
-					 external resistor and thereby bypasses
-					 the internal compensation resistor.
- - adi,dc-dc-phase:
-	Valid values for DC DC Phase control is:
-	0: All dc-to-dc converters clock on the same edge.
-	1: Channel A and Channel B clock on the same edge,
-	   Channel C and Channel D clock on opposite edges.
-	2: Channel A and Channel C clock on the same edge,
-	   Channel B and Channel D clock on opposite edges.
-	3: Channel A, Channel B, Channel C, and Channel D
-	   clock 90 degrees out of phase from each other.
- - adi,dc-dc-freq-hz:
-	Valid values for DC DC frequency is [Hz]:
-	250000
-	410000
-	650000
- - adi,dc-dc-max-microvolt:
-	Valid values for the maximum allowed Vboost voltage supplied by
-	the dc-to-dc converter is:
-	23000000
-	24500000
-	27000000
-	29500000
-
-Optional for every channel:
- - adi,mode:
-	Valid values for DAC modes is:
-	0: 0 V to 5 V voltage range.
-	1: 0 V to 10 V voltage range.
-	2: Plus minus 5 V voltage range.
-	3: Plus minus 10 V voltage range.
-	4: 4 mA to 20 mA current range.
-	5: 0 mA to 20 mA current range.
-	6: 0 mA to 24 mA current range.
- - adi,ext-current-sense-resistor: boolean set if the hardware a external
-				   current sense resistor.
- - adi,enable-voltage-overrange: boolean enable voltage overrange
- - adi,slew: Array of slewrate settings should contain 3 fields:
-	1: Should be either 0 or 1 in order to enable or disable slewrate.
-	2: Slew rate settings:
-		Valid values for the slew rate update frequency:
-		64000
-		32000
-		16000
-		8000
-		4000
-		2000
-		1000
-		500
-		250
-		125
-		64
-		32
-		16
-		8
-		4
-		0
-	3: Slew step size:
-		Valid values for the step size LSBs:
-		1
-		2
-		4
-		16
-		32
-		64
-		128
-		256
-
-Example:
-dac@0 {
-	#address-cells = <1>;
-	#size-cells = <0>;
-	compatible = "adi,ad5755";
-	reg = <0>;
-	spi-max-frequency = <1000000>;
-	spi-cpha;
-	adi,dc-dc-phase = <0>;
-	adi,dc-dc-freq-hz = <410000>;
-	adi,dc-dc-max-microvolt = <23000000>;
-	channel@0 {
-		reg = <0>;
-		adi,mode = <4>;
-		adi,ext-current-sense-resistor;
-		adi,slew = <0 64000 1>;
-	};
-	channel@1 {
-		reg = <1>;
-		adi,mode = <4>;
-		adi,ext-current-sense-resistor;
-		adi,slew = <0 64000 1>;
-	};
-	channel@2 {
-		reg = <2>;
-		adi,mode = <4>;
-		adi,ext-current-sense-resistor;
-		adi,slew = <0 64000 1>;
-	};
-	channel@3 {
-		reg = <3>;
-		adi,mode = <4>;
-		adi,ext-current-sense-resistor;
-		adi,slew = <0 64000 1>;
-	};
-};
Documentation/devicetree/bindings/iio/dac/adi,ad5755.yaml new file +171 -0

171 lines not on this page · raw message

Signature · 1 line
2.31.1
maintainer
#2 lore raw

Re: [PATCH 1/2] dt-bindings:iio:dac:ad5755: txt to yaml format conversion.

Quoted 60 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Straight forward conversion. Only fiddly bit is the XOR of spi-cpol and spi-cpha.

---
 .../devicetree/bindings/iio/dac/ad5755.txt    | 124 -------------
 .../bindings/iio/dac/adi,ad5755.yaml          | 171 ++++++++++++++++++
 2 files changed, 171 insertions(+), 124 deletions(-)
Documentation/devicetree/bindings/iio/dac/adi,ad5755.yaml new file +40 -0
new file mode 100644
index 000000000000..5d6a87f28b12
@@ -0,0 +1,171 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/dac/adi,ad5755.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices AD5755 Multi-Channel DAC
+
+maintainers:
+  - Sean Nyekjaer <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - adi,ad5755
+      - adi,ad5755-1
+      - adi,ad5757
+      - adi,ad5735
+      - adi,ad5737
+
+  reg:
+    maxItems: 1
+
+  spi-cpha:
+    description: Either this or spi-cpol but not both.
+  spi-cpol: true
+
+  spi-max-frequency: true
+
+  adi,ext-dc-dc-compenstation-resistor:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description:
+      Set if the hardware have an external resistor and thereby bypasses
+      the internal compensation resistor.
+
+  adi,dc-dc-phase:
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 1, 2, 3]
+    description: |
+      Valid values for DC DC Phase control is:

Documentation/devicetree/bindings/iio/dac/adi,ad5755.yaml line 50

Quoted 10 lines
Documentation/devicetree/bindings/iio/dac/adi,ad5755.yaml new file +10 -0
+      0: All dc-to-dc converters clock on the same edge.
+      1: Channel A and Channel B clock on the same edge,
+         Channel C and Channel D clock on opposite edges.
+      2: Channel A and Channel C clock on the same edge,
+         Channel B and Channel D clock on opposite edges.
+      3: Channel A, Channel B, Channel C, and Channel D
+         clock 90 degrees out of phase from each other.
+
+  adi,dc-dc-freq-hz:
+    $ref: /schemas/types.yaml#/definitions/uint32

Don't need a type ref.

Documentation/devicetree/bindings/iio/dac/adi,ad5755.yaml line 54

Quoted 4 lines
Documentation/devicetree/bindings/iio/dac/adi,ad5755.yaml new file +4 -0
+    enum: [250000, 410000, 650000]
+
+  adi,dc-dc-max-microvolt:
+    $ref: /schemas/types.yaml#/definitions/uint32

Don't need a type ref.

Quoted 11 lines
Documentation/devicetree/bindings/iio/dac/adi,ad5755.yaml new file +11 -0
+    description:
+      Maximum allowed Vboost voltage supplied by the dc-to-dc converter.
+    enum: [23000000, 24500000, 27000000, 29500000]
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+  "#io-channel-cells":

Documentation/devicetree/bindings/iio/dac/adi,ad5755.yaml line 75

Quoted 10 lines
Documentation/devicetree/bindings/iio/dac/adi,ad5755.yaml new file +10 -0
+    const: 1
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+patternProperties:
+  "^(channel@)[0-7]$":

Don't need ().

Quoted 99 lines
Documentation/devicetree/bindings/iio/dac/adi,ad5755.yaml new file +96 -0
+    type: object
+    description: Child node to describe a channel
+    properties:
+      reg:
+        maxItems: 1
+
+      adi,mode:
+        $ref: /schemas/types.yaml#/definitions/uint32
+        minimum: 0
+        maximum: 6
+        description: |
+          Valid values for DAC modes is:
+          0: 0 V to 5 V voltage range.
+          1: 0 V to 10 V voltage range.
+          2: Plus minus 5 V voltage range.
+          3: Plus minus 10 V voltage range.
+          4: 4 mA to 20 mA current range.
+          5: 0 mA to 20 mA current range.
+          6: 0 mA to 24 mA current range.
+
+      adi,ext-current-sense-resistor:
+        $ref: /schemas/types.yaml#/definitions/flag
+        description:
+          Set if the hardware has an external current sense resistor
+
+      adi,enable-voltage-overrange:
+        $ref: /schemas/types.yaml#/definitions/flag
+        description: Enable voltage overrange
+
+      adi,slew:
+        $ref: /schemas/types.yaml#/definitions/uint32-array
+        description: |
+          Array of slewrate settings should contain 3 fields:
+          1: Should be either 0 or 1 in order to enable or disable slewrate.
+          2: Slew rate update frequency
+          3: Slew step size
+        items:
+          - enum: [0, 1]
+          - enum: [64000, 32000, 16000, 8000, 4000, 2000, 1000, 500, 250, 125, 64, 32, 16, 8, 4, 0]
+          - enum: [1, 2, 4, 16, 32, 64, 128, 256]
+
+    required:
+      - reg
+
+    additionalProperties: false
+
+oneOf:
+  - required:
+      - spi-cpha
+  - required:
+      - spi-cpol
+
+examples:
+  - |
+    #include <dt-bindings/iio/adi,ad5592r.h>
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        dac@0 {
+            #address-cells = <1>;
+            #size-cells = <0>;
+            compatible = "adi,ad5755";
+            reg = <0>;
+            spi-max-frequency = <1000000>;
+            spi-cpha;
+            adi,dc-dc-phase = <0>;
+            adi,dc-dc-freq-hz = <410000>;
+            adi,dc-dc-max-microvolt = <23000000>;
+            channel@0 {
+                reg = <0>;
+                adi,mode = <4>;
+                adi,ext-current-sense-resistor;
+                adi,slew = <0 64000 1>;
+            };
+            channel@1 {
+                reg = <1>;
+                adi,mode = <4>;
+                adi,ext-current-sense-resistor;
+                adi,slew = <0 64000 1>;
+            };
+            channel@2 {
+                reg = <2>;
+                adi,mode = <4>;
+                adi,ext-current-sense-resistor;
+                adi,slew = <0 64000 1>;
+            };
+            channel@3 {
+                reg = <3>;
+                adi,mode = <4>;
+                adi,ext-current-sense-resistor;
+                adi,slew = <0 64000 1>;
+            };
+        };
+    };
+...
Signature · 1 line
2.31.1
author maintainer
#3 lore raw

PATCH 2/2 dt-bindings:iio:dac:ti,dac082s085 yaml conversion

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

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

---
 .../bindings/iio/dac/ti,dac082s085.yaml       | 72 +++++++++++++++++++
 .../bindings/iio/dac/ti-dac082s085.txt        | 34 ---------
 2 files changed, 72 insertions(+), 34 deletions(-)
Documentation/devicetree/bindings/iio/dac/ti,dac082s085.yaml new file +72 -0
new file mode 100644
index 000000000000..b0157050f1ee
@@ -0,0 +1,72 @@
+# 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 <[email protected]>
+
+properties:
+  compatible:
+    enum:
+      - ti,dac082s085
+      - ti,dac102s085
+      - ti,dac122s085
+      - ti,dac084s085
+      - ti,dac104s085
+      - ti,dac124s085
+
+  reg:
+    maxItems: 1
+
+  spi-cpha: true
+  spi-cpol:
+    description:
+      Must 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
+
+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>;
+        };
+    };
+...
Documentation/devicetree/bindings/iio/dac/ti-dac082s085.txt deleted +0 -34
deleted file mode 100644
index 9cb0e10df704..000000000000
@@ -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>;
-	};
Signature · 1 line
2.31.1
maintainer Reviewed-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] dt-bindings:iio:dac:ti,dac082s085 yaml conversion

Quoted 5 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

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

Quoted 8 lines
---
 .../bindings/iio/dac/ti,dac082s085.yaml       | 72 +++++++++++++++++++
 .../bindings/iio/dac/ti-dac082s085.txt        | 34 ---------
 2 files changed, 72 insertions(+), 34 deletions(-)
author maintainer
#5 lore raw

Re: [PATCH 2/2] dt-bindings:iio:dac:ti,dac082s085 yaml conversion

Quoted 15 lines · On Fri, 9 Apr 2021 09:31:15 -0500 Rob Herring <[email protected]> wrote:
Quoted 5 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

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

Quoted 8 lines
---
 .../bindings/iio/dac/ti,dac082s085.yaml       | 72 +++++++++++++++++++
 .../bindings/iio/dac/ti-dac082s085.txt        | 34 ---------
 2 files changed, 72 insertions(+), 34 deletions(-)
Quoted 1 line

Applied to the togreg branch of iio.git and pushed out as testing for all the normal reasons.

Thanks,

Jonathan