iio: dac: Add AD5413 support - #2786
Conversation
gastmaier
left a comment
There was a problem hiding this comment.
Added the warnings that caused the ci to exit with an error but were not logged
ba5d87d to
1401608
Compare
|
Hi, sorry for the pr failure, I updated the checkout strategy to retry by deepening the fetch until the rebase succeeds. please see CI output, checkpatch is failing for example |
|
Hi @dlech, @mhennerich, @nunojsa, All feedback so far has been addressed in the latest commits. Could you kindly take a look and let me know if anything else is required for approval? Thanks! |
15694b1 to
8174327
Compare
4674362 to
78b10cd
Compare
|
@BruceTsaoADI please properly rebase your patches on top of the target branch. |
6114e4f to
e196cfc
Compare
e196cfc to
fdad854
Compare
d859997 to
f41ce13
Compare
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. |
ae283b1 to
dcb3553
Compare
| #include <linux/property.h> | ||
| #include <linux/spi/spi.h> | ||
| #include <linux/units.h> | ||
| #include <linux/util_macros.h> |
There was a problem hiding this comment.
include paths should be in alphabetical order
|
|
||
| MODULE_AUTHOR("Bruce Tsao <bruce.tsao@analog.com>"); | ||
| MODULE_DESCRIPTION("Analog Devices AD5413 DAC"); | ||
| MODULE_LICENSE("GPL v2"); |
There was a problem hiding this comment.
seems like you have some warnings here
| { | ||
| struct ad5413_state *st; | ||
| struct iio_dev *indio_dev; | ||
| int ret, i; |
| return ad5413_spi_write_mask(st, | ||
| AD5413_REG_DAC_CONFIG, | ||
| AD5413_REG_DAC_CONFIG_OUT_EN_MSK, | ||
| FIELD_PREP(AD5413_REG_DAC_CONFIG_OUT_EN_MSK, 1)); |
There was a problem hiding this comment.
still issues with formatting
|
|
||
| *val = ret; | ||
| return IIO_VAL_INT; | ||
| } |
| if (ret < 0) { | ||
| return dev_err_probe(&st->spi->dev, ret, | ||
| "Failed to initiate a calibration memory refresh\n"); | ||
| } |
| /* | ||
| * Poll until the bit clears. ad5413_spi_reg_read() returns a negative | ||
| * errno on failure, so stop polling on error and propagate it. | ||
| */ |
There was a problem hiding this comment.
I would say you don't need to comment what the API does
| u32 cmd; | ||
|
|
||
| cmd = (u32)AD5413_WR_FLAG_MSK(AD5413_REG_TWO_STAGE_READBACK_SELECT) << 24; | ||
| cmd |= (u32)addr << 8; |
| if (ret < 0) | ||
| return ret; | ||
|
|
||
| return (be32_to_cpu(st->d32[2]) >> 8) & 0xFFFF; |
There was a problem hiding this comment.
Oh just noticed this now. Don't mix error codes (returns) with proper read values. It just makes it weird. Just pass in a proper u16 * pointer as a argument and set it:
*val = be32_to_cpu(st->d32[2]) >> 8
Then no need for the mask as we already have an implicit cast to u16
|
@BruceTsaoADI if you rebase again on top of testing so that only your two patches exist, we can trigger a final LLM review on your series before going upstream. |
1719553 to
55ab0e3
Compare
|
Done. Rebased on top of the latest testing with only the two patches. All review comments addressed. Ready for the final LLM review. |
|
@BruceTsaoADI we still 135 commits in the PR. You need to base your branch on the branch/tree |
|
Hi @nunojsa, I've rebased the branch onto the latest testing. The PR now contains only my two patches (dt-bindings + driver). I also addressed two minor items in the driver patch:
CI is still red, but the failure is unrelated to this series and happens before my code is compiled. The auto_set_kconfig step fails to load Kconfig: That file isn't touched by my patches, and the kernel's own Kconfig parser accepts this syntax fine (an arm64 build of the AD5413 driver passes locally). It looks like a pre-existing issue in the CI Kconfig helper on the current testing tip — all four build jobs fail at the same line regardless of arch/compiler. Could you advise how you'd like to proceed? Thanks! |
|
Updated the driver commit with the following changes:
Verified on hardware (Raspberry Pi 5 + EVAL-AD5413SDZ): cold-boot probe Only current-output mode has been tested so far; voltage-output mode is not The commit structure is unchanged (dt-bindings + driver). |
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>
The AD5413 is a single-channel, 14-bit, voltage and current output digital-to-analog converter (DAC) with programmable output ranges, slew rate control and on-chip diagnostics. Add an IIO driver supporting the +-10.5 V voltage range and the 0-24 mA current range, output enable, slew rate control and device reset over the SPI interface. The device powers up with the SPI CRC enabled, so every frame carries a CRC-8 byte and the interface is configured for SPI mode 1. This lets the driver bring the device up directly from a cold boot without any pre-conditioning. Signed-off-by: Bruce Tsao <bruce.tsao@analog.com>
|
CI is green now. The build failures were due to a missing Also: voltage-output mode is now hardware-verified (RPi5 SPI1 + EVAL-AD5413SDZ, Folded one fix into the driver commit: the voltage-channel IIO offset had a Both current- and voltage-output modes are now hardware-verified. |
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
ad5413.cunderdrivers/iio/dac/adi,ad5413.yamlunderDocumentation/devicetree/bindings/iio/dac/Datasheet:
https://www.analog.com/media/en/technical-documentation/data-sheets/ad5413.pdf
PR Description
necessary to understand them. List any dependencies required for this change.
any space), or simply check them after publishing the PR.
description and try to push all related PRs simultaneously.
PR Type
PR Checklist