Skip to content

Commit

Permalink
arch/arm64/src/imx9/imx9_lpi2c.c: Add error recovery on timeout
Browse files Browse the repository at this point in the history
Signed-off-by: Jukka Laitinen <[email protected]>
  • Loading branch information
jlaitine committed Sep 17, 2024
1 parent 18494f3 commit ba2eea6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions arch/arm64/src/imx9/imx9_lpi2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -2077,6 +2077,17 @@ static int imx9_lpi2c_transfer(struct i2c_master_s *dev,
ret = -ETIMEDOUT;
i2cerr("ERROR: Timed out: MSR: status: 0x0%" PRIx32 "\n",
priv->status);

/* Stop the ongoing transfer and clear the FIFOs */

imx9_lpi2c_stop_transfer(priv);

imx9_lpi2c_modifyreg(priv, IMX9_LPI2C_MCR_OFFSET, 0,
LPI2C_MCR_RTF | LPI2C_MCR_RRF);

/* Clear any errors */

imx9_lpi2c_putreg(priv, IMX9_LPI2C_MSR_OFFSET, LPI2C_MSR_ERROR_MASK);
}

/* Check for error status conditions */
Expand Down

0 comments on commit ba2eea6

Please sign in to comment.