Commit ec83a0b3 authored by Mark Brown's avatar Mark Brown

ASoC: rt5640: Fix various IRQ handling issues

Merge series from Hans de Goede <hdegoede@redhat.com>:

The recent(ish) rt5640 changes to add HDA header jack-detect support
and the related suspend/resume handling fixes have introduced several
issues with IRQ handling on boards not using the HDA header jack-detect
support.

This series fixes these issues, see the individual commit messages
for details.
parents 18789be8 8fc7cc50
...@@ -2403,13 +2403,11 @@ static irqreturn_t rt5640_irq(int irq, void *data) ...@@ -2403,13 +2403,11 @@ static irqreturn_t rt5640_irq(int irq, void *data)
struct rt5640_priv *rt5640 = data; struct rt5640_priv *rt5640 = data;
int delay = 0; int delay = 0;
if (rt5640->jd_src == RT5640_JD_SRC_HDA_HEADER) { if (rt5640->jd_src == RT5640_JD_SRC_HDA_HEADER)
cancel_delayed_work_sync(&rt5640->jack_work);
delay = 100; delay = 100;
}
if (rt5640->jack) if (rt5640->jack)
queue_delayed_work(system_long_wq, &rt5640->jack_work, delay); mod_delayed_work(system_long_wq, &rt5640->jack_work, delay);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -2565,10 +2563,9 @@ static void rt5640_enable_jack_detect(struct snd_soc_component *component, ...@@ -2565,10 +2563,9 @@ static void rt5640_enable_jack_detect(struct snd_soc_component *component,
if (jack_data && jack_data->use_platform_clock) if (jack_data && jack_data->use_platform_clock)
rt5640->use_platform_clock = jack_data->use_platform_clock; rt5640->use_platform_clock = jack_data->use_platform_clock;
ret = devm_request_threaded_irq(component->dev, rt5640->irq, ret = request_irq(rt5640->irq, rt5640_irq,
NULL, rt5640_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "rt5640", rt5640);
"rt5640", rt5640);
if (ret) { if (ret) {
dev_warn(component->dev, "Failed to request IRQ %d: %d\n", rt5640->irq, ret); dev_warn(component->dev, "Failed to request IRQ %d: %d\n", rt5640->irq, ret);
rt5640_disable_jack_detect(component); rt5640_disable_jack_detect(component);
...@@ -2621,14 +2618,14 @@ static void rt5640_enable_hda_jack_detect( ...@@ -2621,14 +2618,14 @@ static void rt5640_enable_hda_jack_detect(
rt5640->jack = jack; rt5640->jack = jack;
ret = devm_request_threaded_irq(component->dev, rt5640->irq, ret = request_irq(rt5640->irq, rt5640_irq,
NULL, rt5640_irq, IRQF_TRIGGER_RISING | IRQF_ONESHOT, IRQF_TRIGGER_RISING | IRQF_ONESHOT, "rt5640", rt5640);
"rt5640", rt5640);
if (ret) { if (ret) {
dev_warn(component->dev, "Failed to request IRQ %d: %d\n", rt5640->irq, ret); dev_warn(component->dev, "Failed to request IRQ %d: %d\n", rt5640->irq, ret);
rt5640->irq = -ENXIO; rt5640->jack = NULL;
return; return;
} }
rt5640->irq_requested = true;
/* sync initial jack state */ /* sync initial jack state */
queue_delayed_work(system_long_wq, &rt5640->jack_work, 0); queue_delayed_work(system_long_wq, &rt5640->jack_work, 0);
...@@ -2801,12 +2798,12 @@ static int rt5640_suspend(struct snd_soc_component *component) ...@@ -2801,12 +2798,12 @@ static int rt5640_suspend(struct snd_soc_component *component)
{ {
struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component); struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
if (rt5640->irq) { if (rt5640->jack) {
/* disable jack interrupts during system suspend */ /* disable jack interrupts during system suspend */
disable_irq(rt5640->irq); disable_irq(rt5640->irq);
rt5640_cancel_work(rt5640);
} }
rt5640_cancel_work(rt5640);
snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF); snd_soc_component_force_bias_level(component, SND_SOC_BIAS_OFF);
rt5640_reset(component); rt5640_reset(component);
regcache_cache_only(rt5640->regmap, true); regcache_cache_only(rt5640->regmap, true);
...@@ -2829,9 +2826,6 @@ static int rt5640_resume(struct snd_soc_component *component) ...@@ -2829,9 +2826,6 @@ static int rt5640_resume(struct snd_soc_component *component)
regcache_cache_only(rt5640->regmap, false); regcache_cache_only(rt5640->regmap, false);
regcache_sync(rt5640->regmap); regcache_sync(rt5640->regmap);
if (rt5640->irq)
enable_irq(rt5640->irq);
if (rt5640->jack) { if (rt5640->jack) {
if (rt5640->jd_src == RT5640_JD_SRC_HDA_HEADER) { if (rt5640->jd_src == RT5640_JD_SRC_HDA_HEADER) {
snd_soc_component_update_bits(component, snd_soc_component_update_bits(component,
...@@ -2859,6 +2853,7 @@ static int rt5640_resume(struct snd_soc_component *component) ...@@ -2859,6 +2853,7 @@ static int rt5640_resume(struct snd_soc_component *component)
} }
} }
enable_irq(rt5640->irq);
queue_delayed_work(system_long_wq, &rt5640->jack_work, 0); queue_delayed_work(system_long_wq, &rt5640->jack_work, 0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment