Skip to contentSkip to conversation

i2c: i2c-omap: Fix BUFSTAT_REG reading

PATCH In review [email protected] 2 participants 4 messages Nov 25, 2008

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: i2c-omap: Fix BUFSTAT_REG reading

From: Eero Nurkkala <[email protected]>

The amount of bytes to receive is read from wrong place with omap 2430 and omap 3430. It is the 6 bits starting from the bit 8 from BUFSTAT_REG that indicate this amount. Not the 8 LSB:s. Only 6 LSB:s are used for the TX buffer. Moreover, only the 6 LSB:s are relevant for XDR.

---
 drivers/i2c/busses/i2c-omap.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-omap.c +19 -6
index 96f3bed..630702c 100644
@@ -672,11 +672,19 @@ omap_i2c_isr(int this_irq, void *dev_id)
 		if (stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)) {
 			u8 num_bytes = 1;
 			if (dev->fifo_size) {
-				if (stat & OMAP_I2C_STAT_RRDY)
+				if (stat & OMAP_I2C_STAT_RRDY) {
 					num_bytes = dev->fifo_size;
-				else
-					num_bytes = omap_i2c_read_reg(dev,
+				} else {
+					if (dev->rev >= OMAP_I2C_REV_ON_2430)
+						num_bytes =
+							(omap_i2c_read_reg(dev,
+							 OMAP_I2C_BUFSTAT_REG)
+							 >> 8) & 0x3F;
+					else
+						num_bytes =
+							omap_i2c_read_reg(dev,
 							OMAP_I2C_BUFSTAT_REG);
+				}
 			}
 			while (num_bytes) {
 				num_bytes--;
@@ -711,11 +719,16 @@ omap_i2c_isr(int this_irq, void *dev_id)
 		if (stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR)) {
 			u8 num_bytes = 1;
 			if (dev->fifo_size) {
-				if (stat & OMAP_I2C_STAT_XRDY)
+				if (stat & OMAP_I2C_STAT_XRDY) {
 					num_bytes = dev->fifo_size;
-				else
-					num_bytes = omap_i2c_read_reg(dev,
+				} else {
+					num_bytes =
+						omap_i2c_read_reg(dev,
 							OMAP_I2C_BUFSTAT_REG);
+
+					if (dev->rev >= OMAP_I2C_REV_ON_2430)
+						num_bytes &= 0x3F;
+				}
 			}
 			while (num_bytes) {
 				num_bytes--;
Signature · 1 line
1.6.0
#1 lore raw
Quoted 4 lines · On Monday 24 November 2008, [email protected] wrote:

From: Eero Nurkkala <[email protected]>

The amount of bytes to receive is read from wrong
place with omap 2430 and omap 3430.

More simply: on all OMAPs with highspeed I2C support, which involves a FIFO and BUFSTAT_REG.

Quoted 16 lines

It is the 6 bits
starting from the bit 8 from BUFSTAT_REG that indicate this amount. Not the 8 LSB:s. Only 6 LSB:s are used for the TX buffer. Moreover, only the 6 LSB:s are relevant for XDR.

---
 drivers/i2c/busses/i2c-omap.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-omap.c +0 -0
index 96f3bed..630702c 100644

drivers/i2c/busses/i2c-omap.c omap_i2c_isr(int this_irq, void *dev_id) · line 674

Quoted 3 lines
drivers/i2c/busses/i2c-omap.c +0 -0
@@ -672,11 +672,19 @@ omap_i2c_isr(int this_irq, void *dev_id)
 		if (stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)) {
 			u8 num_bytes = 1;
 			if (dev->fifo_size) {

... i.e. if (dev->rev >= OMAP_I2C_REV_ON_2430) ..

Quoted 5 lines
drivers/i2c/busses/i2c-omap.c +1 -3
-				if (stat & OMAP_I2C_STAT_RRDY)
+				if (stat & OMAP_I2C_STAT_RRDY) {
 					num_bytes = dev->fifo_size;
-				else
-					num_bytes = omap_i2c_read_reg(dev,

drivers/i2c/busses/i2c-omap.c omap_i2c_isr(int this_irq, void *dev_id) · line 686

Quoted 10 lines
drivers/i2c/busses/i2c-omap.c +9 -0
+				} else {
+					if (dev->rev >= OMAP_I2C_REV_ON_2430)
+						num_bytes =
+							(omap_i2c_read_reg(dev,
+							 OMAP_I2C_BUFSTAT_REG)
+							 >> 8) & 0x3F;
+					else
+						num_bytes =
+							omap_i2c_read_reg(dev,
 							OMAP_I2C_BUFSTAT_REG);

... so this "else" branch is not needed, neither is the "if" test defining the two branches ...

drivers/i2c/busses/i2c-omap.c omap_i2c_isr(int this_irq, void *dev_id) · line 721

Quoted 8 lines
drivers/i2c/busses/i2c-omap.c +1 -0
+				}
 			}
 			while (num_bytes) {
 				num_bytes--;
@@ -711,11 +719,16 @@ omap_i2c_isr(int this_irq, void *dev_id)
 		if (stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR)) {
 			u8 num_bytes = 1;
 			if (dev->fifo_size) {

... likewise ...

drivers/i2c/busses/i2c-omap.c omap_i2c_isr(int this_irq, void *dev_id) · line 730

Quoted 12 lines
drivers/i2c/busses/i2c-omap.c +7 -3
-				if (stat & OMAP_I2C_STAT_XRDY)
+				if (stat & OMAP_I2C_STAT_XRDY) {
 					num_bytes = dev->fifo_size;
-				else
-					num_bytes = omap_i2c_read_reg(dev,
+				} else {
+					num_bytes =
+						omap_i2c_read_reg(dev,
 							OMAP_I2C_BUFSTAT_REG);
+
+					if (dev->rev >= OMAP_I2C_REV_ON_2430)
+						num_bytes &= 0x3F;

... and likewise.

Quoted 13 lines
drivers/i2c/busses/i2c-omap.c +1 -0
+				}
 			}
 			while (num_bytes) {
 				num_bytes--;
Signature · 6 lines
1.6.0

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#2 lore raw

Shortly: Restate the introductory header and resend the patches?

Quoted 95 lines · ext David Brownell
Quoted 4 lines · On Monday 24 November 2008, [email protected] wrote:

From: Eero Nurkkala <[email protected]>

The amount of bytes to receive is read from wrong
place with omap 2430 and omap 3430.

More simply: on all OMAPs with highspeed I2C support, which involves a FIFO and BUFSTAT_REG.

Quoted 16 lines

It is the 6 bits
starting from the bit 8 from BUFSTAT_REG that indicate this amount. Not the 8 LSB:s. Only 6 LSB:s are used for the TX buffer. Moreover, only the 6 LSB:s are relevant for XDR.

---
 drivers/i2c/busses/i2c-omap.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)
drivers/i2c/busses/i2c-omap.c +0 -0
index 96f3bed..630702c 100644

drivers/i2c/busses/i2c-omap.c omap_i2c_isr(int this_irq, void *dev_id) · line 674

Quoted 3 lines
drivers/i2c/busses/i2c-omap.c +0 -0
@@ -672,11 +672,19 @@ omap_i2c_isr(int this_irq, void *dev_id)
 		if (stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)) {
 			u8 num_bytes = 1;
 			if (dev->fifo_size) {

... i.e. if (dev->rev >= OMAP_I2C_REV_ON_2430) ..

Quoted 5 lines
drivers/i2c/busses/i2c-omap.c +1 -3
-				if (stat & OMAP_I2C_STAT_RRDY)
+				if (stat & OMAP_I2C_STAT_RRDY) {
 					num_bytes = dev->fifo_size;
-				else
-					num_bytes = omap_i2c_read_reg(dev,

drivers/i2c/busses/i2c-omap.c omap_i2c_isr(int this_irq, void *dev_id) · line 686

Quoted 10 lines
drivers/i2c/busses/i2c-omap.c +9 -0
+				} else {
+					if (dev->rev >= OMAP_I2C_REV_ON_2430)
+						num_bytes =
+							(omap_i2c_read_reg(dev,
+							 OMAP_I2C_BUFSTAT_REG)
+							 >> 8) & 0x3F;
+					else
+						num_bytes =
+							omap_i2c_read_reg(dev,
 							OMAP_I2C_BUFSTAT_REG);

... so this "else" branch is not needed, neither is the "if" test defining the two branches ...

drivers/i2c/busses/i2c-omap.c omap_i2c_isr(int this_irq, void *dev_id) · line 721

Quoted 8 lines
drivers/i2c/busses/i2c-omap.c +1 -0
+				}
 			}
 			while (num_bytes) {
 				num_bytes--;
@@ -711,11 +719,16 @@ omap_i2c_isr(int this_irq, void *dev_id)
 		if (stat & (OMAP_I2C_STAT_XRDY | OMAP_I2C_STAT_XDR)) {
 			u8 num_bytes = 1;
 			if (dev->fifo_size) {

... likewise ...

drivers/i2c/busses/i2c-omap.c omap_i2c_isr(int this_irq, void *dev_id) · line 730

Quoted 12 lines
drivers/i2c/busses/i2c-omap.c +7 -3
-				if (stat & OMAP_I2C_STAT_XRDY)
+				if (stat & OMAP_I2C_STAT_XRDY) {
 					num_bytes = dev->fifo_size;
-				else
-					num_bytes = omap_i2c_read_reg(dev,
+				} else {
+					num_bytes =
+						omap_i2c_read_reg(dev,
 							OMAP_I2C_BUFSTAT_REG);
+
+					if (dev->rev >= OMAP_I2C_REV_ON_2430)
+						num_bytes &= 0x3F;

... and likewise.

Quoted 13 lines
drivers/i2c/busses/i2c-omap.c +1 -0
+				}
 			}
 			while (num_bytes) {
 				num_bytes--;
Signature · 6 lines
1.6.0

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
Quoted 1 line · Eero Nurkkala

Shortly: Restate the introductory header and resend the patches?

Restate, and update the patch to address the issues noted inline. You had added the

	if (34xx) {
		...
	} else /* must be 2430 */ {
		...
	}

branches, but since 34xx and 2430 act the same there (per Tony's check of the 2430 manual) ... neither the check, nor the "else" branch, is needed.