AD4691 driver

ADC driver for Analog Devices Inc. AD4691 family of multichannel SAR ADCs. The module name is ad4691.

Supported devices

The following chips are supported by this driver:

  • AD4691 — 16-channel, 500 kSPS

  • AD4692 — 16-channel, 1 MSPS

  • AD4693 — 8-channel, 500 kSPS

  • AD4694 — 8-channel, 1 MSPS

IIO channels

Each physical ADC input maps to one IIO voltage channel. The AD4691 and AD4692 expose 16 channels (voltage0 through voltage15); the AD4693 and AD4694 expose 8 channels (voltage0 through voltage7).

All channels share a common scale (in_voltage_scale), derived from the reference voltage. Each channel independently exposes:

  • in_voltageN_raw — single-shot ADC result

  • in_voltageN_sampling_frequency — per-channel effective output rate, defined as the internal oscillator frequency divided by the channel’s oversampling ratio. Writing this attribute selects the nearest achievable rate for the current OSR; the value read back reflects the actual rate after snapping to the closest valid oscillator entry.

  • in_voltageN_sampling_frequency_available — list of achievable effective rates for the channel’s current oversampling ratio. The list updates dynamically when the oversampling ratio changes.

The following attributes are only available in CNV Burst Mode:

  • in_voltageN_oversampling_ratio — per-channel hardware oversampling depth; see Oversampling below.

  • in_voltageN_oversampling_ratio_available — valid ratios: 1, 2, 4, 8, 16, 32.

Operating modes

The driver supports two operating modes, selected automatically from the device tree at probe time.

Manual Mode

Selected when no pwms property is present in the device tree. The CNV pin is tied to the SPI chip-select: every CS assertion triggers a conversion and returns the previous result. A user-defined IIO trigger (e.g. hrtimer trigger) drives the buffer.

Oversampling is not supported in Manual Mode.

CNV Burst Mode

Selected when a pwms property is present in the device tree. A PWM drives the CNV pin at the configured conversion rate. A GP pin wired to the SoC and declared in the device tree signals DATA_READY at the end of each burst, triggering a readout of all active channel results into the IIO buffer.

The buffer output rate is controlled by the sampling_frequency attribute on the IIO buffer. In practice the PWM rate should be set low enough to allow the SPI readout to complete before the next conversion burst begins.

Autonomous Mode (idle / single-shot)

When the IIO buffer is disabled, in_voltageN_raw reads perform a single conversion on the requested channel using the internal oscillator. The oscillator is started and stopped around each read to save power.

Oversampling

In CNV Burst Mode each channel has an independent hardware accumulator that averages a configurable number of successive conversions. The result is always returned as a 16-bit mean, so realbits and storagebits are unaffected by the oversampling ratio. Valid ratios are 1, 2, 4, 8, 16 and 32; the default is 1 (no averaging). Oversampling is not supported in Manual Mode.

# Set oversampling ratio to 16 on channel 0
echo 16 > /sys/bus/iio/devices/iio:device0/in_voltage0_oversampling_ratio

# Read the resulting effective sampling frequency
cat /sys/bus/iio/devices/iio:device0/in_voltage0_sampling_frequency

Writing oversampling_ratio stores the new depth for that channel; the internal oscillator is unaffected. The effective rate read back via in_voltageN_sampling_frequency becomes osc_freq / new_osr automatically. oversampling_ratio and sampling_frequency are orthogonal: one controls averaging depth, the other controls the oscillator.

All channels share one internal oscillator. Writing sampling_frequency for any channel updates the oscillator and therefore affects the effective rate read back from all other channels.

Reference voltage

The driver supports two reference configurations, mutually exclusive:

  • External reference (ref-supply): a voltage between 2.4 V and 5.25 V supplied externally.

  • Buffered internal reference (refin-supply): an internal reference buffer is enabled by the driver.

Exactly one of ref-supply or refin-supply must be present in the device tree. The reference voltage determines the full-scale range reported via in_voltage_scale.

LDO supply

The chip contains an internal LDO that powers part of the analog front-end. The supply configuration is mutually exclusive:

  • External VDD (vdd-supply): an external 1.8 V supply is used directly; the internal LDO is disabled.

  • Internal LDO (ldo-in-supply): the internal LDO is enabled and fed from the ldo-in regulator. Use this when no external 1.8 V VDD is present.

Exactly one of vdd-supply or ldo-in-supply must be provided.

Reset

The driver supports two reset mechanisms:

  • Hardware reset (reset-gpios in device tree): asserted at probe by the reset controller framework.

  • Software reset (fallback when reset-gpios is absent): written automatically at probe.

GP pins and interrupts

The chip exposes up to four general-purpose (GP) pins. In CNV Burst Mode (non-offload), one GP pin must be wired to an interrupt-capable SoC input and declared in the device tree using the interrupts and interrupt-names properties. The interrupt-names value identifies which GP pin is used ("gp0" through "gp3").

Example device tree fragment:

adc@0 {
    compatible = "adi,ad4692";
    ...
    interrupts = <17 IRQ_TYPE_LEVEL_HIGH>;
    interrupt-parent = <&gpio0>;
    interrupt-names = "gp0";
};

SPI offload support

When a SPI offload engine (e.g. the AXI SPI Engine) is present, the driver uses DMA-backed transfers for CPU-independent, high-throughput data capture. SPI offload is detected automatically at probe; if no offload hardware is available the driver falls back to the software triggered-buffer path.

Two SPI offload sub-modes exist:

CNV Burst offload

Used when a pwms property is present and SPI offload is available. The PWM drives CNV at the configured rate; on DATA_READY the offload engine reads all active channel results and streams them directly to the IIO DMA buffer with no CPU involvement. The GP pin used as DATA_READY trigger is supplied by the trigger-source consumer at buffer enable time; no interrupt-names entry is required.

Manual offload

Used when no pwms property is present and SPI offload is available. A periodic SPI offload trigger controls the conversion rate and the offload engine streams results directly to the IIO DMA buffer.

The sampling_frequency attribute on the IIO buffer controls the trigger rate (in Hz). The initial rate is 100 kHz.

Oversampling is not supported in Manual Mode.