Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1489977 > unrolled thread
| Started by | Masahiro Yamada <yamada.masahiro@socionext.com> |
|---|---|
| First post | 2016-09-23 14:10 +0200 |
| Last post | 2016-09-23 15:40 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] i2c: uniphier-f: fix misdetection of incomplete STOP condition Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-09-23 14:10 +0200
Re: [PATCH] i2c: uniphier-f: fix misdetection of incomplete STOP condition Wolfram Sang <wsa@the-dreams.de> - 2016-09-23 14:20 +0200
Re: [PATCH] i2c: uniphier-f: fix misdetection of incomplete STOP condition Masahiro Yamada <yamada.masahiro@socionext.com> - 2016-09-23 15:40 +0200
| From | Masahiro Yamada <yamada.masahiro@socionext.com> |
|---|---|
| Date | 2016-09-23 14:10 +0200 |
| Subject | [PATCH] i2c: uniphier-f: fix misdetection of incomplete STOP condition |
| Message-ID | <skxsJ-3rG-3@gated-at.bofh.it> |
Currently, the status register FI2C_SR is checked immediately after
a STOP condition is issued in case of the deferred STOP condition.
It takes typically 5-10 usec until the corresponding bits in the
register are set, so the error check for "stop condition was not
completed" is very likely to be false positive.
Add wait code to relax the status register check.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
drivers/i2c/busses/i2c-uniphier-f.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/i2c/busses/i2c-uniphier-f.c b/drivers/i2c/busses/i2c-uniphier-f.c
index 829df91..e5886eb 100644
--- a/drivers/i2c/busses/i2c-uniphier-f.c
+++ b/drivers/i2c/busses/i2c-uniphier-f.c
@@ -13,6 +13,7 @@
*/
#include <linux/clk.h>
+#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/io.h>
@@ -348,10 +349,19 @@ static int uniphier_fi2c_master_xfer_one(struct i2c_adapter *adap,
dev_dbg(&adap->dev, "complete\n");
if (unlikely(priv->flags & UNIPHIER_FI2C_DEFER_STOP_COMP)) {
- u32 status = readl(priv->membase + UNIPHIER_FI2C_SR);
+ time_left = 20;
- if (!(status & UNIPHIER_FI2C_SR_STS) ||
- status & UNIPHIER_FI2C_SR_BB) {
+ while (--time_left) {
+ u32 status = readl(priv->membase + UNIPHIER_FI2C_SR);
+
+ if ((status & UNIPHIER_FI2C_SR_STS) &&
+ !(status & UNIPHIER_FI2C_SR_BB))
+ break;
+
+ udelay(1);
+ }
+
+ if (!time_left) {
dev_err(&adap->dev,
"stop condition was not completed.\n");
uniphier_fi2c_recover(priv);
--
1.9.1
[toc] | [next] | [standalone]
| From | Wolfram Sang <wsa@the-dreams.de> |
|---|---|
| Date | 2016-09-23 14:20 +0200 |
| Subject | Re: [PATCH] i2c: uniphier-f: fix misdetection of incomplete STOP condition |
| Message-ID | <skxCq-3yR-27@gated-at.bofh.it> |
| In reply to | #1489977 |
[Multipart message — attachments visible in raw view] — view raw
On Fri, Sep 23, 2016 at 09:04:01PM +0900, Masahiro Yamada wrote: > Currently, the status register FI2C_SR is checked immediately after > a STOP condition is issued in case of the deferred STOP condition. > It takes typically 5-10 usec until the corresponding bits in the > register are set, so the error check for "stop condition was not > completed" is very likely to be false positive. > > Add wait code to relax the status register check. > > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Use readl_poll_timeout?
[toc] | [prev] | [next] | [standalone]
| From | Masahiro Yamada <yamada.masahiro@socionext.com> |
|---|---|
| Date | 2016-09-23 15:40 +0200 |
| Message-ID | <skyRQ-4e3-13@gated-at.bofh.it> |
| In reply to | #1489996 |
Hi Wolfram, 2016-09-23 21:12 GMT+09:00 Wolfram Sang <wsa@the-dreams.de>: > On Fri, Sep 23, 2016 at 09:04:01PM +0900, Masahiro Yamada wrote: >> Currently, the status register FI2C_SR is checked immediately after >> a STOP condition is issued in case of the deferred STOP condition. >> It takes typically 5-10 usec until the corresponding bits in the >> register are set, so the error check for "stop condition was not >> completed" is very likely to be false positive. >> >> Add wait code to relax the status register check. >> >> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> > > Use readl_poll_timeout? > Yes, thanks for your advice! -- Best Regards Masahiro Yamada
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web