[PATCH] ASoC: rt5640: Handle nested IRQs

From: Sheetal

Date: Thu May 07 2026 - 05:48:45 EST


From: Anupama Kunkulagunta <akunkulagunt@xxxxxxxxxx>

On some Tegra platforms, the RT5640 codec interrupt line
is connected via a GPIO controller that operates as a
nested IRQ domain. Since nested IRQ controllers only
support threaded handlers, request_irq() returns -EINVAL:

rt5640 3-001c: Failed to request IRQ 186: -22

Switch to request_any_context_irq() to let the kernel
pick the appropriate handler type based on the parent
IRQ controller.

Signed-off-by: Anupama Kunkulagunta <akunkulagunt@xxxxxxxxxx>
Signed-off-by: Sheetal <sheetal@xxxxxxxxxx>
---
sound/soc/codecs/rt5640.c | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c
index f6c6294e1588..f4bee5a68db7 100644
--- a/sound/soc/codecs/rt5640.c
+++ b/sound/soc/codecs/rt5640.c
@@ -2553,10 +2553,12 @@ static void rt5640_enable_jack_detect(struct snd_soc_component *component,
rt5640->jd_gpio = jack_data->jd_gpio;
rt5640->jd_gpio_irq = gpiod_to_irq(rt5640->jd_gpio);

- ret = request_irq(rt5640->jd_gpio_irq, rt5640_jd_gpio_irq,
- IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
- "rt5640-jd-gpio", rt5640);
- if (ret) {
+ ret = request_any_context_irq(rt5640->jd_gpio_irq,
+ rt5640_jd_gpio_irq,
+ IRQF_TRIGGER_RISING |
+ IRQF_TRIGGER_FALLING,
+ "rt5640-jd-gpio", rt5640);
+ if (ret < 0) {
dev_warn(component->dev, "Failed to request jd GPIO IRQ %d: %d\n",
rt5640->jd_gpio_irq, ret);
rt5640_disable_jack_detect(component);
@@ -2568,10 +2570,10 @@ static void rt5640_enable_jack_detect(struct snd_soc_component *component,
if (jack_data && jack_data->use_platform_clock)
rt5640->use_platform_clock = jack_data->use_platform_clock;

- ret = request_irq(rt5640->irq, rt5640_irq,
- IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
- "rt5640", rt5640);
- if (ret) {
+ ret = request_any_context_irq(rt5640->irq, rt5640_irq,
+ IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
+ "rt5640", rt5640);
+ if (ret < 0) {
dev_warn(component->dev, "Failed to request IRQ %d: %d\n", rt5640->irq, ret);
rt5640_disable_jack_detect(component);
return;
@@ -2622,9 +2624,9 @@ static void rt5640_enable_hda_jack_detect(

rt5640->jack = jack;

- ret = request_irq(rt5640->irq, rt5640_irq,
- IRQF_TRIGGER_RISING, "rt5640", rt5640);
- if (ret) {
+ ret = request_any_context_irq(rt5640->irq, rt5640_irq,
+ IRQF_TRIGGER_RISING, "rt5640", rt5640);
+ if (ret < 0) {
dev_warn(component->dev, "Failed to request IRQ %d: %d\n", rt5640->irq, ret);
rt5640->jack = NULL;
return;
--
2.17.1