From aeddec2ec549ccfdb25879a0f81c72a729748ce9 Mon Sep 17 00:00:00 2001 From: Jari Nippula Date: Wed, 1 Mar 2023 09:55:22 +0200 Subject: [PATCH] clear i2c ints before the transfer starts If transfer is restarted in irq handler the interrupts shall be cleared before the start bit is set in control register. This is to avoid ints being accidentally cleared before they are handled leading to timeout error. --- arch/risc-v/src/mpfs/mpfs_i2c.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/risc-v/src/mpfs/mpfs_i2c.c b/arch/risc-v/src/mpfs/mpfs_i2c.c index 5e7bde97b0b..8ca4f1b20ac 100644 --- a/arch/risc-v/src/mpfs/mpfs_i2c.c +++ b/arch/risc-v/src/mpfs/mpfs_i2c.c @@ -396,6 +396,11 @@ static int mpfs_i2c_irq(int cpuint, void *context, void *arg) break; case MPFS_I2C_ST_LOST_ARB: + + /* Clear interrupt. */ + + modifyreg32(MPFS_I2C_CTRL, MPFS_I2C_CTRL_SI_MASK, 0); + clear_irq = 0u; modifyreg32(MPFS_I2C_CTRL, MPFS_I2C_CTRL_STA_MASK, MPFS_I2C_CTRL_STA_MASK); break; @@ -416,6 +421,10 @@ static int mpfs_i2c_irq(int cpuint, void *context, void *arg) } else if (msg->flags & I2C_M_NOSTOP) { + /* Clear interrupt. */ + + modifyreg32(MPFS_I2C_CTRL, MPFS_I2C_CTRL_SI_MASK, 0); + clear_irq = 0u; modifyreg32(MPFS_I2C_CTRL, MPFS_I2C_CTRL_STA_MASK, MPFS_I2C_CTRL_STA_MASK);