summaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorDavid Engraf <david.engraf@sysgo.com>2018-04-26 11:53:14 +0200
committerWolfram Sang <wsa@the-dreams.de>2018-04-30 10:39:28 +0200
commite8f39e9fc0e0b7bce24922da925af820bacb8ef8 (patch)
treee5924b6a5f72b3a9e98f3970a1319b2959447b5e /drivers/i2c
parent562de4ff4cd2beb1bd3a1581e22623f05b114c97 (diff)
i2c: at91: Read all available bytes at once
With FIFO enabled it is possible to read multiple bytes at once in the interrupt handler as long as RXRDY is set. This may also reduce the number of interrupts. This patch polls RXRDY and reads all available bytes at once. Signed-off-by: David Engraf <david.engraf@sysgo.com> Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com> [wsa: reformatted comment] Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-at91.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index bfd1fdff64a9..3f3e8b3bf5ff 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -518,8 +518,16 @@ static irqreturn_t atmel_twi_interrupt(int irq, void *dev_id)
* the RXRDY interrupt first in order to not keep garbage data in the
* Receive Holding Register for the next transfer.
*/
- if (irqstatus & AT91_TWI_RXRDY)
- at91_twi_read_next_byte(dev);
+ if (irqstatus & AT91_TWI_RXRDY) {
+ /*
+ * Read all available bytes at once by polling RXRDY usable w/
+ * and w/o FIFO. With FIFO enabled we could also read RXFL and
+ * avoid polling RXRDY.
+ */
+ do {
+ at91_twi_read_next_byte(dev);
+ } while (at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_RXRDY);
+ }
/*
* When a NACK condition is detected, the I2C controller sets the NACK,