[v1,3/3] dt-bindings: iio: adc: add ADS7924

Message ID 20221222203610.2571287-4-hugo@hugovil.com
State New
Headers
Series iio: adc: ti-ads7924: add ADS7924 driver |

Commit Message

Hugo Villeneuve Dec. 22, 2022, 8:36 p.m. UTC
  From: Hugo Villeneuve <hvilleneuve@dimonoff.com>

Add device tree bindings document for the Texas Instruments ADS7924
ADC.

Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
---
 .../bindings/iio/adc/ti,ads7924.yaml          | 103 ++++++++++++++++++
 1 file changed, 103 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,ads7924.yaml
  

Comments

Krzysztof Kozlowski Dec. 23, 2022, 8:19 a.m. UTC | #1
On 22/12/2022 21:36, Hugo Villeneuve wrote:
> From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> 
> Add device tree bindings document for the Texas Instruments ADS7924
> ADC.
> 
> Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> ---
>  .../bindings/iio/adc/ti,ads7924.yaml          | 103 ++++++++++++++++++
>  1 file changed, 103 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,ads7924.yaml
> 
> diff --git a/Documentation/devicetree/bindings/iio/adc/ti,ads7924.yaml b/Documentation/devicetree/bindings/iio/adc/ti,ads7924.yaml
> new file mode 100644
> index 000000000000..5408ec95e417
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/adc/ti,ads7924.yaml
> @@ -0,0 +1,103 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/adc/ti,ads7924.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: TI ADS7924 4 channels 12 bits I2C analog to digital converter
> +
> +maintainers:
> +  - Hugo Villeneuve <hvilleneuve@dimonoff.com>
> +
> +description: |
> +  Texas Instruments ADS7924 4 channels 12 bits I2C analog to digital converter
> +
> +  Specifications:
> +    https://www.ti.com/lit/gpn/ads7924
> +
> +properties:
> +  compatible:
> +    const: ti,ads7924
> +
> +  vref-supply:
> +    description:
> +      The regulator supply for the ADC reference voltage (AVDD)
> +
> +  reg:
> +    maxItems: 1
> +
> +  reset-gpios:
> +    description:
> +      GPIO used for controlling the reset pin

Drop description, it's obvious (unless you want to actually describe
some pieces of the hardware).

> +    maxItems: 1
> +
> +  "#address-cells":
> +    const: 1
> +
> +  "#size-cells":
> +    const: 0
> +
> +  "#io-channel-cells":
> +    const: 1
> +
> +required:
> +  - compatible
> +  - reg
> +  - vref-supply
> +  - "#address-cells"
> +  - "#size-cells"

Keep the same order as in properties. This one is more common (reg after
compatible).

> +
> +additionalProperties: false
> +
> +patternProperties:

patternProperties go immediately after properties.

> +  "^channel@[0-3]+$":
> +    type: object

additionalProperties: false on this level

> +    description:
> +      Child nodes needed for each channel that the platform uses.

I cannot understand this sentence at all. Instead describe the hardware
you are here representing. What's this?

> +
> +    properties:
> +      reg:
> +        description: |
> +          0: Voltage over AIN0 and GND.
> +          1: Voltage over AIN1 and GND.
> +          2: Voltage over AIN2 and GND.
> +          3: Voltage over AIN3 and GND.
> +        items:
> +          - minimum: 0
> +            maximum: 3
> +
> +    required:
> +      - reg
> +
> +examples:
> +  - |
> +    i2c {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        adc@48 {
> +            compatible = "ti,ads7924";
> +            reg = <0x48>;
> +            vref-supply = <&ads7924_reg>;
> +            reset-gpios = <&gpio 5 GPIO_ACTIVE_LOW>;
> +            #address-cells = <1>;
> +            #size-cells = <0>;
> +            channel@0 {
> +              reg = <0>;

Messed indentation. Keep 4 spaces.

> +              label = "CH0";
> +            };
> +            channel@1 {
> +              reg = <1>;
> +              label = "CH1";
> +            };
> +            channel@2 {
> +              reg = <2>;
> +              label = "CH2";
> +            };
> +            channel@3 {
> +              reg = <3>;
> +              label = "CH3";
> +            };
> +        };
> +    };
> +...

Best regards,
Krzysztof
  
Jonathan Cameron Dec. 23, 2022, 2:09 p.m. UTC | #2
> 
> > +    description:
> > +      Child nodes needed for each channel that the platform uses.  
> 
> I cannot understand this sentence at all. Instead describe the hardware
> you are here representing. What's this?

Needs rewording, but basically - "Which pins are connected to anything?"
  
Jonathan Cameron Dec. 23, 2022, 2:50 p.m. UTC | #3
On Thu, 22 Dec 2022 15:36:10 -0500
Hugo Villeneuve <hugo@hugovil.com> wrote:

> From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> 
> Add device tree bindings document for the Texas Instruments ADS7924
> ADC.
> 
> Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>

Hi Hugo,

Whilst you aren't using it yet, the binding should still attempt to be
a full description of the hardware, so I'd expect the interrupt line to
be part of it.

Otherwise, Krzysztof already covered this in detail.

Jonathan


> ---
>  .../bindings/iio/adc/ti,ads7924.yaml          | 103 ++++++++++++++++++
>  1 file changed, 103 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,ads7924.yaml
> 
> diff --git a/Documentation/devicetree/bindings/iio/adc/ti,ads7924.yaml b/Documentation/devicetree/bindings/iio/adc/ti,ads7924.yaml
> new file mode 100644
> index 000000000000..5408ec95e417
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/adc/ti,ads7924.yaml
> @@ -0,0 +1,103 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/iio/adc/ti,ads7924.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: TI ADS7924 4 channels 12 bits I2C analog to digital converter
> +
> +maintainers:
> +  - Hugo Villeneuve <hvilleneuve@dimonoff.com>
> +
> +description: |
> +  Texas Instruments ADS7924 4 channels 12 bits I2C analog to digital converter
> +
> +  Specifications:
> +    https://www.ti.com/lit/gpn/ads7924
> +
> +properties:
> +  compatible:
> +    const: ti,ads7924
> +
> +  vref-supply:
> +    description:
> +      The regulator supply for the ADC reference voltage (AVDD)
> +
> +  reg:
> +    maxItems: 1
> +
> +  reset-gpios:
> +    description:
> +      GPIO used for controlling the reset pin
> +    maxItems: 1
> +
> +  "#address-cells":
> +    const: 1
> +
> +  "#size-cells":
> +    const: 0
> +
> +  "#io-channel-cells":
> +    const: 1
> +
> +required:
> +  - compatible
> +  - reg
> +  - vref-supply
> +  - "#address-cells"
> +  - "#size-cells"
> +
> +additionalProperties: false
> +
> +patternProperties:
> +  "^channel@[0-3]+$":
> +    type: object
> +    description:
> +      Child nodes needed for each channel that the platform uses.
> +
> +    properties:
> +      reg:
> +        description: |
> +          0: Voltage over AIN0 and GND.
> +          1: Voltage over AIN1 and GND.
> +          2: Voltage over AIN2 and GND.
> +          3: Voltage over AIN3 and GND.
> +        items:
> +          - minimum: 0
> +            maximum: 3
> +
> +    required:
> +      - reg
> +
> +examples:
> +  - |
> +    i2c {
> +        #address-cells = <1>;
> +        #size-cells = <0>;
> +
> +        adc@48 {
> +            compatible = "ti,ads7924";
> +            reg = <0x48>;
> +            vref-supply = <&ads7924_reg>;
> +            reset-gpios = <&gpio 5 GPIO_ACTIVE_LOW>;
> +            #address-cells = <1>;
> +            #size-cells = <0>;
> +            channel@0 {
> +              reg = <0>;
> +              label = "CH0";
> +            };
> +            channel@1 {
> +              reg = <1>;
> +              label = "CH1";
> +            };
> +            channel@2 {
> +              reg = <2>;
> +              label = "CH2";
> +            };
> +            channel@3 {
> +              reg = <3>;
> +              label = "CH3";
> +            };
> +        };
> +    };
> +...
  
Hugo Villeneuve Dec. 23, 2022, 5:56 p.m. UTC | #4
On Fri, 23 Dec 2022 14:09:08 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> > 
> > > +    description:
> > > +      Child nodes needed for each channel that the platform uses.  
> > 
> > I cannot understand this sentence at all. Instead describe the hardware
> > you are here representing. What's this?
> 
> Needs rewording, but basically - "Which pins are connected to anything?"

Hi Jonathan and Krzysztof,
when writing this driver a few months ago, I used as a starting point the C source file and the YAML file of the TI ADS1015 driver.

I cannot say that I fully understand the sentence myself :) So I will reword it.

I will also take care of the other dt-bindings comments for version 2.

Thank you for your feedback.

Hugo V.
  
Hugo Villeneuve Dec. 23, 2022, 7:24 p.m. UTC | #5
On Fri, 23 Dec 2022 14:50:13 +0000
Jonathan Cameron <jic23@kernel.org> wrote:

> On Thu, 22 Dec 2022 15:36:10 -0500
> Hugo Villeneuve <hugo@hugovil.com> wrote:
> 
> > From: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> > 
> > Add device tree bindings document for the Texas Instruments ADS7924
> > ADC.
> > 
> > Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
> 
> Hi Hugo,
> 
> Whilst you aren't using it yet, the binding should still attempt to be
> a full description of the hardware, so I'd expect the interrupt line to
> be part of it.
> 
> Otherwise, Krzysztof already covered this in detail.

Ok, makes sense. Added.

Hugo.

 > Jonathan
> 
> 
> > ---
> >  .../bindings/iio/adc/ti,ads7924.yaml          | 103 ++++++++++++++++++
> >  1 file changed, 103 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/iio/adc/ti,ads7924.yaml
> > 
> > diff --git a/Documentation/devicetree/bindings/iio/adc/ti,ads7924.yaml b/Documentation/devicetree/bindings/iio/adc/ti,ads7924.yaml
> > new file mode 100644
> > index 000000000000..5408ec95e417
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/iio/adc/ti,ads7924.yaml
> > @@ -0,0 +1,103 @@
> > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> > +%YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/iio/adc/ti,ads7924.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: TI ADS7924 4 channels 12 bits I2C analog to digital converter
> > +
> > +maintainers:
> > +  - Hugo Villeneuve <hvilleneuve@dimonoff.com>
> > +
> > +description: |
> > +  Texas Instruments ADS7924 4 channels 12 bits I2C analog to digital converter
> > +
> > +  Specifications:
> > +    https://www.ti.com/lit/gpn/ads7924
> > +
> > +properties:
> > +  compatible:
> > +    const: ti,ads7924
> > +
> > +  vref-supply:
> > +    description:
> > +      The regulator supply for the ADC reference voltage (AVDD)
> > +
> > +  reg:
> > +    maxItems: 1
> > +
> > +  reset-gpios:
> > +    description:
> > +      GPIO used for controlling the reset pin
> > +    maxItems: 1
> > +
> > +  "#address-cells":
> > +    const: 1
> > +
> > +  "#size-cells":
> > +    const: 0
> > +
> > +  "#io-channel-cells":
> > +    const: 1
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - vref-supply
> > +  - "#address-cells"
> > +  - "#size-cells"
> > +
> > +additionalProperties: false
> > +
> > +patternProperties:
> > +  "^channel@[0-3]+$":
> > +    type: object
> > +    description:
> > +      Child nodes needed for each channel that the platform uses.
> > +
> > +    properties:
> > +      reg:
> > +        description: |
> > +          0: Voltage over AIN0 and GND.
> > +          1: Voltage over AIN1 and GND.
> > +          2: Voltage over AIN2 and GND.
> > +          3: Voltage over AIN3 and GND.
> > +        items:
> > +          - minimum: 0
> > +            maximum: 3
> > +
> > +    required:
> > +      - reg
> > +
> > +examples:
> > +  - |
> > +    i2c {
> > +        #address-cells = <1>;
> > +        #size-cells = <0>;
> > +
> > +        adc@48 {
> > +            compatible = "ti,ads7924";
> > +            reg = <0x48>;
> > +            vref-supply = <&ads7924_reg>;
> > +            reset-gpios = <&gpio 5 GPIO_ACTIVE_LOW>;
> > +            #address-cells = <1>;
> > +            #size-cells = <0>;
> > +            channel@0 {
> > +              reg = <0>;
> > +              label = "CH0";
> > +            };
> > +            channel@1 {
> > +              reg = <1>;
> > +              label = "CH1";
> > +            };
> > +            channel@2 {
> > +              reg = <2>;
> > +              label = "CH2";
> > +            };
> > +            channel@3 {
> > +              reg = <3>;
> > +              label = "CH3";
> > +            };
> > +        };
> > +    };
> > +...
> 
>
  

Patch

diff --git a/Documentation/devicetree/bindings/iio/adc/ti,ads7924.yaml b/Documentation/devicetree/bindings/iio/adc/ti,ads7924.yaml
new file mode 100644
index 000000000000..5408ec95e417
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/ti,ads7924.yaml
@@ -0,0 +1,103 @@ 
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/adc/ti,ads7924.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: TI ADS7924 4 channels 12 bits I2C analog to digital converter
+
+maintainers:
+  - Hugo Villeneuve <hvilleneuve@dimonoff.com>
+
+description: |
+  Texas Instruments ADS7924 4 channels 12 bits I2C analog to digital converter
+
+  Specifications:
+    https://www.ti.com/lit/gpn/ads7924
+
+properties:
+  compatible:
+    const: ti,ads7924
+
+  vref-supply:
+    description:
+      The regulator supply for the ADC reference voltage (AVDD)
+
+  reg:
+    maxItems: 1
+
+  reset-gpios:
+    description:
+      GPIO used for controlling the reset pin
+    maxItems: 1
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+  "#io-channel-cells":
+    const: 1
+
+required:
+  - compatible
+  - reg
+  - vref-supply
+  - "#address-cells"
+  - "#size-cells"
+
+additionalProperties: false
+
+patternProperties:
+  "^channel@[0-3]+$":
+    type: object
+    description:
+      Child nodes needed for each channel that the platform uses.
+
+    properties:
+      reg:
+        description: |
+          0: Voltage over AIN0 and GND.
+          1: Voltage over AIN1 and GND.
+          2: Voltage over AIN2 and GND.
+          3: Voltage over AIN3 and GND.
+        items:
+          - minimum: 0
+            maximum: 3
+
+    required:
+      - reg
+
+examples:
+  - |
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        adc@48 {
+            compatible = "ti,ads7924";
+            reg = <0x48>;
+            vref-supply = <&ads7924_reg>;
+            reset-gpios = <&gpio 5 GPIO_ACTIVE_LOW>;
+            #address-cells = <1>;
+            #size-cells = <0>;
+            channel@0 {
+              reg = <0>;
+              label = "CH0";
+            };
+            channel@1 {
+              reg = <1>;
+              label = "CH1";
+            };
+            channel@2 {
+              reg = <2>;
+              label = "CH2";
+            };
+            channel@3 {
+              reg = <3>;
+              label = "CH3";
+            };
+        };
+    };
+...