From: "Tanislav, Cosmin" <Cosmin.Tanislav@analog.com>
To: Jonathan Cameron <jic23@kernel.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Lars-Peter Clausen <lars@metafoo.de>,
"Hennerich, Michael" <Michael.Hennerich@analog.com>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
Rob Herring <robh+dt@kernel.org>,
"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH 5/5] iio: addac: ad74413r: add support for reset-gpio
Date: Mon, 14 Nov 2022 13:52:26 +0000 [thread overview]
Message-ID: <095a454b55cf497392a621649f24e067@analog.com> (raw)
In-Reply-To: <20221112170705.7efe1673@jic23-huawei>
> -----Original Message-----
> From: Jonathan Cameron <jic23@kernel.org>
> Sent: Saturday, November 12, 2022 7:07 PM
> To: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> Cc: Tanislav, Cosmin <Cosmin.Tanislav@analog.com>; Lars-Peter Clausen
> <lars@metafoo.de>; Hennerich, Michael <Michael.Hennerich@analog.com>;
> devicetree@vger.kernel.org; Rob Herring <robh+dt@kernel.org>; linux-
> iio@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH 5/5] iio: addac: ad74413r: add support for reset-gpio
>
> [External]
>
> On Fri, 11 Nov 2022 15:39:21 +0100
> Rasmus Villemoes <linux@rasmusvillemoes.dk> 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.
>
> I'm a little confused on polarity here. The pin is a !reset so
> we need to drive it low briefly to trigger a reset.
> I'm guessing for your board the pin is set to active low? (an example
> in the dt would have made that clearer) Hence the pulse
> in here to 1 is actually briefly driving it low before restoring to high?
>
> For a pin documented as !reset that seems backwards though you have
> called it reset so that is fine, but this description doesn't make that
> celar.
My opinion is that the driver shouldn't exactly know the polarity of the reset,
and just assume that setting the reset GPIO to 1 means putting it in reset,
and setting it to 0 means bringing out of reset.
>
> Perhaps just add some more description here to make it clear the GPIO
> is active low, and then refer to setting it to true and false to avoid
> the confusing high / low terminology which are inverted...
>
> >
> > 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@rasmusvillemoes.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);
> > +
> > st->refin_reg = devm_regulator_get_optional(st->dev, "refin");
> > if (IS_ERR(st->refin_reg)) {
> > ret = PTR_ERR(st->refin_reg);
next prev parent reply other threads:[~2022-11-14 13:52 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 14:39 [PATCH 0/5] iio: addac: ad74413r: various fixups Rasmus Villemoes
2022-11-11 14:39 ` [PATCH 1/5] iio: addac: ad74413r: add spi_device_id table Rasmus Villemoes
2022-11-12 16:50 ` Jonathan Cameron
2022-11-14 8:02 ` Rasmus Villemoes
2022-11-14 19:39 ` Jonathan Cameron
2022-11-11 14:39 ` [PATCH 2/5] dt-bindings: iio: ad74413r: make refin-supply optional Rasmus Villemoes
2022-11-12 16:54 ` Jonathan Cameron
2022-11-14 8:10 ` Rasmus Villemoes
2022-11-11 14:39 ` [PATCH 3/5] iio: addac: ad74413r: implement support for optional refin-supply Rasmus Villemoes
2022-11-12 16:56 ` Jonathan Cameron
2022-11-11 14:39 ` [PATCH 4/5] dt-bindings: iio: ad74413r: add optional reset-gpios Rasmus Villemoes
2022-11-12 17:00 ` Jonathan Cameron
2022-11-11 14:39 ` [PATCH 5/5] iio: addac: ad74413r: add support for reset-gpio Rasmus Villemoes
2022-11-12 17:07 ` Jonathan Cameron
2022-11-14 8:37 ` Rasmus Villemoes
2022-11-14 19:41 ` Jonathan Cameron
2022-11-14 13:52 ` Tanislav, Cosmin [this message]
2022-11-14 19:44 ` Jonathan Cameron
2022-11-15 14:49 ` Nuno Sá
2022-11-15 16:10 ` Jonathan Cameron
2022-11-15 19:10 ` Rasmus Villemoes
2022-11-16 10:22 ` Jonathan Cameron
2022-11-16 12:06 ` Nuno Sá
2022-11-18 11:21 ` Rasmus Villemoes
2022-11-15 14:53 ` Nuno Sá
2022-11-15 9:55 ` [PATCH v2 0/3] iio: addac: ad74413r: add spi device id table, support reset gpio Rasmus Villemoes
2022-11-15 9:55 ` [PATCH v2 1/3] iio: addac: ad74413r: add spi_device_id table Rasmus Villemoes
2022-11-15 9:55 ` [PATCH v2 2/3] dt-bindings: iio: ad74413r: add optional reset-gpios Rasmus Villemoes
2022-11-15 10:12 ` Krzysztof Kozlowski
2022-11-15 9:55 ` [PATCH v2 3/3] iio: addac: ad74413r: add support for reset-gpio Rasmus Villemoes
2022-11-23 20:55 ` [PATCH v2 0/3] iio: addac: ad74413r: add spi device id table, support reset gpio Jonathan Cameron
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=095a454b55cf497392a621649f24e067@analog.com \
--to=cosmin.tanislav@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).