Skip to contentSkip to conversation

dt-bindings:iio:adc: Convert generic ADC channel binding to yaml

PATCH In review Jonathan Cameron 2 participants 7 messages Oct 31, 2020 – Nov 28, 2020

Subsystems (4)
lore
Share & tools
lore

Jonathan Cameron

author maintainer
#0 lore raw

cover dt-bindings:iio:adc: Convert generic ADC channel binding to yaml

From: Jonathan Cameron <[email protected]>

This channel binding is not yet that heavily used, though that will slowly change now we have a standard binding. There are more properties coming for this binding in the near future.

This series converts the channel binding itself then leverages it to reduce repitition and improve consistency in a couple of drivers.

One thing to note is that we have similar defintion for DACs but so far there are no generic properties.

Jonathan Cameron (3):
dt-bindings:iio:adc: convert adc.txt to yaml dt-bindings:iio:adc:adi,ad7124: Use the new adc.yaml channel binding dt-bindings:iio:adc:adi,ad7292: Use new adc.yaml binding for channels.

 .../devicetree/bindings/iio/adc/adc.txt       | 23 -----------
 .../devicetree/bindings/iio/adc/adc.yaml      | 38 +++++++++++++++++++
 .../bindings/iio/adc/adi,ad7124.yaml          | 14 +++----
 .../bindings/iio/adc/adi,ad7292.yaml          |  8 ++--
 4 files changed, 47 insertions(+), 36 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/adc/adc.txt
 create mode 100644 Documentation/devicetree/bindings/iio/adc/adc.yaml
Signature · 1 line
2.28.0
author maintainer
#1 lore raw

PATCH 1/3 dt-bindings:iio:adc: convert adc.txt to yaml

From: Jonathan Cameron <[email protected]>

Each driver that uses this will need to use a $ref
We can't always enable it like most of the generic bindings due to channel@X matching far more widely than IIO.

---
 .../devicetree/bindings/iio/adc/adc.txt       | 23 -----------
 .../devicetree/bindings/iio/adc/adc.yaml      | 38 +++++++++++++++++++
 2 files changed, 38 insertions(+), 23 deletions(-)
Documentation/devicetree/bindings/iio/adc/adc.txt deleted +0 -23
deleted file mode 100644
index 5bbaa330a250..000000000000
@@ -1,23 +0,0 @@
-Common ADCs properties
-
-Optional properties for child nodes:
-- bipolar : Boolean, if set the channel is used in bipolar mode.
-- diff-channels : Differential channels muxed for this ADC. The first value
-		specifies the positive input pin, the second value the negative
-		input pin.
-
-Example:
-	adc@0 {
-		compatible = "some,adc";
-		...
-		channel@0 {
-			bipolar;
-			diff-channels = <0 1>;
-			...
-		};
-
-		channel@1 {
-			diff-channels = <2 3>;
-			...
-		};
-	};
Documentation/devicetree/bindings/iio/adc/adc.yaml new file +38 -0
new file mode 100644
index 000000000000..328a4318feee
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/adc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Generic IIO bindings for ADC channels
+
+maintainers:
+  - Jonathan Cameron <[email protected]>
+
+description:
+  A few properties are defined in a common way ADC channels.
+
+properties:
+  $nodename:
+    pattern: "^channel(@[0-9a-f]+)?$"
+    description:
+      A channel index should match reg.
+
+  reg:
+    maxItems: 1
+
+  bipolar:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description: If provided, the channel is to be used in bipolar mode.
+
+  diff-channels:
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    maxItems: 2
+    minItems: 2
+    description:
+      Many ADCs have dual Muxes to allow different input pins to be routed
+      to both the positive and negative inputs of a differential ADC.
+      The first value specifies the positive input pin, the second
+      specifies the negative input pin.
+
+additionalProperties: true
Signature · 1 line
2.28.0
author maintainer
#2 lore raw

Re: [PATCH 1/3] dt-bindings:iio:adc: convert adc.txt to yaml

Quoted 5 lines · On Sat, 31 Oct 2020 18:24:21 +0000 Jonathan Cameron <[email protected]> wrote:

From: Jonathan Cameron <[email protected]>

Each driver that uses this will need to use a $ref
We can't always enable it like most of the generic bindings due to channel@X matching far more widely than IIO.

This patch crossed with the introduction of a label attribute to the txt file. As that was trivial I've just moved that over to the yaml file and applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.

Thanks,

Jonathan

Quoted 80 lines
---
 .../devicetree/bindings/iio/adc/adc.txt       | 23 -----------
 .../devicetree/bindings/iio/adc/adc.yaml      | 38 +++++++++++++++++++
 2 files changed, 38 insertions(+), 23 deletions(-)
Documentation/devicetree/bindings/iio/adc/adc.txt deleted +0 -23
deleted file mode 100644
index 5bbaa330a250..000000000000
@@ -1,23 +0,0 @@
-Common ADCs properties
-
-Optional properties for child nodes:
-- bipolar : Boolean, if set the channel is used in bipolar mode.
-- diff-channels : Differential channels muxed for this ADC. The first value
-		specifies the positive input pin, the second value the negative
-		input pin.
-
-Example:
-	adc@0 {
-		compatible = "some,adc";
-		...
-		channel@0 {
-			bipolar;
-			diff-channels = <0 1>;
-			...
-		};
-
-		channel@1 {
-			diff-channels = <2 3>;
-			...
-		};
-	};
Documentation/devicetree/bindings/iio/adc/adc.yaml new file +38 -0
new file mode 100644
index 000000000000..328a4318feee
@@ -0,0 +1,38 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/adc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Generic IIO bindings for ADC channels
+
+maintainers:
+  - Jonathan Cameron <[email protected]>
+
+description:
+  A few properties are defined in a common way ADC channels.
+
+properties:
+  $nodename:
+    pattern: "^channel(@[0-9a-f]+)?$"
+    description:
+      A channel index should match reg.
+
+  reg:
+    maxItems: 1
+
+  bipolar:
+    $ref: /schemas/types.yaml#/definitions/flag
+    description: If provided, the channel is to be used in bipolar mode.
+
+  diff-channels:
+    $ref: /schemas/types.yaml#/definitions/uint32-array
+    maxItems: 2
+    minItems: 2
+    description:
+      Many ADCs have dual Muxes to allow different input pins to be routed
+      to both the positive and negative inputs of a differential ADC.
+      The first value specifies the positive input pin, the second
+      specifies the negative input pin.
+
+additionalProperties: true
author maintainer
#3 lore raw

PATCH 2/3 dt-bindings:iio:adc:adi,ad7124: Use the new adc.yaml channel binding

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

This both ensures this binding is compliant with the generic properties and reduces the amount we need to specify in this separate binding.

Whilst here mark the child node as additionalProperties: false

Cc Michael Hennerich <[email protected]>
---
 .../devicetree/bindings/iio/adc/adi,ad7124.yaml    | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml +5 -9
index f1c574c896cb..fb3d0dae9bae 100644
@@ -63,10 +63,10 @@ required:
 
 patternProperties:
   "^channel@([0-9]|1[0-5])$":
+    $ref: "adc.yaml"
     type: object
     description: |
       Represents the external channels which are connected to the ADC.
-      See Documentation/devicetree/bindings/iio/adc/adc.txt.
 
     properties:
       reg:
@@ -88,15 +88,9 @@ patternProperties:
         $ref: /schemas/types.yaml#/definitions/uint32
         enum: [0, 1, 3]
 
-      diff-channels:
-        description: see Documentation/devicetree/bindings/iio/adc/adc.txt
-        items:
-          minimum: 0
-          maximum: 15
+      diff-channels: true
 
-      bipolar:
-        description: see Documentation/devicetree/bindings/iio/adc/adc.txt
-        type: boolean
+      bipolar: true
 
       adi,buffered-positive:
         description: Enable buffered mode for positive input.
@@ -110,6 +104,8 @@ patternProperties:
       - reg
       - diff-channels
 
+    additionalProperties: false
+
 additionalProperties: false
 
 examples:
Signature · 1 line
2.28.0
author maintainer
#4 lore raw

PATCH 3/3 dt-bindings:iio:adc:adi,ad7292: Use new adc.yaml binding for channels.

In reply to Jonathan Cameron

From: Jonathan Cameron <[email protected]>

Also add additionalProperties: false for the child nodes.

---
 Documentation/devicetree/bindings/iio/adc/adi,ad7292.yaml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/iio/adc/adi,ad7292.yaml +4 -4
index 108d202b288f..a3e39a40c9b3 100644
@@ -45,10 +45,10 @@ required:
 
 patternProperties:
   "^channel@[0-7]$":
+    $ref: "adc.yaml"
     type: object
     description: |
       Represents the external channels which are connected to the ADC.
-      See Documentation/devicetree/bindings/iio/adc/adc.txt.
 
     properties:
       reg:
@@ -58,13 +58,13 @@ patternProperties:
           - minimum: 0
             maximum: 7
 
-      diff-channels:
-        description: see Documentation/devicetree/bindings/iio/adc/adc.txt
-        maxItems: 1
+      diff-channels: true
 
     required:
       - reg
 
+    additionalProperties: true
+
 additionalProperties: false
 
 examples:
Signature · 1 line
2.28.0
maintainer Reviewed-by on the v1 series
#5 lore raw
In reply to Jonathan Cameron
Quoted 9 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

This channel binding is not yet that heavily used, though that will slowly change now we have a standard binding. There are more properties coming for this binding in the near future.

This series converts the channel binding itself then leverages it to reduce repitition and improve consistency in a couple of drivers.

Quoted 7 lines

One thing to note is that we have similar defintion for DACs but so far there are no generic properties.

Jonathan Cameron (3):
dt-bindings:iio:adc: convert adc.txt to yaml dt-bindings:iio:adc:adi,ad7124: Use the new adc.yaml channel binding dt-bindings:iio:adc:adi,ad7292: Use new adc.yaml binding for channels.

For the series:

Quoted 12 lines
 .../devicetree/bindings/iio/adc/adc.txt       | 23 -----------
 .../devicetree/bindings/iio/adc/adc.yaml      | 38 +++++++++++++++++++
 .../bindings/iio/adc/adi,ad7124.yaml          | 14 +++----
 .../bindings/iio/adc/adi,ad7292.yaml          |  8 ++--
 4 files changed, 47 insertions(+), 36 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/adc/adc.txt
 create mode 100644 Documentation/devicetree/bindings/iio/adc/adc.yaml
Signature · 1 line
2.28.0
author maintainer
#6 lore raw
Quoted 13 lines · On Mon, 2 Nov 2020 20:31:46 -0600 Rob Herring <[email protected]> wrote:
Quoted 12 lines · Jonathan Cameron

From: Jonathan Cameron <[email protected]>

This channel binding is not yet that heavily used, though that will slowly change now we have a standard binding. There are more properties coming for this binding in the near future.

This series converts the channel binding itself then leverages it to reduce repitition and improve consistency in a couple of drivers.

One thing to note is that we have similar defintion for DACs but so far there are no generic properties.

Quoted 8 lines
Quoted 4 lines

Jonathan Cameron (3):
dt-bindings:iio:adc: convert adc.txt to yaml dt-bindings:iio:adc:adi,ad7124: Use the new adc.yaml channel binding dt-bindings:iio:adc:adi,ad7292: Use new adc.yaml binding for channels.

For the series:

Series applied with just that small addition to patch 1.

Thanks,

Jonathan

Quoted 13 lines
Quoted 13 lines

 .../devicetree/bindings/iio/adc/adc.txt       | 23 -----------
 .../devicetree/bindings/iio/adc/adc.yaml      | 38 +++++++++++++++++++
 .../bindings/iio/adc/adi,ad7124.yaml          | 14 +++----
 .../bindings/iio/adc/adi,ad7292.yaml          |  8 ++--
 4 files changed, 47 insertions(+), 36 deletions(-)
 delete mode 100644 Documentation/devicetree/bindings/iio/adc/adc.txt
 create mode 100644 Documentation/devicetree/bindings/iio/adc/adc.yaml
Signature · 1 line
2.28.0