aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-omap.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 0195d9969df..faaa0522490 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -302,15 +302,9 @@ static void __omap_i2c_init(struct omap_i2c_dev *dev)
302 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate); 302 omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate);
303} 303}
304 304
305static int omap_i2c_init(struct omap_i2c_dev *dev) 305static int omap_i2c_reset(struct omap_i2c_dev *dev)
306{ 306{
307 u16 psc = 0, scll = 0, sclh = 0;
308 u16 fsscll = 0, fssclh = 0, hsscll = 0, hssclh = 0;
309 unsigned long fclk_rate = 12000000;
310 unsigned long timeout; 307 unsigned long timeout;
311 unsigned long internal_clk = 0;
312 struct clk *fclk;
313
314 if (dev->rev >= OMAP_I2C_OMAP1_REV_2) { 308 if (dev->rev >= OMAP_I2C_OMAP1_REV_2) {
315 /* Disable I2C controller before soft reset */ 309 /* Disable I2C controller before soft reset */
316 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 310 omap_i2c_write_reg(dev, OMAP_I2C_CON_REG,
@@ -348,14 +342,27 @@ static int omap_i2c_init(struct omap_i2c_dev *dev)
348 342
349 omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, 343 omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG,
350 dev->syscstate); 344 dev->syscstate);
351 /*
352 * Enabling all wakup sources to stop I2C freezing on
353 * WFI instruction.
354 * REVISIT: Some wkup sources might not be needed.
355 */
356 dev->westate = OMAP_I2C_WE_ALL;
357 } 345 }
358 } 346 }
347 return 0;
348}
349
350static int omap_i2c_init(struct omap_i2c_dev *dev)
351{
352 u16 psc = 0, scll = 0, sclh = 0;
353 u16 fsscll = 0, fssclh = 0, hsscll = 0, hssclh = 0;
354 unsigned long fclk_rate = 12000000;
355 unsigned long internal_clk = 0;
356 struct clk *fclk;
357
358 if (dev->rev >= OMAP_I2C_REV_ON_3430_3530) {
359 /*
360 * Enabling all wakup sources to stop I2C freezing on
361 * WFI instruction.
362 * REVISIT: Some wkup sources might not be needed.
363 */
364 dev->westate = OMAP_I2C_WE_ALL;
365 }
359 366
360 if (dev->flags & OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK) { 367 if (dev->flags & OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK) {
361 /* 368 /*
@@ -599,7 +606,8 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
599 OMAP_I2C_TIMEOUT); 606 OMAP_I2C_TIMEOUT);
600 if (timeout == 0) { 607 if (timeout == 0) {
601 dev_err(dev->dev, "controller timed out\n"); 608 dev_err(dev->dev, "controller timed out\n");
602 omap_i2c_init(dev); 609 omap_i2c_reset(dev);
610 __omap_i2c_init(dev);
603 return -ETIMEDOUT; 611 return -ETIMEDOUT;
604 } 612 }
605 613
@@ -609,7 +617,8 @@ static int omap_i2c_xfer_msg(struct i2c_adapter *adap,
609 /* We have an error */ 617 /* We have an error */
610 if (dev->cmd_err & (OMAP_I2C_STAT_AL | OMAP_I2C_STAT_ROVR | 618 if (dev->cmd_err & (OMAP_I2C_STAT_AL | OMAP_I2C_STAT_ROVR |
611 OMAP_I2C_STAT_XUDF)) { 619 OMAP_I2C_STAT_XUDF)) {
612 omap_i2c_init(dev); 620 omap_i2c_reset(dev);
621 __omap_i2c_init(dev);
613 return -EIO; 622 return -EIO;
614 } 623 }
615 624