Skip to content

iio: dac: Add AD5413 support#2786

Open
BruceTsaoADI wants to merge 8 commits intoanalogdevicesinc:mirror_ci/jic23/iio/testingfrom
BruceTsaoADI:add-ad5413-driver
Open

iio: dac: Add AD5413 support#2786
BruceTsaoADI wants to merge 8 commits intoanalogdevicesinc:mirror_ci/jic23/iio/testingfrom
BruceTsaoADI:add-ad5413-driver

Conversation

@BruceTsaoADI
Copy link
Copy Markdown

Summary

This PR adds initial support for the Analog Devices AD5413, a 14-bit single-channel DAC capable of voltage and current output.

Key changes

  • New driver: ad5413.c under drivers/iio/dac/
  • Devicetree binding: adi,ad5413.yaml under Documentation/devicetree/bindings/iio/dac/
  • Integrated with Kconfig and Makefile

Datasheet:

https://www.analog.com/media/en/technical-documentation/data-sheets/ad5413.pdf

PR Description

  • Please replace this comment with a summary of your changes, and add any context
    necessary to understand them. List any dependencies required for this change.
  • To check the checkboxes below, insert a 'x' between square brackets (without
    any space), or simply check them after publishing the PR.
  • If you changes include a breaking change, please specify dependent PRs in the
    description and try to push all related PRs simultaneously.

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 tested the changes on the relevant hardware
  • I have updated the documentation outside this repo accordingly (if there is the case)

Copy link
Copy Markdown
Collaborator

@gastmaier gastmaier left a comment

Choose a reason for hiding this comment

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

Added the warnings that caused the ci to exit with an error but were not logged

Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread Documentation/devicetree/bindings/iio/dac/adi,ad5413.yaml Outdated
Comment thread Documentation/devicetree/bindings/iio/dac/adi,ad5413.yaml Outdated
Comment thread Documentation/devicetree/bindings/iio/dac/adi,ad5413.yaml Outdated
Comment thread Documentation/devicetree/bindings/iio/dac/adi,ad5413.yaml Outdated
Comment thread Documentation/devicetree/bindings/iio/dac/adi,ad5413.yaml Outdated
Comment thread drivers/iio/dac/ad5413.c
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread drivers/iio/dac/ad5413.c
Comment thread Documentation/devicetree/bindings/iio/dac/adi,ad5413.yaml Outdated
Comment thread Documentation/devicetree/bindings/iio/dac/adi,ad5413.yaml Outdated
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread drivers/iio/dac/ad5413.c
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread drivers/iio/dac/ad5413.c Outdated
@BruceTsaoADI BruceTsaoADI force-pushed the add-ad5413-driver branch 3 times, most recently from ba5d87d to 1401608 Compare June 29, 2025 05:51
Comment thread Documentation/devicetree/bindings/iio/dac/adi,ad5413.yaml Outdated
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread Documentation/devicetree/bindings/iio/dac/adi,ad5413.yaml
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread drivers/iio/dac/ad5413.c Outdated
Comment thread drivers/iio/dac/ad5413.c Outdated
@gastmaier
Copy link
Copy Markdown
Collaborator

gastmaier commented Jul 4, 2025

Hi, sorry for the pr failure, I updated the checkout strategy to retry by deepening the fetch until the rebase succeeds.
(It is not mega clear to me why it was failing in the first place, the total depth should be 7 (ahead + behind), but rebase only succeeds with around 24 or so.)

please see CI output, checkpatch is failing for example

Comment thread Documentation/devicetree/bindings/iio/dac/adi,ad5413.yaml Outdated
@BruceTsaoADI
Copy link
Copy Markdown
Author

Hi @dlech, @mhennerich, @nunojsa,

All feedback so far has been addressed in the latest commits.
CI still shows some false positives (e.g. checkpatch whitespace), but local checks pass with --strict and no errors.

Could you kindly take a look and let me know if anything else is required for approval?

Thanks!

@BruceTsaoADI BruceTsaoADI force-pushed the add-ad5413-driver branch 9 times, most recently from 15694b1 to 8174327 Compare September 14, 2025 09:41
@BruceTsaoADI
Copy link
Copy Markdown
Author

Thanks for the detailed review and for pointing this out again.

I went through the comments and addressed them in the updated series.
I also changed the PR base branch to mirror_ci/jic23/iio/testing as suggested so it runs with the stricter CI.

After rebasing onto that branch, the PR now only contains the two upstream-relevant patches:

  1. dt-bindings
  2. iio: dac: add AD5413 driver

All checks are passing now.

@gastmaier gastmaier force-pushed the mirror_ci/jic23/iio/testing branch 4 times, most recently from 4674362 to 78b10cd Compare April 27, 2026 00:12
@nunojsa
Copy link
Copy Markdown
Collaborator

nunojsa commented Apr 27, 2026

@BruceTsaoADI please properly rebase your patches on top of the target branch.

@gastmaier gastmaier force-pushed the mirror_ci/jic23/iio/testing branch 8 times, most recently from 6114e4f to e196cfc Compare May 5, 2026 00:12
maxskiier and others added 6 commits May 5, 2026 13:45
Replace mutex_lock() and mutex_unlock() calls in rm3100-core.c with
the more modern guard(mutex)() family. This will help modernize the
driver and bring it up-to-date with modern available macros/functions.

While replacing mutex_lock() and mutex_unlock(), the critical sections
of rm3100_read_mag() and rm3100_get_samp_freq() have been extended to
include negligible operations for cleaner logic.

Add new helper-wrapper function rm3100_guarded_regmap_bulk_read() to
help keep rm3100_trigger_handler() switch-cases clean while maintaining
mutex locking and avoiding re-entrancy risks from potential callbacks.

While at it, remove redundant gotos where applicable, and use direct
returns instead. In addition, remove regmap variable in
rm3100_trigger_handler() as its references have been replaced with
variable data.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Maxwell Doose <m32285159@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Rewrite MCP3422_CHANNEL_MASK, MCP3422_SRATE_MASK, MCP3422_PGA_MASK
and MCP3422_CONT_SAMPLING using GENMASK() and BIT() macros from
bits.h.

The other macros MCP3422_SRATE_{240, 60, 15, 3} were not changed
because they are also used as array indices.

Signed-off-by: Marcelo Machado Lage <marcelomlage@usp.br>
Co-developed-by: Vinicius Lira <vinilira@usp.br>
Signed-off-by: Vinicius Lira <vinilira@usp.br>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Replace manual bit manipulations with FIELD_GET(), FIELD_PREP() and
FIELD_MODIFY() calls. The resulting code is more readable and
maintainable, and 6 macros previously defined in the header are not
needed anymore.

Signed-off-by: Marcelo Machado Lage <marcelomlage@usp.br>
Co-developed-by: Vinicius Lira <vinilira@usp.br>
Signed-off-by: Vinicius Lira <vinilira@usp.br>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Use guard(mutex)() for handling mutex lock instead of
manually locking and unlocking the mutex. This prevents forgotten
locks due to early exits and removes the need of gotos.

Signed-off-by: Pedro Barletta Gennari <pedro.pbg@usp.br>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Handle errors as early as possible by replacing 'if (!ret)' with the
more common form 'if (ret)'. This makes the code easier to read.

Signed-off-by: Pedro Barletta Gennari <pedro.pbg@usp.br>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
patch ci

Signed-off-by: CSE CI <cse-ci-notifications@analog.com>
@gastmaier gastmaier force-pushed the mirror_ci/jic23/iio/testing branch from e196cfc to fdad854 Compare May 6, 2026 00:11
Document the devicetree bindings for the Analog Devices AD5413, a
single-channel precision DAC controlled via SPI. The device supports
voltage or current output modes and programmable slew-rate control.

Signed-off-by: Bruce Tsao <bruce.tsao@analog.com>
Signed-off-by: Bruce Tsao <bruce.tsao@analog.com>
@BruceTsaoADI
Copy link
Copy Markdown
Author

BruceTsaoADI commented May 6, 2026

@BruceTsaoADI please properly rebase your patches on top of the target branch.

Thanks @nunojsa .

I fetched the latest mirror_ci/jic23/iio/testing target branch and rebased the two AD5413 patches on top of fdad854.

The PR branch has been force-pushed again. CI is now passing and there are no conflicts with the base branch.

@gastmaier gastmaier force-pushed the mirror_ci/jic23/iio/testing branch 4 times, most recently from 4783e10 to ae283b1 Compare May 10, 2026 00:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants