Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio: resolver: ad2s1210: add reset gpio support
@ 2023-10-16 15:43 David Lechner
  2023-10-17 13:46 ` Hennerich, Michael
  0 siblings, 1 reply; 3+ messages in thread
From: David Lechner @ 2023-10-16 15:43 UTC (permalink / raw)
  To: linux-iio
  Cc: David Lechner, Jonathan Cameron, Michael Hennerich, nuno.sa,
	linux-kernel

This adds support for the optional reset gpio to the ad2s1210 resolver
driver. If the gpio is present in the device tree, it is toggled during
driver probe before the reset of the device initialization. As per the
devicetree bindings, it is expected for the gpio to configured as active
low.

Suggested-by: Michael Hennerich <Michael.Hennerich@analog.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
---
 drivers/iio/resolver/ad2s1210.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/iio/resolver/ad2s1210.c b/drivers/iio/resolver/ad2s1210.c
index 8646389ec88d..a414eef12e5e 100644
--- a/drivers/iio/resolver/ad2s1210.c
+++ b/drivers/iio/resolver/ad2s1210.c
@@ -1426,6 +1426,7 @@ static int ad2s1210_setup_gpios(struct ad2s1210_state *st)
 {
 	struct device *dev = &st->sdev->dev;
 	struct gpio_descs *resolution_gpios;
+	struct gpio_desc *reset_gpio;
 	DECLARE_BITMAP(bitmap, 2);
 	int ret;
 
@@ -1481,6 +1482,17 @@ static int ad2s1210_setup_gpios(struct ad2s1210_state *st)
 					     "failed to set resolution gpios\n");
 	}
 
+	/* If the optional reset GPIO is present, toggle it to do a hard reset. */
+	reset_gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
+	if (IS_ERR(reset_gpio))
+		return dev_err_probe(dev, PTR_ERR(reset_gpio),
+				     "failed to request reset GPIO\n");
+
+	if (reset_gpio) {
+		udelay(10);
+		gpiod_set_value(reset_gpio, 0);
+	}
+
 	return 0;
 }
 
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] iio: resolver: ad2s1210: add reset gpio support
  2023-10-16 15:43 [PATCH] iio: resolver: ad2s1210: add reset gpio support David Lechner
@ 2023-10-17 13:46 ` Hennerich, Michael
  2023-10-18 19:26   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Hennerich, Michael @ 2023-10-17 13:46 UTC (permalink / raw)
  To: David Lechner, linux-iio@vger.kernel.org
  Cc: David Lechner, Jonathan Cameron, Sa, Nuno,
	linux-kernel@vger.kernel.org



> -----Original Message-----
> From: David Lechner <dlechner@baylibre.com>
> Sent: Montag, 16. Oktober 2023 17:43
> To: linux-iio@vger.kernel.org
> Cc: David Lechner <dlechner@baylibre.com>; Jonathan Cameron
> <jic23@kernel.org>; Hennerich, Michael <Michael.Hennerich@analog.com>;
> Sa, Nuno <Nuno.Sa@analog.com>; linux-kernel@vger.kernel.org
> Subject: [PATCH] iio: resolver: ad2s1210: add reset gpio support
> 
> 
> This adds support for the optional reset gpio to the ad2s1210 resolver driver. If
> the gpio is present in the device tree, it is toggled during driver probe before the
> reset of the device initialization. As per the devicetree bindings, it is expected for
> the gpio to configured as active low.
> 
> Suggested-by: Michael Hennerich <Michael.Hennerich@analog.com>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---

Acked-by: Michael Hennerich <michael.hennerich@analog.com>

>  drivers/iio/resolver/ad2s1210.c | 12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/drivers/iio/resolver/ad2s1210.c b/drivers/iio/resolver/ad2s1210.c
> index 8646389ec88d..a414eef12e5e 100644
> --- a/drivers/iio/resolver/ad2s1210.c
> +++ b/drivers/iio/resolver/ad2s1210.c
> @@ -1426,6 +1426,7 @@ static int ad2s1210_setup_gpios(struct
> ad2s1210_state *st)  {
>  	struct device *dev = &st->sdev->dev;
>  	struct gpio_descs *resolution_gpios;
> +	struct gpio_desc *reset_gpio;
>  	DECLARE_BITMAP(bitmap, 2);
>  	int ret;
> 
> @@ -1481,6 +1482,17 @@ static int ad2s1210_setup_gpios(struct
> ad2s1210_state *st)
>  					     "failed to set resolution gpios\n");
>  	}
> 
> +	/* If the optional reset GPIO is present, toggle it to do a hard reset. */
> +	reset_gpio = devm_gpiod_get_optional(dev, "reset",
> GPIOD_OUT_HIGH);
> +	if (IS_ERR(reset_gpio))
> +		return dev_err_probe(dev, PTR_ERR(reset_gpio),
> +				     "failed to request reset GPIO\n");
> +
> +	if (reset_gpio) {
> +		udelay(10);
> +		gpiod_set_value(reset_gpio, 0);
> +	}
> +
>  	return 0;
>  }
> 
> --
> 2.42.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] iio: resolver: ad2s1210: add reset gpio support
  2023-10-17 13:46 ` Hennerich, Michael
@ 2023-10-18 19:26   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2023-10-18 19:26 UTC (permalink / raw)
  To: Hennerich, Michael
  Cc: David Lechner, linux-iio@vger.kernel.org, Sa, Nuno,
	linux-kernel@vger.kernel.org

On Tue, 17 Oct 2023 13:46:51 +0000
"Hennerich, Michael" <Michael.Hennerich@analog.com> wrote:

> > -----Original Message-----
> > From: David Lechner <dlechner@baylibre.com>
> > Sent: Montag, 16. Oktober 2023 17:43
> > To: linux-iio@vger.kernel.org
> > Cc: David Lechner <dlechner@baylibre.com>; Jonathan Cameron
> > <jic23@kernel.org>; Hennerich, Michael <Michael.Hennerich@analog.com>;
> > Sa, Nuno <Nuno.Sa@analog.com>; linux-kernel@vger.kernel.org
> > Subject: [PATCH] iio: resolver: ad2s1210: add reset gpio support
> > 
> > 
> > This adds support for the optional reset gpio to the ad2s1210 resolver driver. If
> > the gpio is present in the device tree, it is toggled during driver probe before the
> > reset of the device initialization. As per the devicetree bindings, it is expected for
> > the gpio to configured as active low.
> > 
> > Suggested-by: Michael Hennerich <Michael.Hennerich@analog.com>
> > Signed-off-by: David Lechner <dlechner@baylibre.com>
> > ---  
> 
> Acked-by: Michael Hennerich <michael.hennerich@analog.com>
Applied and pushed out as testing for 0-day to poke at it.

Thanks,

Jonathan

> 
> >  drivers/iio/resolver/ad2s1210.c | 12 ++++++++++++
> >  1 file changed, 12 insertions(+)
> > 
> > diff --git a/drivers/iio/resolver/ad2s1210.c b/drivers/iio/resolver/ad2s1210.c
> > index 8646389ec88d..a414eef12e5e 100644
> > --- a/drivers/iio/resolver/ad2s1210.c
> > +++ b/drivers/iio/resolver/ad2s1210.c
> > @@ -1426,6 +1426,7 @@ static int ad2s1210_setup_gpios(struct
> > ad2s1210_state *st)  {
> >  	struct device *dev = &st->sdev->dev;
> >  	struct gpio_descs *resolution_gpios;
> > +	struct gpio_desc *reset_gpio;
> >  	DECLARE_BITMAP(bitmap, 2);
> >  	int ret;
> > 
> > @@ -1481,6 +1482,17 @@ static int ad2s1210_setup_gpios(struct
> > ad2s1210_state *st)
> >  					     "failed to set resolution gpios\n");
> >  	}
> > 
> > +	/* If the optional reset GPIO is present, toggle it to do a hard reset. */
> > +	reset_gpio = devm_gpiod_get_optional(dev, "reset",
> > GPIOD_OUT_HIGH);
> > +	if (IS_ERR(reset_gpio))
> > +		return dev_err_probe(dev, PTR_ERR(reset_gpio),
> > +				     "failed to request reset GPIO\n");
> > +
> > +	if (reset_gpio) {
> > +		udelay(10);
> > +		gpiod_set_value(reset_gpio, 0);
> > +	}
> > +
> >  	return 0;
> >  }
> > 
> > --
> > 2.42.0  
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-10-18 19:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-16 15:43 [PATCH] iio: resolver: ad2s1210: add reset gpio support David Lechner
2023-10-17 13:46 ` Hennerich, Michael
2023-10-18 19:26   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox