Patchwork [V10,Resend] i2c/designware: Provide i2c bus recovery support

login
register
mail settings
Submitter viresh kumar
Date June 17, 2013, 1:16 p.m.
Message ID <70c7ee79478cc2b89ad876d814207c6433e26a59.1371474881.git.viresh.kumar@linaro.org>
Download mbox | patch
Permalink /patch/251846/
State New
Headers show

Comments

viresh kumar - June 17, 2013, 1:16 p.m.
Add bus recovery support for designware_i2c controller. It uses generic gpio
based i2c_gpio_recover_bus() routine. Platforms need to pass struct
i2c_bus_recovery_info as platform data to designware I2C controller.

Signed-off-by: Vincenzo Frascino <vincenzo.frascino@st.com>
Signed-off-by: Shiraz Hashim <shiraz.hashim@st.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---

This patch isn't drawing attention since sometime, so sending it again.

 drivers/i2c/busses/i2c-designware-core.c    | 5 ++++-
 drivers/i2c/busses/i2c-designware-platdrv.c | 6 ++++++
 2 files changed, 10 insertions(+), 1 deletion(-)
viresh kumar - July 24, 2013, 9:16 a.m.
On 17 June 2013 18:46, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> Add bus recovery support for designware_i2c controller. It uses generic gpio
> based i2c_gpio_recover_bus() routine. Platforms need to pass struct
> i2c_bus_recovery_info as platform data to designware I2C controller.
>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@st.com>
> Signed-off-by: Shiraz Hashim <shiraz.hashim@st.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>
> This patch isn't drawing attention since sometime, so sending it again.
>
>  drivers/i2c/busses/i2c-designware-core.c    | 5 ++++-
>  drivers/i2c/busses/i2c-designware-platdrv.c | 6 ++++++
>  2 files changed, 10 insertions(+), 1 deletion(-)

Ping!!
--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wolfram Sang - Sept. 8, 2013, 5:25 p.m.
On Mon, Jun 17, 2013 at 06:46:45PM +0530, Viresh Kumar wrote:
> Add bus recovery support for designware_i2c controller. It uses generic gpio
> based i2c_gpio_recover_bus() routine. Platforms need to pass struct
> i2c_bus_recovery_info as platform data to designware I2C controller.
> 
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@st.com>
> Signed-off-by: Shiraz Hashim <shiraz.hashim@st.com>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---

I come back thinking about it every once in a while but I can't convince
myself to let masters reset the bus after a timeout in the driver. I am
all open for suggestions here...

Patch

diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
index c41ca63..5ecb2f0 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -583,7 +583,10 @@  i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
 	ret = wait_for_completion_interruptible_timeout(&dev->cmd_complete, HZ);
 	if (ret == 0) {
 		dev_err(dev->dev, "controller timed out\n");
-		i2c_dw_init(dev);
+
+		if (i2c_recover_bus(adap) < 0)
+			i2c_dw_init(dev);
+
 		ret = -ETIMEDOUT;
 		goto done;
 	} else if (ret < 0)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index 35b70a1..c3ada3e 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -162,6 +162,12 @@  static int dw_i2c_probe(struct platform_device *pdev)
 	adap->dev.parent = &pdev->dev;
 	adap->dev.of_node = pdev->dev.of_node;
 
+	/* Bus recovery support */
+	adap->bus_recovery_info = dev_get_platdata(&pdev->dev);
+	if (adap->bus_recovery_info)
+		adap->bus_recovery_info->recover_bus =
+			i2c_generic_gpio_recovery;
+
 	r = i2c_add_numbered_adapter(adap);
 	if (r) {
 		dev_err(&pdev->dev, "failure adding adapter\n");