Skip to content

Add adaq2387x support - #3496

Open
DeaconescuDaniel wants to merge 9 commits into
mainfrom
add_adaq2387x_support
Open

Add adaq2387x support#3496
DeaconescuDaniel wants to merge 9 commits into
mainfrom
add_adaq2387x_support

Conversation

@DeaconescuDaniel

Copy link
Copy Markdown
Collaborator

PR Description

Add Linux support for the ADAQ23875, ADAQ23876, and ADAQ23878 ADCs on the Xilinx Zedboard. All three parts wrap the LTC2387 behind an integrated fully-differential amplifier. The 23875 has fixed FDA gain of 2; the 23876 and 23878 have a board-strapped gain (0.37, 0.73, 0.87, 1.38, or 2.25) that the driver needs to reflect in in_voltage_scale.

Changes:

  • Extend the LTC2387 driver: distinct info entries per compatible, new adi,gain-milli DT property, and adi,use-one-lane boolean to select the one lane bitstream.
  • Update the LTC2387 DT binding with adi,gain-milli (enum) and adi,use-one-lane (boolean).
  • Refactor the existing ADAQ23875/23878 device trees onto a shareddtsi (zynq-zed-adv7511-adaq2387x.dtsi) and add per-part dtsis + dts for the one lane versions
  • Add new ADAQ23876 board files (dtsi + two-lane .dts + one-lane .dts).

Tested on ADAQ23875 + Zedboard with one and two lane bitstreams

PR Type

  • Bug fix (a change that fixes an issue)
  • New feature (a change that adds new functionality)
  • Breaking change (a change that affects other repos or cause CIs to fail)

PR Checklist

  • I have conducted a self-review of my own code changes
  • I have compiled my changes, including the documentation
  • I have tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly
  • I have provided links for the relevant upstream lore

#include "zynq-zed-adv7511-adaq23875.dtsi"

&adaq23875 {
adi,use-one-lane;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

For

Replace the deprecated adi,use-two-lanes property with the updated
convention where two-lane operation is the default. Introduce
adi,use-one-lane to explicitly select single-lane mode.

the devicetree is not really about defaults, but the topology.
Not clear how adi,use-two-lanes -> adi,use-one-lane is future-proof.

Where/when was that discussed?

@DeaconescuDaniel DeaconescuDaniel Aug 26, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'd meant to ask about it in the pull request as i wasn't sure of what convention to follow when naming this property.
currently, we have:

  • num-lanes(int)
  • lane-mode(enum)
  • one-lane(my commits change it to two)
    Having two lanes as the default for the adaq drivers helps achieve the maximum sample rate of the chip, which is why i thought it made sense. It's worth discussing the exact naming convention for this property in order to fall in line with other adc implementations

@gastmaier gastmaier added the llm review Request a review from a LLM Reviewer label Aug 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

LLM review

This series adds ADAQ23875/76/78 (LTC2387-based) support: a driver cleanup
for iio: adc: ltc2387, new DT bindings/board files for Zedboard, and a
couple of unrelated cn0577/EEPROM DT tweaks.

run: 32902194316

2252799c1 - driver cleanup and ADAQ2387x compatibles

Regression: ltc2387_probe() now defaults gain_milli to 2000
unconditionally when adi,gain-milli is not in DT, for every compatible,
not just ADAQ2387x. The binding itself says this property is "only
meaningful for ADAQ2387x parts". Plain ltc2387-16/-16-x4/-18/-18-x4
boards without adi,gain-milli (zynq-zed-adv7511-cn0577.dts,
zynq-zed-adv7511-ltc2387.dts) will now report in_voltage_scale at
exactly half the correct value (verified numerically, and cross-checked the
FSR = Vref / gain formula against the ADAQ23875/76/78 datasheets). See
patch 1.

3ac52d973 - fix duty offset condition, sampling freq, default to two-lanes

Contains a dozen leftover pr_err("\nadaq2387 ...") bring-up traces that
are removed again in the very next commit. The final tree is clean, but
this intermediate commit is not really mergeable/bisectable on its own —
worth squashing before this lands upstream. The actual logic changes
(>= boundary fix for duty_offset_ns, computing sampling_freq from the
realized PWM period) look correct.

c02bc00f0 - update EEPROM node size and addressing

Changes the FMC ID EEPROM in the shared zynq-zed-adv7511.dtsi (included
by ~70 leaf board files) from at24,24c02 (256 B) to atmel,24c32 (4 KB,
different address width). Almost every other ADI FMC carrier .dts
(zc706, zc702, microblaze boards) uses at24,24c02 for the same node, which
matches the VITA-57.1 standard FMC ID EEPROM size. Could not verify this
against a Zedboard schematic (not available through the ADI doctools
mirror). Given the blast radius, please confirm against hardware/schematic
before merging.

CI warnings

The checkpatch warning for Documentation/devicetree/bindings/iio/adc/lltc,ltc2387.yaml
("DT binding docs and includes should be a separate patch") is reproducible
locally against 51bc6d878 (mixes the yaml binding update with new
.dts/.dtsi files). The other CI warnings (dtc duplicate unit-address in
adi-adrv9002.dtsi, kernel_smatch in kernel/module/main.c) are in files
not touched by this series and are unrelated pre-existing noise.

Regarding the review comment on the lltc,ltc2387.yaml filename: lltc is
a valid, pre-existing vendor prefix (Linear Technology Corp) distinct from
the ltc2387 part number, so the double l is not a typo.

Verification data

ADAQ23875, ADAQ23876 and ADAQ23878 datasheets were fetched from the
doctools docling mirror and used to confirm the FSR = Vref / gain scale
relationship and the 370/730/870/1380/2250 pin-strap gain enum in the
binding. Built for arm with xilinx_zynq_defconfig (set_arch gcc_arm);
drivers/iio/adc/ltc2387.o and all new/changed .dts files build cleanly
before and after the suggested fixups. A small Python model of the
IIO_VAL_FRACTIONAL scale math was used to numerically confirm the 2x
scale regression and the fix.

Suggested patches

Apply the suggested patches with:

cd path/to/repository
export GITHUB_TOKEN=ghp_***
apply-patches --repo=analogdevicesinc/linux 32902194316
Install instructions

The following one-liner installs the script if not present already:

curl -fSsL "https://raw.githubusercontent.com/analogdevicesinc/doctools/refs/heads/main/ci/scripts/apply-patches.sh"      -o ~/.local/bin/apply-patches.sh &&   grep -q "/apply-patches.sh" ~/.bashrc || echo "source ~/.local/bin/apply-patches.sh" >> $_ ; . $_

More information at AI Usage.

StancaPop and others added 9 commits August 26, 2026 15:03
Add the adi,channels DMA configuration, setting a 32-bit source bus
width (aligned with the 18-bit ADC output) and a 64-bit destination
width.

Replace the deprecated adi,use-two-lanes property with the updated
convention where two-lane operation is the default. Introduce
adi,use-one-lane to explicitly select single-lane mode.

Also fix the device title and add an HDL configuration note.

Signed-off-by: Stanca Pop <stanca.pop@analog.com>
Signed-off-by: Nicolae-Daniel Deaconescu <Nicolae-daniel.deaconescu@analog.com>
… default

Fix the duty offset boundary check to also handle the equal case, and
compute sampling_freq from the actual PWM period length rather than the
requested frequency.

Change the lane mode default to two-lanes, matching the reference HDL
which ships with TWOLANES=1, and introduce adi,use-one-lane for boards
wired for single-lane output.

Signed-off-by: Stanca Pop <stanca.pop@analog.com>
Signed-off-by: Nicolae-Daniel Deaconescu <Nicolae-daniel.deaconescu@analog.com>
Add device tree support for the ADAQ23875 (LTC2387-16, 16-bit) and
ADAQ23878 (LTC2387-18, 18-bit) uModule ADCs on the Xilinx Zedboard.

Shared carrier pieces live in adaq2387x.dtsi: the 4.096 V reference
regulator, the 120 MHz reference clock the HDL produces, the DMA
controller, the PWM generator driving CNV and CLK_EN, and the GPIOs for
the test-pattern and power-down pins. Per-part dtsis add the matching
DMA data width and instantiate the ADC node, and each part gets a
two-lane leaf .dts plus a -1lane variant for the reduced-throughput
bitstream.

Both parts declare adi,gain-milli for their front-end amplifier gain:
the ADAQ23875 is fixed at 2, while the ADAQ23878 is pin-strapped and
defaults here to 0.87.

Override the FMC FRU ID EEPROM to atmel,24c32 for these boards. The
EV-ADAQ2387xFMCZ carries a 24AA32A, which is 4 kbyte and needs 16-bit
addressing, whereas zynq-zed-adv7511.dtsi declares the 256-byte 8-bit
part. That node sits on axi_iic_fmc, reached through FMC LPC pins C30
and C31, so it describes the daughtercard rather than the carrier and
is overridden per board instead of in the shared file.

Signed-off-by: Stanca Pop <stanca.pop@analog.com>
Signed-off-by: Nicolae-Daniel Deaconescu <Nicolae-daniel.deaconescu@analog.com>
Document adi,gain-milli, the front-end amplifier gain of the ADAQ2387x
modules expressed as gain * 1000. The ADAQ23875 is fixed at 2; the
ADAQ23876 and ADAQ23878 are pin-selectable over 0.37 to 2.25. The bare
ltc2387-* parts have no amplifier, so they default to unity.

Document adi,use-one-lane, which selects one-lane DDR output instead of
the two-lane default, and vref-supply, which the driver already consumes.

Add the additionalProperties constraint and correct $id to match the
file name, both required by the current dt-schema meta-schema.

Signed-off-by: Nicolae-Daniel Deaconescu <Nicolae-daniel.deaconescu@analog.com>
Consolidated cleanup pass on the LTC2387 driver in preparation for the
ADAQ2387x variants:

  - Fix typos in the vref regulator error string and in the PWM
    disable callback name.
  - Change sampling_freq to u32 and drop unused struct fields.
  - Factor the DDR test patterns into named macros.
  - Split the ADAQ2387x compatibles into distinct info entries with
    per-variant .name so indio_dev->name reflects the actual board.
  - Cache vref_mv at probe instead of re-reading the regulator in
    read_raw.
  - Clamp the conversion period to the clk_gate period so the PWM
    core's stricter duty > period check is satisfied.

Signed-off-by: Nicolae-Daniel Deaconescu <Nicolae-daniel.deaconescu@analog.com>
The ADAQ2387x modules place a fully-differential amplifier ahead of the
LTC2387 die, so a code read back from the converter corresponds to a
smaller voltage at the SMA input than at the die. Read the amplifier
gain from adi,gain-milli and fold it into IIO_CHAN_INFO_SCALE so
in_voltage_scale is referred to the SMA input.

The default is carried per compatible rather than as a single constant:
the bare ltc2387-* parts have no amplifier and so default to unity,
while the adaq2387x parts default to 2. Using one global default would
have halved the reported scale on the plain LTC2387 boards, which do not
set the property.

Signed-off-by: Nicolae-Daniel Deaconescu <Nicolae-daniel.deaconescu@analog.com>
sampling_freq was derived from the conversion period the driver asked
the PWM core for, rather than the one the hardware ends up running. The
core truncates the period to whole ref_clk cycles, and a cycle count is
generally not an integer number of nanoseconds: at 120 MHz a 15 MHz
conversion period is 66.67 ns, so it has to be requested as 67 ns.
Dividing NSEC_PER_SEC by that rounded-up period reported 14.93 MHz for a
pin running at exactly 15 MHz.

The error is worse in one-lane mode, where the clk_en duty cycle forces
the period clamp and lands further from a cycle boundary: an 18-bit part
at 120 MHz reported 11.11 MHz while converting at 12 MHz, off by 7.4%.
That is enough to visibly misplace FFT bins for anyone who trusts
in_voltage_sampling_frequency.

Mirror the core's truncation to recover the cycle count and divide the
reference clock by it, which is exact for every supported combination of
reference clock, resolution and lane mode.

Signed-off-by: Nicolae-Daniel Deaconescu <Nicolae-daniel.deaconescu@analog.com>
read_raw() has always handled IIO_CHAN_INFO_SCALE, but no channel
advertised it, so IIO never created the attribute and the case was
unreachable from userspace. Applications had to hardcode the conversion
from raw codes to volts.

Advertise it via info_mask_shared_by_type, which yields a single
in_voltage_scale shared by every voltage channel rather than one
attribute per channel: the scale depends on the reference voltage and the
front-end gain, both of which are device-wide. Using
info_mask_shared_by_all instead would name the attribute plain "scale",
which libiio does not recognise as the channel scale.

On an ADAQ23875 with a 4.096 V reference and the fixed gain of 2 this
reports 0.062500000 mV/LSB, so the 16-bit code range spans the 4.096 V
peak-to-peak the SMA inputs accept.

Signed-off-by: Nicolae-Daniel Deaconescu <Nicolae-daniel.deaconescu@analog.com>
Introduce a common dtsi and two leaf .dts files for the ADAQ23876 on
Zedboard. The 23876 shares the LTC2387-16 die with the 23875, so the
digital protocol and DMA path are identical; only the front-end
amplifier gain differs. Default the gain to 0.87 (adi,gain-milli =
870); the -1lane variant additionally sets adi,use-one-lane for the
reduced-throughput HDL bitstream.

Signed-off-by: Nicolae-Daniel Deaconescu <Nicolae-daniel.deaconescu@analog.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm review Request a review from a LLM Reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants