Skip to contentSkip to conversation

i2c: npcm: Add clock toggle in case of stuck bus during init

PATCH New [email protected] 1 participant 2 messages Mar 24, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover i2c: npcm: Add clock toggle in case of stuck bus during init

From: Tali Perry <[email protected]>

Hi,

During init of the bus, the module checks that the bus is idle. If one of the lines are stuck try to toggle them first.

Fixes 76487532f797 (i2c: npcm: Add slave enable/disable function)

---

Tali Perry (1):
i2c: npcm: Add clock toggle in case of stuck bus during init in
npcm_i2c_init_module

 drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/1 i2c: npcm: Add clock toggle in case of stuck bus during init in npcm_i2c_init_module

From: Tali Perry <[email protected]>

---
 drivers/i2c/busses/i2c-npcm7xx.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-npcm7xx.c +8 -4
index 3ad6124be80f..78c85015d955 100644
@@ -2043,10 +2043,14 @@ static int npcm_i2c_init_module(struct npcm_i2c *bus, enum i2c_mode mode,
 
 	/* Check HW is OK: SDA and SCL should be high at this point. */
 	if ((npcm_i2c_get_SDA(&bus->adap) == 0) || (npcm_i2c_get_SCL(&bus->adap) == 0)) {
-		dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num);
-		dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap),
-			npcm_i2c_get_SCL(&bus->adap));
-		return -ENXIO;
+		dev_warn(bus->dev, " I2C%d SDA=%d SCL=%d, attempt recover\n", bus->num,
+				 npcm_i2c_get_SDA(&bus->adap), npcm_i2c_get_SCL(&bus->adap));
+		if (npcm_i2c_recovery_tgclk(&bus->adap)) {
+			dev_err(bus->dev, "I2C%d init fail: lines are low\n", bus->num);
+			dev_err(bus->dev, "SDA=%d SCL=%d\n", npcm_i2c_get_SDA(&bus->adap),
+				npcm_i2c_get_SCL(&bus->adap));
+			return -ENXIO;
+		}
 	}
 
 	npcm_i2c_int_enable(bus, true);
Signature · 4 lines
2.34.1

**Reported-by: Mohammed Elbadry <[email protected]>**
**Tested-by: Mohammed Elbadry <[email protected]>**