Re: [PATCH v2 5/5] iio: dac: ad5504: add optional GPIO control for CLR and LDAC
From: Nuno Sá
Date: Wed Mar 11 2026 - 07:58:52 EST
On Tue, 2026-03-10 at 17:48 +0000, Taha Ed-Dafili wrote:
> Add support for the optional 'clear-gpios' and 'ldac-gpios' properties
> defined in the device tree bindings.
>
> Use devm_gpiod_get_optional() with GPIOD_OUT_LOW to ensure the pins are
> initialized to their inactive state.
>
> Signed-off-by: Taha Ed-Dafili <0rayn.dev@xxxxxxxxx>
> ---
> drivers/iio/dac/ad5504.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/drivers/iio/dac/ad5504.c b/drivers/iio/dac/ad5504.c
> index cd563460fc0a..58538f5263fc 100644
> --- a/drivers/iio/dac/ad5504.c
> +++ b/drivers/iio/dac/ad5504.c
> @@ -7,7 +7,9 @@
>
> #include <linux/bits.h>
> #include <linux/device.h>
> +#include <linux/err.h>
> #include <linux/errno.h>
> +#include <linux/gpio/consumer.h>
> #include <linux/interrupt.h>
> #include <linux/kernel.h>
> #include <linux/mod_devicetable.h>
> @@ -48,6 +50,8 @@
> * @vref_mv: actual reference voltage used
> * @pwr_down_mask: power down mask
> * @pwr_down_mode: current power down mode
> + * @gpio_clear: GPIO descriptor for the /CLR pin
> + * @gpio_ldac: GPIO descriptor for the /LDAC pin
> * @data: transfer buffer
> */
> struct ad5504_state {
> @@ -56,6 +60,8 @@ struct ad5504_state {
> unsigned short vref_mv;
> unsigned pwr_down_mask;
> unsigned pwr_down_mode;
> + struct gpio_desc *gpio_clear;
> + struct gpio_desc *gpio_ldac;
>
> __be16 data[2] __aligned(IIO_DMA_MINALIGN);
> };
> @@ -299,6 +305,14 @@ static int ad5504_probe(struct spi_device *spi)
> if (pdata && pdata->vref_mv)
> st->vref_mv = pdata->vref_mv;
>
> + st->gpio_clear = devm_gpiod_get_optional(dev, "clear", GPIOD_OUT_LOW);
> + if (IS_ERR(st->gpio_clear))
> + return PTR_ERR(st->gpio_clear);
> +
> + st->gpio_ldac = devm_gpiod_get_optional(dev, "ldac", GPIOD_OUT_LOW);
> + if (IS_ERR(st->gpio_ldac))
> + return PTR_ERR(st->gpio_ldac);
> +
Fine having the above in bindings but as it stands now, not seeing the purpose of
having it in the driver. We're not handling these gpios at all.
- Nuno Sá
>