Skip to content

Commit

Permalink
i2c: img-scb: add handle for stop detected interrupt
Browse files Browse the repository at this point in the history
Stop Detected interrupt is triggered when a Stop bit is detected on
the bus, which indicates the end of the current transfer.

When the end of a transfer is indicated by the Stop Detected interrupt,
drain the FIFO and signal completion for the transaction.

Signed-off-by: Sifan Naeem <sifan.naeem@imgtec.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
  • Loading branch information
Sifan Naeem authored and Wolfram Sang committed Jan 2, 2016
1 parent a8c5a8d commit dd29207
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion drivers/i2c/busses/i2c-img-scb.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@
#define INT_TRANSACTION_DONE BIT(15)
#define INT_SLAVE_EVENT BIT(16)
#define INT_TIMING BIT(18)
#define INT_STOP_DETECTED BIT(19)

#define INT_FIFO_FULL_FILLING (INT_FIFO_FULL | INT_FIFO_FILLING)

Expand All @@ -175,7 +176,8 @@
INT_WRITE_ACK_ERR | \
INT_FIFO_FULL | \
INT_FIFO_FILLING | \
INT_FIFO_EMPTY)
INT_FIFO_EMPTY | \
INT_STOP_DETECTED)

#define INT_ENABLE_MASK_WAITSTOP (INT_SLAVE_EVENT | \
INT_ADDR_ACK_ERR | \
Expand Down Expand Up @@ -865,6 +867,13 @@ static unsigned int img_i2c_auto(struct img_i2c *i2c,

mod_timer(&i2c->check_timer, jiffies + msecs_to_jiffies(1));

if (int_status & INT_STOP_DETECTED) {
/* Drain remaining data in FIFO and complete transaction */
if (i2c->msg.flags & I2C_M_RD)
img_i2c_read_fifo(i2c);
return ISR_COMPLETE(0);
}

if (i2c->msg.flags & I2C_M_RD) {
if (int_status & INT_FIFO_FULL_FILLING) {
img_i2c_read_fifo(i2c);
Expand Down

0 comments on commit dd29207

Please sign in to comment.