[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241101081243.1230797-1-loven.liu@jaguarmicro.com>
Date: Fri, 1 Nov 2024 16:12:43 +0800
From: Liu Peibao <loven.liu@...uarmicro.com>
To: Jarkko Nikula <jarkko.nikula@...ux.intel.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Jan Dabros <jsd@...ihalf.com>,
Andi Shyti <andi.shyti@...nel.org>
Cc: "xiaowu . ding" <xiaowu.ding@...uarmicro.com>,
Angus Chen <angus.chen@...uarmicro.com>,
Liu Peibao <loven.liu@...uarmicro.com>,
linux-i2c@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH RESEND TO CC MAILLIST] i2c: designware: fix master holding SCL low when I2C_DYNAMIC_TAR_UPDATE not set
When Tx FIFO empty and last command with 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 quiet similar as commit 2409205acd3c ("i2c: designware:
fix __i2c_dw_disable() in case master is holding SCL low") mentioned.
Check BIT(7) MST_HOLD_TX_FIFO_EMPTY in IC_STATUS also which is available
when IC_STAT_FOR_CLK_STRETCH is set.
Signed-off-by: Liu Peibao <loven.liu@...uarmicro.com>
Signed-off-by: xiaowu.ding <xiaowu.ding@...uarmicro.com>
Signed-off-by: Angus Chen <angus.chen@...uarmicro.com>
---
drivers/i2c/busses/i2c-designware-common.c | 6 ++++--
drivers/i2c/busses/i2c-designware-core.h | 1 +
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-common.c b/drivers/i2c/busses/i2c-designware-common.c
index f31d352d98b5..9d88b4fa03e4 100644
--- a/drivers/i2c/busses/i2c-designware-common.c
+++ b/drivers/i2c/busses/i2c-designware-common.c
@@ -524,7 +524,7 @@ int i2c_dw_set_sda_hold(struct dw_i2c_dev *dev)
void __i2c_dw_disable(struct dw_i2c_dev *dev)
{
struct i2c_timings *t = &dev->timings;
- unsigned int raw_intr_stats;
+ unsigned int raw_intr_stats, ic_stats;
unsigned int enable;
int timeout = 100;
bool abort_needed;
@@ -532,9 +532,11 @@ void __i2c_dw_disable(struct dw_i2c_dev *dev)
int ret;
regmap_read(dev->map, DW_IC_RAW_INTR_STAT, &raw_intr_stats);
+ regmap_read(dev->map, DW_IC_STATUS, &ic_stats);
regmap_read(dev->map, DW_IC_ENABLE, &enable);
- abort_needed = raw_intr_stats & DW_IC_INTR_MST_ON_HOLD;
+ abort_needed = (raw_intr_stats & DW_IC_INTR_MST_ON_HOLD) ||
+ (ic_stats & DW_IC_STATUS_MASTER_HOLD_TX_FIFO_EMPTY);
if (abort_needed) {
if (!(enable & DW_IC_ENABLE_ENABLE)) {
regmap_write(dev->map, DW_IC_ENABLE, DW_IC_ENABLE_ENABLE);
diff --git a/drivers/i2c/busses/i2c-designware-core.h b/drivers/i2c/busses/i2c-designware-core.h
index 8e8854ec9882..2d32896d0673 100644
--- a/drivers/i2c/busses/i2c-designware-core.h
+++ b/drivers/i2c/busses/i2c-designware-core.h
@@ -116,6 +116,7 @@
#define DW_IC_STATUS_RFNE BIT(3)
#define DW_IC_STATUS_MASTER_ACTIVITY BIT(5)
#define DW_IC_STATUS_SLAVE_ACTIVITY BIT(6)
+#define DW_IC_STATUS_MASTER_HOLD_TX_FIFO_EMPTY BIT(7)
#define DW_IC_SDA_HOLD_RX_SHIFT 16
#define DW_IC_SDA_HOLD_RX_MASK GENMASK(23, 16)
--
2.34.1
Powered by blists - more mailing lists