LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] i2c: at91: Read all available bytes at once
@ 2018-04-18 12:40 David Engraf
  2018-04-25 15:08 ` Ludovic Desroches
  0 siblings, 1 reply; 9+ messages in thread
From: David Engraf @ 2018-04-18 12:40 UTC (permalink / raw)
  To: ludovic.desroches, nicolas.ferre, alexandre.belloni
  Cc: linux-i2c, linux-arm-kernel, linux-kernel, David Engraf

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.

Signed-off-by: David Engraf <david.engraf@sysgo.com>
---
 drivers/i2c/busses/i2c-at91.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index bfd1fdff64a9..d01c2b2384bd 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -518,8 +518,12 @@ 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 when FIFO is used */
+		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,
-- 
2.14.1

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-04-30  6:11 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-18 12:40 [PATCH] i2c: at91: Read all available bytes at once David Engraf
2018-04-25 15:08 ` Ludovic Desroches
2018-04-25 15:43   ` David Engraf
2018-04-26  8:25     ` Ludovic Desroches
2018-04-26  9:53       ` [PATCH v2] " David Engraf
2018-04-26 12:30         ` Ludovic Desroches
2018-04-28 12:38         ` Wolfram Sang
2018-04-30  6:11           ` David Engraf
2018-04-26  5:52   ` [PATCH] " David Engraf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).