Skip to content

Commit

Permalink
i2c: uniphier-f: fix misdetection of incomplete STOP condition
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Wolfram Sang <[email protected]>
  • Loading branch information
masahir0y authored and Wolfram Sang committed Sep 24, 2016
1 parent 6212e1d commit fcbd4bd
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions drivers/i2c/busses/i2c-uniphier-f.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#include <linux/clk.h>
#include <linux/i2c.h>
#include <linux/iopoll.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/module.h>
Expand Down Expand Up @@ -348,14 +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);

if (!(status & UNIPHIER_FI2C_SR_STS) ||
status & UNIPHIER_FI2C_SR_BB) {
u32 status;
int ret;

ret = readl_poll_timeout(priv->membase + UNIPHIER_FI2C_SR,
status,
(status & UNIPHIER_FI2C_SR_STS) &&
!(status & UNIPHIER_FI2C_SR_BB),
1, 20);
if (ret) {
dev_err(&adap->dev,
"stop condition was not completed.\n");
uniphier_fi2c_recover(priv);
return -EBUSY;
return ret;
}
}

Expand Down

0 comments on commit fcbd4bd

Please sign in to comment.