[PATCH v3 8/9] iio: amplifiers: ad8366: consume enable gpio

Rodrigo Alencar via B4 Relay posted 9 patches 6 days, 5 hours ago
[PATCH v3 8/9] iio: amplifiers: ad8366: consume enable gpio
Posted by Rodrigo Alencar via B4 Relay 6 days, 5 hours ago
From: Rodrigo Alencar <rodrigo.alencar@analog.com>

Some parts may consume enable GPIO to enable serial mode
(HMC1119's and HMC792A P/S pin) or powerup the device
(e.g. ADA4961's PWUP pin). Also, add a comment explaining
that even though chips like HMC271A has a reset gpio, this
driver previously considered the reset pin for parts that
don't actually have a reset gpio, so it might have been
used to enable/power the device.

Signed-off-by: Rodrigo Alencar <rodrigo.alencar@analog.com>
---
 drivers/iio/amplifiers/ad8366.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/amplifiers/ad8366.c b/drivers/iio/amplifiers/ad8366.c
index dc2fe94c53cd..92865ab96ade 100644
--- a/drivers/iio/amplifiers/ad8366.c
+++ b/drivers/iio/amplifiers/ad8366.c
@@ -204,7 +204,7 @@ static const struct iio_chan_spec ad8366_channels[] = {
 
 static int ad8366_probe(struct spi_device *spi)
 {
-	struct gpio_desc *reset_gpio;
+	struct gpio_desc *reset_gpio, *enable_gpio;
 	struct iio_dev *indio_dev;
 	struct ad8366_state *st;
 	int ret;
@@ -226,11 +226,22 @@ static int ad8366_probe(struct spi_device *spi)
 	st->spi = spi;
 	st->info = spi_get_device_match_data(spi);
 
+	/*
+	 * Previously, this driver considered the reset gpio for some devices
+	 * that don't actually have a reset pin, which could have been wired
+	 * up to the enable pin instead, so some users might be relying on this
+	 * to turn the chip on rather than reset it.
+	 */
 	reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH);
 	if (IS_ERR(reset_gpio))
 		return dev_err_probe(&spi->dev, PTR_ERR(reset_gpio),
 				     "Failed to get reset GPIO\n");
 
+	enable_gpio = devm_gpiod_get_optional(&spi->dev, "enable", GPIOD_OUT_HIGH);
+	if (IS_ERR(enable_gpio))
+		return dev_err_probe(&spi->dev, PTR_ERR(enable_gpio),
+				     "Failed to get enable GPIO\n");
+
 	indio_dev->name = spi_get_device_id(spi)->name;
 	indio_dev->info = &ad8366_info;
 	indio_dev->modes = INDIO_DIRECT_MODE;

-- 
2.43.0
Re: [PATCH v3 8/9] iio: amplifiers: ad8366: consume enable gpio
Posted by Andy Shevchenko 5 days, 14 hours ago
On Tue, Feb 03, 2026 at 11:24:14AM +0000, Rodrigo Alencar via B4 Relay wrote:

> Some parts may consume enable GPIO to enable serial mode
> (HMC1119's and HMC792A P/S pin) or powerup the device
> (e.g. ADA4961's PWUP pin). Also, add a comment explaining
> that even though chips like HMC271A has a reset gpio, this
> driver previously considered the reset pin for parts that
> don't actually have a reset gpio, so it might have been
> used to enable/power the device.

...

> +	/*
> +	 * Previously, this driver considered the reset gpio for some devices

GPIO

> +	 * that don't actually have a reset pin, which could have been wired
> +	 * up to the enable pin instead, so some users might be relying on this
> +	 * to turn the chip on rather than reset it.
> +	 */
>  	reset_gpio = devm_gpiod_get_optional(&spi->dev, "reset", GPIOD_OUT_HIGH);
>  	if (IS_ERR(reset_gpio))
>  		return dev_err_probe(&spi->dev, PTR_ERR(reset_gpio),
>  				     "Failed to get reset GPIO\n");

Yeah, this needs to be addressed somewhere in drivers/gpio/gpiolib-of.c.
Because OUT_HIGH for the reset doesn't sound right if the polarity is active high.

> +	enable_gpio = devm_gpiod_get_optional(&spi->dev, "enable", GPIOD_OUT_HIGH);
> +	if (IS_ERR(enable_gpio))
> +		return dev_err_probe(&spi->dev, PTR_ERR(enable_gpio),
> +				     "Failed to get enable GPIO\n");

-- 
With Best Regards,
Andy Shevchenko