Skip to contentSkip to conversation

OMAP3: I2C: Errata ID i207: Clear wrong RDR interrupt

PATCH Superseded Manjunatha GK 4 participants 5 messages Apr 13, 2010 – Apr 23, 2010 1 message not in the archive

Subsystems (4)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 OMAP3: I2C: Errata ID i207: Clear wrong RDR interrupt

Under certain rare conditions, I2C_STAT[13].RDR bit may be set and the corresponding interrupt fire, even there is no data in the receive FIFO, or the I2C data transfer is still ongoing. These spurious RDR events must be ignored by the software.

This patch handles and ignores RDR spurious interrupts.

Patch tested on OMAP zoom3 board.

---
Review comments for earlier post can be found at:
https://patchwork.kernel.org/patch/90122/

 drivers/i2c/busses/i2c-omap.c |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)
drivers/i2c/busses/i2c-omap.c +31 -1
index ae6f5c1..d4ec886 100644
@@ -733,10 +733,40 @@ complete:
 		}
 		if (stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)) {
 			u8 num_bytes = 1;
+
+			/*
+			 * I2C Errata(Errata Nos. OMAP2: 1.67, OMAP3: 1.8)
+			 * Not applicable for OMAP4.
+			 * Under certain rare conditions, RDR could be set again
+			 * when the bus is busy, then ignore the interrupt and
+			 * clear the interrupt.
+			 */
+			if ((stat & OMAP_I2C_STAT_RDR) && !cpu_is_omap44xx()) {
+				/* Step 1: If RDR is set, clear it */
+				omap_i2c_ack_stat(dev, stat & OMAP_I2C_STAT_RDR);
+
+				/* Step 2: */
+				if(!(omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG)
+							& OMAP_I2C_STAT_BB)) {
+					/* Step 3: */
+					while(omap_i2c_read_reg(dev,
+						OMAP_I2C_STAT_REG)
+							& OMAP_I2C_STAT_RDR) {
+						omap_i2c_ack_stat(dev, stat
+							& OMAP_I2C_STAT_RDR);
+						dev_err(dev->dev,
+						"I2C : RDR when the bus is busy.\n");
+						continue;
+					}
+
+				}
+				else
+					return IRQ_HANDLED;
+			}
 			if (dev->fifo_size) {
 				if (stat & OMAP_I2C_STAT_RRDY)
 					num_bytes = dev->fifo_size;
-				else    /* read RXSTAT on RDR interrupt */
+				else  /* Step4: read RXSTAT on RDR interrupt */
 					num_bytes = (omap_i2c_read_reg(dev,
 							OMAP_I2C_BUFSTAT_REG)
 							>> 8) & 0x3F;
Signature · 1 line
1.6.0.4

A message that is not in the archive (sent off-list or not yet received): 1271167302-17776-1-git-send-email-manjugk-l0cyMroinI0@public.gmane.org

#2 lore raw
Quoted 15 lines · Manjunath Kondaiah

Under certain rare conditions, I2C_STAT[13].RDR bit may be set and the corresponding interrupt fire, even there is no data in the receive FIFO, or the I2C data transfer is still ongoing. These spurious RDR events must be ignored by the software.

This patch handles and ignores RDR spurious interrupts.

Patch tested on OMAP zoom3 board.

Quoted 3 lines

---
Review comments for earlier post can be found at:
https://patchwork.kernel.org/patch/90122/

Overall, the comments have not been implemented, so my NAK continues unfortunately. please review the comments again.

Quoted 26 lines
  drivers/i2c/busses/i2c-omap.c |   32 +++++++++++++++++++++++++++++++-
  1 files changed, 31 insertions(+), 1 deletions(-)
drivers/i2c/busses/i2c-omap.c +14 -0
index ae6f5c1..d4ec886 100644
@@ -733,10 +733,40 @@ complete:
  		}
  		if (stat&  (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)) {
  			u8 num_bytes = 1;
+
+			/*
+			 * I2C Errata(Errata Nos. OMAP2: 1.67, OMAP3: 1.8)
+			 * Not applicable for OMAP4.
+			 * Under certain rare conditions, RDR could be set again
+			 * when the bus is busy, then ignore the interrupt and
+			 * clear the interrupt.
+			 */
+			if ((stat&  OMAP_I2C_STAT_RDR)&&  !cpu_is_omap44xx()) {
+				/* Step 1: If RDR is set, clear it */
+				omap_i2c_ack_stat(dev, stat&  OMAP_I2C_STAT_RDR);
+
+				/* Step 2: */
+				if(!(omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG)

drivers/i2c/busses/i2c-omap.c complete: · line 759

Quoted 10 lines
drivers/i2c/busses/i2c-omap.c +10 -0
+							&  OMAP_I2C_STAT_BB)) {
+					/* Step 3: */
+					while(omap_i2c_read_reg(dev,
+						OMAP_I2C_STAT_REG)
+							&  OMAP_I2C_STAT_RDR) {
+						omap_i2c_ack_stat(dev, stat
+							&  OMAP_I2C_STAT_RDR);
+						dev_err(dev->dev,
+						"I2C : RDR when the bus is busy.\n");
+						continue;

continue in the inner while loop? NAK. should have been an if condition here.

drivers/i2c/busses/i2c-omap.c complete: · line 764

Quoted 5 lines
drivers/i2c/busses/i2c-omap.c +5 -0
+					}
+
+				}
+				else
+					return IRQ_HANDLED;

using a continue is better as commented for patch v1.

drivers/i2c/busses/i2c-omap.c complete: · line 769

Quoted 6 lines
drivers/i2c/busses/i2c-omap.c +2 -1
+			}
  			if (dev->fifo_size) {
  				if (stat&  OMAP_I2C_STAT_RRDY)
  					num_bytes = dev->fifo_size;
-				else    /* read RXSTAT on RDR interrupt */
+				else  /* Step4: read RXSTAT on RDR interrupt */

dont really need this..

drivers/i2c/busses/i2c-omap.c complete:

Quoted 3 lines
drivers/i2c/busses/i2c-omap.c +0 -0
  					num_bytes = (omap_i2c_read_reg(dev,
  							OMAP_I2C_BUFSTAT_REG)
  							>>  8)&  0x3F;

Regards,
Nishanth Menon

#3 lore raw
Quoted 30 lines

-----Original Message-----
From: Menon, Nishanth
Sent: Tuesday, April 13, 2010 10:18 PM
To: G, Manjunath Kondaiah
Cc: [email protected]; [email protected]; [email protected]; Kalliguddi, Hema
Subject: Re: [PATCH v2] OMAP3: I2C: Errata ID i207: Clear wrong RDR interrupt

Quoted 15 lines · Manjunath Kondaiah

Under certain rare conditions, I2C_STAT[13].RDR bit may be set and the corresponding interrupt fire, even there is no data in the receive FIFO, or the I2C data transfer is still ongoing. These spurious RDR events must be ignored by the software.

This patch handles and ignores RDR spurious interrupts.

Patch tested on OMAP zoom3 board.

Quoted 3 lines

---
Review comments for earlier post can be found at:
https://patchwork.kernel.org/patch/90122/

Quoted 2 lines

Overall, the comments have not been implemented, so my NAK continues unfortunately. please review the comments again.

This errata is applicable to OMAP2 and OMAP3 and not applicable to OMAP4. I will update the same in patch description.

Rest of review comments will be taken care as explained below.

Quoted 46 lines
Quoted 3 lines

  drivers/i2c/busses/i2c-omap.c |   32 

+++++++++++++++++++++++++++++++-

Review

Quoted 3 lines
  1 files changed, 31 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/drivers/i2c/busses/i2c-omap.c

drivers/i2c/busses/i2c-omap.c complete: · line 738

Quoted 10 lines

index ae6f5c1..d4ec886 100644

drivers/i2c/busses/i2c-omap.c +3 -0
@@ -733,10 +733,40 @@ complete:
  		}
  		if (stat&  (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)) {
  			u8 num_bytes = 1;
+
+			/*
+			 * I2C Errata(Errata Nos. OMAP2: 1.67, 

OMAP3: 1.8)

drivers/i2c/busses/i2c-omap.c complete: · line 740

Quoted 2 lines
drivers/i2c/busses/i2c-omap.c +2 -0
+			 * Not applicable for OMAP4.
+			 * Under certain rare conditions, RDR 

could be set again

drivers/i2c/busses/i2c-omap.c complete: · line 741

Quoted 1 line
drivers/i2c/busses/i2c-omap.c +1 -0
+			 * when the bus is busy, then ignore 

the interrupt and

drivers/i2c/busses/i2c-omap.c complete:

Quoted 3 lines
drivers/i2c/busses/i2c-omap.c +3 -0
+			 * clear the interrupt.
+			 */
+			if ((stat&  OMAP_I2C_STAT_RDR)&&  

!cpu_is_omap44xx()) {

drivers/i2c/busses/i2c-omap.c complete: · line 746

Quoted 2 lines
drivers/i2c/busses/i2c-omap.c +2 -0
+				/* Step 1: If RDR is set, clear it */
+				omap_i2c_ack_stat(dev, stat&  

OMAP_I2C_STAT_RDR);

drivers/i2c/busses/i2c-omap.c complete:

Quoted 3 lines
drivers/i2c/busses/i2c-omap.c +3 -0
+
+				/* Step 2: */
+				if(!(omap_i2c_read_reg(dev, 

OMAP_I2C_STAT_REG)

drivers/i2c/busses/i2c-omap.c complete: · line 750

Quoted 1 line
drivers/i2c/busses/i2c-omap.c +1 -0
+							&  

OMAP_I2C_STAT_BB)) {

drivers/i2c/busses/i2c-omap.c complete:

Quoted 4 lines
drivers/i2c/busses/i2c-omap.c +4 -0
+					/* Step 3: */
+					while(omap_i2c_read_reg(dev,
+						OMAP_I2C_STAT_REG)
+							&  

OMAP_I2C_STAT_RDR) {

drivers/i2c/busses/i2c-omap.c complete: · line 755

Quoted 1 line
drivers/i2c/busses/i2c-omap.c +1 -0
+						

omap_i2c_ack_stat(dev, stat

drivers/i2c/busses/i2c-omap.c complete: · line 756

Quoted 1 line
drivers/i2c/busses/i2c-omap.c +1 -0
+							&  

OMAP_I2C_STAT_RDR);

Quoted 7 lines

drivers/i2c/busses/i2c-omap.c complete: · line 758

Quoted 2 lines
drivers/i2c/busses/i2c-omap.c +2 -0
+						dev_err(dev->dev,
+						"I2C : RDR when 

the bus is busy.\n");

drivers/i2c/busses/i2c-omap.c complete: · line 759

Quoted 1 line
drivers/i2c/busses/i2c-omap.c +1 -0
+						continue;

continue in the inner while loop? NAK. should have been an if condition
here.

It's my bad. I will fix it.

Quoted 7 lines

drivers/i2c/busses/i2c-omap.c complete: · line 764

Quoted 6 lines
drivers/i2c/busses/i2c-omap.c +5 -0
+					}
+
+				}
+				else
+					return IRQ_HANDLED;

using a continue is better as commented for patch v1.

Agreed.

Quoted 10 lines

drivers/i2c/busses/i2c-omap.c complete:

Quoted 6 lines
drivers/i2c/busses/i2c-omap.c +1 -1
+			}
  			if (dev->fifo_size) {
  				if (stat&  OMAP_I2C_STAT_RRDY)
  					num_bytes = dev->fifo_size;
-				else    /* read RXSTAT on RDR 

interrupt */

drivers/i2c/busses/i2c-omap.c complete: · line 769

Quoted 1 line
drivers/i2c/busses/i2c-omap.c +1 -0
+				else  /* Step4: read RXSTAT on 

RDR interrupt */
dont really need this..

I have changed only comment. I will revert if it is not required.

-Manjunath

maintainer
#4 lore raw
In reply to Manjunatha GK
Quoted 50 lines · Manjunatha GK

Under certain rare conditions, I2C_STAT[13].RDR bit may be set and the corresponding interrupt fire, even there is no data in the receive FIFO, or the I2C data transfer is still ongoing. These spurious RDR events must be ignored by the software.

This patch handles and ignores RDR spurious interrupts.

Patch tested on OMAP zoom3 board.

---
Review comments for earlier post can be found at:
https://patchwork.kernel.org/patch/90122/

 drivers/i2c/busses/i2c-omap.c |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)
drivers/i2c/busses/i2c-omap.c +20 -0
index ae6f5c1..d4ec886 100644
@@ -733,10 +733,40 @@ complete:
 		}
 		if (stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)) {
 			u8 num_bytes = 1;
+
+			/*
+			 * I2C Errata(Errata Nos. OMAP2: 1.67, OMAP3: 1.8)
+			 * Not applicable for OMAP4.
+			 * Under certain rare conditions, RDR could be set again
+			 * when the bus is busy, then ignore the interrupt and
+			 * clear the interrupt.
+			 */
+			if ((stat & OMAP_I2C_STAT_RDR) && !cpu_is_omap44xx()) {
+				/* Step 1: If RDR is set, clear it */
+				omap_i2c_ack_stat(dev, stat & OMAP_I2C_STAT_RDR);
+
+				/* Step 2: */
+				if(!(omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG)
+							& OMAP_I2C_STAT_BB)) {
+					/* Step 3: */
+					while(omap_i2c_read_reg(dev,
+						OMAP_I2C_STAT_REG)
+							& OMAP_I2C_STAT_RDR) {
+						omap_i2c_ack_stat(dev, stat

drivers/i2c/busses/i2c-omap.c complete: · line 765

Quoted 10 lines
drivers/i2c/busses/i2c-omap.c +10 -0
+							& OMAP_I2C_STAT_RDR);
+						dev_err(dev->dev,
+						"I2C : RDR when the bus is busy.\n");
+						continue;
+					}
+
+				}
+				else
+					return IRQ_HANDLED;
+			}

Please move these hacks into a separate inline function that you initialize during the init. Then in the function you do it if OMAP_I2C_QUIRK_1234 flag has been set.

In general, it seems that a lot of TI omap4 patches just do:

if (!cpu_is_omap4430()) {
	indent_old_code_even_more
	...
} else {
	add_hacks_for_omap4
	...
}

And sprinkle that all over the place.

This is not a maintainable way of doing things. Please do something like this instead:

#ifdef CONFIG_ARCH_OMAP4
static inline void omap_i2c_quirk_1234(struct device *dev)

{
	/* Do hacks here */	
}

#else
static inline void omap_i2c_quirk_1234(struct device *dev) {
}
#endif

int omap_i2_some_function(struct device *dev)

{
	...
	if (dev->quirks & OMAP_I2C_QUIRK_1234)
		omap_i2c_quirk_1234(dev);
	...
}

And then in the driver init just set the quirks you need.

Regards,

Tony

#5 lore raw

Tony,

Quoted 107 lines

-----Original Message-----
From: Tony Lindgren [mailto:[email protected]]
Sent: Thursday, April 22, 2010 3:13 AM
To: G, Manjunath Kondaiah
Cc: [email protected]; [email protected]; [email protected]; Kalliguddi, Hema; Menon, Nishanth
Subject: Re: [PATCH v2] OMAP3: I2C: Errata ID i207: Clear wrong RDR interrupt

Quoted 15 lines · Manjunatha GK

Under certain rare conditions, I2C_STAT[13].RDR bit may be set and the corresponding interrupt fire, even there is no data in the receive FIFO, or the I2C data transfer is still ongoing. These spurious RDR events must be ignored by the software.

This patch handles and ignores RDR spurious interrupts.

Patch tested on OMAP zoom3 board.

Quoted 5 lines

---
Review comments for earlier post can be found at:
https://patchwork.kernel.org/patch/90122/

 drivers/i2c/busses/i2c-omap.c |   32 

+++++++++++++++++++++++++++++++-

Review

Quoted 3 lines
 1 files changed, 31 insertions(+), 1 deletions(-)
(quoted diff) +0 -0

b/drivers/i2c/busses/i2c-omap.c

drivers/i2c/busses/i2c-omap.c complete: · line 738

Quoted 10 lines

index ae6f5c1..d4ec886 100644

drivers/i2c/busses/i2c-omap.c +3 -0
@@ -733,10 +733,40 @@ complete:
 		}
 		if (stat & (OMAP_I2C_STAT_RRDY | OMAP_I2C_STAT_RDR)) {
 			u8 num_bytes = 1;
+
+			/*
+			 * I2C Errata(Errata Nos. OMAP2: 1.67, 

OMAP3: 1.8)

drivers/i2c/busses/i2c-omap.c complete: · line 740

Quoted 2 lines
drivers/i2c/busses/i2c-omap.c +2 -0
+			 * Not applicable for OMAP4.
+			 * Under certain rare conditions, RDR 

could be set again

drivers/i2c/busses/i2c-omap.c complete: · line 741

Quoted 1 line
drivers/i2c/busses/i2c-omap.c +1 -0
+			 * when the bus is busy, then ignore 

the interrupt and

drivers/i2c/busses/i2c-omap.c complete:

Quoted 3 lines
drivers/i2c/busses/i2c-omap.c +3 -0
+			 * clear the interrupt.
+			 */
+			if ((stat & OMAP_I2C_STAT_RDR) && 

!cpu_is_omap44xx()) {

drivers/i2c/busses/i2c-omap.c complete: · line 746

Quoted 2 lines
drivers/i2c/busses/i2c-omap.c +2 -0
+				/* Step 1: If RDR is set, clear it */
+				omap_i2c_ack_stat(dev, stat & 

OMAP_I2C_STAT_RDR);

drivers/i2c/busses/i2c-omap.c complete:

Quoted 3 lines
drivers/i2c/busses/i2c-omap.c +3 -0
+
+				/* Step 2: */
+				if(!(omap_i2c_read_reg(dev, 

OMAP_I2C_STAT_REG)

drivers/i2c/busses/i2c-omap.c complete: · line 750

Quoted 1 line
drivers/i2c/busses/i2c-omap.c +1 -0
+							& 

OMAP_I2C_STAT_BB)) {

drivers/i2c/busses/i2c-omap.c complete:

Quoted 4 lines
drivers/i2c/busses/i2c-omap.c +4 -0
+					/* Step 3: */
+					while(omap_i2c_read_reg(dev,
+						OMAP_I2C_STAT_REG)
+							& 

OMAP_I2C_STAT_RDR) {

drivers/i2c/busses/i2c-omap.c complete: · line 755

Quoted 1 line
drivers/i2c/busses/i2c-omap.c +1 -0
+						

omap_i2c_ack_stat(dev, stat

drivers/i2c/busses/i2c-omap.c complete: · line 756

Quoted 1 line
drivers/i2c/busses/i2c-omap.c +1 -0
+							& 

OMAP_I2C_STAT_RDR);

drivers/i2c/busses/i2c-omap.c complete: · line 758

Quoted 2 lines
drivers/i2c/busses/i2c-omap.c +2 -0
+						dev_err(dev->dev,
+						"I2C : RDR when 

the bus is busy.\n");

drivers/i2c/busses/i2c-omap.c complete: · line 765

Quoted 7 lines
drivers/i2c/busses/i2c-omap.c +7 -0
+						continue;
+					}
+
+				}
+				else
+					return IRQ_HANDLED;
+			}

Please move these hacks into a separate inline function that you initialize
during the init. Then in the function you do it if OMAP_I2C_QUIRK_1234 flag
has been set.

In general, it seems that a lot of TI omap4 patches just do:

if (!cpu_is_omap4430()) {
	indent_old_code_even_more
	...
} else {
	add_hacks_for_omap4
	...
}

And sprinkle that all over the place.

This is not a maintainable way of doing things. Please do something like this instead:

#ifdef CONFIG_ARCH_OMAP4
static inline void omap_i2c_quirk_1234(struct device *dev)

Quoted 8 lines
{
	/* Do hacks here */	
}

#else
static inline void omap_i2c_quirk_1234(struct device *dev) {
}
#endif

This might create issue for multi omap build?

-Manjunath