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 Pan <b54642-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
Cc: wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org,
	shawnguo-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	B20596-KZfg59tc24xl57MIdRCFDg@public.gmane.org,
	b38611-KZfg59tc24xl57MIdRCFDg@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Subject: Re: [Patch V5] i2c: imx: implement bus recovery
Date: Fri, 18 Sep 2015 09:54:57 +0200	[thread overview]
Message-ID: <20150918075457.GT5327@pengutronix.de> (raw)
In-Reply-To: <1441968155-10918-1-git-send-email-b54642-KZfg59tc24xl57MIdRCFDg@public.gmane.org>

Hello,

On Fri, Sep 11, 2015 at 06:42:34PM +0800, Gao Pan wrote:
> V5:
>  -introduce a dedicated gpio state for bus recovery.
>  -assign adapter.bus_recovery_info after the two gpios were aquired successfully.

You also do this if the gpios were not acquired successfully.

> +	if (IS_ERR(i2c_imx->pinctrl_pins_default))
> +		dev_warn(&pdev->dev, "could not get default state\n");
> +	else {
> +		i2c_imx->pinctrl_pins_gpio = pinctrl_lookup_state(i2c_imx->pinctrl,
> +						I2C_PINCTRL_STATE_GPIO);
> +		if (IS_ERR(i2c_imx->pinctrl_pins_gpio))
> +			dev_warn(&pdev->dev, "could not get gpio state\n");

IMHO pinctrl_lookup_state returning an error is enough to not try a
recovery.

> +	}
> +
>  	/* Request IRQ */
>  	ret = devm_request_irq(&pdev->dev, irq, i2c_imx_isr, 0,
>  				pdev->name, i2c_imx);
> @@ -1057,6 +1146,24 @@ static int i2c_imx_probe(struct platform_device *pdev)
>  	if (ret < 0)
>  		goto rpm_disable;
>  
> +	/* Init recover pins */
> +	i2c_imx->pins.sda =
> +		devm_gpiod_get_optional(&pdev->dev, "sda-gpios", GPIOD_IN);
> +	i2c_imx->pins.scl =
> +		devm_gpiod_get_optional(&pdev->dev, "scl-gpios", GPIOD_IN);
> +
> +	if (IS_ERR(i2c_imx->pins.sda)) {
> +		ret = PTR_ERR(i2c_imx->pins.sda);
> +		goto clk_disable;
> +	}
> +
> +	if (IS_ERR(i2c_imx->pins.scl)) {
> +		ret = PTR_ERR(i2c_imx->pins.scl);
> +		goto clk_disable;
> +	}
> +

if (i2c_imx->pins.sda && i2c_imx->pins.scl)

> +	i2c_imx->adapter.bus_recovery_info = &i2c_imx_bus_recovery_info;
> +
>  	/* Set up clock divider */
>  	i2c_imx->bitrate = IMX_I2C_BIT_RATE;
>  	ret = of_property_read_u32(pdev->dev.of_node,

Best regards
Uwe

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

  parent reply	other threads:[~2015-09-18  7:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-11 10:42 [Patch V5] i2c: imx: implement bus recovery Gao Pan
     [not found] ` <1441968155-10918-1-git-send-email-b54642-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-09-11 10:42   ` [Patch V5] ARM: dts: imx6qdl-sabresd: add i2c pinctrl gpio state for " Gao Pan
     [not found]     ` <1441968155-10918-2-git-send-email-b54642-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2015-09-18  7:39       ` Gao Pandy
2015-09-18  7:40   ` [Patch V5] i2c: imx: implement " Gao Pandy
2015-09-18  7:54   ` Uwe Kleine-König [this message]
2015-09-21  4:29     ` Gao Pandy
2015-09-21  6:33       ` Uwe Kleine-König
2015-09-21  8:13         ` Gao Pandy
2015-09-18  7:58   ` Sascha Hauer

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=20150918075457.GT5327@pengutronix.de \
    --to=u.kleine-koenig-bicnvbalz9megne8c9+irq@public.gmane.org \
    --cc=B20596-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=b38611-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=b54642-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
    --cc=kernel-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=shawnguo-DgEjT+Ai2ygdnm+yROfE0A@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).