linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
To: Gao Pandy <gaopan-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
Cc: "wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org"
	<wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>,
	"linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	Li Frank <Frank.Li-KZfg59tc24xl57MIdRCFDg@public.gmane.org>,
	Duan Andy <fugang.duan-KZfg59tc24xl57MIdRCFDg@public.gmane.org>,
	Linus Walleij
	<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: Re: [Patch v2] i2c: imx: implement bus recovery
Date: Wed, 19 Aug 2015 09:02:18 +0200	[thread overview]
Message-ID: <20150819070218.GE9999@pengutronix.de> (raw)
In-Reply-To: <CY1PR0301MB0858E4EEEC54C81BC4E7A621CF670-YrwGdl+PljlUWoKpOwApjpwN6zqB+hSMnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>

Hello,

Cc += Linus Walleij

On Wed, Aug 19, 2015 at 03:44:49AM +0000, Gao Pandy wrote:
> From: Uwe Kleine-König <mailto:u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org> Sent: Thursday, August 13, 2015 4:15 PM
> > > +static void i2c_imx_prepare_recovery(struct i2c_adapter *adap) {
> > > +	struct imx_i2c_struct *i2c_imx;
> > > +
> > > +	i2c_imx = container_of(adap, struct imx_i2c_struct, adapter);
> > > +	if (i2c_imx->pins.sda && i2c_imx->pins.scl) {
> > > +		pinctrl_pm_select_sleep_state(&adap->dev);
> > 
> > Your requirement that the sleep state should configure the pins as gpio
> > is strange. Maybe better introduce a dedicated state for recovery? At
> > least you should document this requirement.
> 
> In general, pinctrl sleep mode is gpio function. I will add this in binding doc. Thanks.

Linus, do you have to say something here? It might be right to have the
gpio function as configuration for sleep mode, but it doesn't look right
for me to use this for recovery purposes.

 
> > 
> > > @@ -1004,12 +1073,13 @@ static int i2c_imx_probe(struct
> > > platform_device *pdev)
> > >
> > >  	/* Setup i2c_imx driver structure */
> > >  	strlcpy(i2c_imx->adapter.name, pdev->name, sizeof(i2c_imx-
> > >adapter.name));
> > > -	i2c_imx->adapter.owner		= THIS_MODULE;
> > > -	i2c_imx->adapter.algo		= &i2c_imx_algo;
> > > -	i2c_imx->adapter.dev.parent	= &pdev->dev;
> > > -	i2c_imx->adapter.nr		= pdev->id;
> > > -	i2c_imx->adapter.dev.of_node	= pdev->dev.of_node;
> > > -	i2c_imx->base			= base;
> > > +	i2c_imx->adapter.owner = THIS_MODULE;
> > > +	i2c_imx->adapter.algo = &i2c_imx_algo;
> > > +	i2c_imx->adapter.dev.parent = &pdev->dev;
> > > +	i2c_imx->adapter.nr = pdev->id;
> > > +	i2c_imx->adapter.dev.of_node = pdev->dev.of_node;
> > > +	i2c_imx->adapter.bus_recovery_info = &i2c_imx_bus_recovery_info;
> > 
> > What happens if the device tree only specifies a gpio for sda but not scl?
> > The recovery stuff is still hooked up, right? What about only doing that
> > if both properties are valid? This would also get rid of the tests for
> > validity in the recovery callbacks.
> 
> It requires device tree to specify gpio for sda and scl in both. Once only sda is defined, 
> the driver doesn't carry out the recovery process.

Right, and still it is convinced it is able to recover the bus, right?
Can you please change this?

> > 
> > > @@ -1037,6 +1107,24 @@ static int i2c_imx_probe(struct platform_device
> > *pdev)
> > >  	/* Set up adapter data */
> > >  	i2c_set_adapdata(&i2c_imx->adapter, i2c_imx);
> > >
> > > +	/* Init recover pins */
> > > +	i2c_imx->pins.sda =
> > > +		devm_gpiod_get_optional(&pdev->dev, "sda-gpio", 0);
> > > +	i2c_imx->pins.scl =
> > > +		devm_gpiod_get_optional(&pdev->dev, "scl-gpio", 0);
> > 
> > 0 is wrong here, better use GPIOD_ASIS. Is there a reason not to
> > configure the direction as input already here?
>  
> Thanks, 0 is inappropriate here. Actually, we should use GPIOD_OUT_HIGH
> to set the gpios high. 

Are you sure? Consider the bus is blocked and you switch to gpio mode to
do recovery you have a device pulling SDA to 0 and the imx pulling it to
1. That's wrong, isn't it?

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

  parent reply	other threads:[~2015-08-19  7:02 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-17  2:36 [Patch v2] i2c: imx: implement bus recovery Gao Pan
     [not found] ` <1437100605-28047-1-git-send-email-b54642-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-08-13  5:51   ` Gao Pandy
2015-08-13  8:15   ` Uwe Kleine-König
     [not found]     ` <20150813081528.GA9999-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-08-19  3:44       ` Gao Pandy
     [not found]         ` <CY1PR0301MB0858E4EEEC54C81BC4E7A621CF670-YrwGdl+PljlUWoKpOwApjpwN6zqB+hSMnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2015-08-19  7:02           ` Uwe Kleine-König [this message]
     [not found]             ` <20150819070218.GE9999-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-08-19  7:43               ` Gao Pandy
     [not found]                 ` <CY1PR0301MB0858A807E83F5B1665A99EB9CF670-YrwGdl+PljlUWoKpOwApjpwN6zqB+hSMnBOFsp37pqbUKgpGm//BTAC/G2K4zDHf@public.gmane.org>
2015-08-19  7:52                   ` Uwe Kleine-König
2015-08-25 14:18               ` Linus Walleij
     [not found]                 ` <CACRpkdYy3xQ3N7199GcV83-HrgOERnffNLh=qak8K8hpcAHs1Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-07  8:00                   ` Uwe Kleine-König
     [not found]                     ` <20150907080032.GO9999-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-09-08 14:18                       ` Linus Walleij
     [not found]                         ` <CACRpkdaRu0jLJUddpjVvO9cBCRfHJpzAm0K1v825dCiSy0Zweg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-09-08 20:22                           ` Uwe Kleine-König
     [not found]                             ` <20150908202258.GY14598-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2015-09-09  8:46                               ` Linus Walleij

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=20150819070218.GE9999@pengutronix.de \
    --to=u.kleine-koenig-bicnvbalz9megne8c9+irq@public.gmane.org \
    --cc=Frank.Li-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=fugang.duan-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=gaopan-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.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).