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 <jukkax@ssrc.tii.ae>
This commit is contained in:
parent
120dfbd45f
commit
2b10b38c1d
1 changed files with 32 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue