[PATCH] i2c: i2c-omap: Fix BUFSTAT_REG reading

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Eero Nurkkala <ext-eero.nurkkala@xxxxxxxxx>

The amount of bytes to receive is read from wrong
place. 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. Also, with
omap 3430, only the 6 LSB:s are relevant for XDR.

Signed-off-by: Eero Nurkkala <ext-eero.nurkkala@xxxxxxxxx>
---
 drivers/i2c/busses/i2c-omap.c |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index a999606..e708ebd 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -618,11 +618,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 (cpu_is_omap34xx())
+						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--;
@@ -657,11 +665,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 (cpu_is_omap34xx())
+						num_bytes &= 0x3F;
+				}
 			}
 			while (num_bytes) {
 				num_bytes--;
-- 
1.6.0

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Arm (vger)]     [ARM Kernel]     [ARM MSM]     [Linux Tegra]     [Linux WPAN Networking]     [Linux Wireless Networking]     [Maemo Users]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux