linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MFD: TWL 6030: clear IRQ status register only once
@ 2012-02-23  2:03 Nishanth Menon
  2012-02-27 14:38 ` Samuel Ortiz
  0 siblings, 1 reply; 2+ messages in thread
From: Nishanth Menon @ 2012-02-23  2:03 UTC (permalink / raw)
  To: Samuel Ortiz; +Cc: linux-omap, lkml, Nishanth Menon

TWL6030 family of PMIC use a shadow interrupt status register
while kernel processes the current interrupt event.
However, any write(0 or 1) to register INT_STS_A, INT_STS_B or
INT_STS_C clears all 3 interrupt status registers.

Since clear of the interrupt is done on 32k clk, depending on I2C
bus speed, we could in-adverently clear the status of a interrupt
status pending on shadow register in the current implementation.
This is due to the fact that multi-byte i2c write operation into
three seperate status register could result in multiple load
and clear of status and result in lost interrupts.

Instead, doing a single byte write to INT_STS_A register with 0x0
will clear all three interrupt status registers without the related
risk.

Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
---
 drivers/mfd/twl6030-irq.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
index c6b456a..aa367a2 100644
--- a/drivers/mfd/twl6030-irq.c
+++ b/drivers/mfd/twl6030-irq.c
@@ -185,8 +185,17 @@ static int twl6030_irq_thread(void *data)
 			}
 		local_irq_enable();
 		}
-		ret = twl_i2c_write(TWL_MODULE_PIH, sts.bytes,
-				REG_INT_STS_A, 3); /* clear INT_STS_A */
+
+		/*
+		 * NOTE:
+		 * Simulation confirms that documentation is wrong w.r.t the
+		 * interrupt status clear operation. A single *byte* write to
+		 * any one of STS_A to STS_C register results in all three
+		 * STS registers being reset. Since it does not matter which
+		 * value is written, all three registers are cleared on a
+		 * single byte write, so we just use 0x0 to clear.
+		 */
+		ret = twl_i2c_write_u8(TWL_MODULE_PIH, 0x00, REG_INT_STS_A);
 		if (ret)
 			pr_warning("twl6030: I2C error in clearing PIH ISR\n");
 
-- 
1.7.5.4


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

* Re: [PATCH] MFD: TWL 6030: clear IRQ status register only once
  2012-02-23  2:03 [PATCH] MFD: TWL 6030: clear IRQ status register only once Nishanth Menon
@ 2012-02-27 14:38 ` Samuel Ortiz
  0 siblings, 0 replies; 2+ messages in thread
From: Samuel Ortiz @ 2012-02-27 14:38 UTC (permalink / raw)
  To: Nishanth Menon; +Cc: linux-omap, lkml

Hi Nishan,

On Wed, Feb 22, 2012 at 08:03:45PM -0600, Nishanth Menon wrote:
> TWL6030 family of PMIC use a shadow interrupt status register
> while kernel processes the current interrupt event.
> However, any write(0 or 1) to register INT_STS_A, INT_STS_B or
> INT_STS_C clears all 3 interrupt status registers.
> 
> Since clear of the interrupt is done on 32k clk, depending on I2C
> bus speed, we could in-adverently clear the status of a interrupt
> status pending on shadow register in the current implementation.
> This is due to the fact that multi-byte i2c write operation into
> three seperate status register could result in multiple load
> and clear of status and result in lost interrupts.
> 
> Instead, doing a single byte write to INT_STS_A register with 0x0
> will clear all three interrupt status registers without the related
> risk.
Applied, thanks.

Cheers,
Samuel.

-- 
Intel Open Source Technology Centre
http://oss.intel.com/

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

end of thread, other threads:[~2012-02-27 14:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-23  2:03 [PATCH] MFD: TWL 6030: clear IRQ status register only once Nishanth Menon
2012-02-27 14:38 ` Samuel Ortiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).