diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-12-10 13:01:47 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-12-10 13:01:47 -0600 |
commit | 8a40d2184703e8ace4e3d0a5b3b86783987d197c (patch) | |
tree | af638a4b711f3716f51151b078acd77cb152ba52 /nuttx | |
parent | 1c5abb17abdb5ac0d8d895b6f74407d098c0fa1b (diff) | |
download | nuttx-8a40d2184703e8ace4e3d0a5b3b86783987d197c.tar.gz nuttx-8a40d2184703e8ace4e3d0a5b3b86783987d197c.tar.bz2 nuttx-8a40d2184703e8ace4e3d0a5b3b86783987d197c.zip |
Tiva I2C: Add workaround for errata; clean up some error handling
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/arch/arm/src/tiva/tiva_i2c.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/nuttx/arch/arm/src/tiva/tiva_i2c.c b/nuttx/arch/arm/src/tiva/tiva_i2c.c index de3f3e093..152d8c02b 100644 --- a/nuttx/arch/arm/src/tiva/tiva_i2c.c +++ b/nuttx/arch/arm/src/tiva/tiva_i2c.c @@ -996,11 +996,20 @@ static int tiva_i2c_interrupt(struct tiva_i2c_priv_s *priv, uint32_t status) { uint32_t mcs; +#ifndef CONFIG_I2C_POLLED /* Clear the pending master interrupt */ tiva_i2c_putreg(priv, TIVA_I2CM_ICR_OFFSET, I2CM_ICR_MIC); status &= ~I2CM_RIS_MRIS; + /* Workaround for I2C master interrupt clear errata for rev B Tiva + * devices. For later devices, this write is ignored and therefore + * harmless (other than the slight performance hit). + */ + + (void)tiva_i2c_getreg(priv, TIVA_I2CM_MIS_OFFSET); +#endif + /* We need look at the Master Control/Status register to determine the cause * of the master interrupt. */ @@ -1179,7 +1188,9 @@ static int tiva_i2c_interrupt(struct tiva_i2c_priv_s *priv, uint32_t status) /* Make sure that all pending interrupts were handled */ +#ifndef CONFIG_I2C_POLLED DEBUGASSERT(status == 0); +#endif return OK; } @@ -1571,7 +1582,11 @@ static int tiva_i2c_process(struct i2c_dev_s *dev, struct i2c_msg_s *msgs, i2cdbg("ERROR: Timed out\n"); errval = ETIMEDOUT; } - else if ((priv->status & I2CM_CS_ERROR) != 0) +#ifdef I2CM_CS_CLKTO + else if ((priv->status & (I2CM_CS_ERROR | I2CM_CS_ARBLST | I2CM_CS_CLKTO)) != 0) +#else + else if ((priv->status & (I2CM_CS_ERROR | I2CM_CS_ARBLST)) != 0) +#endif { if ((priv->status & I2CM_CS_ARBLST) != 0) { @@ -1609,7 +1624,9 @@ static int tiva_i2c_process(struct i2c_dev_s *dev, struct i2c_msg_s *msgs, if ((tiva_i2c_getreg(priv, TIVA_I2CM_CS_OFFSET) & (I2CM_CS_BUSY | I2CM_CS_BUSBSY)) != 0) { - /* I2C Bus is for some reason busy */ + /* I2C Bus is for some reason busy. If I2CM_CS_BUSY then none of the + * other bits are valid. + */ errval = EBUSY; } |