From: Sascha Hauer <s.hauer@pengutronix.de>
To: Gao Pan <b54642@freescale.com>
Cc: wsa@the-dreams.de, linux-i2c@vger.kernel.org,
B20596@freescale.com, b38611@freescale.com,
u.kleine-koenig@pengutronix.de, kernel@pengutronix.de,
hkallweit1@gmail.com
Subject: Re: [Patch V7] i2c: imx: implement bus recovery
Date: Fri, 16 Oct 2015 09:14:54 +0200 [thread overview]
Message-ID: <20151016071454.GZ7858@pengutronix.de> (raw)
In-Reply-To: <1444809643-25329-1-git-send-email-b54642@freescale.com>
On Wed, Oct 14, 2015 at 04:00:43PM +0800, Gao Pan wrote:
> Implement bus recovery methods for i2c-imx so we can recover from
> situations where SCL/SDA are stuck low.
>
> Once i2c bus SCL/SDA are stuck low during transfer, config the i2c
> pinctrl to gpio mode by calling pinctrl sleep set function, and then
> use GPIO to emulate the i2c protocol to send nine dummy clock to recover
> i2c device. After recovery, set i2c pinctrl to default group setting.
>
> Signed-off-by: Fugang Duan <B38611@freescale.com>
> Signed-off-by: Gao Pan <b54642@freescale.com>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> V2:
> As Uwe Kleine-König's suggestion, the version do below changes:
> -replace of_get_named_gpio() with devm_gpiod_get_optional()
> -move gpio_direction_input() and gpio_direction_output() call to the
> prepare callback
> -use 0 and 1 as return value for the get_scl and get_sda callbacks
>
> V3:
> -replace "...-gpio" with "...-gpios" in i2c binding doc
> -document the requirement of using sleep state to configure
> the pins as gpio in i2c binding doc
> -remove i2c_recover_bus() in i2c_imx_trx_complete()
> -use GPIOD_OUT_HIGH as the parameter of devm_gpiod_get_optional to
> config the gpios as output high
> -add error disposal as devm_gpiod_get_optional meets error
>
> V4:
> -remove include <linux/of_gpio.h>
> -call i2c_recover_bus under the condition of the existing of
> both sda and scl. Drop the sda and scl check in i2c_imx_get_scl,
> i2c_imx_get_sda, i2c_imx_set_scl, i2c_imx_prepare_recovery and
> i2c_imx_prepare_recovery
> -use GPIOD_OUT_IN as the parameter of devm_gpiod_get_optional
> -remove documenting the requirement of using sleep state to configure
> the pins as gpio in i2c binding doc
>
> V5:
> -introduce a dedicated gpio state for bus recovery.
> -assign adapter.bus_recovery_info after the two gpios were aquired successfully
>
> V6:
> -assign adapter.bus_recovery_info under the condition that gpios are acquired successfully
> -not try the recovery when pinctrl_lookup_state returns an error
>
> V7:
> -execute the bus recovery once in a transfer, when the controller fails to start
> -use i2c_generic_gpio_recovery() to handle the bus recovery with gpios
>
> Documentation/devicetree/bindings/i2c/i2c-imx.txt | 9 +++
> drivers/i2c/busses/i2c-imx.c | 84 +++++++++++++++++++++--
> 2 files changed, 87 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/devicetree/bindings/i2c/i2c-imx.txt b/Documentation/devicetree/bindings/i2c/i2c-imx.txt
> index ce4311d..eab5836 100644
> --- a/Documentation/devicetree/bindings/i2c/i2c-imx.txt
> +++ b/Documentation/devicetree/bindings/i2c/i2c-imx.txt
> @@ -14,6 +14,10 @@ Optional properties:
> The absence of the propoerty indicates the default frequency 100 kHz.
> - dmas: A list of two dma specifiers, one for each entry in dma-names.
> - dma-names: should contain "tx" and "rx".
> +- scl-gpios: specify the gpio related to SCL pin
> +- sda-gpios: specify the gpio related to SDA pin
> +- pinctrl: add extra pinctrl to configure i2c pins to gpio function for i2c
> + bus recovery, call it "gpio" state
>
> Examples:
>
> @@ -37,4 +41,9 @@ i2c0: i2c@40066000 { /* i2c0 on vf610 */
> dmas = <&edma0 0 50>,
> <&edma0 0 51>;
> dma-names = "rx","tx";
> + pinctrl-names = "default", "gpio";
> + pinctrl-0 = <&pinctrl_i2c1>;
> + pinctrl-1 = <&pinctrl_i2c1_gpio>;
> + scl-gpios = <&gpio5 26 GPIO_ACTIVE_HIGH>;
> + sda-gpios = <&gpio5 27 GPIO_ACTIVE_HIGH>;
> };
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 91bdf28..c3a0d43 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -49,6 +49,7 @@
> #include <linux/of.h>
> #include <linux/of_device.h>
> #include <linux/of_dma.h>
> +#include <linux/of_gpio.h>
> #include <linux/platform_data/i2c-imx.h>
> #include <linux/platform_device.h>
> #include <linux/sched.h>
> @@ -64,6 +65,8 @@
> /* Default value */
> #define IMX_I2C_BIT_RATE 100000 /* 100kHz */
>
> +#define I2C_PINCTRL_STATE_GPIO "gpio"
This is unused, please remove.
> static u32 i2c_imx_func(struct i2c_adapter *adapter)
> {
> return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL
> @@ -1011,12 +1075,12 @@ 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->base = base;
unrelated whitespace changes. Please drop this.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2015-10-16 7:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-14 8:00 [Patch V7] i2c: imx: implement bus recovery Gao Pan
2015-10-16 7:14 ` Sascha Hauer [this message]
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=20151016071454.GZ7858@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=B20596@freescale.com \
--cc=b38611@freescale.com \
--cc=b54642@freescale.com \
--cc=hkallweit1@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-i2c@vger.kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
--cc=wsa@the-dreams.de \
/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).