You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/02/06 16:52:42 UTC
(nuttx) 06/07: arch/risc-v/src/mpfs/mpfs_i2c.c: Add more i2cerr traces
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 2b10b38c1d02477851f2964cbdc649ce2974b99e
Author: Jukka Laitinen <ju...@ssrc.tii.ae>
AuthorDate: Wed Jan 10 08:45:25 2024 +0200
arch/risc-v/src/mpfs/mpfs_i2c.c: Add more i2cerr traces
Add sanity checks for debugging possible errors in the driver.
Signed-off-by: Jukka Laitinen <ju...@ssrc.tii.ae>
---
arch/risc-v/src/mpfs/mpfs_i2c.c | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/arch/risc-v/src/mpfs/mpfs_i2c.c b/arch/risc-v/src/mpfs/mpfs_i2c.c
index e9754d4ddd..495ff7658c 100644
--- a/arch/risc-v/src/mpfs/mpfs_i2c.c
+++ b/arch/risc-v/src/mpfs/mpfs_i2c.c
@@ -721,6 +721,10 @@ static int mpfs_i2c_transfer(struct i2c_master_s *dev,
{
struct mpfs_i2c_priv_s *priv = (struct mpfs_i2c_priv_s *)dev;
int ret = OK;
+#ifdef CONFIG_DEBUG_I2C_ERROR
+ int sval;
+ uint32_t status;
+#endif
i2cinfo("Starting transfer request of %d message(s):\n", count);
@@ -735,6 +739,24 @@ static int mpfs_i2c_transfer(struct i2c_master_s *dev,
return ret;
}
+#ifdef CONFIG_DEBUG_I2C_ERROR
+ /* We should never start at transfer with semaphore already signalled */
+
+ sem_getvalue(&priv->sem_isr, &sval);
+ if (sval != 0)
+ {
+ i2cerr("Already signalled at start? %d\n", sval);
+ }
+
+ /* We should always be idle before transfer */
+
+ status = getreg32(MPFS_I2C_STATUS);
+ if (status != MPFS_I2C_ST_IDLE)
+ {
+ i2cerr("I2C bus not idle before transfer! Status: 0x%x\n", status);
+ }
+#endif
+
priv->msgv = msgs;
priv->msgc = count;
@@ -827,6 +849,16 @@ static int mpfs_i2c_transfer(struct i2c_master_s *dev,
i2cinfo("Message %" PRIu8 " transfer complete.\n", priv->msgid);
}
+#ifdef CONFIG_DEBUG_I2C_ERROR
+ /* We should always be idle after the transfers */
+
+ status = getreg32(MPFS_I2C_STATUS);
+ if (status != MPFS_I2C_ST_IDLE)
+ {
+ i2cerr("I2C bus not idle after transfer! Status: 0x%x\n", status);
+ }
+#endif
+
/* Irq was enabled at mpfs_i2c_sendstart() */
up_disable_irq(priv->plic_irq);