From: Peter Rosin <peda@axentia.se>
To: Mike Looijmans <mike.looijmans@topic.nl>, linux-i2c@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] i2c-mux-pca954x: Force reset on probe if available
Date: Tue, 8 May 2018 08:36:23 +0200 [thread overview]
Message-ID: <bc56d669-b02f-a017-844d-e095bbbcb7cd@axentia.se> (raw)
In-Reply-To: <1525174932-8865-1-git-send-email-mike.looijmans@topic.nl>
On 2018-05-01 13:42, Mike Looijmans wrote:
> Instead of just hogging the reset GPIO into deactivated state, activate and
> then de-activate the reset. This allows for better recovery if the CPU was
> reset halfway through an I2C transaction for example.
I can't see any problems with this, and a reset at load time can certainly
be a benefit. Some questions below though...
Cheers,
Peter
> Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
> ---
> drivers/i2c/muxes/i2c-mux-pca954x.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c
> index 09bafd3..13e10d0 100644
> --- a/drivers/i2c/muxes/i2c-mux-pca954x.c
> +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c
> @@ -36,6 +36,7 @@
> */
>
> #include <linux/device.h>
> +#include <linux/delay.h>
> #include <linux/gpio/consumer.h>
> #include <linux/i2c.h>
> #include <linux/i2c-mux.h>
> @@ -389,10 +390,17 @@ static int pca954x_probe(struct i2c_client *client,
> i2c_set_clientdata(client, muxc);
> data->client = client;
>
> - /* Get the mux out of reset if a reset GPIO is specified. */
> - gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_LOW);
> + /* Reset the mux if a reset GPIO is specified. */
> + gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH);
> if (IS_ERR(gpio))
> return PTR_ERR(gpio);
> + if (gpio) {
> + /* Datasheet specifies a 4 ns reset-low time */
> + udelay(1);
ndelay(4) ?
> + gpiod_set_value_cansleep(gpio, 0);
> + /* Datasheet specifies a 500 ns reset recovery time */
> + udelay(1);
ndelay(500) ?
> + }
>
> match = of_match_device(of_match_ptr(pca954x_of_match), &client->dev);
> if (match)
>
next prev parent reply other threads:[~2018-05-08 6:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-01 11:42 Mike Looijmans
2018-05-08 6:36 ` Peter Rosin [this message]
2018-05-08 8:06 ` Mike Looijmans
2018-05-19 21:58 ` Peter Rosin
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=bc56d669-b02f-a017-844d-e095bbbcb7cd@axentia.se \
--to=peda@axentia.se \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.looijmans@topic.nl \
/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
all inboxes | Powered by JetHome®