Skip to content

Commit e8f39e9

Browse files
dengrafWolfram Sang
authored andcommitted
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>
1 parent 562de4f commit e8f39e9

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

drivers/i2c/busses/i2c-at91.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,8 +518,16 @@ static irqreturn_t atmel_twi_interrupt(int irq, void *dev_id)
518518
* the RXRDY interrupt first in order to not keep garbage data in the
519519
* Receive Holding Register for the next transfer.
520520
*/
521-
if (irqstatus & AT91_TWI_RXRDY)
522-
at91_twi_read_next_byte(dev);
521+
if (irqstatus & AT91_TWI_RXRDY) {
522+
/*
523+
* Read all available bytes at once by polling RXRDY usable w/
524+
* and w/o FIFO. With FIFO enabled we could also read RXFL and
525+
* avoid polling RXRDY.
526+
*/
527+
do {
528+
at91_twi_read_next_byte(dev);
529+
} while (at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_RXRDY);
530+
}
523531

524532
/*
525533
* When a NACK condition is detected, the I2C controller sets the NACK,

0 commit comments

Comments
 (0)