[PATCH 14/22] iio: dac: ad5686: add support for missing power supplies

Rodrigo Alencar via B4 Relay
2026-04-22T14:46:24Z

From: Rodrigo Alencar <rodrigo.alencar@analog.com>

Get optional regulators for vdd, vlogic and vref input power pins. vdd is
the input power supply, while vlogic powers the digital side. vref is
replacing vcc, which is being deprecated, but still supported. The value
of vref_mv is checked so that a device without internal voltage reference
cannot proceed without an explicit supply. Error report uses
dev_err_probe(), which helps debugging an init issue.

Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
drivers/iio/dac/ad5686.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/dac/ad5686.c b/drivers/iio/dac/ad5686.c
index 07a944311f0e..4989404a7b6e 100644
--- a/drivers/iio/dac/ad5686.c
+++ b/drivers/iio/dac/ad5686.c
@@ -7,6 +7,7 @@

#include <linux/array_size.h>
#include <linux/bitfield.h>
+#include <linux/dev_printk.h>
#include <linux/err.h>
#include <linux/export.h>
#include <linux/module.h>
@@ -471,13 +472,27 @@ int ad5686_probe(struct device *dev,
st->read = read;
st->chip_info = chip_info;

- ret = devm_regulator_get_enable_read_voltage(dev, "vcc");
+ ret = devm_regulator_get_enable_optional(dev, "vdd");
+ if (ret && ret != -ENODEV)
+ return dev_err_probe(dev, ret, "failed to enable vdd supply\n");
+
+ ret = devm_regulator_get_enable_optional(dev, "vlogic");
+ if (ret && ret != -ENODEV)
+ return dev_err_probe(dev, ret, "failed to enable vlogic supply\n");
+
+ ret = devm_regulator_get_enable_read_voltage(dev, "vref");
+ if (ret == -ENODEV) /* vcc-supply is deprecated, but supported still */
+ ret = devm_regulator_get_enable_read_voltage(dev, "vcc");
if (ret < 0 && ret != -ENODEV)
- return ret;
+ return dev_err_probe(dev, ret, "failed to read vref voltage\n");

st->use_internal_vref = ret == -ENODEV;
st->vref_mv = st->use_internal_vref ? st->chip_info->int_vref_mv : ret / 1000;

+ if (!st->vref_mv)
+ return dev_err_probe(dev, -EINVAL,
+ "invalid or not provided vref voltage\n");
+
/* Set all the power down mode for all channels to 1K pulldown */
st->pwr_down_mode = ~0U;
st->pwr_down_mask = ~0U;

--
2.43.0