[PATCH 3/3] ASoC: wm8962: fix interrupt mis-firing during runtime_resume()

From: Laurentiu Mihalcea

Date: Fri Nov 27 2026 - 12:06:31 EST


From: Laurentiu Mihalcea <laurentiu.mihalcea@xxxxxxx>

During testing, it has been observed that the runtime_resume() function
may cause the codec interrupt to become asserted. Interestingly enough,
for the MR-NAVQ95 platform, the logic HIGH signal would sometimes peak at
about 50% of DBVDD (1.8V), which seems to be enough to make the downstream
PCAL6416 chip (which is edge triggered) think an interrupt has occurred
and report it downstream.

A sample of the captured waveform is shown below (sample is taken around
the time wm8962_i2c_probe() is called). WM8962_GPIO2 is the GPIO2 pin of
the codec and is configured to generate interrupts for the downstream PCAL
chip. PCAL6416_INT_N is the PCAL's INT_N pin. The GPIO2 active HIGH signal
peaks at about 0.7V in this particular snippet.

3.3V

WM8962_GPIO2
-------- --------
| | | |
0V ____________| |__________________| |_____

3.3V
_______________________________________
|
PCAL6416_INT_N |
|
0V |_____________

The fix for this would be to mask interrupts during runtime_supend() and
unmask them during runtime_resume() only after all of the operations have
finished (i.e. before returning from the function). This requires the
IRQ_DISABLE_UNLAZY IRQ flag be set to handle interrupt controllers which
don't implement the .irq_disable() callback. This ought to make sure that
the interrupt is at least masked after disable_irq() is called.

Signed-off-by: Laurentiu Mihalcea <laurentiu.mihalcea@xxxxxxx>
---
sound/soc/codecs/wm8962.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
index 3bbaacb08aaf..8c9523d60219 100644
--- a/sound/soc/codecs/wm8962.c
+++ b/sound/soc/codecs/wm8962.c
@@ -4021,7 +4021,7 @@ static int wm8962_i2c_probe(struct i2c_client *i2c)

ret = devm_request_threaded_irq(&i2c->dev, wm8962->irq, NULL,
wm8962_irq,
- trigger | IRQF_ONESHOT,
+ trigger | IRQF_ONESHOT | IRQF_NO_AUTOEN,
"wm8962", &i2c->dev);
if (ret != 0) {
dev_err(&i2c->dev, "Failed to request IRQ %d: %d\n",
@@ -4039,6 +4039,15 @@ static int wm8962_i2c_probe(struct i2c_client *i2c)
/* enable GPIO IRQs if need be */
wm8962_init_gpio_irq(wm8962);
}
+
+ /*
+ * we are forced to keep interrupts disabled while doing runtime_resume().
+ * Otherwise, we may end up with some unwanted transitions on the interrupt
+ * line. Some interrupt controllers may not implement the .irq_disable()
+ * callback. In such cases, the interrupts will only be masked if
+ * IRQ_DISABLE_UNLAZY is set.
+ */
+ irq_set_status_flags(wm8962->irq, IRQ_DISABLE_UNLAZY);
}

pm_runtime_enable(&i2c->dev);
@@ -4131,6 +4140,10 @@ static int wm8962_runtime_resume(struct device *dev)
WM8962_MSTR, WM8962_MSTR);
msleep(5);

+ /* keep this last - keeps the interrupt line from mis-firing */
+ if (wm8962->irq)
+ enable_irq(wm8962->irq);
+
return 0;

cache_sync_err:
@@ -4147,6 +4160,9 @@ static int wm8962_runtime_suspend(struct device *dev)
{
struct wm8962_priv *wm8962 = dev_get_drvdata(dev);

+ if (wm8962->irq)
+ disable_irq(wm8962->irq);
+
if (wm8962->master_flag)
regmap_update_bits(wm8962->regmap, WM8962_AUDIO_INTERFACE_0,
WM8962_MSTR, 0);
--
2.53.0