i2c-designware: Disable TX_EMPTY when all i2c_msg msgs has been processed
authorShinya Kuribayashi <shinya.kuribayashi@necel.com>
Fri, 6 Nov 2009 12:51:00 +0000 (21:51 +0900)
committerBen Dooks <ben-linux@fluff.org>
Wed, 9 Dec 2009 00:19:12 +0000 (00:19 +0000)
Currently we disable TX_EMPTY interrupt when buf_len is zero, but this
is wrong.  (buf_len == 0) means that all transmit data in the current
i2c_msg message has been sent out, but that doesn't necessarily mean
all i2c_msg messages have been processed.

TX_EMPTY interrupt is used as the driving force of DW I2C transactions,
so we need to keep it enabled as long as i2c_msg messages are available.

Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi@necel.com>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
drivers/i2c/busses/i2c-designware.c

index f184d822d3d448a1133454a08b117ce0c7c49f1a..6acbe846e9c67be41a342f4de0c1a873f941929f 100644 (file)
@@ -415,12 +415,17 @@ i2c_dw_xfer_msg(struct dw_i2c_dev *dev)
                        /* more bytes to be written */
                        dev->status |= STATUS_WRITE_IN_PROGRESS;
                        break;
-               } else {
+               } else
                        dev->status &= ~STATUS_WRITE_IN_PROGRESS;
-                       intr_mask &= ~DW_IC_INTR_TX_EMPTY;
-               }
        }
 
+       /*
+        * If i2c_msg index search is completed, we don't need TX_EMPTY
+        * interrupt any more.
+        */
+       if (dev->msg_write_idx == dev->msgs_num)
+               intr_mask &= ~DW_IC_INTR_TX_EMPTY;
+
        writel(intr_mask, dev->base + DW_IC_INTR_MASK);
 }