Skip to content

Commit

Permalink
arch/risc-v/src/mpfs/mpfs_i2c.c: Clear I2C_CTRL bits when initializin…
Browse files Browse the repository at this point in the history
…g/deinitializing bus

Ensure that there are no pending state or interrupts in the i2c controller. This removes
errors caused by deinitialize/initialize sequences in error cases.

Signed-off-by: Jukka Laitinen <[email protected]>
  • Loading branch information
Jukka Laitinen committed Jan 11, 2024
1 parent 082e76f commit 100136e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions arch/risc-v/src/mpfs/mpfs_i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,9 @@ static int mpfs_i2c_init(struct mpfs_i2c_priv_s *priv)

putreg32(priv->ser_address, MPFS_I2C_ADDR);

/* Enable i2c bus */
/* Enable i2c bus, clear all other bits */

modifyreg32(MPFS_I2C_CTRL, MPFS_I2C_CTRL_ENS1_MASK,
MPFS_I2C_CTRL_ENS1_MASK);
putreg32(MPFS_I2C_CTRL_ENS1_MASK, MPFS_I2C_CTRL);

priv->initialized = true;
}
Expand All @@ -384,8 +383,7 @@ static void mpfs_i2c_deinit(struct mpfs_i2c_priv_s *priv)
up_disable_irq(priv->plic_irq);
irq_detach(priv->plic_irq);

modifyreg32(MPFS_I2C_CTRL, MPFS_I2C_CTRL_ENS1_MASK,
~MPFS_I2C_CTRL_ENS1_MASK);
putreg32(0, MPFS_I2C_CTRL);

priv->initialized = false;
}
Expand Down

0 comments on commit 100136e

Please sign in to comment.