diff options
Diffstat (limited to 'drivers/i2c/busses/i2c-designware.c')
-rw-r--r-- | drivers/i2c/busses/i2c-designware.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/drivers/i2c/busses/i2c-designware.c b/drivers/i2c/busses/i2c-designware.c index e8e2212d576e..c3702a8647cb 100644 --- a/drivers/i2c/busses/i2c-designware.c +++ b/drivers/i2c/busses/i2c-designware.c | |||
@@ -360,8 +360,7 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev) | |||
360 | { | 360 | { |
361 | struct i2c_msg *msgs = dev->msgs; | 361 | struct i2c_msg *msgs = dev->msgs; |
362 | u32 intr_mask; | 362 | u32 intr_mask; |
363 | int tx_limit = dev->tx_fifo_depth - readl(dev->base + DW_IC_TXFLR); | 363 | int tx_limit, rx_limit; |
364 | int rx_limit = dev->rx_fifo_depth - readl(dev->base + DW_IC_RXFLR); | ||
365 | u32 addr = msgs[dev->msg_write_idx].addr; | 364 | u32 addr = msgs[dev->msg_write_idx].addr; |
366 | u32 buf_len = dev->tx_buf_len; | 365 | u32 buf_len = dev->tx_buf_len; |
367 | u8 *buf = dev->tx_buf;; | 366 | u8 *buf = dev->tx_buf;; |
@@ -389,6 +388,9 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev) | |||
389 | buf_len = msgs[dev->msg_write_idx].len; | 388 | buf_len = msgs[dev->msg_write_idx].len; |
390 | } | 389 | } |
391 | 390 | ||
391 | tx_limit = dev->tx_fifo_depth - readl(dev->base + DW_IC_TXFLR); | ||
392 | rx_limit = dev->rx_fifo_depth - readl(dev->base + DW_IC_RXFLR); | ||
393 | |||
392 | while (buf_len > 0 && tx_limit > 0 && rx_limit > 0) { | 394 | while (buf_len > 0 && tx_limit > 0 && rx_limit > 0) { |
393 | if (msgs[dev->msg_write_idx].flags & I2C_M_RD) { | 395 | if (msgs[dev->msg_write_idx].flags & I2C_M_RD) { |
394 | writel(0x100, dev->base + DW_IC_DATA_CMD); | 396 | writel(0x100, dev->base + DW_IC_DATA_CMD); |
@@ -418,7 +420,7 @@ i2c_dw_read(struct dw_i2c_dev *dev) | |||
418 | { | 420 | { |
419 | struct i2c_msg *msgs = dev->msgs; | 421 | struct i2c_msg *msgs = dev->msgs; |
420 | u32 addr = msgs[dev->msg_read_idx].addr; | 422 | u32 addr = msgs[dev->msg_read_idx].addr; |
421 | int rx_valid = readl(dev->base + DW_IC_RXFLR); | 423 | int rx_valid; |
422 | 424 | ||
423 | for (; dev->msg_read_idx < dev->msgs_num; dev->msg_read_idx++) { | 425 | for (; dev->msg_read_idx < dev->msgs_num; dev->msg_read_idx++) { |
424 | u32 len; | 426 | u32 len; |
@@ -439,6 +441,8 @@ i2c_dw_read(struct dw_i2c_dev *dev) | |||
439 | buf = dev->rx_buf; | 441 | buf = dev->rx_buf; |
440 | } | 442 | } |
441 | 443 | ||
444 | rx_valid = readl(dev->base + DW_IC_RXFLR); | ||
445 | |||
442 | for (; len > 0 && rx_valid > 0; len--, rx_valid--) | 446 | for (; len > 0 && rx_valid > 0; len--, rx_valid--) |
443 | *buf++ = readl(dev->base + DW_IC_DATA_CMD); | 447 | *buf++ = readl(dev->base + DW_IC_DATA_CMD); |
444 | 448 | ||