The DS44xx devices have no reset pin or reset bit, so output registers
may retain preconfigured values across reboot or warm reset.
Also, the driver suspend/resume path restores from data->raw. When the
device is first probed, data->raw is zero-initialized and may not match
the actual hardware state. A later suspend/resume can therefore change an
output from a preconfigured non-zero value to 0 mA.
Initialize all channels to 0 output current during probe to ensure a
deterministic baseline and consistent suspend/resume behavior.
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
drivers/iio/dac/ds4424.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c
index a0c60eb89717..2d299a52cede 100644
--- a/drivers/iio/dac/ds4424.c
+++ b/drivers/iio/dac/ds4424.c
@@ -220,6 +220,20 @@ static int ds4424_verify_chip(struct iio_dev *indio_dev)
return ret;
}
+static int ds4424_init(struct iio_dev *indio_dev)
+{
+ int i, ret;
+
+ /* Set all channels to 0 current. */
+ for (i = 0; i < indio_dev->num_channels; i++) {
+ ret = ds4424_set_value(indio_dev, 0, &indio_dev->channels[i]);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
static int ds4424_setup_channels(struct i2c_client *client,
struct ds4424_data *data,
struct iio_dev *indio_dev)
@@ -397,6 +411,11 @@ static int ds4424_probe(struct i2c_client *client)
if (ret)
goto fail;
+ /* No reset pin/bit: clear any preconfigured output on probe. */
+ ret = ds4424_init(indio_dev);
+ if (ret)
+ goto fail;
+
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &ds4424_iio_info;
--
2.47.3
On Mon, 19 Jan 2026 19:24:22 +0100
Oleksij Rempel <o.rempel@pengutronix.de> wrote:
> The DS44xx devices have no reset pin or reset bit, so output registers
> may retain preconfigured values across reboot or warm reset.
>
> Also, the driver suspend/resume path restores from data->raw. When the
> device is first probed, data->raw is zero-initialized and may not match
> the actual hardware state. A later suspend/resume can therefore change an
> output from a preconfigured non-zero value to 0 mA.
For DACs we often want to retain settings from before kernel load (or
on exit of the driver). Can we just read them back from the device to
fill in the cached versions? If we can I think that would be preferred
option.
Jonathan
>
> Initialize all channels to 0 output current during probe to ensure a
> deterministic baseline and consistent suspend/resume behavior.
>
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
> drivers/iio/dac/ds4424.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/drivers/iio/dac/ds4424.c b/drivers/iio/dac/ds4424.c
> index a0c60eb89717..2d299a52cede 100644
> --- a/drivers/iio/dac/ds4424.c
> +++ b/drivers/iio/dac/ds4424.c
> @@ -220,6 +220,20 @@ static int ds4424_verify_chip(struct iio_dev *indio_dev)
> return ret;
> }
>
> +static int ds4424_init(struct iio_dev *indio_dev)
> +{
> + int i, ret;
> +
> + /* Set all channels to 0 current. */
> + for (i = 0; i < indio_dev->num_channels; i++) {
> + ret = ds4424_set_value(indio_dev, 0, &indio_dev->channels[i]);
> + if (ret < 0)
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> static int ds4424_setup_channels(struct i2c_client *client,
> struct ds4424_data *data,
> struct iio_dev *indio_dev)
> @@ -397,6 +411,11 @@ static int ds4424_probe(struct i2c_client *client)
> if (ret)
> goto fail;
>
> + /* No reset pin/bit: clear any preconfigured output on probe. */
> + ret = ds4424_init(indio_dev);
> + if (ret)
> + goto fail;
> +
> indio_dev->modes = INDIO_DIRECT_MODE;
> indio_dev->info = &ds4424_iio_info;
>
On Fri, Jan 23, 2026 at 09:38:04AM +0000, Jonathan Cameron wrote: > On Mon, 19 Jan 2026 19:24:22 +0100 > Oleksij Rempel <o.rempel@pengutronix.de> wrote: > > > The DS44xx devices have no reset pin or reset bit, so output registers > > may retain preconfigured values across reboot or warm reset. > > > > Also, the driver suspend/resume path restores from data->raw. When the > > device is first probed, data->raw is zero-initialized and may not match > > the actual hardware state. A later suspend/resume can therefore change an > > output from a preconfigured non-zero value to 0 mA. > > For DACs we often want to retain settings from before kernel load (or > on exit of the driver). Can we just read them back from the device to > fill in the cached versions? If we can I think that would be preferred > option. ACK, i was not sure what is the best way here. Best Regards, Oleksij -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
On Mon, Jan 19, 2026 at 07:24:22PM +0100, Oleksij Rempel wrote:
> The DS44xx devices have no reset pin or reset bit, so output registers
> may retain preconfigured values across reboot or warm reset.
>
> Also, the driver suspend/resume path restores from data->raw. When the
> device is first probed, data->raw is zero-initialized and may not match
> the actual hardware state. A later suspend/resume can therefore change an
> output from a preconfigured non-zero value to 0 mA.
>
> Initialize all channels to 0 output current during probe to ensure a
> deterministic baseline and consistent suspend/resume behavior.
...
> +static int ds4424_init(struct iio_dev *indio_dev)
> +{
> + int i, ret;
Why is 'i' signed?
> +
> + /* Set all channels to 0 current. */
> + for (i = 0; i < indio_dev->num_channels; i++) {
for (unsigned int i = ...) {
> + ret = ds4424_set_value(indio_dev, 0, &indio_dev->channels[i]);
> + if (ret < 0)
> + return ret;
> + }
> +
> + return 0;
> +}
--
With Best Regards,
Andy Shevchenko
© 2016 - 2026 Red Hat, Inc.