Skip to content

Commit 1ddbc8e

Browse files
Liu Peibaogregkh
authored andcommitted
i2c: designware: do not hold SCL low when I2C_DYNAMIC_TAR_UPDATE is not set
commit 8de3e97 upstream. When the Tx FIFO is empty and the last command has no STOP bit set, the master holds SCL low. If I2C_DYNAMIC_TAR_UPDATE is not set, BIT(13) MST_ON_HOLD of IC_RAW_INTR_STAT is not enabled, causing the __i2c_dw_disable() timeout. This is quite similar to commit 2409205 ("i2c: designware: fix __i2c_dw_disable() in case master is holding SCL low"). Also check BIT(7) MST_HOLD_TX_FIFO_EMPTY in IC_STATUS, which is available when IC_STAT_FOR_CLK_STRETCH is set. Fixes: 2409205 ("i2c: designware: fix __i2c_dw_disable() in case master is holding SCL low") Co-developed-by: Xiaowu Ding <xiaowu.ding@jaguarmicro.com> Signed-off-by: Xiaowu Ding <xiaowu.ding@jaguarmicro.com> Co-developed-by: Angus Chen <angus.chen@jaguarmicro.com> Signed-off-by: Angus Chen <angus.chen@jaguarmicro.com> Signed-off-by: Liu Peibao <loven.liu@jaguarmicro.com> Acked-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 6450e73 commit 1ddbc8e

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

drivers/i2c/busses/i2c-designware-common.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,17 +442,19 @@ int i2c_dw_set_sda_hold(struct dw_i2c_dev *dev)
442442
void __i2c_dw_disable(struct dw_i2c_dev *dev)
443443
{
444444
struct i2c_timings *t = &dev->timings;
445-
unsigned int raw_intr_stats;
445+
unsigned int raw_intr_stats, ic_stats;
446446
unsigned int enable;
447447
int timeout = 100;
448448
bool abort_needed;
449449
unsigned int status;
450450
int ret;
451451

452452
regmap_read(dev->map, DW_IC_RAW_INTR_STAT, &raw_intr_stats);
453+
regmap_read(dev->map, DW_IC_STATUS, &ic_stats);
453454
regmap_read(dev->map, DW_IC_ENABLE, &enable);
454455

455-
abort_needed = raw_intr_stats & DW_IC_INTR_MST_ON_HOLD;
456+
abort_needed = (raw_intr_stats & DW_IC_INTR_MST_ON_HOLD) ||
457+
(ic_stats & DW_IC_STATUS_MASTER_HOLD_TX_FIFO_EMPTY);
456458
if (abort_needed) {
457459
if (!(enable & DW_IC_ENABLE_ENABLE)) {
458460
regmap_write(dev->map, DW_IC_ENABLE, DW_IC_ENABLE_ENABLE);

drivers/i2c/busses/i2c-designware-core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
#define DW_IC_STATUS_RFNE BIT(3)
118118
#define DW_IC_STATUS_MASTER_ACTIVITY BIT(5)
119119
#define DW_IC_STATUS_SLAVE_ACTIVITY BIT(6)
120+
#define DW_IC_STATUS_MASTER_HOLD_TX_FIFO_EMPTY BIT(7)
120121

121122
#define DW_IC_SDA_HOLD_RX_SHIFT 16
122123
#define DW_IC_SDA_HOLD_RX_MASK GENMASK(23, 16)

0 commit comments

Comments
 (0)