Skip to content

Add support for AD4052 ADC Family #2642

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
16 changes: 16 additions & 0 deletions Documentation/ABI/testing/sysfs-bus-iio
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Description:
What: /sys/bus/iio/devices/iio:deviceX/sampling_frequency
What: /sys/bus/iio/devices/iio:deviceX/in_intensity_sampling_frequency
What: /sys/bus/iio/devices/iio:deviceX/buffer/sampling_frequency
What: /sys/bus/iio/devices/iio:deviceX/events/sampling_frequency
What: /sys/bus/iio/devices/triggerX/sampling_frequency
KernelVersion: 2.6.35
Contact: [email protected]
Expand Down Expand Up @@ -138,6 +139,21 @@ Contact: [email protected]
Description:
Hardware dependent values supported by the oversampling filter.

What: /sys/bus/iio/devices/iio:deviceX/oversampling_frequency
KernelVersion: 6.15
Contact: [email protected]
Description:
Some devices have internal clocks for the ADC oversampling.
Sets the resulting sampling frequency to trigger a conversion
used by the oversampling filter.

What: /sys/bus/iio/devices/iio:deviceX/oversampling_frequency_available
KernelVersion: 6.15
Contact: [email protected]
Description:
Hardware dependent values supported by the oversampling
frequency.

What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_raw
What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_raw
What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_i_raw
Expand Down
98 changes: 98 additions & 0 deletions Documentation/devicetree/bindings/iio/adc/adi,ad4052.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
# Copyright 2025 Analog Devices Inc.
%YAML 1.2
---
$id: http://devicetree.org/schemas/iio/adc/adi,ad4052.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Analog Devices AD4052 ADC family device driver

maintainers:
- Jorge Marques <[email protected]>

description: |
Analog Devices AD4052 Single Channel Precision SAR ADC family

https://www.analog.com/media/en/technical-documentation/data-sheets/ad4050-ad4056.pdf
https://www.analog.com/media/en/technical-documentation/data-sheets/ad4052-ad4058.pdf

properties:
compatible:
enum:
- adi,ad4050
- adi,ad4052
- adi,ad4056
- adi,ad4058

reg:
maxItems: 1

interrupts:
items:
- description: Signal coming from the GP0 pin (threshold).
- description: Signal coming from the GP1 pin (data ready).

interrupt-names:
items:
- const: gp0
- const: gp1

gpio-controller: true

"#gpio-cells":
const: 2
description: |
The first cell is the GPn number: 0 to 1.
The second cell takes standard GPIO flags.

cnv-gpios:
description: The Convert Input (CNV). If omitted, CNV is tied to SPI CS.
maxItems: 1

spi-max-frequency:
maximum: 62500000

vdd-supply:
description: Analog power supply.

vio-supply:
description: Digital interface logic power supply.

vref-supply:
description: Reference voltage to set the ADC full-scale range.

required:
- compatible
- reg
- vdd-supply
- vio-supply

allOf:
- $ref: /schemas/spi/spi-peripheral-props.yaml#

unevaluatedProperties: 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,ad4052";
reg = <0>;
vdd-supply = <&adc_vdd>;
vio-supply = <&adc_vio>;
spi-max-frequency = <25000000>;

interrupt-parent = <&gpio>;
interrupts = <0 0 IRQ_TYPE_EDGE_RISING>,
<0 1 IRQ_TYPE_EDGE_FALLING>;
interrupt-names = "gp0", "gp1";
cnv-gpios = <&gpio 2 GPIO_ACTIVE_HIGH>;
};
};
...
95 changes: 95 additions & 0 deletions Documentation/iio/ad4052.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
.. SPDX-License-Identifier: GPL-2.0-only

=============
AD4052 driver
=============

ADC driver for Analog Devices Inc. AD4052 and similar devices.
The module name is ``ad4052``.

Supported devices
=================

The following chips are supported by this driver:

* `AD4050 <https://www.analog.com/AD4050>`_
* `AD4052 <https://www.analog.com/AD4052>`_
* `AD4056 <https://www.analog.com/AD4056>`_
* `AD4058 <https://www.analog.com/AD4058>`_

Wiring modes
============

The ADC uses SPI 4-wire mode, and contain two programmable GPIOs and
a CNV pin.

The CNV pin is exposed as the ``cnv-gpios`` and triggers a ADC conversion.
GP1 is ADC conversion ready signal and GP0 Threshold event interrupt, both
exposed as interrupts.

Omit ``cnv-gpios`` and tie CNV and CS together to use the rising edge
of the CS as the CNV signal.

Device attributes
=================

The ADC contain only one channels, and the following attributes:

.. list-table:: Driver attributes
:header-rows: 1

* - Attribute
- Description
* - ``in_voltage0_raw``
- Raw ADC voltage value
* - ``in_voltage0_oversampling_ratio``
- Enable the device's burst averaging mode to over sample using
the internal sample rate.
* - ``in_voltage0_oversampling_ratio_available``
- List of available oversampling values. Value 0 disable the burst
averaging mode.
* - ``conversion_frequency``
- Device internal sample rate used in the burst averaging mode.
* - ``conversion_frequency_available``
- List of available sample rates.

Threshold events
================

The ADC supports a monitoring mode to raise threshold events.
The driver supports a single interrupt for both rising and falling
readings.

The feature is enabled/disabled by setting ``thresh_either_en``.
During monitor mode, the device continuously operates in autonomous mode until
put back in configuration mode, due to this, the device returns busy until the
feature is disabled.

Low-power mode
==============

The device enters low-power mode on idle to save power.
Enabling an event puts the device out of the low-power since the ADC
autonomously samples to assert the event condition.

SPI offload support
===================

To be able to achieve the maximum sample rate, the driver can be used with the
`AXI SPI Engine`_ to provide SPI offload support.

.. _AXI SPI Engine: http://analogdevicesinc.github.io/hdl/projects/ad4052_ardz/index.html

When SPI offload is being used, additional attributes are present:

.. list-table:: Additional attributes
:header-rows: 1

* - Attribute
- Description
* - ``in_voltage0_sampling_frequency``
- Set the sampling frequency.
* - ``in_voltage0_sampling_frequency_available``
- Get the sampling frequency range.

The scan type is different when the buffer with offload support is enabled.
109 changes: 109 additions & 0 deletions arch/arm/boot/dts/xilinx/zynq-coraz7s-ad4052.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Analog Devices AD4052
*
* hdl_project: <ad4052_ardz/coraz7s>
*
* Copyright (C) 2025 Analog Devices Inc.
*/

/dts-v1/;
#include "zynq-coraz7s.dtsi"
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/gpio/gpio.h>

/ {
adc_vdd: regulator-vref-adc {
compatible = "regulator-fixed";
regulator-name = "adc-vdd";
regulator-min-microvolt = <3600000>;
regulator-max-microvolt = <3600000>;
regulator-always-on;
};

adc_vio: regulator-vio-adc {
compatible = "regulator-fixed";
regulator-name = "adc_vio";
regulator-min-microvolt = <3600000>;
regulator-max-microvolt = <3600000>;
regulator-always-on;
};
};

&fpga_axi {
axi_iic: i2c@41600000 {
compatible = "xlnx,axi-iic-1.01.b", "xlnx,xps-iic-2.00.a";
reg = <0x41600000 0x10000>;
interrupt-parent = <&intc>;
interrupts = <0 55 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clkc 15>;
clock-names = "s_axi_aclk";

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

eeprom1: eeprom@52 {
compatible = "atmel,24c32";
reg = <0x52>;
};

};

rx_dma: rx-dmac@44a30000 {
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 15>;
};

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

adc_trigger: pwm@44b00000 {
compatible = "adi,axi-pwmgen-2.00.a";
reg = <0x44b00000 0x1000>;
#pwm-cells = <2>;
clocks = <&spi_clk>;
};

axi_spi_engine: spi@44a00000 {
compatible = "adi,axi-spi-engine-1.00.a";
reg = <0x44a00000 0x1FF>;
interrupt-parent = <&intc>;
interrupts = <0 56 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clkc 15>, <&spi_clk>;
clock-names = "s_axi_aclk", "spi_clk";

dmas = <&rx_dma 0>;
dma-names = "offload0-rx";
trigger-sources = <&ad4052>;

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

ad4052: ad4052@0 {
compatible = "adi,ad4052";
reg = <0>;
vdd-supply = <&adc_vdd>;
vio-supply = <&adc_vio>;
spi-max-frequency = <31250000>;

#trigger-source-cells = <0>;
pwms = <&adc_trigger 0 10000 0>;

interrupt-parent = <&gpio0>;
interrupts = <86 IRQ_TYPE_EDGE_RISING>,
<87 IRQ_TYPE_EDGE_FALLING>;
interrupt-names = "gp0", "gp1";
cnv-gpios = <&gpio0 88 GPIO_ACTIVE_HIGH>;
};
};
};
1 change: 1 addition & 0 deletions drivers/iio/Kconfig.adi
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ config IIO_ALL_ADI_DRIVERS
imply ADXL380_SPI if SPI

imply AD4000
imply AD4052
imply AD4630
imply AD4695
imply AD4130
Expand Down
14 changes: 14 additions & 0 deletions drivers/iio/adc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ config AD4000
To compile this driver as a module, choose M here: the module will be
called ad4000.

config AD4052
tristate "Analog Devices AD4052 Driver"
depends on SPI
select SPI_OFFLOAD
select IIO_BUFFER
select IIO_BUFFER_DMAENGINE
select REGMAP_SPI
help
Say yes here to build support for Analog Devices AD4052 SPI analog
to digital converters (ADC).

To compile this driver as a module, choose M here: the module will be
called ad4052.

config AD4134
tristate "Analog Device AD4134 ADC Driver"
depends on SPI
Expand Down
1 change: 1 addition & 0 deletions drivers/iio/adc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ obj-$(CONFIG_AD4130) += ad4130.o
obj-$(CONFIG_AD_PULSAR) += ad_pulsar.o
obj-$(CONFIG_AD400X) += ad400x.o
obj-$(CONFIG_AD4000) += ad4000.o
obj-$(CONFIG_AD4052) += ad4052.o
obj-$(CONFIG_AD4134) += ad4134.o
obj-$(CONFIG_AD4630) += ad4630.o
obj-$(CONFIG_AD6676) += ad6676.o
Expand Down
Loading
Loading