Skip to content
Closed
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
160 changes: 160 additions & 0 deletions Documentation/devicetree/bindings/iio/adc/adi,ad4052.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
# 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 <jorge.marques@analog.com>

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:
description:
Two pins are available that can be configured as either a general purpose
digital output, device enable signal (used to synchronise other parts of
the signal chain with ADC sampling), device ready (GP1 only) or various
interrupt signals. If intended for use as a GPIO or device enable, will not
present here.
minItems: 1
items:
- description:
GP0 pin, cannot be configured as DEV_RDY.
- description:
GP1 pin, can be configured to any setting.

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

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

pwms:
maxItems: 1
description: PWM connected to the CNV pin.

trigger-sources:
minItems: 1
maxItems: 2
description:
Describes the output pin and event associated.

"#trigger-source-cells":
const: 2
description: |
Output pins used as trigger source.

Cell 0 defines the event:
* 0 = Data ready
* 1 = Min threshold
* 2 = Max threshold
* 3 = Either threshold
* 4 = CHOP control
* 5 = Device enable
* 6 = Device ready (only GP1)

Cell 1 defines which pin:
* 0 = GP0
* 1 = GP1

For convenience, macros for these values are available in
dt-bindings/iio/adc/adi,ad4052.h.

spi-max-frequency:
maximum: 83333333

vdd-supply:
description: Analog power supply.

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

ref-supply:
description:
Reference voltage to set the ADC full-scale range. If not present,
vdd-supply is used as the reference voltage.

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>
#include <dt-bindings/iio/adc/adi,ad4052.h>

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

adc@0 {
compatible = "adi,ad4052";
reg = <0>;
vdd-supply = <&vdd>;
vio-supply = <&vio>;
ref-supply = <&ref>;
spi-max-frequency = <83333333>;

interrupt-parent = <&gpio>;
interrupts = <0 0 IRQ_TYPE_EDGE_RISING>;
interrupt-names = "gp0";
cnv-gpios = <&gpio 2 GPIO_ACTIVE_HIGH>;
};
};
- |
#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/iio/adc/adi,ad4052.h>

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

trigger-sources = <&adc AD4052_TRIGGER_EVENT_DATA_READY
AD4052_TRIGGER_PIN_GP1>;

adc@0 {
compatible = "adi,ad4052";
reg = <0>;
vdd-supply = <&vdd>;
vio-supply = <&vio>;
spi-max-frequency = <83333333>;
pwms = <&adc_trigger 0 10000 0>;

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>;
};
};
142 changes: 142 additions & 0 deletions Documentation/iio/ad4052.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
.. 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 an 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.

The two programmable GPIOS are optional and have a role assigned if present in
the devicetree ``interrupt-names`` property:

- GP0: Is assigned the role of Threshold Either signal.
- GP1: Is assigned the role of Data Ready signal.

If the property ``gpio-controller`` is present in the devicetree, then the GPO
not present in the ``interrupt-names`` is exposed as a GPO.

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

The ADC contains only one channel with following attributes:

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

* - Attribute
- Description
* - ``in_voltage_calibscale``
- Sets the gain scaling factor that the hardware applies to the sample,
to compensate for system gain error.
* - ``in_voltage_oversampling_ratio``
- Sets device's burst averaging mode to over sample using the
internal sample rate. Value 1 disable the burst averaging mode.
* - ``in_voltage_oversampling_ratio_available``
- List of available oversampling values.
* - ``in_voltage_raw``
- Returns the raw ADC voltage value.
* - ``in_voltage_scale``
- Returns the channel scale in reference to the reference voltage
``ref-supply`` or ``vdd-supply`` if the former not present.
* - ``in_voltage_sampling_frequency``
- Sets the internal sample rate (fosc) used in burst averaging mode.
The scan duration is ``(n_avg - 1) / fosc + tconv``, where
``n_avg`` is the oversampling ratio and ``tconv`` is the ADC
conversion time.
* - ``in_voltage_sampling_frequency_available``
- Lists the available sampling frequencies. If the oversampling
ratio is 1, the frequency is ``1/tconv``.

Interrupts
==========

The ``interrupt-names`` ``gp0`` entry sets the role of Threshold signal, and
entry ``gp1`` sets the role of Data Ready signal. If it is not, the driver will
not wait for the data ready assertion, and will result in reading a sample
before it's ready, particularly in oversampling mode.

A second element in the ``interrupt-names`` property sets which GPIO has the
role of the threshold event. If not provided, the IIO events attributes are
still present, but no IIO Event will ever be triggered. This allows to use the
GPIO output to trigger other resource.

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

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.

The following event attributes are available:

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

* - Attribute
- Description
* - ``sampling_frequency``
- Frequency used in the monitoring mode, sets the device internal sample
rate when the mode is activated.
* - ``sampling_frequency_available``
- List of available sample rates.
* - ``thresh_either_en``
- Enable monitoring mode.
* - ``thresh_falling_hysteresis``
- Set the hysteresis value for the minimum threshold.
* - ``thresh_falling_value``
- Set the minimum threshold value.
* - ``thresh_rising_hysteresis``
- Set the hysteresis value for the maximum threshold.
* - ``thresh_rising_value``
- Set the maximum threshold value.

GPO controller support
======================

The device supports using GP0 and GP1 as GPOs. If the devicetree contains the
node ``gpio-controller```, the device is marked as a GPIO controller and the
GPs not listed in ``interrupt-names`` are exposed as a GPO. The GPIO index
matches the pin name, so if GP0 is not exposed but GP1 is, index 0 is masked
out and only index 1 can be set.
1 change: 1 addition & 0 deletions Documentation/iio/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Industrial I/O Kernel Drivers
ad3552r
ad4000
ad4030
ad4052
ad4695
ad7191
ad7380
Expand Down
13 changes: 5 additions & 8 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -1296,16 +1296,13 @@ F: Documentation/devicetree/bindings/iio/adc/adi,ad4000.yaml
F: Documentation/iio/ad4000.rst
F: drivers/iio/adc/ad4000.c

AD4030 ADC DRIVER (AD4030-24/AD4630-16/AD4630-24/AD4632-16/AD4632-24)
M: Michael Hennerich <michael.hennerich@analog.com>
M: Nuno Sá <nuno.sa@analog.com>
R: Esteban Blanc <eblanc@baylibre.com>
L: linux-iio@vger.kernel.org
ANALOG DEVICES INC AD4052 DRIVER
M: Jorge Marques <jorge.marques@analog.com>
S: Supported
W: https://ez.analog.com/linux-software-drivers
F: Documentation/devicetree/bindings/iio/adc/adi,ad4030.yaml
F: Documentation/iio/ad4030.rst
F: drivers/iio/adc/ad4030.c
F: Documentation/devicetree/bindings/iio/adc/adi,ad4052.yaml
F: Documentation/iio/ad4052.rst
F: drivers/iio/adc/ad4052.c

ANALOG DEVICES INC AD4130 DRIVER
M: Cosmin Tanislav <cosmin.tanislav@analog.com>
Expand Down
Loading
Loading