[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <27be5a5bf23fbea31d82cf2e7b3f9747d7c610eb.camel@gmail.com>
Date: Tue, 15 Nov 2022 15:53:06 +0100
From: Nuno Sá <noname.nuno@...il.com>
To: Rasmus Villemoes <linux@...musvillemoes.dk>,
Cosmin Tanislav <cosmin.tanislav@...log.com>,
Lars-Peter Clausen <lars@...afoo.de>,
Michael Hennerich <Michael.Hennerich@...log.com>,
Jonathan Cameron <jic23@...nel.org>
Cc: devicetree@...r.kernel.org, Rob Herring <robh+dt@...nel.org>,
linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 5/5] iio: addac: ad74413r: add support for reset-gpio
On Fri, 2022-11-11 at 15:39 +0100, Rasmus Villemoes wrote:
> We have a board where the reset pin of the ad74412 is connected to a
> gpio, but also pulled low by default. Hence to get the chip out of
> reset, the driver needs to know about that gpio and set it high
> before
> attempting to communicate with it.
>
> When a reset-gpio is given in device tree, use that instead of the
> software reset. According to the data sheet, the two methods are
> functionally equivalent.
>
> Signed-off-by: Rasmus Villemoes <linux@...musvillemoes.dk>
> ---
> drivers/iio/addac/ad74413r.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/iio/addac/ad74413r.c
> b/drivers/iio/addac/ad74413r.c
> index 9f77d2f514de..af09d43f921c 100644
> --- a/drivers/iio/addac/ad74413r.c
> +++ b/drivers/iio/addac/ad74413r.c
> @@ -71,6 +71,7 @@ struct ad74413r_state {
> struct regmap *regmap;
> struct device *dev;
> struct iio_trigger *trig;
> + struct gpio_desc *reset_gpio;
>
> size_t adc_active_channels;
> struct spi_message adc_samples_msg;
> @@ -393,6 +394,13 @@ static int ad74413r_reset(struct ad74413r_state
> *st)
> {
> int ret;
>
> + if (st->reset_gpio) {
> + gpiod_set_value_cansleep(st->reset_gpio, 1);
> + fsleep(50);
> + gpiod_set_value_cansleep(st->reset_gpio, 0);
> + return 0;
> + }
> +
> ret = regmap_write(st->regmap, AD74413R_REG_CMD_KEY,
> AD74413R_CMD_KEY_RESET1);
> if (ret)
> @@ -1316,6 +1324,10 @@ static int ad74413r_probe(struct spi_device
> *spi)
> if (IS_ERR(st->regmap))
> return PTR_ERR(st->regmap);
>
> + st->reset_gpio = devm_gpiod_get_optional(st->dev, "reset",
> GPIOD_OUT_LOW);
> + if (IS_ERR(st->reset_gpio))
> + return PTR_ERR(st->reset_gpio);
> +
Minor thing but,
I would move this into ad74413r_reset() as there's no real need to have
the gpio_desc in struct ad74413r_state.
- Nuno Sá
Powered by blists - more mailing lists