All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/8] i2c: i2c-bfin-twi: Illegal i2c bus lock upon certain transfer scenarios.
@ 2012-05-16  7:20 ` sonic.zhang
  0 siblings, 0 replies; 58+ messages in thread
From: sonic.zhang @ 2012-05-16  7:20 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: linux-i2c, LKML, uclinux-dist-devel, Michael Hennerich, Sonic Zhang

From: Michael Hennerich <michael.hennerich@analog.com>

For transfer counts > 255 bytes i2c-bfin-twi sets the data
transfer counter DCNT to 0xFF indicating unlimited transfers.
It then uses a flag iface->manual_stop to manually issue the STOP
condition, once the required amount of bytes are received.

We found that on I2C receive operation issuing the STOP condition
together with a FULL RCV FIFO (2bytes) will cause SDA and SCL be
constantly driven low.

Temporary workaround until further investigation:
Discard the RCV FIFO before issuing the STOP condition.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>

git-svn-id: svn://localhost/svn/linux-kernel/trunk@9011 526b6c2d-f592-4532-a319-5dd88ccb003d
---
 drivers/i2c/busses/i2c-bfin-twi.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index cdb59e5..e6dd3c9 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -131,6 +131,10 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 			iface->transPtr++;
 			iface->readNum--;
 		} else if (iface->manual_stop) {
+			/* Avoid possible bus stall -
+			 * Flush FIFO before issuing the STOP condition
+			 */
+			read_RCV_DATA16(iface);
 			write_MASTER_CTL(iface,
 				read_MASTER_CTL(iface) | STOP);
 		} else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
-- 
1.7.0.4



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

* [PATCH 1/8] i2c: i2c-bfin-twi: Illegal i2c bus lock upon certain transfer scenarios.
@ 2012-05-16  7:20 ` sonic.zhang
  0 siblings, 0 replies; 58+ messages in thread
From: sonic.zhang @ 2012-05-16  7:20 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: linux-i2c, LKML, uclinux-dist-devel, Michael Hennerich, Sonic Zhang

From: Michael Hennerich <michael.hennerich@analog.com>

For transfer counts > 255 bytes i2c-bfin-twi sets the data
transfer counter DCNT to 0xFF indicating unlimited transfers.
It then uses a flag iface->manual_stop to manually issue the STOP
condition, once the required amount of bytes are received.

We found that on I2C receive operation issuing the STOP condition
together with a FULL RCV FIFO (2bytes) will cause SDA and SCL be
constantly driven low.

Temporary workaround until further investigation:
Discard the RCV FIFO before issuing the STOP condition.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>

git-svn-id: svn://localhost/svn/linux-kernel/trunk@9011 526b6c2d-f592-4532-a319-5dd88ccb003d
---
 drivers/i2c/busses/i2c-bfin-twi.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index cdb59e5..e6dd3c9 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -131,6 +131,10 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 			iface->transPtr++;
 			iface->readNum--;
 		} else if (iface->manual_stop) {
+			/* Avoid possible bus stall -
+			 * Flush FIFO before issuing the STOP condition
+			 */
+			read_RCV_DATA16(iface);
 			write_MASTER_CTL(iface,
 				read_MASTER_CTL(iface) | STOP);
 		} else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
-- 
1.7.0.4

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

* [PATCH 2/8] i2c: i2c-bfin-twi: Stop receiving operation immediately in last rx interrupt.
@ 2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  0 siblings, 0 replies; 58+ messages in thread
From: sonic.zhang @ 2012-05-16  7:20 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang; +Cc: linux-i2c, LKML, uclinux-dist-devel, Sonic Zhang

From: Sonic Zhang <sonic.zhang@analog.com>

Also wake up waiting process when transfer completes.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>

git-svn-id: svn://localhost/svn/linux-kernel/trunk@9105 526b6c2d-f592-4532-a319-5dd88ccb003d
---
 drivers/i2c/busses/i2c-bfin-twi.c |   43 ++++++++++++++++++++----------------
 1 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index e6dd3c9..376e331 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -130,21 +130,25 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 			}
 			iface->transPtr++;
 			iface->readNum--;
-		} else if (iface->manual_stop) {
-			/* Avoid possible bus stall -
-			 * Flush FIFO before issuing the STOP condition
-			 */
-			read_RCV_DATA16(iface);
-			write_MASTER_CTL(iface,
-				read_MASTER_CTL(iface) | STOP);
-		} else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
-		           iface->cur_msg + 1 < iface->msg_num) {
-			if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD)
-				write_MASTER_CTL(iface,
-					read_MASTER_CTL(iface) | RSTART | MDIR);
-			else
+		}
+
+		if (iface->readNum == 0) {
+			if (iface->manual_stop) {
+				/* Avoid possible bus stall -
+				 * Flush FIFO before issuing the STOP condition
+				 */
+				read_RCV_DATA16(iface);
 				write_MASTER_CTL(iface,
-					(read_MASTER_CTL(iface) | RSTART) & ~MDIR);
+					read_MASTER_CTL(iface) | STOP);
+			} else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
+					iface->cur_msg + 1 < iface->msg_num) {
+				if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD)
+					write_MASTER_CTL(iface,
+						read_MASTER_CTL(iface) | RSTART | MDIR);
+				else
+					write_MASTER_CTL(iface,
+						(read_MASTER_CTL(iface) | RSTART) & ~MDIR);
+			}
 		}
 	}
 	if (twi_int_status & MERR) {
@@ -245,12 +249,13 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 				}
 			}
 
-			if (iface->pmsg[iface->cur_msg].len <= 255)
-					write_MASTER_CTL(iface,
+			if (iface->pmsg[iface->cur_msg].len <= 255) {
+				write_MASTER_CTL(iface,
 					(read_MASTER_CTL(iface) &
 					(~(0xff << 6))) |
-				(iface->pmsg[iface->cur_msg].len << 6));
-			else {
+					(iface->pmsg[iface->cur_msg].len << 6));
+				iface->manual_stop = 0;
+			} else {
 				write_MASTER_CTL(iface,
 					(read_MASTER_CTL(iface) |
 					(0xff << 6)));
@@ -264,8 +269,8 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 			write_INT_MASK(iface, 0);
 			write_MASTER_CTL(iface, 0);
 		}
+		complete(&iface->complete);
 	}
-	complete(&iface->complete);
 }
 
 /* Interrupt handler */
-- 
1.7.0.4



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

* [PATCH 2/8] i2c: i2c-bfin-twi: Stop receiving operation immediately in last rx interrupt.
@ 2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  0 siblings, 0 replies; 58+ messages in thread
From: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA @ 2012-05-16  7:20 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b, Sonic Zhang

From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>

Also wake up waiting process when transfer completes.

Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>

git-svn-id: svn://localhost/svn/linux-kernel/trunk@9105 526b6c2d-f592-4532-a319-5dd88ccb003d
---
 drivers/i2c/busses/i2c-bfin-twi.c |   43 ++++++++++++++++++++----------------
 1 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index e6dd3c9..376e331 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -130,21 +130,25 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 			}
 			iface->transPtr++;
 			iface->readNum--;
-		} else if (iface->manual_stop) {
-			/* Avoid possible bus stall -
-			 * Flush FIFO before issuing the STOP condition
-			 */
-			read_RCV_DATA16(iface);
-			write_MASTER_CTL(iface,
-				read_MASTER_CTL(iface) | STOP);
-		} else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
-		           iface->cur_msg + 1 < iface->msg_num) {
-			if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD)
-				write_MASTER_CTL(iface,
-					read_MASTER_CTL(iface) | RSTART | MDIR);
-			else
+		}
+
+		if (iface->readNum == 0) {
+			if (iface->manual_stop) {
+				/* Avoid possible bus stall -
+				 * Flush FIFO before issuing the STOP condition
+				 */
+				read_RCV_DATA16(iface);
 				write_MASTER_CTL(iface,
-					(read_MASTER_CTL(iface) | RSTART) & ~MDIR);
+					read_MASTER_CTL(iface) | STOP);
+			} else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
+					iface->cur_msg + 1 < iface->msg_num) {
+				if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD)
+					write_MASTER_CTL(iface,
+						read_MASTER_CTL(iface) | RSTART | MDIR);
+				else
+					write_MASTER_CTL(iface,
+						(read_MASTER_CTL(iface) | RSTART) & ~MDIR);
+			}
 		}
 	}
 	if (twi_int_status & MERR) {
@@ -245,12 +249,13 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 				}
 			}
 
-			if (iface->pmsg[iface->cur_msg].len <= 255)
-					write_MASTER_CTL(iface,
+			if (iface->pmsg[iface->cur_msg].len <= 255) {
+				write_MASTER_CTL(iface,
 					(read_MASTER_CTL(iface) &
 					(~(0xff << 6))) |
-				(iface->pmsg[iface->cur_msg].len << 6));
-			else {
+					(iface->pmsg[iface->cur_msg].len << 6));
+				iface->manual_stop = 0;
+			} else {
 				write_MASTER_CTL(iface,
 					(read_MASTER_CTL(iface) |
 					(0xff << 6)));
@@ -264,8 +269,8 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 			write_INT_MASK(iface, 0);
 			write_MASTER_CTL(iface, 0);
 		}
+		complete(&iface->complete);
 	}
-	complete(&iface->complete);
 }
 
 /* Interrupt handler */
-- 
1.7.0.4

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

* [PATCH 3/8] i2c: i2c-bfin-twi: Break dead waiting loop if i2c device misbehaves.
@ 2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  0 siblings, 0 replies; 58+ messages in thread
From: sonic.zhang @ 2012-05-16  7:20 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang; +Cc: linux-i2c, LKML, uclinux-dist-devel, Sonic Zhang

From: Sonic Zhang <sonic.zhang@analog.com>

Some fault i2c device may hold the sda/scl line and cause i2c driver
wait in the BUS busy loop. This patch breaks this potential dead
loop.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>

git-svn-id: svn://localhost/svn/linux-kernel/trunk@9291 526b6c2d-f592-4532-a319-5dd88ccb003d
---
 drivers/i2c/busses/i2c-bfin-twi.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index 376e331..4abaf59 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -294,6 +294,8 @@ static irqreturn_t bfin_twi_interrupt_entry(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+#define BFIN_TWI_BUSY_TIMEOUT	1000
+
 /*
  * One i2c master transfer
  */
@@ -303,12 +305,16 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter *adap,
 	struct bfin_twi_iface *iface = adap->algo_data;
 	struct i2c_msg *pmsg;
 	int rc = 0;
+	unsigned int busy_timeout = BFIN_TWI_BUSY_TIMEOUT;
 
 	if (!(read_CONTROL(iface) & TWI_ENA))
 		return -ENXIO;
 
-	while (read_MASTER_STAT(iface) & BUSBUSY)
+	while (read_MASTER_STAT(iface) & BUSBUSY) {
+		if (--busy_timeout == 0)
+			return -EBUSY;
 		yield();
+	}
 
 	iface->pmsg = msgs;
 	iface->msg_num = num;
@@ -403,12 +409,16 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter *adap, u16 addr,
 {
 	struct bfin_twi_iface *iface = adap->algo_data;
 	int rc = 0;
+	unsigned int busy_timeout = BFIN_TWI_BUSY_TIMEOUT;
 
 	if (!(read_CONTROL(iface) & TWI_ENA))
 		return -ENXIO;
 
-	while (read_MASTER_STAT(iface) & BUSBUSY)
+	while (read_MASTER_STAT(iface) & BUSBUSY) {
+		if (--busy_timeout == 0)
+			return -EBUSY;
 		yield();
+	}
 
 	iface->writeNum = 0;
 	iface->readNum = 0;
-- 
1.7.0.4



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

* [PATCH 3/8] i2c: i2c-bfin-twi: Break dead waiting loop if i2c device misbehaves.
@ 2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  0 siblings, 0 replies; 58+ messages in thread
From: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA @ 2012-05-16  7:20 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b, Sonic Zhang

From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>

Some fault i2c device may hold the sda/scl line and cause i2c driver
wait in the BUS busy loop. This patch breaks this potential dead
loop.

Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>

git-svn-id: svn://localhost/svn/linux-kernel/trunk@9291 526b6c2d-f592-4532-a319-5dd88ccb003d
---
 drivers/i2c/busses/i2c-bfin-twi.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index 376e331..4abaf59 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -294,6 +294,8 @@ static irqreturn_t bfin_twi_interrupt_entry(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
+#define BFIN_TWI_BUSY_TIMEOUT	1000
+
 /*
  * One i2c master transfer
  */
@@ -303,12 +305,16 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter *adap,
 	struct bfin_twi_iface *iface = adap->algo_data;
 	struct i2c_msg *pmsg;
 	int rc = 0;
+	unsigned int busy_timeout = BFIN_TWI_BUSY_TIMEOUT;
 
 	if (!(read_CONTROL(iface) & TWI_ENA))
 		return -ENXIO;
 
-	while (read_MASTER_STAT(iface) & BUSBUSY)
+	while (read_MASTER_STAT(iface) & BUSBUSY) {
+		if (--busy_timeout == 0)
+			return -EBUSY;
 		yield();
+	}
 
 	iface->pmsg = msgs;
 	iface->msg_num = num;
@@ -403,12 +409,16 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter *adap, u16 addr,
 {
 	struct bfin_twi_iface *iface = adap->algo_data;
 	int rc = 0;
+	unsigned int busy_timeout = BFIN_TWI_BUSY_TIMEOUT;
 
 	if (!(read_CONTROL(iface) & TWI_ENA))
 		return -ENXIO;
 
-	while (read_MASTER_STAT(iface) & BUSBUSY)
+	while (read_MASTER_STAT(iface) & BUSBUSY) {
+		if (--busy_timeout == 0)
+			return -EBUSY;
 		yield();
+	}
 
 	iface->writeNum = 0;
 	iface->readNum = 0;
-- 
1.7.0.4

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

* [PATCH 4/8] i2c: i2c-bfin-twi: Tighten condition when failing I2C transfer if MEN bit is reset unexpectedly.
@ 2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  0 siblings, 0 replies; 58+ messages in thread
From: sonic.zhang @ 2012-05-16  7:20 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang; +Cc: linux-i2c, LKML, uclinux-dist-devel, Sonic Zhang

From: Sonic Zhang <sonic.zhang@analog.com>

Correct I2C transfer may fail because interrupt status bits XMTSERV and
RCVSERV are not checked when MCOMP interrupt is handled.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
 drivers/i2c/busses/i2c-bfin-twi.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index 4abaf59..63fb84f 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -201,7 +201,8 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 		return;
 	}
 	if (twi_int_status & MCOMP) {
-		if ((read_MASTER_CTL(iface) & MEN) == 0 &&
+		if (twi_int_status & (XMTSERV|RCVSERV) &&
+			(read_MASTER_CTL(iface) & MEN) == 0 &&
 			(iface->cur_mode == TWI_I2C_MODE_REPEAT ||
 			iface->cur_mode == TWI_I2C_MODE_COMBINED)) {
 			iface->result = -1;
-- 
1.7.0.4



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

* [PATCH 4/8] i2c: i2c-bfin-twi: Tighten condition when failing I2C transfer if MEN bit is reset unexpectedly.
@ 2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  0 siblings, 0 replies; 58+ messages in thread
From: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA @ 2012-05-16  7:20 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML

From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>

Correct I2C transfer may fail because interrupt status bits XMTSERV and
RCVSERV are not checked when MCOMP interrupt is handled.

Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
---
 drivers/i2c/busses/i2c-bfin-twi.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index 4abaf59..63fb84f 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -201,7 +201,8 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 		return;
 	}
 	if (twi_int_status & MCOMP) {
-		if ((read_MASTER_CTL(iface) & MEN) == 0 &&
+		if (twi_int_status & (XMTSERV|RCVSERV) &&
+			(read_MASTER_CTL(iface) & MEN) == 0 &&
 			(iface->cur_mode == TWI_I2C_MODE_REPEAT ||
 			iface->cur_mode == TWI_I2C_MODE_COMBINED)) {
 			iface->result = -1;
-- 
1.7.0.4

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

* [PATCH 5/8] i2c:i2c-bfin-twi: TWI fails to restart next transfer in high system load.
@ 2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  0 siblings, 0 replies; 58+ messages in thread
From: sonic.zhang @ 2012-05-16  7:20 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang; +Cc: linux-i2c, LKML, uclinux-dist-devel, Sonic Zhang

From: Sonic Zhang <sonic.zhang@analog.com>

Current driver was developed based on BF537 0.2 HRM. In high system load, BUFRDERR error
interrupt may be raised if XMTSERV interrupt of last TX byte is not served in time
(set RSTART bit), which breaks restart tranfer as expected.

"Buffer Read Error (BUFRDERR)" description in Blackfin HRM only applys to BF537
rev. < 0.3. In later rev. and later announced Blackfin chips, such as BF527 and
BF548, a new TWI master feature "Clock Stretching" is added into the TWI controller,
BUFRDERR interrupt is not triggered after TX FIFO is empty.

This patch sets RSTART bit at the beginning of the first transfer. The SCL and SDA
is hold till XMTSERV interrupt of last TX byte is served. Restart transfer is not broken
in high system load.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
 drivers/i2c/busses/i2c-bfin-twi.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index 63fb84f..594bbb1 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -99,7 +99,7 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 		 */
 		else if (iface->cur_mode == TWI_I2C_MODE_COMBINED)
 			write_MASTER_CTL(iface,
-				read_MASTER_CTL(iface) | MDIR | RSTART);
+				read_MASTER_CTL(iface) | MDIR);
 		else if (iface->manual_stop)
 			write_MASTER_CTL(iface,
 				read_MASTER_CTL(iface) | STOP);
@@ -107,10 +107,10 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 		         iface->cur_msg + 1 < iface->msg_num) {
 			if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD)
 				write_MASTER_CTL(iface,
-					read_MASTER_CTL(iface) | RSTART | MDIR);
+					read_MASTER_CTL(iface) | MDIR);
 			else
 				write_MASTER_CTL(iface,
-					(read_MASTER_CTL(iface) | RSTART) & ~MDIR);
+					read_MASTER_CTL(iface) & ~MDIR);
 		}
 	}
 	if (twi_int_status & RCVSERV) {
@@ -144,10 +144,10 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 					iface->cur_msg + 1 < iface->msg_num) {
 				if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD)
 					write_MASTER_CTL(iface,
-						read_MASTER_CTL(iface) | RSTART | MDIR);
+						read_MASTER_CTL(iface) | MDIR);
 				else
 					write_MASTER_CTL(iface,
-						(read_MASTER_CTL(iface) | RSTART) & ~MDIR);
+						read_MASTER_CTL(iface) & ~MDIR);
 			}
 		}
 	}
@@ -262,9 +262,10 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 					(0xff << 6)));
 				iface->manual_stop = 1;
 			}
-			/* remove restart bit and enable master receive */
-			write_MASTER_CTL(iface,
-				read_MASTER_CTL(iface) & ~RSTART);
+			/* remove restart bit before last message */
+			if (iface->cur_msg+1 == iface->msg_num)
+				write_MASTER_CTL(iface,
+					read_MASTER_CTL(iface) & ~RSTART);
 		} else {
 			iface->result = 1;
 			write_INT_MASK(iface, 0);
@@ -327,7 +328,8 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter *adap,
 		return -EINVAL;
 	}
 
-	iface->cur_mode = TWI_I2C_MODE_REPEAT;
+	if (iface->msg_num > 1)
+		iface->cur_mode = TWI_I2C_MODE_REPEAT;
 	iface->manual_stop = 0;
 	iface->transPtr = pmsg->buf;
 	iface->writeNum = iface->readNum = pmsg->len;
@@ -372,6 +374,7 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter *adap,
 
 	/* Master enable */
 	write_MASTER_CTL(iface, read_MASTER_CTL(iface) | MEN |
+		(iface->msg_num > 1 ? RSTART : 0) |
 		((iface->read_write == I2C_SMBUS_READ) ? MDIR : 0) |
 		((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ > 100) ? FAST : 0));
 	SSYNC();
@@ -540,7 +543,7 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter *adap, u16 addr,
 		else
 			write_MASTER_CTL(iface, 0x1 << 6);
 		/* Master enable */
-		write_MASTER_CTL(iface, read_MASTER_CTL(iface) | MEN |
+		write_MASTER_CTL(iface, read_MASTER_CTL(iface) | MEN | RSTART |
 			((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ>100) ? FAST : 0));
 		break;
 	default:
-- 
1.7.0.4



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

* [PATCH 5/8] i2c:i2c-bfin-twi: TWI fails to restart next transfer in high system load.
@ 2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  0 siblings, 0 replies; 58+ messages in thread
From: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA @ 2012-05-16  7:20 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b, Sonic Zhang

From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>

Current driver was developed based on BF537 0.2 HRM. In high system load, BUFRDERR error
interrupt may be raised if XMTSERV interrupt of last TX byte is not served in time
(set RSTART bit), which breaks restart tranfer as expected.

"Buffer Read Error (BUFRDERR)" description in Blackfin HRM only applys to BF537
rev. < 0.3. In later rev. and later announced Blackfin chips, such as BF527 and
BF548, a new TWI master feature "Clock Stretching" is added into the TWI controller,
BUFRDERR interrupt is not triggered after TX FIFO is empty.

This patch sets RSTART bit at the beginning of the first transfer. The SCL and SDA
is hold till XMTSERV interrupt of last TX byte is served. Restart transfer is not broken
in high system load.

Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
---
 drivers/i2c/busses/i2c-bfin-twi.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index 63fb84f..594bbb1 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -99,7 +99,7 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 		 */
 		else if (iface->cur_mode == TWI_I2C_MODE_COMBINED)
 			write_MASTER_CTL(iface,
-				read_MASTER_CTL(iface) | MDIR | RSTART);
+				read_MASTER_CTL(iface) | MDIR);
 		else if (iface->manual_stop)
 			write_MASTER_CTL(iface,
 				read_MASTER_CTL(iface) | STOP);
@@ -107,10 +107,10 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 		         iface->cur_msg + 1 < iface->msg_num) {
 			if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD)
 				write_MASTER_CTL(iface,
-					read_MASTER_CTL(iface) | RSTART | MDIR);
+					read_MASTER_CTL(iface) | MDIR);
 			else
 				write_MASTER_CTL(iface,
-					(read_MASTER_CTL(iface) | RSTART) & ~MDIR);
+					read_MASTER_CTL(iface) & ~MDIR);
 		}
 	}
 	if (twi_int_status & RCVSERV) {
@@ -144,10 +144,10 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 					iface->cur_msg + 1 < iface->msg_num) {
 				if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD)
 					write_MASTER_CTL(iface,
-						read_MASTER_CTL(iface) | RSTART | MDIR);
+						read_MASTER_CTL(iface) | MDIR);
 				else
 					write_MASTER_CTL(iface,
-						(read_MASTER_CTL(iface) | RSTART) & ~MDIR);
+						read_MASTER_CTL(iface) & ~MDIR);
 			}
 		}
 	}
@@ -262,9 +262,10 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 					(0xff << 6)));
 				iface->manual_stop = 1;
 			}
-			/* remove restart bit and enable master receive */
-			write_MASTER_CTL(iface,
-				read_MASTER_CTL(iface) & ~RSTART);
+			/* remove restart bit before last message */
+			if (iface->cur_msg+1 == iface->msg_num)
+				write_MASTER_CTL(iface,
+					read_MASTER_CTL(iface) & ~RSTART);
 		} else {
 			iface->result = 1;
 			write_INT_MASK(iface, 0);
@@ -327,7 +328,8 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter *adap,
 		return -EINVAL;
 	}
 
-	iface->cur_mode = TWI_I2C_MODE_REPEAT;
+	if (iface->msg_num > 1)
+		iface->cur_mode = TWI_I2C_MODE_REPEAT;
 	iface->manual_stop = 0;
 	iface->transPtr = pmsg->buf;
 	iface->writeNum = iface->readNum = pmsg->len;
@@ -372,6 +374,7 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter *adap,
 
 	/* Master enable */
 	write_MASTER_CTL(iface, read_MASTER_CTL(iface) | MEN |
+		(iface->msg_num > 1 ? RSTART : 0) |
 		((iface->read_write == I2C_SMBUS_READ) ? MDIR : 0) |
 		((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ > 100) ? FAST : 0));
 	SSYNC();
@@ -540,7 +543,7 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter *adap, u16 addr,
 		else
 			write_MASTER_CTL(iface, 0x1 << 6);
 		/* Master enable */
-		write_MASTER_CTL(iface, read_MASTER_CTL(iface) | MEN |
+		write_MASTER_CTL(iface, read_MASTER_CTL(iface) | MEN | RSTART |
 			((CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ>100) ? FAST : 0));
 		break;
 	default:
-- 
1.7.0.4

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

* [PATCH 6/8] i2c:i2c-bfin-twi: include twi head file
@ 2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  0 siblings, 0 replies; 58+ messages in thread
From: sonic.zhang @ 2012-05-16  7:20 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: linux-i2c, LKML, uclinux-dist-devel, Sonic Zhang, Bob Liu

From: Sonic Zhang <sonic.zhang@analog.com>

TWI bit mask macros are moved to twi head file.

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
Signed-off-by: Bob Liu <lliubbo@gmail.com>
---
 drivers/i2c/busses/i2c-bfin-twi.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index 594bbb1..d7e8fba 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -25,6 +25,7 @@
 #include <asm/blackfin.h>
 #include <asm/portmux.h>
 #include <asm/irq.h>
+#include <asm/bfin_twi.h>
 
 /* SMBus mode*/
 #define TWI_I2C_MODE_STANDARD		1
-- 
1.7.0.4



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

* [PATCH 6/8] i2c:i2c-bfin-twi: include twi head file
@ 2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  0 siblings, 0 replies; 58+ messages in thread
From: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA @ 2012-05-16  7:20 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML

From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>

TWI bit mask macros are moved to twi head file.

Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Bob Liu <lliubbo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/i2c/busses/i2c-bfin-twi.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index 594bbb1..d7e8fba 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -25,6 +25,7 @@
 #include <asm/blackfin.h>
 #include <asm/portmux.h>
 #include <asm/irq.h>
+#include <asm/bfin_twi.h>
 
 /* SMBus mode*/
 #define TWI_I2C_MODE_STANDARD		1
-- 
1.7.0.4

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

* [PATCH 7/8] i2c: i2c-bfin-twi: Move TWI peripheral pin request array to platform data.
@ 2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  0 siblings, 0 replies; 58+ messages in thread
From: sonic.zhang @ 2012-05-16  7:20 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang; +Cc: linux-i2c, LKML, uclinux-dist-devel, Sonic Zhang

From: Sonic Zhang <sonic.zhang@analog.com>

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
 drivers/i2c/busses/i2c-bfin-twi.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index d7e8fba..b2ca317 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -78,11 +78,6 @@ DEFINE_TWI_REG(XMT_DATA16, 0x84)
 DEFINE_TWI_REG(RCV_DATA8, 0x88)
 DEFINE_TWI_REG(RCV_DATA16, 0x8C)
 
-static const u16 pin_req[2][3] = {
-	{P_TWI0_SCL, P_TWI0_SDA, 0},
-	{P_TWI1_SCL, P_TWI1_SDA, 0},
-};
-
 static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 					unsigned short twi_int_status)
 {
@@ -719,7 +714,8 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
 	p_adap->timeout = 5 * HZ;
 	p_adap->retries = 3;
 
-	rc = peripheral_request_list(pin_req[pdev->id], "i2c-bfin-twi");
+	rc = peripheral_request_list((unsigned short *)pdev->dev.platform_data,
+					"i2c-bfin-twi");
 	if (rc) {
 		dev_err(&pdev->dev, "Can't setup pin mux!\n");
 		goto out_error_pin_mux;
@@ -766,7 +762,7 @@ out_error_add_adapter:
 	free_irq(iface->irq, iface);
 out_error_req_irq:
 out_error_no_irq:
-	peripheral_free_list(pin_req[pdev->id]);
+	peripheral_free_list((unsigned short *)pdev->dev.platform_data);
 out_error_pin_mux:
 	iounmap(iface->regs_base);
 out_error_ioremap:
@@ -784,7 +780,7 @@ static int i2c_bfin_twi_remove(struct platform_device *pdev)
 
 	i2c_del_adapter(&(iface->adap));
 	free_irq(iface->irq, iface);
-	peripheral_free_list(pin_req[pdev->id]);
+	peripheral_free_list((unsigned short *)pdev->dev.platform_data);
 	iounmap(iface->regs_base);
 	kfree(iface);
 
-- 
1.7.0.4



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

* [PATCH 7/8] i2c: i2c-bfin-twi: Move TWI peripheral pin request array to platform data.
@ 2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  0 siblings, 0 replies; 58+ messages in thread
From: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA @ 2012-05-16  7:20 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b, Sonic Zhang

From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>

Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
---
 drivers/i2c/busses/i2c-bfin-twi.c |   12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index d7e8fba..b2ca317 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -78,11 +78,6 @@ DEFINE_TWI_REG(XMT_DATA16, 0x84)
 DEFINE_TWI_REG(RCV_DATA8, 0x88)
 DEFINE_TWI_REG(RCV_DATA16, 0x8C)
 
-static const u16 pin_req[2][3] = {
-	{P_TWI0_SCL, P_TWI0_SDA, 0},
-	{P_TWI1_SCL, P_TWI1_SDA, 0},
-};
-
 static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 					unsigned short twi_int_status)
 {
@@ -719,7 +714,8 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
 	p_adap->timeout = 5 * HZ;
 	p_adap->retries = 3;
 
-	rc = peripheral_request_list(pin_req[pdev->id], "i2c-bfin-twi");
+	rc = peripheral_request_list((unsigned short *)pdev->dev.platform_data,
+					"i2c-bfin-twi");
 	if (rc) {
 		dev_err(&pdev->dev, "Can't setup pin mux!\n");
 		goto out_error_pin_mux;
@@ -766,7 +762,7 @@ out_error_add_adapter:
 	free_irq(iface->irq, iface);
 out_error_req_irq:
 out_error_no_irq:
-	peripheral_free_list(pin_req[pdev->id]);
+	peripheral_free_list((unsigned short *)pdev->dev.platform_data);
 out_error_pin_mux:
 	iounmap(iface->regs_base);
 out_error_ioremap:
@@ -784,7 +780,7 @@ static int i2c_bfin_twi_remove(struct platform_device *pdev)
 
 	i2c_del_adapter(&(iface->adap));
 	free_irq(iface->irq, iface);
-	peripheral_free_list(pin_req[pdev->id]);
+	peripheral_free_list((unsigned short *)pdev->dev.platform_data);
 	iounmap(iface->regs_base);
 	kfree(iface);
 
-- 
1.7.0.4

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

* [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file.
@ 2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  0 siblings, 0 replies; 58+ messages in thread
From: sonic.zhang @ 2012-05-16  7:20 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang; +Cc: linux-i2c, LKML, uclinux-dist-devel, Sonic Zhang

From: Sonic Zhang <sonic.zhang@analog.com>

Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
---
 drivers/i2c/busses/i2c-bfin-twi.c |   45 -------------------------------------
 1 files changed, 0 insertions(+), 45 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index b2ca317..e6a0cba 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -33,51 +33,6 @@
 #define TWI_I2C_MODE_COMBINED		3
 #define TWI_I2C_MODE_REPEAT		4
 
-struct bfin_twi_iface {
-	int			irq;
-	spinlock_t		lock;
-	char			read_write;
-	u8			command;
-	u8			*transPtr;
-	int			readNum;
-	int			writeNum;
-	int			cur_mode;
-	int			manual_stop;
-	int			result;
-	struct i2c_adapter	adap;
-	struct completion	complete;
-	struct i2c_msg 		*pmsg;
-	int			msg_num;
-	int			cur_msg;
-	u16			saved_clkdiv;
-	u16			saved_control;
-	void __iomem		*regs_base;
-};
-
-
-#define DEFINE_TWI_REG(reg, off) \
-static inline u16 read_##reg(struct bfin_twi_iface *iface) \
-	{ return bfin_read16(iface->regs_base + (off)); } \
-static inline void write_##reg(struct bfin_twi_iface *iface, u16 v) \
-	{ bfin_write16(iface->regs_base + (off), v); }
-
-DEFINE_TWI_REG(CLKDIV, 0x00)
-DEFINE_TWI_REG(CONTROL, 0x04)
-DEFINE_TWI_REG(SLAVE_CTL, 0x08)
-DEFINE_TWI_REG(SLAVE_STAT, 0x0C)
-DEFINE_TWI_REG(SLAVE_ADDR, 0x10)
-DEFINE_TWI_REG(MASTER_CTL, 0x14)
-DEFINE_TWI_REG(MASTER_STAT, 0x18)
-DEFINE_TWI_REG(MASTER_ADDR, 0x1C)
-DEFINE_TWI_REG(INT_STAT, 0x20)
-DEFINE_TWI_REG(INT_MASK, 0x24)
-DEFINE_TWI_REG(FIFO_CTL, 0x28)
-DEFINE_TWI_REG(FIFO_STAT, 0x2C)
-DEFINE_TWI_REG(XMT_DATA8, 0x80)
-DEFINE_TWI_REG(XMT_DATA16, 0x84)
-DEFINE_TWI_REG(RCV_DATA8, 0x88)
-DEFINE_TWI_REG(RCV_DATA16, 0x8C)
-
 static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 					unsigned short twi_int_status)
 {
-- 
1.7.0.4



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

* [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file.
@ 2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  0 siblings, 0 replies; 58+ messages in thread
From: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA @ 2012-05-16  7:20 UTC (permalink / raw)
  To: Ben Dooks, Wolfram Sang
  Cc: uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML

From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>

Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
---
 drivers/i2c/busses/i2c-bfin-twi.c |   45 -------------------------------------
 1 files changed, 0 insertions(+), 45 deletions(-)

diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
index b2ca317..e6a0cba 100644
--- a/drivers/i2c/busses/i2c-bfin-twi.c
+++ b/drivers/i2c/busses/i2c-bfin-twi.c
@@ -33,51 +33,6 @@
 #define TWI_I2C_MODE_COMBINED		3
 #define TWI_I2C_MODE_REPEAT		4
 
-struct bfin_twi_iface {
-	int			irq;
-	spinlock_t		lock;
-	char			read_write;
-	u8			command;
-	u8			*transPtr;
-	int			readNum;
-	int			writeNum;
-	int			cur_mode;
-	int			manual_stop;
-	int			result;
-	struct i2c_adapter	adap;
-	struct completion	complete;
-	struct i2c_msg 		*pmsg;
-	int			msg_num;
-	int			cur_msg;
-	u16			saved_clkdiv;
-	u16			saved_control;
-	void __iomem		*regs_base;
-};
-
-
-#define DEFINE_TWI_REG(reg, off) \
-static inline u16 read_##reg(struct bfin_twi_iface *iface) \
-	{ return bfin_read16(iface->regs_base + (off)); } \
-static inline void write_##reg(struct bfin_twi_iface *iface, u16 v) \
-	{ bfin_write16(iface->regs_base + (off), v); }
-
-DEFINE_TWI_REG(CLKDIV, 0x00)
-DEFINE_TWI_REG(CONTROL, 0x04)
-DEFINE_TWI_REG(SLAVE_CTL, 0x08)
-DEFINE_TWI_REG(SLAVE_STAT, 0x0C)
-DEFINE_TWI_REG(SLAVE_ADDR, 0x10)
-DEFINE_TWI_REG(MASTER_CTL, 0x14)
-DEFINE_TWI_REG(MASTER_STAT, 0x18)
-DEFINE_TWI_REG(MASTER_ADDR, 0x1C)
-DEFINE_TWI_REG(INT_STAT, 0x20)
-DEFINE_TWI_REG(INT_MASK, 0x24)
-DEFINE_TWI_REG(FIFO_CTL, 0x28)
-DEFINE_TWI_REG(FIFO_STAT, 0x2C)
-DEFINE_TWI_REG(XMT_DATA8, 0x80)
-DEFINE_TWI_REG(XMT_DATA16, 0x84)
-DEFINE_TWI_REG(RCV_DATA8, 0x88)
-DEFINE_TWI_REG(RCV_DATA16, 0x8C)
-
 static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
 					unsigned short twi_int_status)
 {
-- 
1.7.0.4

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

* Re: [PATCH 3/8] i2c: i2c-bfin-twi: Break dead waiting loop if i2c device misbehaves.
@ 2012-05-17  5:20     ` Shubhrajyoti Datta
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-05-17  5:20 UTC (permalink / raw)
  To: sonic.zhang; +Cc: Ben Dooks, Wolfram Sang, linux-i2c, LKML, uclinux-dist-devel

Hello,

On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang@analog.com> wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> Some fault i2c device may hold the sda/scl line and cause i2c driver
> wait in the BUS busy loop. This patch breaks this potential dead
> loop.
How about using a non-busy loop while you are at it.

>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
>
> git-svn-id: svn://localhost/svn/linux-kernel/trunk@9291 526b6c2d-f592-4532-a319-5dd88ccb003d

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

* Re: [PATCH 3/8] i2c: i2c-bfin-twi: Break dead waiting loop if i2c device misbehaves.
@ 2012-05-17  5:20     ` Shubhrajyoti Datta
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-05-17  5:20 UTC (permalink / raw)
  To: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  Cc: Ben Dooks, Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b

Hello,

On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> wrote:
> From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>
> Some fault i2c device may hold the sda/scl line and cause i2c driver
> wait in the BUS busy loop. This patch breaks this potential dead
> loop.
How about using a non-busy loop while you are at it.

>
> Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>
> git-svn-id: svn://localhost/svn/linux-kernel/trunk@9291 526b6c2d-f592-4532-a319-5dd88ccb003d

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

* Re: [PATCH 3/8] i2c: i2c-bfin-twi: Break dead waiting loop if i2c device misbehaves.
@ 2012-05-17  5:23       ` Mike Frysinger
  0 siblings, 0 replies; 58+ messages in thread
From: Mike Frysinger @ 2012-05-17  5:23 UTC (permalink / raw)
  To: Shubhrajyoti Datta
  Cc: sonic.zhang, Ben Dooks, Wolfram Sang, linux-i2c, LKML,
	uclinux-dist-devel

On Thu, May 17, 2012 at 1:20 AM, Shubhrajyoti Datta
<omaplinuxkernel@gmail.com> wrote:
> On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang@analog.com> wrote:
>> From: Sonic Zhang <sonic.zhang@analog.com>
>>
>> Some fault i2c device may hold the sda/scl line and cause i2c driver
>> wait in the BUS busy loop. This patch breaks this potential dead
>> loop.
>
> How about using a non-busy loop while you are at it.

the timings here are fairly small ...
-mike

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

* Re: [PATCH 3/8] i2c: i2c-bfin-twi: Break dead waiting loop if i2c device misbehaves.
@ 2012-05-17  5:23       ` Mike Frysinger
  0 siblings, 0 replies; 58+ messages in thread
From: Mike Frysinger @ 2012-05-17  5:23 UTC (permalink / raw)
  To: Shubhrajyoti Datta
  Cc: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA, Ben Dooks, Wolfram Sang,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b

On Thu, May 17, 2012 at 1:20 AM, Shubhrajyoti Datta
<omaplinuxkernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> wrote:
>> From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>>
>> Some fault i2c device may hold the sda/scl line and cause i2c driver
>> wait in the BUS busy loop. This patch breaks this potential dead
>> loop.
>
> How about using a non-busy loop while you are at it.

the timings here are fairly small ...
-mike

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

* Re: [PATCH 3/8] i2c: i2c-bfin-twi: Break dead waiting loop if i2c device misbehaves.
@ 2012-05-17 10:51         ` Shubhrajyoti Datta
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-05-17 10:51 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: sonic.zhang, Ben Dooks, Wolfram Sang, linux-i2c, LKML,
	uclinux-dist-devel

On Thu, May 17, 2012 at 10:53 AM, Mike Frysinger <vapier.adi@gmail.com> wrote:
> On Thu, May 17, 2012 at 1:20 AM, Shubhrajyoti Datta
> <omaplinuxkernel@gmail.com> wrote:
>> On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang@analog.com> wrote:
>>> From: Sonic Zhang <sonic.zhang@analog.com>
>>>
>>> Some fault i2c device may hold the sda/scl line and cause i2c driver
>>> wait in the BUS busy loop. This patch breaks this potential dead
>>> loop.
>>
>> How about using a non-busy loop while you are at it.
>
> the timings here are fairly small ...
OK no issues.
Anyways was just a suggestion.:-)

> -mike

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

* Re: [PATCH 3/8] i2c: i2c-bfin-twi: Break dead waiting loop if i2c device misbehaves.
@ 2012-05-17 10:51         ` Shubhrajyoti Datta
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-05-17 10:51 UTC (permalink / raw)
  To: Mike Frysinger
  Cc: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA, Ben Dooks, Wolfram Sang,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b

On Thu, May 17, 2012 at 10:53 AM, Mike Frysinger <vapier.adi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> On Thu, May 17, 2012 at 1:20 AM, Shubhrajyoti Datta
> <omaplinuxkernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
>> On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> wrote:
>>> From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>>>
>>> Some fault i2c device may hold the sda/scl line and cause i2c driver
>>> wait in the BUS busy loop. This patch breaks this potential dead
>>> loop.
>>
>> How about using a non-busy loop while you are at it.
>
> the timings here are fairly small ...
OK no issues.
Anyways was just a suggestion.:-)

> -mike

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

* Re: [PATCH 4/8] i2c: i2c-bfin-twi: Tighten condition when failing I2C transfer if MEN bit is reset unexpectedly.
@ 2012-05-17 11:30     ` Shubhrajyoti Datta
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-05-17 11:30 UTC (permalink / raw)
  To: sonic.zhang; +Cc: Ben Dooks, Wolfram Sang, linux-i2c, LKML, uclinux-dist-devel

On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang@analog.com> wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> Correct I2C transfer may fail because interrupt status bits XMTSERV and
> RCVSERV are not checked when MCOMP interrupt is handled.
>
Could you expand MCOMP?

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

* Re: [PATCH 4/8] i2c: i2c-bfin-twi: Tighten condition when failing I2C transfer if MEN bit is reset unexpectedly.
@ 2012-05-17 11:30     ` Shubhrajyoti Datta
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-05-17 11:30 UTC (permalink / raw)
  To: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  Cc: Ben Dooks, Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b

On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> wrote:
> From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>
> Correct I2C transfer may fail because interrupt status bits XMTSERV and
> RCVSERV are not checked when MCOMP interrupt is handled.
>
Could you expand MCOMP?

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

* RE: [PATCH 4/8] i2c: i2c-bfin-twi: Tighten condition when failing I2C transfer if MEN bit is reset unexpectedly.
  2012-05-17 11:30     ` Shubhrajyoti Datta
@ 2012-05-18  2:41       ` Zhang, Sonic
  -1 siblings, 0 replies; 58+ messages in thread
From: Zhang, Sonic @ 2012-05-18  2:41 UTC (permalink / raw)
  To: Shubhrajyoti Datta
  Cc: Ben Dooks, Wolfram Sang, linux-i2c, LKML, uclinux-dist-devel



>-----Original Message-----
>From: Shubhrajyoti Datta [mailto:omaplinuxkernel@gmail.com]
>Sent: Thursday, May 17, 2012 7:31 PM
>To: Zhang, Sonic
>Cc: Ben Dooks; Wolfram Sang; linux-i2c@vger.kernel.org; LKML; uclinux-dist-
>devel@blackfin.uclinux.org
>Subject: Re: [PATCH 4/8] i2c: i2c-bfin-twi: Tighten condition when failing I2C
>transfer if MEN bit is reset unexpectedly.
>
>On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang@analog.com> wrote:
>> From: Sonic Zhang <sonic.zhang@analog.com>
>>
>> Correct I2C transfer may fail because interrupt status bits XMTSERV and
>> RCVSERV are not checked when MCOMP interrupt is handled.
>>
>Could you expand MCOMP?

Master transfer complete (MCOMP)
[1] The initiated master transfer has completed. In the absence of a
repeat start, the bus has been released.
[0] The completion of a transfer has not been detected.


Regards,

Sonic


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

* RE: [PATCH 4/8] i2c: i2c-bfin-twi: Tighten condition when failing I2C transfer if MEN bit is reset unexpectedly.
@ 2012-05-18  2:41       ` Zhang, Sonic
  0 siblings, 0 replies; 58+ messages in thread
From: Zhang, Sonic @ 2012-05-18  2:41 UTC (permalink / raw)
  To: Shubhrajyoti Datta
  Cc: Ben Dooks, Wolfram Sang, linux-i2c, LKML, uclinux-dist-devel



>-----Original Message-----
>From: Shubhrajyoti Datta [mailto:omaplinuxkernel@gmail.com]
>Sent: Thursday, May 17, 2012 7:31 PM
>To: Zhang, Sonic
>Cc: Ben Dooks; Wolfram Sang; linux-i2c@vger.kernel.org; LKML; uclinux-dist-
>devel@blackfin.uclinux.org
>Subject: Re: [PATCH 4/8] i2c: i2c-bfin-twi: Tighten condition when failing I2C
>transfer if MEN bit is reset unexpectedly.
>
>On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang@analog.com> wrote:
>> From: Sonic Zhang <sonic.zhang@analog.com>
>>
>> Correct I2C transfer may fail because interrupt status bits XMTSERV and
>> RCVSERV are not checked when MCOMP interrupt is handled.
>>
>Could you expand MCOMP?

Master transfer complete (MCOMP)
[1] The initiated master transfer has completed. In the absence of a
repeat start, the bus has been released.
[0] The completion of a transfer has not been detected.


Regards,

Sonic

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

* Re: [PATCH 4/8] i2c: i2c-bfin-twi: Tighten condition when failing I2C transfer if MEN bit is reset unexpectedly.
@ 2012-05-18  6:22         ` Shubhrajyoti Datta
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-05-18  6:22 UTC (permalink / raw)
  To: Zhang, Sonic; +Cc: Ben Dooks, Wolfram Sang, linux-i2c, LKML, uclinux-dist-devel

On Fri, May 18, 2012 at 8:11 AM, Zhang, Sonic <Sonic.Zhang@analog.com> wrote:
>
>
>>-----Original Message-----
>>From: Shubhrajyoti Datta [mailto:omaplinuxkernel@gmail.com]
>>Sent: Thursday, May 17, 2012 7:31 PM
>>To: Zhang, Sonic
>>Cc: Ben Dooks; Wolfram Sang; linux-i2c@vger.kernel.org; LKML; uclinux-dist-
>>devel@blackfin.uclinux.org
>>Subject: Re: [PATCH 4/8] i2c: i2c-bfin-twi: Tighten condition when failing I2C
>>transfer if MEN bit is reset unexpectedly.
>>
>>On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang@analog.com> wrote:
>>> From: Sonic Zhang <sonic.zhang@analog.com>
>>>
>>> Correct I2C transfer may fail because interrupt status bits XMTSERV and
>>> RCVSERV are not checked when MCOMP interrupt is handled.
>>>
>>Could you expand MCOMP?
>
> Master transfer complete (MCOMP)
> [1] The initiated master transfer has completed. In the absence of a
> repeat start, the bus has been released.
> [0] The completion of a transfer has not been detected.
>

A trivial suggestion may be the changelog could be enhanced.
Thanks for the explanation.

>
> Regards,
>
> Sonic
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH 4/8] i2c: i2c-bfin-twi: Tighten condition when failing I2C transfer if MEN bit is reset unexpectedly.
@ 2012-05-18  6:22         ` Shubhrajyoti Datta
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-05-18  6:22 UTC (permalink / raw)
  To: Zhang, Sonic
  Cc: Ben Dooks, Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b

On Fri, May 18, 2012 at 8:11 AM, Zhang, Sonic <Sonic.Zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> wrote:
>
>
>>-----Original Message-----
>>From: Shubhrajyoti Datta [mailto:omaplinuxkernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
>>Sent: Thursday, May 17, 2012 7:31 PM
>>To: Zhang, Sonic
>>Cc: Ben Dooks; Wolfram Sang; linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; LKML; uclinux-dist-
>>devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b@public.gmane.org
>>Subject: Re: [PATCH 4/8] i2c: i2c-bfin-twi: Tighten condition when failing I2C
>>transfer if MEN bit is reset unexpectedly.
>>
>>On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> wrote:
>>> From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>>>
>>> Correct I2C transfer may fail because interrupt status bits XMTSERV and
>>> RCVSERV are not checked when MCOMP interrupt is handled.
>>>
>>Could you expand MCOMP?
>
> Master transfer complete (MCOMP)
> [1] The initiated master transfer has completed. In the absence of a
> repeat start, the bus has been released.
> [0] The completion of a transfer has not been detected.
>

A trivial suggestion may be the changelog could be enhanced.
Thanks for the explanation.

>
> Regards,
>
> Sonic
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH 1/8] i2c: i2c-bfin-twi: Illegal i2c bus lock upon certain transfer scenarios.
  2012-05-16  7:20 ` sonic.zhang
                   ` (7 preceding siblings ...)
  (?)
@ 2012-05-24  9:17 ` Sonic Zhang
  -1 siblings, 0 replies; 58+ messages in thread
From: Sonic Zhang @ 2012-05-24  9:17 UTC (permalink / raw)
  To: sonic.zhang
  Cc: Ben Dooks, Wolfram Sang, linux-i2c, LKML, uclinux-dist-devel,
	Michael Hennerich

PING


On Wed, May 16, 2012 at 3:20 PM,  <sonic.zhang@analog.com> wrote:
> From: Michael Hennerich <michael.hennerich@analog.com>
>
> For transfer counts > 255 bytes i2c-bfin-twi sets the data
> transfer counter DCNT to 0xFF indicating unlimited transfers.
> It then uses a flag iface->manual_stop to manually issue the STOP
> condition, once the required amount of bytes are received.
>
> We found that on I2C receive operation issuing the STOP condition
> together with a FULL RCV FIFO (2bytes) will cause SDA and SCL be
> constantly driven low.
>
> Temporary workaround until further investigation:
> Discard the RCV FIFO before issuing the STOP condition.
>
> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
>
> git-svn-id: svn://localhost/svn/linux-kernel/trunk@9011 526b6c2d-f592-4532-a319-5dd88ccb003d
> ---
>  drivers/i2c/busses/i2c-bfin-twi.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index cdb59e5..e6dd3c9 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -131,6 +131,10 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>                        iface->transPtr++;
>                        iface->readNum--;
>                } else if (iface->manual_stop) {
> +                       /* Avoid possible bus stall -
> +                        * Flush FIFO before issuing the STOP condition
> +                        */
> +                       read_RCV_DATA16(iface);
>                        write_MASTER_CTL(iface,
>                                read_MASTER_CTL(iface) | STOP);
>                } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
> --
> 1.7.0.4
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH 2/8] i2c: i2c-bfin-twi: Stop receiving operation immediately in last rx interrupt.
  2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  (?)
@ 2012-05-24  9:18   ` Sonic Zhang
  -1 siblings, 0 replies; 58+ messages in thread
From: Sonic Zhang @ 2012-05-24  9:18 UTC (permalink / raw)
  To: sonic.zhang; +Cc: Ben Dooks, Wolfram Sang, linux-i2c, LKML, uclinux-dist-devel

PING

On Wed, May 16, 2012 at 3:20 PM,  <sonic.zhang@analog.com> wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> Also wake up waiting process when transfer completes.
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
>
> git-svn-id: svn://localhost/svn/linux-kernel/trunk@9105 526b6c2d-f592-4532-a319-5dd88ccb003d
> ---
>  drivers/i2c/busses/i2c-bfin-twi.c |   43 ++++++++++++++++++++----------------
>  1 files changed, 24 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index e6dd3c9..376e331 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -130,21 +130,25 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>                        }
>                        iface->transPtr++;
>                        iface->readNum--;
> -               } else if (iface->manual_stop) {
> -                       /* Avoid possible bus stall -
> -                        * Flush FIFO before issuing the STOP condition
> -                        */
> -                       read_RCV_DATA16(iface);
> -                       write_MASTER_CTL(iface,
> -                               read_MASTER_CTL(iface) | STOP);
> -               } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
> -                          iface->cur_msg + 1 < iface->msg_num) {
> -                       if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD)
> -                               write_MASTER_CTL(iface,
> -                                       read_MASTER_CTL(iface) | RSTART | MDIR);
> -                       else
> +               }
> +
> +               if (iface->readNum == 0) {
> +                       if (iface->manual_stop) {
> +                               /* Avoid possible bus stall -
> +                                * Flush FIFO before issuing the STOP condition
> +                                */
> +                               read_RCV_DATA16(iface);
>                                write_MASTER_CTL(iface,
> -                                       (read_MASTER_CTL(iface) | RSTART) & ~MDIR);
> +                                       read_MASTER_CTL(iface) | STOP);
> +                       } else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
> +                                       iface->cur_msg + 1 < iface->msg_num) {
> +                               if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD)
> +                                       write_MASTER_CTL(iface,
> +                                               read_MASTER_CTL(iface) | RSTART | MDIR);
> +                               else
> +                                       write_MASTER_CTL(iface,
> +                                               (read_MASTER_CTL(iface) | RSTART) & ~MDIR);
> +                       }
>                }
>        }
>        if (twi_int_status & MERR) {
> @@ -245,12 +249,13 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>                                }
>                        }
>
> -                       if (iface->pmsg[iface->cur_msg].len <= 255)
> -                                       write_MASTER_CTL(iface,
> +                       if (iface->pmsg[iface->cur_msg].len <= 255) {
> +                               write_MASTER_CTL(iface,
>                                        (read_MASTER_CTL(iface) &
>                                        (~(0xff << 6))) |
> -                               (iface->pmsg[iface->cur_msg].len << 6));
> -                       else {
> +                                       (iface->pmsg[iface->cur_msg].len << 6));
> +                               iface->manual_stop = 0;
> +                       } else {
>                                write_MASTER_CTL(iface,
>                                        (read_MASTER_CTL(iface) |
>                                        (0xff << 6)));
> @@ -264,8 +269,8 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>                        write_INT_MASK(iface, 0);
>                        write_MASTER_CTL(iface, 0);
>                }
> +               complete(&iface->complete);
>        }
> -       complete(&iface->complete);
>  }
>
>  /* Interrupt handler */
> --
> 1.7.0.4
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH 6/8] i2c:i2c-bfin-twi: include twi head file
@ 2012-05-24  9:18     ` Sonic Zhang
  0 siblings, 0 replies; 58+ messages in thread
From: Sonic Zhang @ 2012-05-24  9:18 UTC (permalink / raw)
  To: sonic.zhang
  Cc: Ben Dooks, Wolfram Sang, linux-i2c, LKML, uclinux-dist-devel, Bob Liu

PING

On Wed, May 16, 2012 at 3:20 PM,  <sonic.zhang@analog.com> wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> TWI bit mask macros are moved to twi head file.
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> Signed-off-by: Bob Liu <lliubbo@gmail.com>
> ---
>  drivers/i2c/busses/i2c-bfin-twi.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index 594bbb1..d7e8fba 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -25,6 +25,7 @@
>  #include <asm/blackfin.h>
>  #include <asm/portmux.h>
>  #include <asm/irq.h>
> +#include <asm/bfin_twi.h>
>
>  /* SMBus mode*/
>  #define TWI_I2C_MODE_STANDARD          1
> --
> 1.7.0.4
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH 6/8] i2c:i2c-bfin-twi: include twi head file
@ 2012-05-24  9:18     ` Sonic Zhang
  0 siblings, 0 replies; 58+ messages in thread
From: Sonic Zhang @ 2012-05-24  9:18 UTC (permalink / raw)
  To: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  Cc: Ben Dooks, Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b, Bob Liu

PING

On Wed, May 16, 2012 at 3:20 PM,  <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> wrote:
> From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>
> TWI bit mask macros are moved to twi head file.
>
> Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Bob Liu <lliubbo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/i2c/busses/i2c-bfin-twi.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index 594bbb1..d7e8fba 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -25,6 +25,7 @@
>  #include <asm/blackfin.h>
>  #include <asm/portmux.h>
>  #include <asm/irq.h>
> +#include <asm/bfin_twi.h>
>
>  /* SMBus mode*/
>  #define TWI_I2C_MODE_STANDARD          1
> --
> 1.7.0.4
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file.
@ 2012-05-24  9:19     ` Sonic Zhang
  0 siblings, 0 replies; 58+ messages in thread
From: Sonic Zhang @ 2012-05-24  9:19 UTC (permalink / raw)
  To: sonic.zhang; +Cc: Ben Dooks, Wolfram Sang, linux-i2c, LKML, uclinux-dist-devel

PING

On Wed, May 16, 2012 at 3:20 PM,  <sonic.zhang@analog.com> wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> ---
>  drivers/i2c/busses/i2c-bfin-twi.c |   45 -------------------------------------
>  1 files changed, 0 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index b2ca317..e6a0cba 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -33,51 +33,6 @@
>  #define TWI_I2C_MODE_COMBINED          3
>  #define TWI_I2C_MODE_REPEAT            4
>
> -struct bfin_twi_iface {
> -       int                     irq;
> -       spinlock_t              lock;
> -       char                    read_write;
> -       u8                      command;
> -       u8                      *transPtr;
> -       int                     readNum;
> -       int                     writeNum;
> -       int                     cur_mode;
> -       int                     manual_stop;
> -       int                     result;
> -       struct i2c_adapter      adap;
> -       struct completion       complete;
> -       struct i2c_msg          *pmsg;
> -       int                     msg_num;
> -       int                     cur_msg;
> -       u16                     saved_clkdiv;
> -       u16                     saved_control;
> -       void __iomem            *regs_base;
> -};
> -
> -
> -#define DEFINE_TWI_REG(reg, off) \
> -static inline u16 read_##reg(struct bfin_twi_iface *iface) \
> -       { return bfin_read16(iface->regs_base + (off)); } \
> -static inline void write_##reg(struct bfin_twi_iface *iface, u16 v) \
> -       { bfin_write16(iface->regs_base + (off), v); }
> -
> -DEFINE_TWI_REG(CLKDIV, 0x00)
> -DEFINE_TWI_REG(CONTROL, 0x04)
> -DEFINE_TWI_REG(SLAVE_CTL, 0x08)
> -DEFINE_TWI_REG(SLAVE_STAT, 0x0C)
> -DEFINE_TWI_REG(SLAVE_ADDR, 0x10)
> -DEFINE_TWI_REG(MASTER_CTL, 0x14)
> -DEFINE_TWI_REG(MASTER_STAT, 0x18)
> -DEFINE_TWI_REG(MASTER_ADDR, 0x1C)
> -DEFINE_TWI_REG(INT_STAT, 0x20)
> -DEFINE_TWI_REG(INT_MASK, 0x24)
> -DEFINE_TWI_REG(FIFO_CTL, 0x28)
> -DEFINE_TWI_REG(FIFO_STAT, 0x2C)
> -DEFINE_TWI_REG(XMT_DATA8, 0x80)
> -DEFINE_TWI_REG(XMT_DATA16, 0x84)
> -DEFINE_TWI_REG(RCV_DATA8, 0x88)
> -DEFINE_TWI_REG(RCV_DATA16, 0x8C)
> -
>  static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>                                        unsigned short twi_int_status)
>  {
> --
> 1.7.0.4
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file.
@ 2012-05-24  9:19     ` Sonic Zhang
  0 siblings, 0 replies; 58+ messages in thread
From: Sonic Zhang @ 2012-05-24  9:19 UTC (permalink / raw)
  To: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  Cc: Ben Dooks, Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b

PING

On Wed, May 16, 2012 at 3:20 PM,  <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> wrote:
> From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>
> Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
> ---
>  drivers/i2c/busses/i2c-bfin-twi.c |   45 -------------------------------------
>  1 files changed, 0 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index b2ca317..e6a0cba 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -33,51 +33,6 @@
>  #define TWI_I2C_MODE_COMBINED          3
>  #define TWI_I2C_MODE_REPEAT            4
>
> -struct bfin_twi_iface {
> -       int                     irq;
> -       spinlock_t              lock;
> -       char                    read_write;
> -       u8                      command;
> -       u8                      *transPtr;
> -       int                     readNum;
> -       int                     writeNum;
> -       int                     cur_mode;
> -       int                     manual_stop;
> -       int                     result;
> -       struct i2c_adapter      adap;
> -       struct completion       complete;
> -       struct i2c_msg          *pmsg;
> -       int                     msg_num;
> -       int                     cur_msg;
> -       u16                     saved_clkdiv;
> -       u16                     saved_control;
> -       void __iomem            *regs_base;
> -};
> -
> -
> -#define DEFINE_TWI_REG(reg, off) \
> -static inline u16 read_##reg(struct bfin_twi_iface *iface) \
> -       { return bfin_read16(iface->regs_base + (off)); } \
> -static inline void write_##reg(struct bfin_twi_iface *iface, u16 v) \
> -       { bfin_write16(iface->regs_base + (off), v); }
> -
> -DEFINE_TWI_REG(CLKDIV, 0x00)
> -DEFINE_TWI_REG(CONTROL, 0x04)
> -DEFINE_TWI_REG(SLAVE_CTL, 0x08)
> -DEFINE_TWI_REG(SLAVE_STAT, 0x0C)
> -DEFINE_TWI_REG(SLAVE_ADDR, 0x10)
> -DEFINE_TWI_REG(MASTER_CTL, 0x14)
> -DEFINE_TWI_REG(MASTER_STAT, 0x18)
> -DEFINE_TWI_REG(MASTER_ADDR, 0x1C)
> -DEFINE_TWI_REG(INT_STAT, 0x20)
> -DEFINE_TWI_REG(INT_MASK, 0x24)
> -DEFINE_TWI_REG(FIFO_CTL, 0x28)
> -DEFINE_TWI_REG(FIFO_STAT, 0x2C)
> -DEFINE_TWI_REG(XMT_DATA8, 0x80)
> -DEFINE_TWI_REG(XMT_DATA16, 0x84)
> -DEFINE_TWI_REG(RCV_DATA8, 0x88)
> -DEFINE_TWI_REG(RCV_DATA16, 0x8C)
> -
>  static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>                                        unsigned short twi_int_status)
>  {
> --
> 1.7.0.4
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file.
@ 2012-05-25  9:48     ` Shubhrajyoti Datta
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-05-25  9:48 UTC (permalink / raw)
  To: sonic.zhang; +Cc: Ben Dooks, Wolfram Sang, linux-i2c, LKML, uclinux-dist-devel

Hi ,
Some minor comments/ doubts.
On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang@analog.com> wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
>

A small description may be helpful.
Also the $SUBJECT says move the patch looks more like the remove.
Am I missing something.

> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> ---
>  drivers/i2c/busses/i2c-bfin-twi.c |   45 -------------------------------------
>  1 files changed, 0 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index b2ca317..e6a0cba 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -33,51 +33,6 @@
>  #define TWI_I2C_MODE_COMBINED          3
>  #define TWI_I2C_MODE_REPEAT            4
>
> -struct bfin_twi_iface {
> -       int                     irq;
> -       spinlock_t              lock;
> -       char                    read_write;
> -       u8                      command;
> -       u8                      *transPtr;
> -       int                     readNum;
> -       int                     writeNum;
> -       int                     cur_mode;
> -       int                     manual_stop;
> -       int                     result;
> -       struct i2c_adapter      adap;
> -       struct completion       complete;
> -       struct i2c_msg          *pmsg;
> -       int                     msg_num;
> -       int                     cur_msg;
> -       u16                     saved_clkdiv;
> -       u16                     saved_control;
> -       void __iomem            *regs_base;
> -};
> -
> -
> -#define DEFINE_TWI_REG(reg, off) \
> -static inline u16 read_##reg(struct bfin_twi_iface *iface) \
> -       { return bfin_read16(iface->regs_base + (off)); } \
> -static inline void write_##reg(struct bfin_twi_iface *iface, u16 v) \
> -       { bfin_write16(iface->regs_base + (off), v); }
> -
> -DEFINE_TWI_REG(CLKDIV, 0x00)
> -DEFINE_TWI_REG(CONTROL, 0x04)
> -DEFINE_TWI_REG(SLAVE_CTL, 0x08)
> -DEFINE_TWI_REG(SLAVE_STAT, 0x0C)
> -DEFINE_TWI_REG(SLAVE_ADDR, 0x10)
> -DEFINE_TWI_REG(MASTER_CTL, 0x14)
> -DEFINE_TWI_REG(MASTER_STAT, 0x18)
> -DEFINE_TWI_REG(MASTER_ADDR, 0x1C)
> -DEFINE_TWI_REG(INT_STAT, 0x20)
> -DEFINE_TWI_REG(INT_MASK, 0x24)
> -DEFINE_TWI_REG(FIFO_CTL, 0x28)
> -DEFINE_TWI_REG(FIFO_STAT, 0x2C)
> -DEFINE_TWI_REG(XMT_DATA8, 0x80)
> -DEFINE_TWI_REG(XMT_DATA16, 0x84)
> -DEFINE_TWI_REG(RCV_DATA8, 0x88)
> -DEFINE_TWI_REG(RCV_DATA16, 0x8C)
> -
>  static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>                                        unsigned short twi_int_status)
>  {
> --
> 1.7.0.4
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file.
@ 2012-05-25  9:48     ` Shubhrajyoti Datta
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-05-25  9:48 UTC (permalink / raw)
  To: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  Cc: Ben Dooks, Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b

Hi ,
Some minor comments/ doubts.
On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> wrote:
> From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>

A small description may be helpful.
Also the $SUBJECT says move the patch looks more like the remove.
Am I missing something.

> Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
> ---
>  drivers/i2c/busses/i2c-bfin-twi.c |   45 -------------------------------------
>  1 files changed, 0 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index b2ca317..e6a0cba 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -33,51 +33,6 @@
>  #define TWI_I2C_MODE_COMBINED          3
>  #define TWI_I2C_MODE_REPEAT            4
>
> -struct bfin_twi_iface {
> -       int                     irq;
> -       spinlock_t              lock;
> -       char                    read_write;
> -       u8                      command;
> -       u8                      *transPtr;
> -       int                     readNum;
> -       int                     writeNum;
> -       int                     cur_mode;
> -       int                     manual_stop;
> -       int                     result;
> -       struct i2c_adapter      adap;
> -       struct completion       complete;
> -       struct i2c_msg          *pmsg;
> -       int                     msg_num;
> -       int                     cur_msg;
> -       u16                     saved_clkdiv;
> -       u16                     saved_control;
> -       void __iomem            *regs_base;
> -};
> -
> -
> -#define DEFINE_TWI_REG(reg, off) \
> -static inline u16 read_##reg(struct bfin_twi_iface *iface) \
> -       { return bfin_read16(iface->regs_base + (off)); } \
> -static inline void write_##reg(struct bfin_twi_iface *iface, u16 v) \
> -       { bfin_write16(iface->regs_base + (off), v); }
> -
> -DEFINE_TWI_REG(CLKDIV, 0x00)
> -DEFINE_TWI_REG(CONTROL, 0x04)
> -DEFINE_TWI_REG(SLAVE_CTL, 0x08)
> -DEFINE_TWI_REG(SLAVE_STAT, 0x0C)
> -DEFINE_TWI_REG(SLAVE_ADDR, 0x10)
> -DEFINE_TWI_REG(MASTER_CTL, 0x14)
> -DEFINE_TWI_REG(MASTER_STAT, 0x18)
> -DEFINE_TWI_REG(MASTER_ADDR, 0x1C)
> -DEFINE_TWI_REG(INT_STAT, 0x20)
> -DEFINE_TWI_REG(INT_MASK, 0x24)
> -DEFINE_TWI_REG(FIFO_CTL, 0x28)
> -DEFINE_TWI_REG(FIFO_STAT, 0x2C)
> -DEFINE_TWI_REG(XMT_DATA8, 0x80)
> -DEFINE_TWI_REG(XMT_DATA16, 0x84)
> -DEFINE_TWI_REG(RCV_DATA8, 0x88)
> -DEFINE_TWI_REG(RCV_DATA16, 0x8C)
> -
>  static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>                                        unsigned short twi_int_status)
>  {
> --
> 1.7.0.4
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

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

* RE: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file.
@ 2012-05-25  9:54       ` Zhang, Sonic
  0 siblings, 0 replies; 58+ messages in thread
From: Zhang, Sonic @ 2012-05-25  9:54 UTC (permalink / raw)
  To: Shubhrajyoti Datta
  Cc: Ben Dooks, Wolfram Sang, linux-i2c, LKML, uclinux-dist-devel



>-----Original Message-----
>From: Shubhrajyoti Datta [mailto:omaplinuxkernel@gmail.com]
>Sent: Friday, May 25, 2012 5:48 PM
>To: Zhang, Sonic
>Cc: Ben Dooks; Wolfram Sang; linux-i2c@vger.kernel.org; LKML; uclinux-dist-
>devel@blackfin.uclinux.org
>Subject: Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access
>Macro to head file.
>
>Hi ,
>Some minor comments/ doubts.
>On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang@analog.com> wrote:
>> From: Sonic Zhang <sonic.zhang@analog.com>
>>
>
>A small description may be helpful.
>Also the $SUBJECT says move the patch looks more like the remove.
>Am I missing something.

The subject says these definitions are moved to a head file by the other patch for Blackfin architecture.

Regards,

Sonic

>
>> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
>> ---
>>  drivers/i2c/busses/i2c-bfin-twi.c |   45 -------------------------------------
>>  1 files changed, 0 insertions(+), 45 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
>> index b2ca317..e6a0cba 100644
>> --- a/drivers/i2c/busses/i2c-bfin-twi.c
>> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
>> @@ -33,51 +33,6 @@
>>  #define TWI_I2C_MODE_COMBINED          3
>>  #define TWI_I2C_MODE_REPEAT            4
>>
>> -struct bfin_twi_iface {
>> -       int                     irq;
>> -       spinlock_t              lock;
>> -       char                    read_write;
>> -       u8                      command;
>> -       u8                      *transPtr;
>> -       int                     readNum;
>> -       int                     writeNum;
>> -       int                     cur_mode;
>> -       int                     manual_stop;
>> -       int                     result;
>> -       struct i2c_adapter      adap;
>> -       struct completion       complete;
>> -       struct i2c_msg          *pmsg;
>> -       int                     msg_num;
>> -       int                     cur_msg;
>> -       u16                     saved_clkdiv;
>> -       u16                     saved_control;
>> -       void __iomem            *regs_base;
>> -};
>> -
>> -
>> -#define DEFINE_TWI_REG(reg, off) \
>> -static inline u16 read_##reg(struct bfin_twi_iface *iface) \
>> -       { return bfin_read16(iface->regs_base + (off)); } \
>> -static inline void write_##reg(struct bfin_twi_iface *iface, u16 v) \
>> -       { bfin_write16(iface->regs_base + (off), v); }
>> -
>> -DEFINE_TWI_REG(CLKDIV, 0x00)
>> -DEFINE_TWI_REG(CONTROL, 0x04)
>> -DEFINE_TWI_REG(SLAVE_CTL, 0x08)
>> -DEFINE_TWI_REG(SLAVE_STAT, 0x0C)
>> -DEFINE_TWI_REG(SLAVE_ADDR, 0x10)
>> -DEFINE_TWI_REG(MASTER_CTL, 0x14)
>> -DEFINE_TWI_REG(MASTER_STAT, 0x18)
>> -DEFINE_TWI_REG(MASTER_ADDR, 0x1C)
>> -DEFINE_TWI_REG(INT_STAT, 0x20)
>> -DEFINE_TWI_REG(INT_MASK, 0x24)
>> -DEFINE_TWI_REG(FIFO_CTL, 0x28)
>> -DEFINE_TWI_REG(FIFO_STAT, 0x2C)
>> -DEFINE_TWI_REG(XMT_DATA8, 0x80)
>> -DEFINE_TWI_REG(XMT_DATA16, 0x84)
>> -DEFINE_TWI_REG(RCV_DATA8, 0x88)
>> -DEFINE_TWI_REG(RCV_DATA16, 0x8C)
>> -
>>  static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>>                                        unsigned short twi_int_status)
>>  {
>> --
>> 1.7.0.4
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/



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

* RE: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file.
@ 2012-05-25  9:54       ` Zhang, Sonic
  0 siblings, 0 replies; 58+ messages in thread
From: Zhang, Sonic @ 2012-05-25  9:54 UTC (permalink / raw)
  To: Shubhrajyoti Datta
  Cc: Ben Dooks, Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b



>-----Original Message-----
>From: Shubhrajyoti Datta [mailto:omaplinuxkernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
>Sent: Friday, May 25, 2012 5:48 PM
>To: Zhang, Sonic
>Cc: Ben Dooks; Wolfram Sang; linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; LKML; uclinux-dist-
>devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b@public.gmane.org
>Subject: Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access
>Macro to head file.
>
>Hi ,
>Some minor comments/ doubts.
>On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> wrote:
>> From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>>
>
>A small description may be helpful.
>Also the $SUBJECT says move the patch looks more like the remove.
>Am I missing something.

The subject says these definitions are moved to a head file by the other patch for Blackfin architecture.

Regards,

Sonic

>
>> Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>> ---
>>  drivers/i2c/busses/i2c-bfin-twi.c |   45 -------------------------------------
>>  1 files changed, 0 insertions(+), 45 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
>> index b2ca317..e6a0cba 100644
>> --- a/drivers/i2c/busses/i2c-bfin-twi.c
>> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
>> @@ -33,51 +33,6 @@
>>  #define TWI_I2C_MODE_COMBINED          3
>>  #define TWI_I2C_MODE_REPEAT            4
>>
>> -struct bfin_twi_iface {
>> -       int                     irq;
>> -       spinlock_t              lock;
>> -       char                    read_write;
>> -       u8                      command;
>> -       u8                      *transPtr;
>> -       int                     readNum;
>> -       int                     writeNum;
>> -       int                     cur_mode;
>> -       int                     manual_stop;
>> -       int                     result;
>> -       struct i2c_adapter      adap;
>> -       struct completion       complete;
>> -       struct i2c_msg          *pmsg;
>> -       int                     msg_num;
>> -       int                     cur_msg;
>> -       u16                     saved_clkdiv;
>> -       u16                     saved_control;
>> -       void __iomem            *regs_base;
>> -};
>> -
>> -
>> -#define DEFINE_TWI_REG(reg, off) \
>> -static inline u16 read_##reg(struct bfin_twi_iface *iface) \
>> -       { return bfin_read16(iface->regs_base + (off)); } \
>> -static inline void write_##reg(struct bfin_twi_iface *iface, u16 v) \
>> -       { bfin_write16(iface->regs_base + (off), v); }
>> -
>> -DEFINE_TWI_REG(CLKDIV, 0x00)
>> -DEFINE_TWI_REG(CONTROL, 0x04)
>> -DEFINE_TWI_REG(SLAVE_CTL, 0x08)
>> -DEFINE_TWI_REG(SLAVE_STAT, 0x0C)
>> -DEFINE_TWI_REG(SLAVE_ADDR, 0x10)
>> -DEFINE_TWI_REG(MASTER_CTL, 0x14)
>> -DEFINE_TWI_REG(MASTER_STAT, 0x18)
>> -DEFINE_TWI_REG(MASTER_ADDR, 0x1C)
>> -DEFINE_TWI_REG(INT_STAT, 0x20)
>> -DEFINE_TWI_REG(INT_MASK, 0x24)
>> -DEFINE_TWI_REG(FIFO_CTL, 0x28)
>> -DEFINE_TWI_REG(FIFO_STAT, 0x2C)
>> -DEFINE_TWI_REG(XMT_DATA8, 0x80)
>> -DEFINE_TWI_REG(XMT_DATA16, 0x84)
>> -DEFINE_TWI_REG(RCV_DATA8, 0x88)
>> -DEFINE_TWI_REG(RCV_DATA16, 0x8C)
>> -
>>  static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>>                                        unsigned short twi_int_status)
>>  {
>> --
>> 1.7.0.4
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/

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

* Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file.
@ 2012-05-25 10:10         ` Shubhrajyoti Datta
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-05-25 10:10 UTC (permalink / raw)
  To: Zhang, Sonic; +Cc: Ben Dooks, Wolfram Sang, linux-i2c, LKML, uclinux-dist-devel

Hi ,
On Fri, May 25, 2012 at 3:24 PM, Zhang, Sonic <Sonic.Zhang@analog.com> wrote:
>
>
>>-----Original Message-----
>>From: Shubhrajyoti Datta [mailto:omaplinuxkernel@gmail.com]
>>Sent: Friday, May 25, 2012 5:48 PM
>>To: Zhang, Sonic
>>Cc: Ben Dooks; Wolfram Sang; linux-i2c@vger.kernel.org; LKML; uclinux-dist-
>>devel@blackfin.uclinux.org
>>Subject: Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access
>>Macro to head file.
>>
>>Hi ,
>>Some minor comments/ doubts.
>>On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang@analog.com> wrote:
>>> From: Sonic Zhang <sonic.zhang@analog.com>
>>>
>>
>>A small description may be helpful.
>>Also the $SUBJECT says move the patch looks more like the remove.
>>Am I missing something.
>
> The subject says these definitions are moved to a head file by the other patch for Blackfin architecture.

Got it thanks.

You may want to add a dependency otherwise it might lead to a compilation break?


>
> Regards,
>
> Sonic

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

* Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file.
@ 2012-05-25 10:10         ` Shubhrajyoti Datta
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-05-25 10:10 UTC (permalink / raw)
  To: Zhang, Sonic
  Cc: Ben Dooks, Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b

Hi ,
On Fri, May 25, 2012 at 3:24 PM, Zhang, Sonic <Sonic.Zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> wrote:
>
>
>>-----Original Message-----
>>From: Shubhrajyoti Datta [mailto:omaplinuxkernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
>>Sent: Friday, May 25, 2012 5:48 PM
>>To: Zhang, Sonic
>>Cc: Ben Dooks; Wolfram Sang; linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; LKML; uclinux-dist-
>>devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b@public.gmane.org
>>Subject: Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access
>>Macro to head file.
>>
>>Hi ,
>>Some minor comments/ doubts.
>>On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> wrote:
>>> From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>>>
>>
>>A small description may be helpful.
>>Also the $SUBJECT says move the patch looks more like the remove.
>>Am I missing something.
>
> The subject says these definitions are moved to a head file by the other patch for Blackfin architecture.

Got it thanks.

You may want to add a dependency otherwise it might lead to a compilation break?


>
> Regards,
>
> Sonic

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

* RE: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file.
  2012-05-25 10:10         ` Shubhrajyoti Datta
@ 2012-05-25 10:12           ` Zhang, Sonic
  -1 siblings, 0 replies; 58+ messages in thread
From: Zhang, Sonic @ 2012-05-25 10:12 UTC (permalink / raw)
  To: Shubhrajyoti Datta
  Cc: Ben Dooks, Wolfram Sang, linux-i2c, LKML, uclinux-dist-devel



>-----Original Message-----
>From: Shubhrajyoti Datta [mailto:omaplinuxkernel@gmail.com]
>Sent: Friday, May 25, 2012 6:10 PM
>To: Zhang, Sonic
>Cc: Ben Dooks; Wolfram Sang; linux-i2c@vger.kernel.org; LKML; uclinux-dist-
>devel@blackfin.uclinux.org
>Subject: Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access
>Macro to head file.
>
>Hi ,
>On Fri, May 25, 2012 at 3:24 PM, Zhang, Sonic <Sonic.Zhang@analog.com>
>wrote:
>>
>>
>>>-----Original Message-----
>>>From: Shubhrajyoti Datta [mailto:omaplinuxkernel@gmail.com]
>>>Sent: Friday, May 25, 2012 5:48 PM
>>>To: Zhang, Sonic
>>>Cc: Ben Dooks; Wolfram Sang; linux-i2c@vger.kernel.org; LKML; uclinux-dist-
>>>devel@blackfin.uclinux.org
>>>Subject: Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access
>>>Macro to head file.
>>>
>>>Hi ,
>>>Some minor comments/ doubts.
>>>On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang@analog.com> wrote:
>>>> From: Sonic Zhang <sonic.zhang@analog.com>
>>>>
>>>
>>>A small description may be helpful.
>>>Also the $SUBJECT says move the patch looks more like the remove.
>>>Am I missing something.
>>
>> The subject says these definitions are moved to a head file by the other patch
>for Blackfin architecture.
>
>Got it thanks.
>
>You may want to add a dependency otherwise it might lead to a compilation break?
>

That patch for Blackfin architecture has already been merged into mainline.

Regards,

Sonic

>
>>
>> Regards,
>>
>> Sonic



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

* RE: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file.
@ 2012-05-25 10:12           ` Zhang, Sonic
  0 siblings, 0 replies; 58+ messages in thread
From: Zhang, Sonic @ 2012-05-25 10:12 UTC (permalink / raw)
  To: Shubhrajyoti Datta
  Cc: Ben Dooks, Wolfram Sang, linux-i2c, LKML, uclinux-dist-devel



>-----Original Message-----
>From: Shubhrajyoti Datta [mailto:omaplinuxkernel@gmail.com]
>Sent: Friday, May 25, 2012 6:10 PM
>To: Zhang, Sonic
>Cc: Ben Dooks; Wolfram Sang; linux-i2c@vger.kernel.org; LKML; uclinux-dist-
>devel@blackfin.uclinux.org
>Subject: Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access
>Macro to head file.
>
>Hi ,
>On Fri, May 25, 2012 at 3:24 PM, Zhang, Sonic <Sonic.Zhang@analog.com>
>wrote:
>>
>>
>>>-----Original Message-----
>>>From: Shubhrajyoti Datta [mailto:omaplinuxkernel@gmail.com]
>>>Sent: Friday, May 25, 2012 5:48 PM
>>>To: Zhang, Sonic
>>>Cc: Ben Dooks; Wolfram Sang; linux-i2c@vger.kernel.org; LKML; uclinux-dist-
>>>devel@blackfin.uclinux.org
>>>Subject: Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access
>>>Macro to head file.
>>>
>>>Hi ,
>>>Some minor comments/ doubts.
>>>On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang@analog.com> wrote:
>>>> From: Sonic Zhang <sonic.zhang@analog.com>
>>>>
>>>
>>>A small description may be helpful.
>>>Also the $SUBJECT says move the patch looks more like the remove.
>>>Am I missing something.
>>
>> The subject says these definitions are moved to a head file by the other patch
>for Blackfin architecture.
>
>Got it thanks.
>
>You may want to add a dependency otherwise it might lead to a compilation break?
>

That patch for Blackfin architecture has already been merged into mainline.

Regards,

Sonic

>
>>
>> Regards,
>>
>> Sonic

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

* Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file.
@ 2012-05-25 10:16             ` Shubhrajyoti Datta
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-05-25 10:16 UTC (permalink / raw)
  To: Zhang, Sonic; +Cc: Ben Dooks, Wolfram Sang, linux-i2c, LKML, uclinux-dist-devel

On Fri, May 25, 2012 at 3:42 PM, Zhang, Sonic <Sonic.Zhang@analog.com> wrote:
>
>
>>-----Original Message-----
>>From: Shubhrajyoti Datta [mailto:omaplinuxkernel@gmail.com]
>>Sent: Friday, May 25, 2012 6:10 PM
>>To: Zhang, Sonic
>>Cc: Ben Dooks; Wolfram Sang; linux-i2c@vger.kernel.org; LKML; uclinux-dist-
>>devel@blackfin.uclinux.org
>>Subject: Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access
>>Macro to head file.
>>
>>Hi ,
>>On Fri, May 25, 2012 at 3:24 PM, Zhang, Sonic <Sonic.Zhang@analog.com>
>>wrote:
>>>
>>>
>>>>-----Original Message-----
>>>>From: Shubhrajyoti Datta [mailto:omaplinuxkernel@gmail.com]
>>>>Sent: Friday, May 25, 2012 5:48 PM
>>>>To: Zhang, Sonic
>>>>Cc: Ben Dooks; Wolfram Sang; linux-i2c@vger.kernel.org; LKML; uclinux-dist-
>>>>devel@blackfin.uclinux.org
>>>>Subject: Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access
>>>>Macro to head file.
>>>>
>>>>Hi ,
>>>>Some minor comments/ doubts.
>>>>On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang@analog.com> wrote:
>>>>> From: Sonic Zhang <sonic.zhang@analog.com>
>>>>>
>>>>
>>>>A small description may be helpful.
>>>>Also the $SUBJECT says move the patch looks more like the remove.
>>>>Am I missing something.
>>>
>>> The subject says these definitions are moved to a head file by the other patch
>>for Blackfin architecture.
>>
>>Got it thanks.
>>
>>You may want to add a dependency otherwise it might lead to a compilation break?
>>
>
> That patch for Blackfin architecture has already been merged into mainline.
Great,

Apologies for the noise.

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

* Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file.
@ 2012-05-25 10:16             ` Shubhrajyoti Datta
  0 siblings, 0 replies; 58+ messages in thread
From: Shubhrajyoti Datta @ 2012-05-25 10:16 UTC (permalink / raw)
  To: Zhang, Sonic
  Cc: Ben Dooks, Wolfram Sang, linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b

On Fri, May 25, 2012 at 3:42 PM, Zhang, Sonic <Sonic.Zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> wrote:
>
>
>>-----Original Message-----
>>From: Shubhrajyoti Datta [mailto:omaplinuxkernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
>>Sent: Friday, May 25, 2012 6:10 PM
>>To: Zhang, Sonic
>>Cc: Ben Dooks; Wolfram Sang; linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; LKML; uclinux-dist-
>>devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b@public.gmane.org
>>Subject: Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access
>>Macro to head file.
>>
>>Hi ,
>>On Fri, May 25, 2012 at 3:24 PM, Zhang, Sonic <Sonic.Zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>>wrote:
>>>
>>>
>>>>-----Original Message-----
>>>>From: Shubhrajyoti Datta [mailto:omaplinuxkernel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org]
>>>>Sent: Friday, May 25, 2012 5:48 PM
>>>>To: Zhang, Sonic
>>>>Cc: Ben Dooks; Wolfram Sang; linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; LKML; uclinux-dist-
>>>>devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b@public.gmane.org
>>>>Subject: Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access
>>>>Macro to head file.
>>>>
>>>>Hi ,
>>>>Some minor comments/ doubts.
>>>>On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> wrote:
>>>>> From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>>>>>
>>>>
>>>>A small description may be helpful.
>>>>Also the $SUBJECT says move the patch looks more like the remove.
>>>>Am I missing something.
>>>
>>> The subject says these definitions are moved to a head file by the other patch
>>for Blackfin architecture.
>>
>>Got it thanks.
>>
>>You may want to add a dependency otherwise it might lead to a compilation break?
>>
>
> That patch for Blackfin architecture has already been merged into mainline.
Great,

Apologies for the noise.

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

* Re: [PATCH 1/8] i2c: i2c-bfin-twi: Illegal i2c bus lock upon certain transfer scenarios.
@ 2012-06-11 16:24   ` Wolfram Sang
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-11 16:24 UTC (permalink / raw)
  To: sonic.zhang
  Cc: Ben Dooks, linux-i2c, LKML, uclinux-dist-devel, Michael Hennerich

[-- Attachment #1: Type: text/plain, Size: 2000 bytes --]

On Wed, May 16, 2012 at 03:20:19PM +0800, sonic.zhang@analog.com wrote:
> From: Michael Hennerich <michael.hennerich@analog.com>
> 
> For transfer counts > 255 bytes i2c-bfin-twi sets the data
> transfer counter DCNT to 0xFF indicating unlimited transfers.
> It then uses a flag iface->manual_stop to manually issue the STOP
> condition, once the required amount of bytes are received.
> 
> We found that on I2C receive operation issuing the STOP condition
> together with a FULL RCV FIFO (2bytes) will cause SDA and SCL be
> constantly driven low.
> 
> Temporary workaround until further investigation:
> Discard the RCV FIFO before issuing the STOP condition.
> 
> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> 
> git-svn-id: svn://localhost/svn/linux-kernel/trunk@9011 526b6c2d-f592-4532-a319-5dd88ccb003d

Please remove this line.

> ---
>  drivers/i2c/busses/i2c-bfin-twi.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index cdb59e5..e6dd3c9 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -131,6 +131,10 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>  			iface->transPtr++;
>  			iface->readNum--;
>  		} else if (iface->manual_stop) {
> +			/* Avoid possible bus stall -
> +			 * Flush FIFO before issuing the STOP condition
> +			 */
> +			read_RCV_DATA16(iface);

Please mention that this is currently only a workaround, so people know
there could be still a proper solution.

>  			write_MASTER_CTL(iface,
>  				read_MASTER_CTL(iface) | STOP);
>  		} else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
> -- 
> 1.7.0.4
> 
> 

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 1/8] i2c: i2c-bfin-twi: Illegal i2c bus lock upon certain transfer scenarios.
@ 2012-06-11 16:24   ` Wolfram Sang
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-11 16:24 UTC (permalink / raw)
  To: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  Cc: Ben Dooks, linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b,
	Michael Hennerich

[-- Attachment #1: Type: text/plain, Size: 2116 bytes --]

On Wed, May 16, 2012 at 03:20:19PM +0800, sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org wrote:
> From: Michael Hennerich <michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
> 
> For transfer counts > 255 bytes i2c-bfin-twi sets the data
> transfer counter DCNT to 0xFF indicating unlimited transfers.
> It then uses a flag iface->manual_stop to manually issue the STOP
> condition, once the required amount of bytes are received.
> 
> We found that on I2C receive operation issuing the STOP condition
> together with a FULL RCV FIFO (2bytes) will cause SDA and SCL be
> constantly driven low.
> 
> Temporary workaround until further investigation:
> Discard the RCV FIFO before issuing the STOP condition.
> 
> Signed-off-by: Michael Hennerich <michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
> Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
> 
> git-svn-id: svn://localhost/svn/linux-kernel/trunk@9011 526b6c2d-f592-4532-a319-5dd88ccb003d

Please remove this line.

> ---
>  drivers/i2c/busses/i2c-bfin-twi.c |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index cdb59e5..e6dd3c9 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -131,6 +131,10 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>  			iface->transPtr++;
>  			iface->readNum--;
>  		} else if (iface->manual_stop) {
> +			/* Avoid possible bus stall -
> +			 * Flush FIFO before issuing the STOP condition
> +			 */
> +			read_RCV_DATA16(iface);

Please mention that this is currently only a workaround, so people know
there could be still a proper solution.

>  			write_MASTER_CTL(iface,
>  				read_MASTER_CTL(iface) | STOP);
>  		} else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
> -- 
> 1.7.0.4
> 
> 

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 2/8] i2c: i2c-bfin-twi: Stop receiving operation immediately in last rx interrupt.
@ 2012-06-11 16:28     ` Wolfram Sang
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-11 16:28 UTC (permalink / raw)
  To: sonic.zhang; +Cc: Ben Dooks, linux-i2c, LKML, uclinux-dist-devel

[-- Attachment #1: Type: text/plain, Size: 3569 bytes --]

On Wed, May 16, 2012 at 03:20:20PM +0800, sonic.zhang@analog.com wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
> 
> Also wake up waiting process when transfer completes.

The description says what you do, but not why it is needed. What bug was
experienced and why is this change proper? Patch 5/8 does that quite
good.

> 
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> 
> git-svn-id: svn://localhost/svn/linux-kernel/trunk@9105 526b6c2d-f592-4532-a319-5dd88ccb003d

Please remove this line.

> ---
>  drivers/i2c/busses/i2c-bfin-twi.c |   43 ++++++++++++++++++++----------------
>  1 files changed, 24 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index e6dd3c9..376e331 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -130,21 +130,25 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>  			}
>  			iface->transPtr++;
>  			iface->readNum--;
> -		} else if (iface->manual_stop) {
> -			/* Avoid possible bus stall -
> -			 * Flush FIFO before issuing the STOP condition
> -			 */
> -			read_RCV_DATA16(iface);
> -			write_MASTER_CTL(iface,
> -				read_MASTER_CTL(iface) | STOP);
> -		} else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
> -		           iface->cur_msg + 1 < iface->msg_num) {
> -			if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD)
> -				write_MASTER_CTL(iface,
> -					read_MASTER_CTL(iface) | RSTART | MDIR);
> -			else
> +		}
> +
> +		if (iface->readNum == 0) {
> +			if (iface->manual_stop) {
> +				/* Avoid possible bus stall -
> +				 * Flush FIFO before issuing the STOP condition
> +				 */
> +				read_RCV_DATA16(iface);
>  				write_MASTER_CTL(iface,
> -					(read_MASTER_CTL(iface) | RSTART) & ~MDIR);
> +					read_MASTER_CTL(iface) | STOP);
> +			} else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
> +					iface->cur_msg + 1 < iface->msg_num) {
> +				if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD)
> +					write_MASTER_CTL(iface,
> +						read_MASTER_CTL(iface) | RSTART | MDIR);
> +				else
> +					write_MASTER_CTL(iface,
> +						(read_MASTER_CTL(iface) | RSTART) & ~MDIR);
> +			}
>  		}
>  	}
>  	if (twi_int_status & MERR) {
> @@ -245,12 +249,13 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>  				}
>  			}
>  
> -			if (iface->pmsg[iface->cur_msg].len <= 255)
> -					write_MASTER_CTL(iface,
> +			if (iface->pmsg[iface->cur_msg].len <= 255) {
> +				write_MASTER_CTL(iface,
>  					(read_MASTER_CTL(iface) &
>  					(~(0xff << 6))) |
> -				(iface->pmsg[iface->cur_msg].len << 6));
> -			else {
> +					(iface->pmsg[iface->cur_msg].len << 6));
> +				iface->manual_stop = 0;
> +			} else {
>  				write_MASTER_CTL(iface,
>  					(read_MASTER_CTL(iface) |
>  					(0xff << 6)));
> @@ -264,8 +269,8 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>  			write_INT_MASK(iface, 0);
>  			write_MASTER_CTL(iface, 0);
>  		}
> +		complete(&iface->complete);
>  	}
> -	complete(&iface->complete);
>  }
>  
>  /* Interrupt handler */
> -- 
> 1.7.0.4
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 2/8] i2c: i2c-bfin-twi: Stop receiving operation immediately in last rx interrupt.
@ 2012-06-11 16:28     ` Wolfram Sang
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-11 16:28 UTC (permalink / raw)
  To: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  Cc: Ben Dooks, linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b

[-- Attachment #1: Type: text/plain, Size: 3680 bytes --]

On Wed, May 16, 2012 at 03:20:20PM +0800, sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org wrote:
> From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
> 
> Also wake up waiting process when transfer completes.

The description says what you do, but not why it is needed. What bug was
experienced and why is this change proper? Patch 5/8 does that quite
good.

> 
> Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
> 
> git-svn-id: svn://localhost/svn/linux-kernel/trunk@9105 526b6c2d-f592-4532-a319-5dd88ccb003d

Please remove this line.

> ---
>  drivers/i2c/busses/i2c-bfin-twi.c |   43 ++++++++++++++++++++----------------
>  1 files changed, 24 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index e6dd3c9..376e331 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -130,21 +130,25 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>  			}
>  			iface->transPtr++;
>  			iface->readNum--;
> -		} else if (iface->manual_stop) {
> -			/* Avoid possible bus stall -
> -			 * Flush FIFO before issuing the STOP condition
> -			 */
> -			read_RCV_DATA16(iface);
> -			write_MASTER_CTL(iface,
> -				read_MASTER_CTL(iface) | STOP);
> -		} else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
> -		           iface->cur_msg + 1 < iface->msg_num) {
> -			if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD)
> -				write_MASTER_CTL(iface,
> -					read_MASTER_CTL(iface) | RSTART | MDIR);
> -			else
> +		}
> +
> +		if (iface->readNum == 0) {
> +			if (iface->manual_stop) {
> +				/* Avoid possible bus stall -
> +				 * Flush FIFO before issuing the STOP condition
> +				 */
> +				read_RCV_DATA16(iface);
>  				write_MASTER_CTL(iface,
> -					(read_MASTER_CTL(iface) | RSTART) & ~MDIR);
> +					read_MASTER_CTL(iface) | STOP);
> +			} else if (iface->cur_mode == TWI_I2C_MODE_REPEAT &&
> +					iface->cur_msg + 1 < iface->msg_num) {
> +				if (iface->pmsg[iface->cur_msg + 1].flags & I2C_M_RD)
> +					write_MASTER_CTL(iface,
> +						read_MASTER_CTL(iface) | RSTART | MDIR);
> +				else
> +					write_MASTER_CTL(iface,
> +						(read_MASTER_CTL(iface) | RSTART) & ~MDIR);
> +			}
>  		}
>  	}
>  	if (twi_int_status & MERR) {
> @@ -245,12 +249,13 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>  				}
>  			}
>  
> -			if (iface->pmsg[iface->cur_msg].len <= 255)
> -					write_MASTER_CTL(iface,
> +			if (iface->pmsg[iface->cur_msg].len <= 255) {
> +				write_MASTER_CTL(iface,
>  					(read_MASTER_CTL(iface) &
>  					(~(0xff << 6))) |
> -				(iface->pmsg[iface->cur_msg].len << 6));
> -			else {
> +					(iface->pmsg[iface->cur_msg].len << 6));
> +				iface->manual_stop = 0;
> +			} else {
>  				write_MASTER_CTL(iface,
>  					(read_MASTER_CTL(iface) |
>  					(0xff << 6)));
> @@ -264,8 +269,8 @@ static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>  			write_INT_MASK(iface, 0);
>  			write_MASTER_CTL(iface, 0);
>  		}
> +		complete(&iface->complete);
>  	}
> -	complete(&iface->complete);
>  }
>  
>  /* Interrupt handler */
> -- 
> 1.7.0.4
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 3/8] i2c: i2c-bfin-twi: Break dead waiting loop if i2c device misbehaves.
  2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  (?)
  (?)
@ 2012-06-11 16:30   ` Wolfram Sang
  2012-06-13  7:47       ` Zhang, Sonic
  -1 siblings, 1 reply; 58+ messages in thread
From: Wolfram Sang @ 2012-06-11 16:30 UTC (permalink / raw)
  To: sonic.zhang; +Cc: Ben Dooks, linux-i2c, LKML, uclinux-dist-devel

[-- Attachment #1: Type: text/plain, Size: 2494 bytes --]

On Wed, May 16, 2012 at 03:20:21PM +0800, sonic.zhang@analog.com wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
> 
> Some fault i2c device may hold the sda/scl line and cause i2c driver
> wait in the BUS busy loop. This patch breaks this potential dead
> loop.
> 
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> 
> git-svn-id: svn://localhost/svn/linux-kernel/trunk@9291 526b6c2d-f592-4532-a319-5dd88ccb003d

^

> ---
>  drivers/i2c/busses/i2c-bfin-twi.c |   14 ++++++++++++--
>  1 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index 376e331..4abaf59 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -294,6 +294,8 @@ static irqreturn_t bfin_twi_interrupt_entry(int irq, void *dev_id)
>  	return IRQ_HANDLED;
>  }
>  
> +#define BFIN_TWI_BUSY_TIMEOUT	1000
> +

Please use a unit like microseconds for the timeout.

>  /*
>   * One i2c master transfer
>   */
> @@ -303,12 +305,16 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter *adap,
>  	struct bfin_twi_iface *iface = adap->algo_data;
>  	struct i2c_msg *pmsg;
>  	int rc = 0;
> +	unsigned int busy_timeout = BFIN_TWI_BUSY_TIMEOUT;
>  
>  	if (!(read_CONTROL(iface) & TWI_ENA))
>  		return -ENXIO;
>  
> -	while (read_MASTER_STAT(iface) & BUSBUSY)
> +	while (read_MASTER_STAT(iface) & BUSBUSY) {
> +		if (--busy_timeout == 0)
> +			return -EBUSY;
>  		yield();
> +	}
>  
>  	iface->pmsg = msgs;
>  	iface->msg_num = num;
> @@ -403,12 +409,16 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter *adap, u16 addr,
>  {
>  	struct bfin_twi_iface *iface = adap->algo_data;
>  	int rc = 0;
> +	unsigned int busy_timeout = BFIN_TWI_BUSY_TIMEOUT;
>  
>  	if (!(read_CONTROL(iface) & TWI_ENA))
>  		return -ENXIO;
>  
> -	while (read_MASTER_STAT(iface) & BUSBUSY)
> +	while (read_MASTER_STAT(iface) & BUSBUSY) {
> +		if (--busy_timeout == 0)
> +			return -EBUSY;
>  		yield();
> +	}
>  
>  	iface->writeNum = 0;
>  	iface->readNum = 0;
> -- 
> 1.7.0.4
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 4/8] i2c: i2c-bfin-twi: Tighten condition when failing I2C transfer if MEN bit is reset unexpectedly.
@ 2012-06-11 16:33       ` Wolfram Sang
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-11 16:33 UTC (permalink / raw)
  To: Shubhrajyoti Datta
  Cc: sonic.zhang, Ben Dooks, linux-i2c, LKML, uclinux-dist-devel

[-- Attachment #1: Type: text/plain, Size: 678 bytes --]

On Thu, May 17, 2012 at 05:00:40PM +0530, Shubhrajyoti Datta wrote:
> On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang@analog.com> wrote:
> > From: Sonic Zhang <sonic.zhang@analog.com>
> >
> > Correct I2C transfer may fail because interrupt status bits XMTSERV and
> > RCVSERV are not checked when MCOMP interrupt is handled.
> >
> Could you expand MCOMP?

I agree. It is nice to understand patch descriptions without needing to
know all the datasheet terminology, so please rework the description a
little.

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 4/8] i2c: i2c-bfin-twi: Tighten condition when failing I2C transfer if MEN bit is reset unexpectedly.
@ 2012-06-11 16:33       ` Wolfram Sang
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-11 16:33 UTC (permalink / raw)
  To: Shubhrajyoti Datta
  Cc: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA, Ben Dooks,
	linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b

[-- Attachment #1: Type: text/plain, Size: 736 bytes --]

On Thu, May 17, 2012 at 05:00:40PM +0530, Shubhrajyoti Datta wrote:
> On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org> wrote:
> > From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
> >
> > Correct I2C transfer may fail because interrupt status bits XMTSERV and
> > RCVSERV are not checked when MCOMP interrupt is handled.
> >
> Could you expand MCOMP?

I agree. It is nice to understand patch descriptions without needing to
know all the datasheet terminology, so please rework the description a
little.

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 6/8] i2c:i2c-bfin-twi: include twi head file
  2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  (?)
  (?)
@ 2012-06-11 16:34   ` Wolfram Sang
  -1 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-11 16:34 UTC (permalink / raw)
  To: sonic.zhang; +Cc: Ben Dooks, linux-i2c, LKML, uclinux-dist-devel, Bob Liu

[-- Attachment #1: Type: text/plain, Size: 1051 bytes --]

On Wed, May 16, 2012 at 03:20:24PM +0800, sonic.zhang@analog.com wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
> 
> TWI bit mask macros are moved to twi head file.
> 
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
> Signed-off-by: Bob Liu <lliubbo@gmail.com>

Please state the dependency if any, or the commit if already merged.

> ---
>  drivers/i2c/busses/i2c-bfin-twi.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index 594bbb1..d7e8fba 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -25,6 +25,7 @@
>  #include <asm/blackfin.h>
>  #include <asm/portmux.h>
>  #include <asm/irq.h>
> +#include <asm/bfin_twi.h>
>  
>  /* SMBus mode*/
>  #define TWI_I2C_MODE_STANDARD		1
> -- 
> 1.7.0.4
> 
> 

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 7/8] i2c: i2c-bfin-twi: Move TWI peripheral pin request array to platform data.
@ 2012-06-11 16:35     ` Wolfram Sang
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-11 16:35 UTC (permalink / raw)
  To: sonic.zhang; +Cc: Ben Dooks, linux-i2c, LKML, uclinux-dist-devel

[-- Attachment #1: Type: text/plain, Size: 2374 bytes --]

On Wed, May 16, 2012 at 03:20:25PM +0800, sonic.zhang@analog.com wrote:
> From: Sonic Zhang <sonic.zhang@analog.com>
> 
> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>

Again, please state the dependency.

> ---
>  drivers/i2c/busses/i2c-bfin-twi.c |   12 ++++--------
>  1 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index d7e8fba..b2ca317 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -78,11 +78,6 @@ DEFINE_TWI_REG(XMT_DATA16, 0x84)
>  DEFINE_TWI_REG(RCV_DATA8, 0x88)
>  DEFINE_TWI_REG(RCV_DATA16, 0x8C)
>  
> -static const u16 pin_req[2][3] = {
> -	{P_TWI0_SCL, P_TWI0_SDA, 0},
> -	{P_TWI1_SCL, P_TWI1_SDA, 0},
> -};
> -
>  static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>  					unsigned short twi_int_status)
>  {
> @@ -719,7 +714,8 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
>  	p_adap->timeout = 5 * HZ;
>  	p_adap->retries = 3;
>  
> -	rc = peripheral_request_list(pin_req[pdev->id], "i2c-bfin-twi");
> +	rc = peripheral_request_list((unsigned short *)pdev->dev.platform_data,
> +					"i2c-bfin-twi");
>  	if (rc) {
>  		dev_err(&pdev->dev, "Can't setup pin mux!\n");
>  		goto out_error_pin_mux;
> @@ -766,7 +762,7 @@ out_error_add_adapter:
>  	free_irq(iface->irq, iface);
>  out_error_req_irq:
>  out_error_no_irq:
> -	peripheral_free_list(pin_req[pdev->id]);
> +	peripheral_free_list((unsigned short *)pdev->dev.platform_data);
>  out_error_pin_mux:
>  	iounmap(iface->regs_base);
>  out_error_ioremap:
> @@ -784,7 +780,7 @@ static int i2c_bfin_twi_remove(struct platform_device *pdev)
>  
>  	i2c_del_adapter(&(iface->adap));
>  	free_irq(iface->irq, iface);
> -	peripheral_free_list(pin_req[pdev->id]);
> +	peripheral_free_list((unsigned short *)pdev->dev.platform_data);
>  	iounmap(iface->regs_base);
>  	kfree(iface);
>  
> -- 
> 1.7.0.4
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 7/8] i2c: i2c-bfin-twi: Move TWI peripheral pin request array to platform data.
@ 2012-06-11 16:35     ` Wolfram Sang
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-11 16:35 UTC (permalink / raw)
  To: sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
  Cc: Ben Dooks, linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b

[-- Attachment #1: Type: text/plain, Size: 2485 bytes --]

On Wed, May 16, 2012 at 03:20:25PM +0800, sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org wrote:
> From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
> 
> Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>

Again, please state the dependency.

> ---
>  drivers/i2c/busses/i2c-bfin-twi.c |   12 ++++--------
>  1 files changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c b/drivers/i2c/busses/i2c-bfin-twi.c
> index d7e8fba..b2ca317 100644
> --- a/drivers/i2c/busses/i2c-bfin-twi.c
> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
> @@ -78,11 +78,6 @@ DEFINE_TWI_REG(XMT_DATA16, 0x84)
>  DEFINE_TWI_REG(RCV_DATA8, 0x88)
>  DEFINE_TWI_REG(RCV_DATA16, 0x8C)
>  
> -static const u16 pin_req[2][3] = {
> -	{P_TWI0_SCL, P_TWI0_SDA, 0},
> -	{P_TWI1_SCL, P_TWI1_SDA, 0},
> -};
> -
>  static void bfin_twi_handle_interrupt(struct bfin_twi_iface *iface,
>  					unsigned short twi_int_status)
>  {
> @@ -719,7 +714,8 @@ static int i2c_bfin_twi_probe(struct platform_device *pdev)
>  	p_adap->timeout = 5 * HZ;
>  	p_adap->retries = 3;
>  
> -	rc = peripheral_request_list(pin_req[pdev->id], "i2c-bfin-twi");
> +	rc = peripheral_request_list((unsigned short *)pdev->dev.platform_data,
> +					"i2c-bfin-twi");
>  	if (rc) {
>  		dev_err(&pdev->dev, "Can't setup pin mux!\n");
>  		goto out_error_pin_mux;
> @@ -766,7 +762,7 @@ out_error_add_adapter:
>  	free_irq(iface->irq, iface);
>  out_error_req_irq:
>  out_error_no_irq:
> -	peripheral_free_list(pin_req[pdev->id]);
> +	peripheral_free_list((unsigned short *)pdev->dev.platform_data);
>  out_error_pin_mux:
>  	iounmap(iface->regs_base);
>  out_error_ioremap:
> @@ -784,7 +780,7 @@ static int i2c_bfin_twi_remove(struct platform_device *pdev)
>  
>  	i2c_del_adapter(&(iface->adap));
>  	free_irq(iface->irq, iface);
> -	peripheral_free_list(pin_req[pdev->id]);
> +	peripheral_free_list((unsigned short *)pdev->dev.platform_data);
>  	iounmap(iface->regs_base);
>  	kfree(iface);
>  
> -- 
> 1.7.0.4
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file.
  2012-05-25 10:16             ` Shubhrajyoti Datta
@ 2012-06-11 16:36               ` Wolfram Sang
  -1 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-11 16:36 UTC (permalink / raw)
  To: Shubhrajyoti Datta
  Cc: Zhang, Sonic, Ben Dooks, linux-i2c, LKML, uclinux-dist-devel

[-- Attachment #1: Type: text/plain, Size: 2170 bytes --]

On Fri, May 25, 2012 at 03:46:06PM +0530, Shubhrajyoti Datta wrote:
> On Fri, May 25, 2012 at 3:42 PM, Zhang, Sonic <Sonic.Zhang@analog.com> wrote:
> >
> >
> >>-----Original Message-----
> >>From: Shubhrajyoti Datta [mailto:omaplinuxkernel@gmail.com]
> >>Sent: Friday, May 25, 2012 6:10 PM
> >>To: Zhang, Sonic
> >>Cc: Ben Dooks; Wolfram Sang; linux-i2c@vger.kernel.org; LKML; uclinux-dist-
> >>devel@blackfin.uclinux.org
> >>Subject: Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access
> >>Macro to head file.
> >>
> >>Hi ,
> >>On Fri, May 25, 2012 at 3:24 PM, Zhang, Sonic <Sonic.Zhang@analog.com>
> >>wrote:
> >>>
> >>>
> >>>>-----Original Message-----
> >>>>From: Shubhrajyoti Datta [mailto:omaplinuxkernel@gmail.com]
> >>>>Sent: Friday, May 25, 2012 5:48 PM
> >>>>To: Zhang, Sonic
> >>>>Cc: Ben Dooks; Wolfram Sang; linux-i2c@vger.kernel.org; LKML; uclinux-dist-
> >>>>devel@blackfin.uclinux.org
> >>>>Subject: Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access
> >>>>Macro to head file.
> >>>>
> >>>>Hi ,
> >>>>Some minor comments/ doubts.
> >>>>On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang@analog.com> wrote:
> >>>>> From: Sonic Zhang <sonic.zhang@analog.com>
> >>>>>
> >>>>
> >>>>A small description may be helpful.
> >>>>Also the $SUBJECT says move the patch looks more like the remove.
> >>>>Am I missing something.
> >>>
> >>> The subject says these definitions are moved to a head file by the other patch
> >>for Blackfin architecture.
> >>
> >>Got it thanks.
> >>
> >>You may want to add a dependency otherwise it might lead to a compilation break?
> >>
> >
> > That patch for Blackfin architecture has already been merged into mainline.
> Great,
> 
> Apologies for the noise.

I don't think this is noise, I agree with you. I'd like to see the
commit which added that and the reasoning. Usually, encapsulating the
accesses in the driver is good, because no one else should bother.

Thanks,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file.
@ 2012-06-11 16:36               ` Wolfram Sang
  0 siblings, 0 replies; 58+ messages in thread
From: Wolfram Sang @ 2012-06-11 16:36 UTC (permalink / raw)
  To: Shubhrajyoti Datta
  Cc: Zhang, Sonic, Ben Dooks, linux-i2c, LKML, uclinux-dist-devel

[-- Attachment #1: Type: text/plain, Size: 2170 bytes --]

On Fri, May 25, 2012 at 03:46:06PM +0530, Shubhrajyoti Datta wrote:
> On Fri, May 25, 2012 at 3:42 PM, Zhang, Sonic <Sonic.Zhang@analog.com> wrote:
> >
> >
> >>-----Original Message-----
> >>From: Shubhrajyoti Datta [mailto:omaplinuxkernel@gmail.com]
> >>Sent: Friday, May 25, 2012 6:10 PM
> >>To: Zhang, Sonic
> >>Cc: Ben Dooks; Wolfram Sang; linux-i2c@vger.kernel.org; LKML; uclinux-dist-
> >>devel@blackfin.uclinux.org
> >>Subject: Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access
> >>Macro to head file.
> >>
> >>Hi ,
> >>On Fri, May 25, 2012 at 3:24 PM, Zhang, Sonic <Sonic.Zhang@analog.com>
> >>wrote:
> >>>
> >>>
> >>>>-----Original Message-----
> >>>>From: Shubhrajyoti Datta [mailto:omaplinuxkernel@gmail.com]
> >>>>Sent: Friday, May 25, 2012 5:48 PM
> >>>>To: Zhang, Sonic
> >>>>Cc: Ben Dooks; Wolfram Sang; linux-i2c@vger.kernel.org; LKML; uclinux-dist-
> >>>>devel@blackfin.uclinux.org
> >>>>Subject: Re: [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access
> >>>>Macro to head file.
> >>>>
> >>>>Hi ,
> >>>>Some minor comments/ doubts.
> >>>>On Wed, May 16, 2012 at 12:50 PM,  <sonic.zhang@analog.com> wrote:
> >>>>> From: Sonic Zhang <sonic.zhang@analog.com>
> >>>>>
> >>>>
> >>>>A small description may be helpful.
> >>>>Also the $SUBJECT says move the patch looks more like the remove.
> >>>>Am I missing something.
> >>>
> >>> The subject says these definitions are moved to a head file by the other patch
> >>for Blackfin architecture.
> >>
> >>Got it thanks.
> >>
> >>You may want to add a dependency otherwise it might lead to a compilation break?
> >>
> >
> > That patch for Blackfin architecture has already been merged into mainline.
> Great,
> 
> Apologies for the noise.

I don't think this is noise, I agree with you. I'd like to see the
commit which added that and the reasoning. Usually, encapsulating the
accesses in the driver is good, because no one else should bother.

Thanks,

   Wolfram

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

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

* RE: [PATCH 3/8] i2c: i2c-bfin-twi: Break dead waiting loop if i2c device misbehaves.
@ 2012-06-13  7:47       ` Zhang, Sonic
  0 siblings, 0 replies; 58+ messages in thread
From: Zhang, Sonic @ 2012-06-13  7:47 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: Ben Dooks, linux-i2c, LKML, uclinux-dist-devel



>-----Original Message-----
>From: Wolfram Sang [mailto:w.sang@pengutronix.de]
>Sent: Tuesday, June 12, 2012 12:31 AM
>To: Zhang, Sonic
>Cc: Ben Dooks; linux-i2c@vger.kernel.org; LKML; uclinux-dist-
>devel@blackfin.uclinux.org
>Subject: Re: [PATCH 3/8] i2c: i2c-bfin-twi: Break dead waiting loop if i2c device
>misbehaves.
>
>On Wed, May 16, 2012 at 03:20:21PM +0800, sonic.zhang@analog.com wrote:
>> From: Sonic Zhang <sonic.zhang@analog.com>
>>
>> Some fault i2c device may hold the sda/scl line and cause i2c driver
>> wait in the BUS busy loop. This patch breaks this potential dead loop.
>>
>> Signed-off-by: Sonic Zhang <sonic.zhang@analog.com>
>>
>> git-svn-id: svn://localhost/svn/linux-kernel/trunk@9291
>> 526b6c2d-f592-4532-a319-5dd88ccb003d
>
>^
>
>> ---
>>  drivers/i2c/busses/i2c-bfin-twi.c |   14 ++++++++++++--
>>  1 files changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c
>> b/drivers/i2c/busses/i2c-bfin-twi.c
>> index 376e331..4abaf59 100644
>> --- a/drivers/i2c/busses/i2c-bfin-twi.c
>> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
>> @@ -294,6 +294,8 @@ static irqreturn_t bfin_twi_interrupt_entry(int irq, void
>*dev_id)
>>      return IRQ_HANDLED;
>>  }
>>
>> +#define BFIN_TWI_BUSY_TIMEOUT       1000
>> +
>
>Please use a unit like microseconds for the timeout.
>

Take a look at the I2C framework code again. I find this loop to poll BUSBUSY bit is not necessary. Just return -EAGAIN, the framework do retry before timeout already.

Regards,

Sonic


>>  /*
>>   * One i2c master transfer
>>   */
>> @@ -303,12 +305,16 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter
>*adap,
>>      struct bfin_twi_iface *iface = adap->algo_data;
>>      struct i2c_msg *pmsg;
>>      int rc = 0;
>> +    unsigned int busy_timeout = BFIN_TWI_BUSY_TIMEOUT;
>>
>>      if (!(read_CONTROL(iface) & TWI_ENA))
>>              return -ENXIO;
>>
>> -    while (read_MASTER_STAT(iface) & BUSBUSY)
>> +    while (read_MASTER_STAT(iface) & BUSBUSY) {
>> +            if (--busy_timeout == 0)
>> +                    return -EBUSY;
>>              yield();
>> +    }
>>
>>      iface->pmsg = msgs;
>>      iface->msg_num = num;
>> @@ -403,12 +409,16 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter
>> *adap, u16 addr,  {
>>      struct bfin_twi_iface *iface = adap->algo_data;
>>      int rc = 0;
>> +    unsigned int busy_timeout = BFIN_TWI_BUSY_TIMEOUT;
>>
>>      if (!(read_CONTROL(iface) & TWI_ENA))
>>              return -ENXIO;
>>
>> -    while (read_MASTER_STAT(iface) & BUSBUSY)
>> +    while (read_MASTER_STAT(iface) & BUSBUSY) {
>> +            if (--busy_timeout == 0)
>> +                    return -EBUSY;
>>              yield();
>> +    }
>>
>>      iface->writeNum = 0;
>>      iface->readNum = 0;
>> --
>> 1.7.0.4
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-i2c"
>> in the body of a message to majordomo@vger.kernel.org More majordomo
>> info at  http://vger.kernel.org/majordomo-info.html
>
>--
>Pengutronix e.K.                           | Wolfram Sang                |
>Industrial Linux Solutions                 | http://www.pengutronix.de/  |


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

* RE: [PATCH 3/8] i2c: i2c-bfin-twi: Break dead waiting loop if i2c device misbehaves.
@ 2012-06-13  7:47       ` Zhang, Sonic
  0 siblings, 0 replies; 58+ messages in thread
From: Zhang, Sonic @ 2012-06-13  7:47 UTC (permalink / raw)
  To: Wolfram Sang
  Cc: Ben Dooks, linux-i2c-u79uwXL29TY76Z2rM5mHXA, LKML,
	uclinux-dist-devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b



>-----Original Message-----
>From: Wolfram Sang [mailto:w.sang-bIcnvbaLZ9MEGnE8C9+IrQ@public.gmane.org]
>Sent: Tuesday, June 12, 2012 12:31 AM
>To: Zhang, Sonic
>Cc: Ben Dooks; linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org; LKML; uclinux-dist-
>devel-ZG0+EudsQA8dtHy/vicBwGD2FQJk+8+b@public.gmane.org
>Subject: Re: [PATCH 3/8] i2c: i2c-bfin-twi: Break dead waiting loop if i2c device
>misbehaves.
>
>On Wed, May 16, 2012 at 03:20:21PM +0800, sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org wrote:
>> From: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>>
>> Some fault i2c device may hold the sda/scl line and cause i2c driver
>> wait in the BUS busy loop. This patch breaks this potential dead loop.
>>
>> Signed-off-by: Sonic Zhang <sonic.zhang-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org>
>>
>> git-svn-id: svn://localhost/svn/linux-kernel/trunk@9291
>> 526b6c2d-f592-4532-a319-5dd88ccb003d
>
>^
>
>> ---
>>  drivers/i2c/busses/i2c-bfin-twi.c |   14 ++++++++++++--
>>  1 files changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-bfin-twi.c
>> b/drivers/i2c/busses/i2c-bfin-twi.c
>> index 376e331..4abaf59 100644
>> --- a/drivers/i2c/busses/i2c-bfin-twi.c
>> +++ b/drivers/i2c/busses/i2c-bfin-twi.c
>> @@ -294,6 +294,8 @@ static irqreturn_t bfin_twi_interrupt_entry(int irq, void
>*dev_id)
>>      return IRQ_HANDLED;
>>  }
>>
>> +#define BFIN_TWI_BUSY_TIMEOUT       1000
>> +
>
>Please use a unit like microseconds for the timeout.
>

Take a look at the I2C framework code again. I find this loop to poll BUSBUSY bit is not necessary. Just return -EAGAIN, the framework do retry before timeout already.

Regards,

Sonic


>>  /*
>>   * One i2c master transfer
>>   */
>> @@ -303,12 +305,16 @@ static int bfin_twi_do_master_xfer(struct i2c_adapter
>*adap,
>>      struct bfin_twi_iface *iface = adap->algo_data;
>>      struct i2c_msg *pmsg;
>>      int rc = 0;
>> +    unsigned int busy_timeout = BFIN_TWI_BUSY_TIMEOUT;
>>
>>      if (!(read_CONTROL(iface) & TWI_ENA))
>>              return -ENXIO;
>>
>> -    while (read_MASTER_STAT(iface) & BUSBUSY)
>> +    while (read_MASTER_STAT(iface) & BUSBUSY) {
>> +            if (--busy_timeout == 0)
>> +                    return -EBUSY;
>>              yield();
>> +    }
>>
>>      iface->pmsg = msgs;
>>      iface->msg_num = num;
>> @@ -403,12 +409,16 @@ int bfin_twi_do_smbus_xfer(struct i2c_adapter
>> *adap, u16 addr,  {
>>      struct bfin_twi_iface *iface = adap->algo_data;
>>      int rc = 0;
>> +    unsigned int busy_timeout = BFIN_TWI_BUSY_TIMEOUT;
>>
>>      if (!(read_CONTROL(iface) & TWI_ENA))
>>              return -ENXIO;
>>
>> -    while (read_MASTER_STAT(iface) & BUSBUSY)
>> +    while (read_MASTER_STAT(iface) & BUSBUSY) {
>> +            if (--busy_timeout == 0)
>> +                    return -EBUSY;
>>              yield();
>> +    }
>>
>>      iface->writeNum = 0;
>>      iface->readNum = 0;
>> --
>> 1.7.0.4
>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-i2c"
>> in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo
>> info at  http://vger.kernel.org/majordomo-info.html
>
>--
>Pengutronix e.K.                           | Wolfram Sang                |
>Industrial Linux Solutions                 | http://www.pengutronix.de/  |

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

end of thread, other threads:[~2012-06-13  7:47 UTC | newest]

Thread overview: 58+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-16  7:20 [PATCH 1/8] i2c: i2c-bfin-twi: Illegal i2c bus lock upon certain transfer scenarios sonic.zhang
2012-05-16  7:20 ` sonic.zhang
2012-05-16  7:20 ` [PATCH 2/8] i2c: i2c-bfin-twi: Stop receiving operation immediately in last rx interrupt sonic.zhang
2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
2012-05-24  9:18   ` Sonic Zhang
2012-06-11 16:28   ` Wolfram Sang
2012-06-11 16:28     ` Wolfram Sang
2012-05-16  7:20 ` [PATCH 3/8] i2c: i2c-bfin-twi: Break dead waiting loop if i2c device misbehaves sonic.zhang
2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
2012-05-17  5:20   ` Shubhrajyoti Datta
2012-05-17  5:20     ` Shubhrajyoti Datta
2012-05-17  5:23     ` Mike Frysinger
2012-05-17  5:23       ` Mike Frysinger
2012-05-17 10:51       ` Shubhrajyoti Datta
2012-05-17 10:51         ` Shubhrajyoti Datta
2012-06-11 16:30   ` Wolfram Sang
2012-06-13  7:47     ` Zhang, Sonic
2012-06-13  7:47       ` Zhang, Sonic
2012-05-16  7:20 ` [PATCH 4/8] i2c: i2c-bfin-twi: Tighten condition when failing I2C transfer if MEN bit is reset unexpectedly sonic.zhang
2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
2012-05-17 11:30   ` Shubhrajyoti Datta
2012-05-17 11:30     ` Shubhrajyoti Datta
2012-05-18  2:41     ` Zhang, Sonic
2012-05-18  2:41       ` Zhang, Sonic
2012-05-18  6:22       ` Shubhrajyoti Datta
2012-05-18  6:22         ` Shubhrajyoti Datta
2012-06-11 16:33     ` Wolfram Sang
2012-06-11 16:33       ` Wolfram Sang
2012-05-16  7:20 ` [PATCH 5/8] i2c:i2c-bfin-twi: TWI fails to restart next transfer in high system load sonic.zhang
2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
2012-05-16  7:20 ` [PATCH 6/8] i2c:i2c-bfin-twi: include twi head file sonic.zhang
2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
2012-05-24  9:18   ` Sonic Zhang
2012-05-24  9:18     ` Sonic Zhang
2012-06-11 16:34   ` Wolfram Sang
2012-05-16  7:20 ` [PATCH 7/8] i2c: i2c-bfin-twi: Move TWI peripheral pin request array to platform data sonic.zhang
2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
2012-06-11 16:35   ` Wolfram Sang
2012-06-11 16:35     ` Wolfram Sang
2012-05-16  7:20 ` [PATCH 8/8] i2c: i2c-bfin-twi: Move blackfin TWI register access Macro to head file sonic.zhang
2012-05-16  7:20   ` sonic.zhang-OyLXuOCK7orQT0dZR+AlfA
2012-05-24  9:19   ` Sonic Zhang
2012-05-24  9:19     ` Sonic Zhang
2012-05-25  9:48   ` Shubhrajyoti Datta
2012-05-25  9:48     ` Shubhrajyoti Datta
2012-05-25  9:54     ` Zhang, Sonic
2012-05-25  9:54       ` Zhang, Sonic
2012-05-25 10:10       ` Shubhrajyoti Datta
2012-05-25 10:10         ` Shubhrajyoti Datta
2012-05-25 10:12         ` Zhang, Sonic
2012-05-25 10:12           ` Zhang, Sonic
2012-05-25 10:16           ` Shubhrajyoti Datta
2012-05-25 10:16             ` Shubhrajyoti Datta
2012-06-11 16:36             ` Wolfram Sang
2012-06-11 16:36               ` Wolfram Sang
2012-05-24  9:17 ` [PATCH 1/8] i2c: i2c-bfin-twi: Illegal i2c bus lock upon certain transfer scenarios Sonic Zhang
2012-06-11 16:24 ` Wolfram Sang
2012-06-11 16:24   ` Wolfram Sang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.