Skip to content

Commit d34cd3e

Browse files
ChiHuaLcarlescufi
authored andcommitted
driver: I2C: npcx: re-enable interrupts after bus error
When the I2C is in the target mode and encounters the bus error, the driver has to reset the bus to recover the I2C hardware. However, when the hardware is disabled, the interrupt enable bits are also cleared automatically by design. As a result, we need to enable the interrupts after resetting the I2C hardware. Signed-off-by: Jun Lin <[email protected]>
1 parent 6529e31 commit d34cd3e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/i2c/i2c_npcx_controller.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,15 @@ static void i2c_ctrl_target_isr(const struct device *dev, uint8_t status)
770770
inst->SMBCTL2 &= ~BIT(NPCX_SMBCTL2_ENABLE);
771771
inst->SMBCTL2 |= BIT(NPCX_SMBCTL2_ENABLE);
772772

773+
/*
774+
* Re-enable interrupts because they are turned off after the SMBus module
775+
* is reset above.
776+
*/
777+
inst->SMBCTL1 |= BIT(NPCX_SMBCTL1_NMINTE) | BIT(NPCX_SMBCTL1_INTEN);
773778
/* End of transaction */
774779
data->oper_state = NPCX_I2C_IDLE;
780+
781+
LOG_DBG("target: Bus error on port%02x!", data->port);
775782
return;
776783
}
777784

0 commit comments

Comments
 (0)