| From b76de9b136ab6f5e6fae14379a6f205bf3af3c9b Mon Sep 17 00:00:00 2001 |
| From: "Chew, Chiau Ee" <chiau.ee.chew@intel.com> |
| Date: Fri, 21 Jun 2013 15:05:28 +0800 |
| Subject: i2c: designware: Manually set RESTART bit between messages |
| |
| If both IC_EMPTYFIFO_HOLD_MASTER_EN and IC_RESTART_EN are set to 1, the |
| Designware I2C controller doesn't generate RESTART unless user specifically |
| requests it by setting RESTART bit in IC_DATA_CMD register. |
| |
| Since IC_EMPTYFIFO_HOLD_MASTER_EN setting can't be detected from hardware |
| register, we must always manually set the restart bit between messages. |
| |
| Signed-off-by: Chew, Chiau Ee <chiau.ee.chew@intel.com> |
| Signed-off-by: Wolfram Sang <wsa@the-dreams.de> |
| (cherry picked from commit 825642455367e5498da82a8044dd345ac7869c8d) |
| Signed-off-by: Darren Hart <dvhart@linux.intel.com> |
| --- |
| drivers/i2c/busses/i2c-designware-core.c | 14 ++++++++++++++ |
| 1 file changed, 14 insertions(+) |
| |
| --- a/drivers/i2c/busses/i2c-designware-core.c |
| +++ b/drivers/i2c/busses/i2c-designware-core.c |
| @@ -419,6 +419,7 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev) |
| u32 addr = msgs[dev->msg_write_idx].addr; |
| u32 buf_len = dev->tx_buf_len; |
| u8 *buf = dev->tx_buf; |
| + bool need_restart = false; |
| |
| intr_mask = DW_IC_INTR_DEFAULT_MASK; |
| |
| @@ -446,6 +447,14 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev) |
| /* new i2c_msg */ |
| buf = msgs[dev->msg_write_idx].buf; |
| buf_len = msgs[dev->msg_write_idx].len; |
| + |
| + /* If both IC_EMPTYFIFO_HOLD_MASTER_EN and |
| + * IC_RESTART_EN are set, we must manually |
| + * set restart bit between messages. |
| + */ |
| + if ((dev->master_cfg & DW_IC_CON_RESTART_EN) && |
| + (dev->msg_write_idx > 0)) |
| + need_restart = true; |
| } |
| |
| tx_limit = dev->tx_fifo_depth - dw_readl(dev, DW_IC_TXFLR); |
| @@ -464,6 +473,11 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev) |
| buf_len == 1) |
| cmd |= BIT(9); |
| |
| + if (need_restart) { |
| + cmd |= BIT(10); |
| + need_restart = false; |
| + } |
| + |
| if (msgs[dev->msg_write_idx].flags & I2C_M_RD) { |
| |
| /* avoid rx buffer overrun */ |