Skip to content
Draft
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
17 changes: 17 additions & 0 deletions Documentation/ABI/testing/sysfs-bus-iio
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,23 @@ Contact: [email protected]
Description:
Hardware dependent values supported by the oversampling filter.

What: /sys/bus/iio/devices/iio:deviceX/oversampling_frequency
KernelVersion: 6.17
Contact: [email protected]
Description:
Some devices have internal clocks for oversampling. Sets the
resulting frequency in Hz to trigger a conversion used by the
oversampling filter. If the device has a fixed internal clock
or is computed based on the sampling frequency parameter, the
parameter is read only.

What: /sys/bus/iio/devices/iio:deviceX/oversampling_frequency_available
KernelVersion: 6.17
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
KernelVersion: 2.6.35
Expand Down
151 changes: 151 additions & 0 deletions Documentation/devicetree/bindings/iio/adc/adi,ad4052.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
# 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:
minItems: 1
maxItems: 2

interrupt-names:
items:
- const: gp0
description: Signal coming from the GP0 pin.
- const: gp1
description: Signal coming from the GP1 pin.

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 1 IRQ_TYPE_EDGE_FALLING>;
interrupt-names = "gp1";
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>;
};
};
139 changes: 139 additions & 0 deletions Documentation/iio/ad4052.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
.. 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.

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

The ADC contains only one channel with following attributes:

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

* - Attribute
- Description
* - ``in_voltage_calibscale``
- Scale factor to multiply the raw value.
* - ``in_voltage_raw``
- Raw ADC voltage value
* - ``in_voltage_oversampling_ratio``
- Enable the device's burst averaging mode to over sample using the
internal sample rate.
* - ``in_voltage_oversampling_ratio_available``
- List of available oversampling values. Value 1 disable the burst
averaging mode.
* - ``in_voltage_sampling_frequency``
- Set the sampling frequency, only present if SPI Offload is being used.

Also contain the following device attributes:

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

* - Attribute
- Description
* - ``oversamling_frequency``
- Frequency used in the burst averaging mode, sets the device internal
sample rate when the mode is activated.
* - ``oversampling_frequency_available``
- List of available sample rates.

Interrupts
==========

The cell of trigger-sources of the parent node sets which GPIO has the role of
data ready signal. If not present, defaults as ``gp0``. If not set in the
``interrupt-names`` property, 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

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

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

* - Attribute
- Description
* - ``in_voltage_sampling_frequency``
- Set the sampling frequency.

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.
1 change: 1 addition & 0 deletions Documentation/iio/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Industrial I/O Kernel Drivers
ad3552r
ad4000
ad4030
ad4052
ad4695
ad7191
ad7380
Expand Down
8 changes: 8 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,14 @@ F: Documentation/devicetree/bindings/iio/adc/adi,ad4030.yaml
F: Documentation/iio/ad4030.rst
F: drivers/iio/adc/ad4030.c

ANALOG DEVICES INC AD4052 DRIVER
M: Jorge Marques <[email protected]>
S: Supported
W: https://ez.analog.com/linux-software-drivers
F: Documentation/devicetree/bindings/iio/adc/adi,ad4052.yaml
F: Documentation/iio/ad4052.rst
F: drivers/iio/adc/ad4052.c

ANALOG DEVICES INC AD4080 DRIVER
M: Antoniu Miclaus <[email protected]>
L: [email protected]
Expand Down
15 changes: 15 additions & 0 deletions drivers/iio/adc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,21 @@ config AD4030
To compile this driver as a module, choose M here: the module will be
called ad4030.

config AD4052
tristate "Analog Devices AD4052 Driver"
depends on SPI
depends on GPIOLIB
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 AD4080
tristate "Analog Devices AD4080 high speed ADC"
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_AB8500_GPADC) += ab8500-gpadc.o
obj-$(CONFIG_AD_SIGMA_DELTA) += ad_sigma_delta.o
obj-$(CONFIG_AD4000) += ad4000.o
obj-$(CONFIG_AD4030) += ad4030.o
obj-$(CONFIG_AD4052) += ad4052.o
obj-$(CONFIG_AD4080) += ad4080.o
obj-$(CONFIG_AD4130) += ad4130.o
obj-$(CONFIG_AD4170_4) += ad4170-4.o
Expand Down
Loading
Loading