[PATCH v1 2/2] iio: dac: ad5504: use adi,output-range-volts for scale calculation
From: Taha Ed-Dafili
Date: Thu Feb 12 2026 - 13:21:33 EST
The driver previously used VCC to calculate the scale, but the datasheet
states the output range is fixed by the R_SEL pin (0-30V or 0-60V).
Update probe to read `adi,output-range-volts` for the scale. Default
to the 60V range if the property is missing, while keeping the VCC
regulator enable for power.
Suggested-by: David Lechner <dlechner@xxxxxxxxxxxx>
Signed-off-by: Taha Ed-Dafili <0rayn.dev@xxxxxxxxx>
---
drivers/iio/dac/ad5504.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c
index 355bcb6a8ba0..1796a9b1e750 100644
--- a/drivers/iio/dac/ad5504.c
+++ b/drivers/iio/dac/ad5504.c
@@ -15,6 +15,7 @@
#include <linux/regulator/consumer.h>
#include <linux/module.h>
#include <linux/bitops.h>
+#include <linux/property.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
@@ -274,6 +275,7 @@ static int ad5504_probe(struct spi_device *spi)
struct iio_dev *indio_dev;
struct ad5504_state *st;
int ret;
+ u32 val;
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
if (!indio_dev)
@@ -281,17 +283,21 @@ static int ad5504_probe(struct spi_device *spi)
st = iio_priv(indio_dev);
- ret = devm_regulator_get_enable_read_voltage(&spi->dev, "vcc");
- if (ret < 0 && ret != -ENODEV)
+ ret = devm_regulator_get_enable(&spi->dev, "vcc");
+ if (ret)
return ret;
- if (ret == -ENODEV) {
- if (pdata->vref_mv)
- st->vref_mv = pdata->vref_mv;
- else
- dev_warn(&spi->dev, "reference voltage unspecified\n");
- } else {
- st->vref_mv = ret / 1000;
- }
+
+ ret = device_property_read_u32(&spi->dev, "adi,output-range-volts", &val);
+ if (ret)
+ val = 60;
+
+ if (val == 60)
+ st->vref_mv = 60000;
+ else
+ st->vref_mv = 30000;
+
+ if (pdata && pdata->vref_mv)
+ st->vref_mv = pdata->vref_mv;
st->spi = spi;
indio_dev->name = spi_get_device_id(st->spi)->name;
--
2.47.3