Skip to content

Commit 8de3e97

Browse files
Liu PeibaoAndi Shyti
authored andcommitted
i2c: designware: do not hold SCL low when I2C_DYNAMIC_TAR_UPDATE is not set
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 <[email protected]> Signed-off-by: Xiaowu Ding <[email protected]> Co-developed-by: Angus Chen <[email protected]> Signed-off-by: Angus Chen <[email protected]> Signed-off-by: Liu Peibao <[email protected]> Acked-by: Jarkko Nikula <[email protected]> Signed-off-by: Andi Shyti <[email protected]>
1 parent ab2e5c8 commit 8de3e97

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,17 +524,19 @@ int i2c_dw_set_sda_hold(struct dw_i2c_dev *dev)
524524
void __i2c_dw_disable(struct dw_i2c_dev *dev)
525525
{
526526
struct i2c_timings *t = &dev->timings;
527-
unsigned int raw_intr_stats;
527+
unsigned int raw_intr_stats, ic_stats;
528528
unsigned int enable;
529529
int timeout = 100;
530530
bool abort_needed;
531531
unsigned int status;
532532
int ret;
533533

534534
regmap_read(dev->map, DW_IC_RAW_INTR_STAT, &raw_intr_stats);
535+
regmap_read(dev->map, DW_IC_STATUS, &ic_stats);
535536
regmap_read(dev->map, DW_IC_ENABLE, &enable);
536537

537-
abort_needed = raw_intr_stats & DW_IC_INTR_MST_ON_HOLD;
538+
abort_needed = (raw_intr_stats & DW_IC_INTR_MST_ON_HOLD) ||
539+
(ic_stats & DW_IC_STATUS_MASTER_HOLD_TX_FIFO_EMPTY);
538540
if (abort_needed) {
539541
if (!(enable & DW_IC_ENABLE_ENABLE)) {
540542
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
@@ -116,6 +116,7 @@
116116
#define DW_IC_STATUS_RFNE BIT(3)
117117
#define DW_IC_STATUS_MASTER_ACTIVITY BIT(5)
118118
#define DW_IC_STATUS_SLAVE_ACTIVITY BIT(6)
119+
#define DW_IC_STATUS_MASTER_HOLD_TX_FIFO_EMPTY BIT(7)
119120

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

0 commit comments

Comments
 (0)