i2c: img-scb: add handle for stop detected interrupt
authorSifan Naeem <sifan.naeem@imgtec.com>
Thu, 19 Nov 2015 09:35:15 +0000 (09:35 +0000)
committerWolfram Sang <wsa@the-dreams.de>
Sat, 2 Jan 2016 21:04:30 +0000 (22:04 +0100)
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>
drivers/i2c/busses/i2c-img-scb.c

index 0af554a16ae5edd899347c43635402b6cce4ff5f..f416010a0b493e0d0c054f923a5ea20241dc6d50 100644 (file)
 #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)
 
                                         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     | \
@@ -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);
This page took 0.025397 seconds and 5 git commands to generate.