From: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org
Cc: u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org,
khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org,
ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org,
linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
spear-devel-nkJGhpqTU55BDgjK7y7TUQ@public.gmane.org,
paul-YHLC2tV1sDlxR4N9A70vTlRxknfHcPLb9dF7HbQ/qKg@public.gmane.org,
Viresh Kumar
<viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Vincenzo Frascino
<vincenzo.frascino-qxv4g6HH51o@public.gmane.org>,
Shiraz Hashim <shiraz.hashim-qxv4g6HH51o@public.gmane.org>
Subject: [PATCH V8 2/2] i2c/designware: Provide i2c bus recovery support
Date: Mon, 3 Dec 2012 08:24:05 +0530 [thread overview]
Message-ID: <7f319334237d8cfad4e6d29499d7424c3e739608.1354502924.git.viresh.kumar@linaro.org> (raw)
In-Reply-To: <547205b4f54e6b48746efc7c22ccc0a59bd9b659.1354502924.git.viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
In-Reply-To: <547205b4f54e6b48746efc7c22ccc0a59bd9b659.1354502924.git.viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
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 designware I2C controller.
Signed-off-by: Vincenzo Frascino <vincenzo.frascino-qxv4g6HH51o@public.gmane.org>
Signed-off-by: Shiraz Hashim <shiraz.hashim-qxv4g6HH51o@public.gmane.org>
Signed-off-by: Viresh Kumar <viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
---
V7->V8:
- Removed setting clock_rate_khz.
drivers/i2c/busses/i2c-designware-core.c | 6 +++++-
drivers/i2c/busses/i2c-designware-platdrv.c | 17 +++++++++++++++--
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-core.c b/drivers/i2c/busses/i2c-designware-core.c
index cbba7db..24feaaf 100644
--- a/drivers/i2c/busses/i2c-designware-core.c
+++ b/drivers/i2c/busses/i2c-designware-core.c
@@ -538,7 +538,11 @@ 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 (adap->bus_recovery_info) {
+ dev_dbg(dev->dev, "try i2c bus recovery\n");
+ adap->bus_recovery_info->recover_bus(adap);
+ }
+
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 0506fef..8c44eb9 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -55,6 +55,7 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev)
struct dw_i2c_dev *dev;
struct i2c_adapter *adap;
struct resource *mem, *ioarea;
+ struct i2c_bus_recovery_info *recovery_info;
int irq, r;
/* NOTE: driver uses the static register mapping */
@@ -141,17 +142,27 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev)
adap->dev.parent = &pdev->dev;
adap->dev.of_node = pdev->dev.of_node;
+ /* Bus recovery support */
+ recovery_info = dev_get_platdata(&pdev->dev);
+ if (recovery_info) {
+ recovery_info->recover_bus = i2c_generic_gpio_recovery;
+ adap->bus_recovery_info = recovery_info;
+ } else {
+ adap->bus_recovery_info = NULL;
+ }
+
adap->nr = pdev->id;
r = i2c_add_numbered_adapter(adap);
if (r) {
dev_err(&pdev->dev, "failure adding adapter\n");
- goto err_free_irq;
+ goto err_free_recovery_info;
}
of_i2c_register_devices(adap);
return 0;
-err_free_irq:
+err_free_recovery_info:
+ kfree(recovery_info);
free_irq(dev->irq, dev);
err_iounmap:
iounmap(dev->base);
@@ -174,6 +185,8 @@ static int __devexit dw_i2c_remove(struct platform_device *pdev)
struct dw_i2c_dev *dev = platform_get_drvdata(pdev);
struct resource *mem;
+ kfree(dev->adapter.bus_recovery_info);
+
platform_set_drvdata(pdev, NULL);
i2c_del_adapter(&dev->adapter);
put_device(&pdev->dev);
--
1.7.12.rc2.18.g61b472e
next prev parent reply other threads:[~2012-12-03 2:54 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-03 2:54 [PATCH V8 1/2] i2c/adapter: Add bus recovery infrastructure Viresh Kumar
[not found] ` <547205b4f54e6b48746efc7c22ccc0a59bd9b659.1354502924.git.viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2012-12-03 2:54 ` Viresh Kumar [this message]
[not found] ` <7f319334237d8cfad4e6d29499d7424c3e739608.1354502924.git.viresh.kumar-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2013-01-24 7:24 ` [PATCH V8 2/2] i2c/designware: Provide i2c bus recovery support Wolfram Sang
[not found] ` <20130124072456.GB8364-8EAEigeeuNG034pCzgS/Qg7AFbiQbgqx@public.gmane.org>
2013-01-24 7:55 ` Viresh Kumar
2012-12-06 2:07 ` [PATCH V8 1/2] i2c/adapter: Add bus recovery infrastructure Viresh Kumar
[not found] ` <CAKohpokjxh0DDZVFy1uN7ejdd_=jkbyVvYCy73jJChMy5dKeGA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-12-06 15:58 ` Paul Carpenter
[not found] ` <50C0C08E.4060807-YHLC2tV1sDlxR4N9A70vTlRxknfHcPLb9dF7HbQ/qKg@public.gmane.org>
2012-12-06 16:01 ` Viresh Kumar
2012-12-06 20:30 ` Paul Carpenter
[not found] ` <50C1005B.7-YHLC2tV1sDlxR4N9A70vTlRxknfHcPLb9dF7HbQ/qKg@public.gmane.org>
2012-12-11 4:52 ` Viresh Kumar
[not found] ` <CAKohpo=4xDOQMcbraq9Hj1Gq1xOgSoDj9xoYLHcosTyUJkD6fg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-12-19 0:00 ` Wolfram Sang
[not found] ` <20121219000000.GC19157-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2012-12-19 1:16 ` Paul Carpenter
2012-12-20 9:17 ` Viresh Kumar
[not found] ` <CAKohponZSSyAGnayRXLOBRZ+AgfB1ut3MLyvHSOTQMPTeU-uxA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-01-07 10:32 ` Viresh Kumar
[not found] ` <CAKohpo=1BfLScbqk-Mt_kA62pP1+EKUxCkSRbKvLfiXhGyvz5A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-01-23 15:44 ` Viresh Kumar
2013-01-24 7:24 ` Wolfram Sang
[not found] ` <20130124072445.GA8364-8EAEigeeuNG034pCzgS/Qg7AFbiQbgqx@public.gmane.org>
2013-01-24 8:47 ` Viresh Kumar
[not found] ` <CAKohpo=HhdsVRqzGN87yUSz3rEn-3MHEh3rM0-XJJgcX19kXUg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-01-25 8:50 ` Wolfram Sang
[not found] ` <20130125085012.GB5684-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-01-25 8:54 ` Viresh Kumar
[not found] ` <CAKohpokBLyJ8PEO6vP-LPt4rj4CkmyBWJ0s9TKiGhKOTEcfywA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-01-25 8:59 ` Wolfram Sang
2013-01-24 10:54 ` Uwe Kleine-König
[not found] ` <20130124105438.GB8668-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-01-24 11:00 ` Viresh Kumar
2013-01-25 8:53 ` Wolfram Sang
[not found] ` <20130125085337.GC5684-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-01-25 9:04 ` Uwe Kleine-König
[not found] ` <20130125090447.GG8668-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org>
2013-01-25 9:23 ` Wolfram Sang
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=7f319334237d8cfad4e6d29499d7424c3e739608.1354502924.git.viresh.kumar@linaro.org \
--to=viresh.kumar-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
--cc=ben-linux-elnMNo+KYs3YtjvyW6yDsg@public.gmane.org \
--cc=khali-PUYAD+kWke1g9hUCZPvPmw@public.gmane.org \
--cc=linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=paul-YHLC2tV1sDlxR4N9A70vTlRxknfHcPLb9dF7HbQ/qKg@public.gmane.org \
--cc=shiraz.hashim-qxv4g6HH51o@public.gmane.org \
--cc=spear-devel-nkJGhpqTU55BDgjK7y7TUQ@public.gmane.org \
--cc=u.kleine-koenig-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org \
--cc=vincenzo.frascino-qxv4g6HH51o@public.gmane.org \
--cc=w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@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).