Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for adaq776x-1 series and add missing features #2587

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 67 additions & 5 deletions Documentation/devicetree/bindings/iio/adc/adi,ad7768-1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,26 @@
$id: http://devicetree.org/schemas/iio/adc/adi,ad7768-1.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Analog Devices AD7768-1 ADC device driver
title: Analog Devices AD7768-1 ADC family device driver

maintainers:
- Michael Hennerich <[email protected]>

description: |
Datasheet at:
https://www.analog.com/media/en/technical-documentation/data-sheets/ad7768-1.pdf
Analog Devices AD7768-1 24-Bit Single Channel Low Power sigma-delta ADC family

https://www.analog.com/media/en/technical-documentation/data-sheets/ad7768-1.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/adaq7767-1.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/adaq7768-1.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/adaq7769-1.pdf

properties:
compatible:
const: adi,ad7768-1
enum:
- adi,ad7768-1
- adi,adaq7767-1
- adi,adaq7768-1
- adi,adaq7769-1

reg:
maxItems: 1
Expand All @@ -39,6 +47,23 @@ properties:
description:
ADC reference voltage supply

adi,aaf-gain:
description: |
Specifies the gain of the Analog Anti-Aliasing Filter (AAF) applied to the
ADC input, measured in milli-units. The AAF provides additional signal
rejection within the frequency range of fs ± f3dB, where fs is the sampling
frequency, and f3dB is the -3dB cutoff frequency. The specific values of
fs and f3dB, as well as the rejection intensity, depend on the digital
filter configuration.

This parameter is required for the ADAQ7767-1 and ADAQ7769-1 devices.
The gain is determined by the selected input pin:
* For the ADAQ7767-1: The input selection of IN1±, IN2± or IN3±.
* For the ADAQ7769-1: The connections of OUT_PGA to IN1_AAF+, IN2_AAF+,
or IN3_AAF+.
$ref: /schemas/types.yaml#/definitions/uint16
enum: [143, 364, 1000]

adi,sync-in-gpios:
maxItems: 1
description:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good to also have a dt check for the gain property.

allOf:
  # Gain property only applies to ADAQ devices
  - if:
      properties:
        compatible:
          not:
            contains:
              enum:
                - adi,adaq7767-1
                - adi,adaq7768-1
                - adi,adaq7769-1
    then:
      properties:
        adi,gain-milli: false

Expand All @@ -47,6 +72,15 @@ properties:
in any way, for example if the filter decimation rate changes.
As the line is active low, it should be marked GPIO_ACTIVE_LOW.

adi,sync-in-spi:
description:
Enables synchronization of multiple devices over SPI. This property is
used when a signal synchronous to the base MCLK signal cannot be provided
via GPIO. It requires the SYNC_OUT pin to be connected to the SYNC_IN pin
on the ADC. In the case of multiple devices, the SYNC_OUT pin of one device
should be routed to the SYNC_IN pins of the other devices.
type: boolean

reset-gpios:
maxItems: 1

Expand All @@ -65,7 +99,6 @@ required:
- vref-supply
- spi-cpol
- spi-cpha
- adi,sync-in-gpios
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't do it all together. One patch for the new parts, another one for the updates to sync pins.
Also, the dt-binding patches should come before the driver changes that use the new dt properties.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noted

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put the gain property and related checks in the same patch that adds the new parts and put the changes related to adi,sync-in-spi property in a separate patch. That's what I wanted to say previously.


patternProperties:
"^channel@([0-9]|1[0-5])$":
Expand All @@ -89,6 +122,35 @@ patternProperties:
allOf:
- $ref: /schemas/spi/spi-peripheral-props.yaml#

# AAF Gain property only applies to ADAQ7767-1 and ADAQ7769-1 devices
- if:
properties:
compatible:
contains:
enum:
- adi,adaq7767-1
- adi,adaq7769-1
then:
required:
adi,aaf-gain
else:
properties:
adi,aaf-gain: false

# adi,sync-in-gpios and adi,sync-in-spi are mutually exclusive (neither is also valid)
- if:
required:
- adi,sync-in-gpios
then:
properties:
adi,sync-in-spi: false
- if:
required:
- adi,sync-in-spi
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this be something that we could assume in the absence of adi,sync-in-gpios or do we really need to be explicit?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's what we have decided for the synchronization:

  • Using GPIO: We define adi,sync-in-gpios and route the GPIO pin to the SYNC_IN pin on the board.
  • Using SPI command: We define the adi,sync-in-spi and route the SYNC_OUT pin to the SYNC_IN pin in the eval board.
  • We also have the option to do use none of them, but in this case the SYNC_IN pulse should be providaded by an external device or another source (e.g., when multiple devices are involved).

If you believe the third option doesn’t need support, we could consider the absence of adi,sync-in-gpios as indicative of the SPI command synchronization. I think it’s good to include the adi,sync-in-spi option, because it clarifies the need to route SYNC_OUT to SYNC_IN for proper operation.

then:
properties:
adi,sync-in-gpios: false

unevaluatedProperties: false

examples:
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/boot/dts/zynq-zed-adv7511-ad7768-1-evb.dts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
};

axi_spi_engine_0: spi@0x44a00000 {
compatible = "adi,axi-spi-engine-1.00.a";
compatible = "adi-ex,axi-spi-engine-1.00.a";
reg = <0x44a00000 0x1000>;
interrupt-parent = <&intc>;
interrupts = <0 56 IRQ_TYPE_LEVEL_HIGH>;
Expand Down
103 changes: 103 additions & 0 deletions arch/arm/boot/dts/zynq-zed-adv7511-adaq7767-1-evb.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Analog Devices ADAQ7767-1
* https://wiki.analog.com/resources/eval/user-guides/ad7768-1
*
* hdl_project: <ad77681evb/zed>
* board_revision: <B>
*
* Copyright (C) 2024 Analog Devices Inc.
*/
/dts-v1/;

#include "zynq-zed.dtsi"
#include "zynq-zed-adv7511.dtsi"
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/gpio/gpio.h>

/ {
vref: regulator-vref {
compatible = "regulator-fixed";
regulator-name = "fixed-supply";
regulator-min-microvolt = <4096000>;
regulator-max-microvolt = <4096000>;
regulator-always-on;
};

clocks {
ad7768_1_mclk: clock@0 {
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <16384000>;
};
};
};

&fpga_axi {
rx_dma: rx-dmac@0x44a30000 {
compatible = "adi,axi-dmac-1.00.a";
reg = <0x44a30000 0x1000>;
#dma-cells = <1>;
interrupt-parent = <&intc>;
interrupts = <0 57 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clkc 16>;

adi,channels {
#size-cells = <0>;
#address-cells = <1>;

dma-channel@0 {
reg = <0>;
adi,source-bus-width = <32>;
adi,source-bus-type = <1>;
adi,destination-bus-width = <64>;
adi,destination-bus-type = <0>;
};
};
};

spi_clock: spieng-axi-clkgen@44a70000 {
compatible = "adi,axi-clkgen-2.00.a";
reg = <0x44a70000 0x10000>;
#clock-cells = <0>;
clocks = <&clkc 15>, <&clkc 16>;
clock-names = "s_axi_aclk", "clkin1";
};

axi_spi_engine_0: spi@0x44a00000 {
compatible = "adi-ex,axi-spi-engine-1.00.a";
reg = <0x44a00000 0x1000>;
interrupt-parent = <&intc>;
interrupts = <0 56 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clkc 15 &spi_clock>;
clock-names = "s_axi_aclk", "spi_clk";
num-cs = <1>;

#address-cells = <0x1>;
#size-cells = <0x0>;

adaq7767_1: adc@0 {
compatible = "adi,adaq7767-1";
reg = <0>;
spi-max-frequency = <40000000>;
spi-cpol;
spi-cpha;
vref-supply = <&vref>;
adi,sync-in-spi;
adi,aaf-gain = /bits/ 16 <143>;
reset-gpios = <&gpio0 86 GPIO_ACTIVE_LOW>;
clocks = <&ad7768_1_mclk>;
clock-names = "mclk";
dmas = <&rx_dma 0>;
dma-names = "rx";
#io-channel-cells = <1>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add

			#address-cells = <1>;
			#size-cells = <0>;

			channel@0 {
				reg = <0>;
				label = "channel_0";
			};

as documented in Documentation/devicetree/bindings/iio/adc/adi,ad7768-1.yaml

#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
label = "channel_0";
};
};
};
};
102 changes: 102 additions & 0 deletions arch/arm/boot/dts/zynq-zed-adv7511-adaq7768-1-evb.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Analog Devices ADAQ7768-1
* https://wiki.analog.com/resources/eval/user-guides/ad7768-1
*
* hdl_project: <ad77681evb/zed>
* board_revision: <B>
*
* Copyright (C) 2024 Analog Devices Inc.
*/
/dts-v1/;

#include "zynq-zed.dtsi"
#include "zynq-zed-adv7511.dtsi"
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/gpio/gpio.h>

/ {
vref: regulator-vref {
compatible = "regulator-fixed";
regulator-name = "fixed-supply";
regulator-min-microvolt = <4096000>;
regulator-max-microvolt = <4096000>;
regulator-always-on;
};

clocks {
ad7768_1_mclk: clock@0 {
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <16384000>;
};
};
};

&fpga_axi {
rx_dma: rx-dmac@0x44a30000 {
compatible = "adi,axi-dmac-1.00.a";
reg = <0x44a30000 0x1000>;
#dma-cells = <1>;
interrupt-parent = <&intc>;
interrupts = <0 57 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clkc 16>;

adi,channels {
#size-cells = <0>;
#address-cells = <1>;

dma-channel@0 {
reg = <0>;
adi,source-bus-width = <32>;
adi,source-bus-type = <1>;
adi,destination-bus-width = <64>;
adi,destination-bus-type = <0>;
};
};
};

spi_clock: spieng-axi-clkgen@44a70000 {
compatible = "adi,axi-clkgen-2.00.a";
reg = <0x44a70000 0x10000>;
#clock-cells = <0>;
clocks = <&clkc 15>, <&clkc 16>;
clock-names = "s_axi_aclk", "clkin1";
};

axi_spi_engine_0: spi@0x44a00000 {
compatible = "adi-ex,axi-spi-engine-1.00.a";
reg = <0x44a00000 0x1000>;
interrupt-parent = <&intc>;
interrupts = <0 56 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clkc 15 &spi_clock>;
clock-names = "s_axi_aclk", "spi_clk";
num-cs = <1>;

#address-cells = <0x1>;
#size-cells = <0x0>;

adaq7768_1: adc@0 {
compatible = "adi,adaq7768-1";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't really checked but can we have a common dtsi and then dedicated dts files just for different pieces?

reg = <0>;
spi-max-frequency = <40000000>;
spi-cpol;
spi-cpha;
vref-supply = <&vref>;
adi,sync-in-spi;
reset-gpios = <&gpio0 86 GPIO_ACTIVE_LOW>;
clocks = <&ad7768_1_mclk>;
clock-names = "mclk";
dmas = <&rx_dma 0>;
dma-names = "rx";
#io-channel-cells = <1>;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, add channel subnode.

#address-cells = <1>;
#size-cells = <0>;

channel@0 {
reg = <0>;
label = "channel_0";
};
};
};
};
Loading