Commit 82564245 authored by Chew, Chiau Ee's avatar Chew, Chiau Ee Committed by Wolfram Sang

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: default avatarChew, Chiau Ee <chiau.ee.chew@intel.com>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 9d3dda5c
...@@ -416,6 +416,7 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev) ...@@ -416,6 +416,7 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
u32 addr = msgs[dev->msg_write_idx].addr; u32 addr = msgs[dev->msg_write_idx].addr;
u32 buf_len = dev->tx_buf_len; u32 buf_len = dev->tx_buf_len;
u8 *buf = dev->tx_buf; u8 *buf = dev->tx_buf;
bool need_restart = false;
intr_mask = DW_IC_INTR_DEFAULT_MASK; intr_mask = DW_IC_INTR_DEFAULT_MASK;
...@@ -443,6 +444,14 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev) ...@@ -443,6 +444,14 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
/* new i2c_msg */ /* new i2c_msg */
buf = msgs[dev->msg_write_idx].buf; buf = msgs[dev->msg_write_idx].buf;
buf_len = msgs[dev->msg_write_idx].len; 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); tx_limit = dev->tx_fifo_depth - dw_readl(dev, DW_IC_TXFLR);
...@@ -461,6 +470,11 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev) ...@@ -461,6 +470,11 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
buf_len == 1) buf_len == 1)
cmd |= BIT(9); cmd |= BIT(9);
if (need_restart) {
cmd |= BIT(10);
need_restart = false;
}
if (msgs[dev->msg_write_idx].flags & I2C_M_RD) { if (msgs[dev->msg_write_idx].flags & I2C_M_RD) {
/* avoid rx buffer overrun */ /* avoid rx buffer overrun */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment