[PATCH 2/3] dt-bindings: iio: adc: add ade9000

Antoniu Miclaus posted 3 patches 2 months, 3 weeks ago
There is a newer version of this series
[PATCH 2/3] dt-bindings: iio: adc: add ade9000
Posted by Antoniu Miclaus 2 months, 3 weeks ago
Add devicetree bindings support for ade9000.

Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
---
 .../bindings/iio/adc/adi,ade9000.yaml         | 157 ++++++++++++++++++
 1 file changed, 157 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ade9000.yaml

diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ade9000.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ade9000.yaml
new file mode 100644
index 000000000000..660dca4ea9b5
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/adi,ade9000.yaml
@@ -0,0 +1,157 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+# Copyright 2025 Analog Devices Inc.
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/bindings/iio/adc/adi,ade9000.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Analog Devices ADE9000 High Performance, Polyphase Energy Metering driver
+
+maintainers:
+  - Antoniu Miclaus <antoniu.miclaus@analog.com>
+
+description: |
+  The ADE9000 s a highly accurate, fully integrated, multiphase energy and power
+  quality monitoring device. Superior analog performance and a digital signal
+  processing (DSP) core enable accurate energy monitoring over a wide dynamic
+  range. An integrated high end reference ensures low drift over temperature
+  with a combined drift of less than ±25 ppm/°C maximum for the entire channel
+  including a programmable gain amplifier (PGA) and an analog-to- digital
+  converter (ADC).
+
+  https://www.analog.com/media/en/technical-documentation/data-sheets/ADE9000.pdf
+
+properties:
+  compatible:
+    enum:
+      - adi,ade9000
+
+  reg:
+    maxItems: 1
+
+  '#address-cells':
+    const: 1
+
+  '#size-cells':
+    const: 0
+
+  spi-max-frequency:
+    maximum: 20000000
+
+  interrupts:
+    maxItems: 2
+
+  reset-gpios:
+    description: |
+      Must be the device tree identifier of the RESET pin. As the line is
+      active low, it should be marked GPIO_ACTIVE_LOW.
+    maxItems: 1
+
+  interrupt-names:
+    items:
+      - const: irq0
+      - const: irq1
+
+  adi,wf-cap-en:
+    description: Enable fixed data rate for waveform buffer instead of resampled data
+    type: boolean
+
+  adi,wf-mode:
+    description: |
+      Waveform buffer filling and trigger mode.
+      0 - Stop when waveform buffer is full
+      1 - Continuous fill, stop only on enabled trigger events
+      2 - Continuous filling, center capture around enabled trigger events
+      3 - Streaming mode
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 1, 2, 3]
+
+  adi,wf-src:
+    description: |
+      Waveform buffer data source selection.
+      0 - Sinc4 output, at 16 kSPS
+      1 - Reserved
+      2 - Sinc4 + IIR LPF output, at 4 kSPS
+      3 - Current and voltage channel waveform samples, processed by the DSP at 4 kSPS
+    $ref: /schemas/types.yaml#/definitions/uint32
+    enum: [0, 2, 3]
+
+  adi,wf-in-en:
+    description: Enable IN waveform samples readout from waveform buffer
+    type: boolean
+
+  adi,egy-time:
+    description: Energy accumulation time setting for energy registers
+    $ref: /schemas/types.yaml#/definitions/uint32
+
+required:
+  - compatible
+  - reg
+  - reset-gpios
+  - interrupts
+  - interrupt-names
+  - adi,wf-mode
+  - adi,wf-src
+
+additionalProperties: false
+
+patternProperties:
+  "^phase@[0-2]$":
+    type: object
+    description: |
+      Represents the external phases which are externally connected. Each phase
+      has a current, voltage and power component
+
+    properties:
+      reg:
+        description: |
+          The phase represented by a number
+          0 - Phase A
+          1 - Phase B
+          2 - Phase C
+        $ref: /schemas/types.yaml#/definitions/uint32
+        enum: [0, 1, 2]
+
+    required:
+      - reg
+
+    additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/gpio/gpio.h>
+    #include <dt-bindings/interrupt-controller/irq.h>
+
+    spi {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        adc@0 {
+            compatible = "adi,ade9000";
+            reg = <0>;
+            spi-max-frequency = <7000000>;
+
+            #address-cells = <1>;
+            #size-cells = <0>;
+            reset-gpios = <&gpio 4 GPIO_ACTIVE_LOW>;
+            interrupts = <2 IRQ_TYPE_EDGE_FALLING>, <3 IRQ_TYPE_EDGE_FALLING>;
+            interrupt-names = "irq0", "irq1";
+            interrupt-parent = <&gpio>;
+
+            adi,wf-cap-en;
+            adi,wf-mode = <3>;
+            adi,wf-src = <3>;
+            adi,wf-in-en;
+
+            phase@0 {
+                reg = <0>;
+            };
+            phase@1 {
+                reg = <1>;
+            };
+            phase@2 {
+                reg = <2>;
+            };
+        };
+    };
+...
-- 
2.49.0

Re: [PATCH 2/3] dt-bindings: iio: adc: add ade9000
Posted by David Lechner 2 months, 3 weeks ago
On 7/11/25 8:02 AM, Antoniu Miclaus wrote:
> Add devicetree bindings support for ade9000.
> 
> Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
> ---
>  .../bindings/iio/adc/adi,ade9000.yaml         | 157 ++++++++++++++++++
>  1 file changed, 157 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ade9000.yaml
> 
> diff --git a/Documentation/devicetree/bindings/iio/adc/adi,ade9000.yaml b/Documentation/devicetree/bindings/iio/adc/adi,ade9000.yaml
> new file mode 100644
> index 000000000000..660dca4ea9b5
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/iio/adc/adi,ade9000.yaml
> @@ -0,0 +1,157 @@
> +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
> +# Copyright 2025 Analog Devices Inc.
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/bindings/iio/adc/adi,ade9000.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Analog Devices ADE9000 High Performance, Polyphase Energy Metering driver
> +
> +maintainers:
> +  - Antoniu Miclaus <antoniu.miclaus@analog.com>
> +
> +description: |
> +  The ADE9000 s a highly accurate, fully integrated, multiphase energy and power
> +  quality monitoring device. Superior analog performance and a digital signal
> +  processing (DSP) core enable accurate energy monitoring over a wide dynamic
> +  range. An integrated high end reference ensures low drift over temperature
> +  with a combined drift of less than ±25 ppm/°C maximum for the entire channel
> +  including a programmable gain amplifier (PGA) and an analog-to- digital
> +  converter (ADC).
> +
> +  https://www.analog.com/media/en/technical-documentation/data-sheets/ADE9000.pdf
> +
> +properties:
> +  compatible:
> +    enum:
> +      - adi,ade9000
> +
> +  reg:
> +    maxItems: 1
> +
> +  '#address-cells':
> +    const: 1
> +
> +  '#size-cells':
> +    const: 0
> +
> +  spi-max-frequency:
> +    maximum: 20000000
> +
> +  interrupts:
> +    maxItems: 2

Let's keep this together with interrupt-names.

> +
> +  reset-gpios:
> +    description: |
> +      Must be the device tree identifier of the RESET pin. As the line is
> +      active low, it should be marked GPIO_ACTIVE_LOW.
> +    maxItems: 1
> +
> +  interrupt-names:
> +    items:
> +      - const: irq0
> +      - const: irq1

The C4/EVENT/DREADY pins can also be an output and would make sense
as a 3rd interrupt.

> +
> +  adi,wf-cap-en:
> +    description: Enable fixed data rate for waveform buffer instead of resampled data
> +    type: boolean

This one sounds like a runtime setting depending on how you want to
configure sampling.

> +
> +  adi,wf-mode:
> +    description: |
> +      Waveform buffer filling and trigger mode.
> +      0 - Stop when waveform buffer is full
> +      1 - Continuous fill, stop only on enabled trigger events
> +      2 - Continuous filling, center capture around enabled trigger events
> +      3 - Streaming mode
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    enum: [0, 1, 2, 3]

This one sounds like something that would be determined by how
a buffered read is setup in the IIO driver, not something that
should be in the devicetree.

> +
> +  adi,wf-src:
> +    description: |
> +      Waveform buffer data source selection.
> +      0 - Sinc4 output, at 16 kSPS
> +      1 - Reserved
> +      2 - Sinc4 + IIR LPF output, at 4 kSPS
> +      3 - Current and voltage channel waveform samples, processed by the DSP at 4 kSPS
> +    $ref: /schemas/types.yaml#/definitions/uint32
> +    enum: [0, 2, 3]

There is a standard filter_type attribute that should be used
for selecting the filter type rather than hard-coding it in the
devicetree.

> +
> +  adi,wf-in-en:
> +    description: Enable IN waveform samples readout from waveform buffer
> +    type: boolean

This one also sounds like something that would be configured based
on how a scan is setup at runtime.

> +
> +  adi,egy-time:
> +    description: Energy accumulation time setting for energy registers
> +    $ref: /schemas/types.yaml#/definitions/uint32

And another one that sounds like it would be more of a runtime
setting based on what type of data capture you are setting up.

> +

Power and reference voltage supplies are missing.

ref-supply, vdd-supply

And there is a clock input and a clock output that we could
add trivial bindings for.


> +required:
> +  - compatible
> +  - reg
> +  - reset-gpios
> +  - interrupts
> +  - interrupt-names
> +  - adi,wf-mode
> +  - adi,wf-src
> +
> +additionalProperties: false
> +
> +patternProperties:
> +  "^phase@[0-2]$":
> +    type: object
> +    description: |
> +      Represents the external phases which are externally connected. Each phase
> +      has a current, voltage and power component
> +
> +    properties:
> +      reg:
> +        description: |
> +          The phase represented by a number
> +          0 - Phase A
> +          1 - Phase B
> +          2 - Phase C
> +        $ref: /schemas/types.yaml#/definitions/uint32
> +        enum: [0, 1, 2]

If we are calling this an ADC, we should be using adc.yaml and
calling these channel@ rather than phase@. There could be a custom
adi,phase property for each channel if needed. But I'm guessing
IAP/IAN is always going to be phase A, IBP/IBN is always going to
be phase B, etc. so I'm not sure we actually need any special channel
properties at this point.

> +
> +    required:
> +      - reg
> +
> +    additionalProperties: false
> +