mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] extcon: usbc-tusb320: always rewrite REG9 to deassert INT_N
@ 2026-07-28 15:37 Advait Dhamorikar
  2026-07-29  7:27 ` Alvin Šipraga
  0 siblings, 1 reply; 4+ messages in thread
From: Advait Dhamorikar @ 2026-07-28 15:37 UTC (permalink / raw)
  To: myungjoo.ham, cw00.choi, linux-kernel
  Cc: alsi, gregkh, marex, heikki.krogerus, Advait Dhamorikar

The IRQ handler currently returns IRQ_NONE without rewriting REG9 when
INTERRUPT_STATUS is clear, skipping the documented interrupt acknowledge
sequence which says that rewrites to this register are needed for the
INT_N to be correctly asserted for all interrupt events.

On some hardware, this can leave INT_N asserted, causing repeated
level-triggered interrupts until the kernel disables the IRQ as
spurious.

Always rewrite REG9 before returning from the IRQ handler, regardless
of the observed INTERRUPT_STATUS bit, and return IRQ_HANDLED once the
acknowledge sequence has been performed. Also report REG9 write
failures to aid debugging.

Fixes: 581c848b610d ("extcon: usbc-tusb320: Update state on probe even if no IRQ pending")
Signed-off-by: Advait Dhamorikar <advaitd@mechasystems.com>
---
 drivers/extcon/extcon-usbc-tusb320.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/extcon/extcon-usbc-tusb320.c b/drivers/extcon/extcon-usbc-tusb320.c
index 920b03421850..56c888004f41 100644
--- a/drivers/extcon/extcon-usbc-tusb320.c
+++ b/drivers/extcon/extcon-usbc-tusb320.c
@@ -375,14 +375,25 @@ static irqreturn_t tusb320_state_update_handler(struct tusb320_priv *priv,
 						bool force_update)
 {
 	unsigned int reg;
+	int ret;
 
-	if (regmap_read(priv->regmap, TUSB320_REG9, &reg)) {
-		dev_err(priv->dev, "error during i2c read!\n");
+	ret = regmap_read(priv->regmap, TUSB320_REG9, &reg);
+	if (ret) {
+		dev_err(priv->dev, "REG9 read failed: %d\n", ret);
 		return IRQ_NONE;
 	}
 
-	if (!force_update && !(reg & TUSB320_REG9_INTERRUPT_STATUS))
-		return IRQ_NONE;
+	if (!force_update && !(reg & TUSB320_REG9_INTERRUPT_STATUS)) {
+		dev_dbg(priv->dev, "IRQ fired but interrupt status not set\n");
+		/*
+		 * Rewrites to this register are needed for the INT_N
+		 * to be correctly asserted for all interrupt events.
+		 */
+		ret = regmap_write(priv->regmap, TUSB320_REG9, reg);
+		if (ret)
+			dev_err(priv->dev, "REG9 write failed: %d\n", ret);
+		return IRQ_HANDLED;
+	}
 
 	tusb320_extcon_irq_handler(priv, reg);
 
@@ -393,7 +404,9 @@ static irqreturn_t tusb320_state_update_handler(struct tusb320_priv *priv,
 	if (priv->port)
 		tusb320_typec_irq_handler(priv, reg);
 
-	regmap_write(priv->regmap, TUSB320_REG9, reg);
+	ret = regmap_write(priv->regmap, TUSB320_REG9, reg);
+	if (ret)
+		dev_err(priv->dev, "REG9 write failed: %d\n", ret);
 
 	return IRQ_HANDLED;
 }
-- 
2.43.0


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

end of thread, other threads:[~2026-07-29 11:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-28 15:37 [PATCH] extcon: usbc-tusb320: always rewrite REG9 to deassert INT_N Advait Dhamorikar
2026-07-29  7:27 ` Alvin Šipraga
2026-07-29 11:08   ` Advait Dhamorikar
2026-07-29 11:28     ` Alvin Šipraga

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®