mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Laurentiu Mihalcea <laurentiumihalcea111@gmail.com>
To: Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Charles Keepax <ckeepax@opensource.cirrus.com>,
	Sebastian Krzyszkowiak <sebastian.krzyszkowiak@puri.sm>,
	elena.popa@nxp.com, cosmin.stoica@nxp.com
Cc: patches@opensource.cirrus.com, linux-sound@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 3/3] ASoC: wm8962: fix interrupt mis-firing during runtime_resume()
Date: Fri, 27 Nov 2026 19:00:39 +0200	[thread overview]
Message-ID: <20261127170039.663-4-laurentiumihalcea111@gmail.com> (raw)
In-Reply-To: <20261127170039.663-1-laurentiumihalcea111@gmail.com>

From: Laurentiu Mihalcea <laurentiu.mihalcea@nxp.com>

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@nxp.com>
---
 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


      parent reply	other threads:[~2026-11-27 17:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 17:00 [PATCH 0/3] ASoC: wm8962: make GPIO-based HP detection work Laurentiu Mihalcea
2026-11-27 17:00 ` [PATCH 1/3] ASoC: wm8962: implement GPIO .get callback Laurentiu Mihalcea
2026-11-27 17:00 ` [PATCH 2/3] ASoC: wm8962: add GPIO interrupt controller support Laurentiu Mihalcea
2026-11-27 17:00 ` Laurentiu Mihalcea [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261127170039.663-4-laurentiumihalcea111@gmail.com \
    --to=laurentiumihalcea111@gmail.com \
    --cc=broonie@kernel.org \
    --cc=ckeepax@opensource.cirrus.com \
    --cc=cosmin.stoica@nxp.com \
    --cc=elena.popa@nxp.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=patches@opensource.cirrus.com \
    --cc=sebastian.krzyszkowiak@puri.sm \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®