Skip to content

add support for AD3532R/AD3532 DAC#3177

Open
kseerp wants to merge 3 commits into
analogdevicesinc:mirror_ci/jic23/iio/testingfrom
kseerp:dev/ad3532r
Open

add support for AD3532R/AD3532 DAC#3177
kseerp wants to merge 3 commits into
analogdevicesinc:mirror_ci/jic23/iio/testingfrom
kseerp:dev/ad3532r

Conversation

@kseerp
Copy link
Copy Markdown
Member

@kseerp kseerp commented Mar 10, 2026

PR Description

Add support for the AD3532R/AD3532 16-channel, 16-bit voltage output DAC.
These devices use a dual-bank register architecture with base addresses at
0x1000 (bank 0) and 0x3000 (bank 1). Channels 0-7 are mapped to bank 0,
while channels 8-15 are mapped to bank 1.

Key Changes:

  • Add AD3532R dual-bank register definitions
  • Add ad3532r_input_ch_reg() and ad3532r_trigger_sw_ldac_reg() for
    bank-aware register addressing
  • Convert sw_ldac_trig_reg from a static register value to a per-variant
    function pointer to support bank-dependent SW LDAC triggering
  • Add AD3532R-specific powerdown modes (1kohm, 10kohm, three-state)
  • Add ad3532r_set_dac_powerdown() to handle the 4-register powerdown
    mapping across both banks
  • Extract ad3530r_normal_op_mode() and extend ad3530r_setup() to
    configure dual-bank software reset, output range, and reference control
  • Expand per-channel state array to accommodate 16 channels

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

@gastmaier
Copy link
Copy Markdown
Collaborator

Same as #3191, if you are upstreaming, please target branches in sync with upstream cycle (the mirror_ci branches), this helps to avoid using deprecated methods.

@kseerp kseerp changed the base branch from main to mirror_ci/jic23/iio/testing March 27, 2026 05:14
@kseerp kseerp force-pushed the dev/ad3532r branch 4 times, most recently from 6b805e2 to 45351b7 Compare March 27, 2026 07:52
@kseerp
Copy link
Copy Markdown
Member Author

kseerp commented Mar 27, 2026

v2:

  • change target branch to mirror_ci/jic23/iio/testing
  • replace magic numbers in ad3532r_set_dac_powerdown() with channel arithmetic instead of switch case

@gastmaier gastmaier force-pushed the mirror_ci/jic23/iio/testing branch 7 times, most recently from 71cdaf3 to 4b97d37 Compare April 3, 2026 00:00
@gastmaier
Copy link
Copy Markdown
Collaborator

Please, don't include the CI/CD commit on your pr.
the upstream branch can also be rebased. base your work in the latest tag, or near the head if your work depends on a pending patch.

@gastmaier gastmaier force-pushed the mirror_ci/jic23/iio/testing branch 2 times, most recently from c87d572 to 0579d93 Compare April 4, 2026 23:59
@gastmaier gastmaier force-pushed the mirror_ci/jic23/iio/testing branch 2 times, most recently from 78b10cd to be1b2a6 Compare April 28, 2026 00:13
@kseerp kseerp added the llm review Request a review from a LLM Reviewer label Apr 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

LLM review

This series adds support for the AD3532R/AD3532 (16-channel) DAC to the existing ad3530r driver, along with a new 10kohm_to_gnd powerdown mode in the IIO ABI.

run: ci/local

0c649c5742ff - iio: dac: ad3530r: Add support for AD3532R/AD3532

Wrong SW LDAC trigger register for AD3530/AD3530R channels 0-3:

The new ad3530r_trigger_sw_ldac_reg() function is shared by all non-AD3532 chip variants (ad3530, ad3530r, ad3531, ad3531r). For AD3530/AD3530R (8-channel devices), channels 0-3 incorrectly return register 0xDD (the AD3531R register) instead of 0xE5:

static int ad3530r_trigger_sw_ldac_reg(unsigned int channel)
{
    if (channel < AD3531R_MAX_CHANNELS)  // < 4
        return AD3531R_SW_LDAC_TRIG_A;  // 0xDD  <- WRONG for AD3530/AD3530R
    return AD3530R_SW_LDAC_TRIG_A;      // 0xE5
}

The AD3530R datasheet (confirmed via register map extraction) shows that SW_LDAC_TRIG for the AD3530R is at address 0xE5 for all channels 0-7. The AD3531R uses 0xDD. This means DAC writes to channels 0-3 on AD3530/AD3530R will trigger an LDAC on the wrong register, resulting in no DAC output update.

The fix is to split into two functions — one that unconditionally returns 0xE5 for AD3530/AD3530R, and one that unconditionally returns 0xDD for AD3531/AD3531R.

f33f9972031a - iio: ABI: add DAC 10kohm_to_gnd powerdown mode

Grammar: "via an 10kOhm resistor" should be "via a 10kOhm resistor". The numeral 10 is pronounced "ten" (consonant onset), and all other entries in the same list use the article "a" consistently.

Kconfig: drivers/iio/dac/Kconfig help text lists AD3532R but omits AD3532 (non-R variant).

DT binding description: Documentation/devicetree/bindings/iio/dac/adi,ad3530r.yaml description block was not updated to mention the AD3532/AD3532R (16-channel) family.

CI warnings

The checkpatch DT binding docs and includes should be a separate patch warning is a false positive — the DT binding is correctly split into its own commit (dac3c24832f5).

Verification data

  • AD3530/AD3530R datasheet downloaded from analog.com and register map extracted with extract_register_map.py to verify SW_LDAC_TRIG addresses (0xE5), OUTPUT_OPERATING_MODE register addresses (0x20/0x21), and powerdown mode bit encodings.
  • AD3531/AD3531R datasheet extracted to verify SW_LDAC_TRIG address (0xDD).
  • Driver compiled for ARM (gcc_arm, CONFIG_AD3530R=y) — clean build.

Suggested patches

Apply the suggested patches with:

cd path/to/repository
git am 0001-fixup-iio-dac-ad3530r-Add-support-for-AD3532R-AD3532.patch
git am 0002-fixup-iio-ABI-add-DAC-10kohm_to_gnd-powerdown-mode.patch
Install instructions

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

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

More information at AI Usage.

@gastmaier gastmaier force-pushed the mirror_ci/jic23/iio/testing branch 8 times, most recently from e196cfc to fdad854 Compare May 6, 2026 00:11
@gastmaier gastmaier force-pushed the mirror_ci/jic23/iio/testing branch 7 times, most recently from 1719553 to 55ab0e3 Compare May 13, 2026 00:11
Add a new powerdown mode for DACs with 10kohm resistor to GND.

Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
kseerp added 2 commits May 13, 2026 19:43
The AD3532R/AD3532 is a 16-channel version of the AD3530R/AD3530.
This adds compatible strings for the AD3532R/AD3532.

Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
The AD3532R/AD3532 is a 16-channel, 16-bit voltage output DAC with a
dual-bank register architecture (bank 0 at 0x1000 for channels 0-7,
bank 1 at 0x3000 for channels 8-15).

Add dual-bank register definitions, bank-aware helper functions for
input channel addressing and SW LDAC triggering, AD3532R-specific
powerdown modes (1kohm, 10kohm, three-state), and extend the setup and
normal operating mode paths to configure both register banks.

Convert sw_ldac_trig_reg from a static value to a per-variant function
pointer and expand the per-channel state array to 16 channels.

Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
@kseerp
Copy link
Copy Markdown
Member Author

kseerp commented May 13, 2026

v4

  • fix SW LDAC trigger register for AD3530/AD3530R channels 0-3 by splitting into per-variant functions
  • add datasheet link on the bindings
  • fix grammar in ABI doc

@kseerp
Copy link
Copy Markdown
Member Author

kseerp commented May 13, 2026

there seems to be a CI issue that's why it's failing

@kseerp kseerp removed the llm review Request a review from a LLM Reviewer label May 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

LLM review

This series adds support for the AD3532R/AD3532 16-channel DAC to the existing ad3530r driver, adds the 10kohm_to_gnd powerdown mode to the IIO ABI, and updates the DT bindings.

run: 25798407816

cb6456db3 - iio: dac: ad3530r: Add support for AD3532R/AD3532

Style bug: Double space in ad3530r_chip info struct at drivers/iio/dac/ad3530r.c:483:

-	.sw_ldac_trig_reg =  ad3530r_trigger_sw_ldac_reg,
+	.sw_ldac_trig_reg = ad3530r_trigger_sw_ldac_reg,

Unannounced bug fix bundled in: The commit silently fixes a pre-existing bug for AD3531R — it was previously using AD3530R powerdown modes (1kohm/7.7kohm/32kohm) instead of the correct AD3531R modes (500ohm/3.85kohm/16kohm), as confirmed by the AD3531R datasheet (Table 70, page 38). The fix is correct but should appear in a separate commit with an appropriate message so it can be bisected and backported independently.

CI warnings

The checkpatch warnings for AD3530R_CHAN() macro arguments _chan and _ext_info being "not used" are false positives — both arguments are used in the macro body (.channel = _chan, .ext_info = _ext_info). checkpatch is confused by the compound initializer syntax that begins with a bare {.

Verification data

The AD3532R datasheet (ad3532r.pdf) was obtained from https://www.analog.com/media/en/technical-documentation/data-sheets/ad3532r.pdf, register tables were extracted with camelot-py, and used to verify all 14 register address constants in the driver, the four powerdown mode bit encodings (Tables 67–69), and the dual-bank register layout. The AD3531R datasheet (ad3531r.pdf) was similarly obtained and used to confirm the corrected powerdown modes (Table 70, page 38). All register addresses and powerdown mode values match the datasheet. Build verified with gcc_arm and gcc_aarch64.

Suggested patches

Apply the suggested patches with:

cd path/to/repository
export GITHUB_TOKEN=ghp_***
apply-patches --repo=analogdevicesinc/linux 25798407816
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.

@github-actions
Copy link
Copy Markdown
Contributor

LLM review

This series adds support for the AD3532R/AD3532 16-channel DAC to the existing ad3530r driver, adds the 10kohm_to_gnd powerdown mode to the IIO ABI documentation, and corrects the powerdown mode names exposed for the AD3531R (previously they showed AD3530R names: 1kohm/7.7kohm/32kohm, now corrected to 500ohm/3.85kohm/16kohm per the AD3531R datasheet).

run: 25798530886

27a12d97 - iio: dac: ad3530r: Add support for AD3532R/AD3532

Cosmetic: trailing double-space in ad3530r_chip initializer (ad3530r.c:483):

.sw_ldac_trig_reg =  ad3530r_trigger_sw_ldac_reg,  /* two spaces after = */

AD3532R_MAX_REG_ADDR is too small by 2 bytes:

The datasheet (Table 40, p.46) lists INPUT_CHn at 0x10EB to 0x10F9 (increments of 2) for bank 0 and 0x30EB to 0x30F9 for bank 1. With val_bits = 8 the regmap accesses two consecutive byte addresses per 16-bit channel register. INPUT_CH15 spans 0x30F9 (high byte) through 0x30FA (low byte). The current AD3532R_MAX_REG_ADDR = 0x30F8 is two addresses short; it should be 0x30FA.

While this does not cause a functional failure in practice (because regmap_writeable_noinc() returns true by default for registers not in a no-increment table, which causes the per-element writeable check in _regmap_raw_write_impl() to be skipped for the bulk write path), it is semantically incorrect and leaves the regmap configuration mismatched with the real register map.

Verification: The AD3532R datasheet (ad3532r.pdf, Rev. 0) was downloaded from analog.com and converted to a register map using extract_register_map.py. Page 44/46 confirms INPUT_CHn address range 0x10EB–0x10F9 / 0x30EB–0x30F9 (increments of 2), meaning the last low-byte address for INPUT_CH15 is 0x30FA.

CI warnings

The checkpatch warning for WARNING: Argument '_chan' is not used in function-like macro at ad3530r.c:422 is a false positive — both _chan and _ext_info are referenced inside the struct initializer body (.channel = _chan and .ext_info = _ext_info). This is a known limitation of checkpatch.pl with multi-line struct initializer macros.

Verification data

The AD3532R datasheet was obtained from https://www.analog.com/media/en/technical-documentation/data-sheets/ad3532r.pdf, converted to a register map using python3 extract_register_map.py ad3532r.pdf, and used to verify register addresses for OUTPUT_OPERATING_MODE_0–3, SW_LDAC_TRIG_0/1, INPUT_CHn, and INTERFACE_CONFIG_A. The AD3531R datasheet was also fetched and confirmed that its OUTPUT_OPERATING_MODE register encodes 01=500Ω, 10=3.85kΩ, 11=16kΩ, validating the new ad3531r_powerdown_modes[] array.

Suggested patches

Apply the suggested patches with:

cd path/to/repository
export GITHUB_TOKEN=ghp_***
apply-patches --repo=analogdevicesinc/linux 25798530886
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.

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.

2 participants