aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-s3c2410.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses/i2c-s3c2410.c')
-rw-r--r--drivers/i2c/busses/i2c-s3c2410.c21
1 files changed, 18 insertions, 3 deletions
diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c
index d27072b2249f..72902e0bbfa7 100644
--- a/drivers/i2c/busses/i2c-s3c2410.c
+++ b/drivers/i2c/busses/i2c-s3c2410.c
@@ -35,9 +35,9 @@
35#include <linux/clk.h> 35#include <linux/clk.h>
36#include <linux/cpufreq.h> 36#include <linux/cpufreq.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/io.h>
38 39
39#include <asm/irq.h> 40#include <asm/irq.h>
40#include <asm/io.h>
41 41
42#include <plat/regs-iic.h> 42#include <plat/regs-iic.h>
43#include <plat/iic.h> 43#include <plat/iic.h>
@@ -482,7 +482,8 @@ static int s3c24xx_i2c_set_master(struct s3c24xx_i2c *i2c)
482static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c, 482static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c,
483 struct i2c_msg *msgs, int num) 483 struct i2c_msg *msgs, int num)
484{ 484{
485 unsigned long timeout; 485 unsigned long iicstat, timeout;
486 int spins = 20;
486 int ret; 487 int ret;
487 488
488 if (i2c->suspended) 489 if (i2c->suspended)
@@ -521,7 +522,21 @@ static int s3c24xx_i2c_doxfer(struct s3c24xx_i2c *i2c,
521 522
522 /* ensure the stop has been through the bus */ 523 /* ensure the stop has been through the bus */
523 524
524 msleep(1); 525 dev_dbg(i2c->dev, "waiting for bus idle\n");
526
527 /* first, try busy waiting briefly */
528 do {
529 iicstat = readl(i2c->regs + S3C2410_IICSTAT);
530 } while ((iicstat & S3C2410_IICSTAT_START) && --spins);
531
532 /* if that timed out sleep */
533 if (!spins) {
534 msleep(1);
535 iicstat = readl(i2c->regs + S3C2410_IICSTAT);
536 }
537
538 if (iicstat & S3C2410_IICSTAT_START)
539 dev_warn(i2c->dev, "timeout waiting for bus idle\n");
525 540
526 out: 541 out:
527 return ret; 542 return ret;