aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/mfd/wm8994/pdata.h5
-rw-r--r--sound/soc/codecs/wm8994.c57
2 files changed, 40 insertions, 22 deletions
diff --git a/include/linux/mfd/wm8994/pdata.h b/include/linux/mfd/wm8994/pdata.h
index 9eab263658be..06869466b7f0 100644
--- a/include/linux/mfd/wm8994/pdata.h
+++ b/include/linux/mfd/wm8994/pdata.h
@@ -103,6 +103,11 @@ struct wm8994_pdata {
103 unsigned int lineout1fb:1; 103 unsigned int lineout1fb:1;
104 unsigned int lineout2fb:1; 104 unsigned int lineout2fb:1;
105 105
106 /* IRQ for microphone detection if brought out directly as a
107 * signal.
108 */
109 int micdet_irq;
110
106 /* Microphone biases: 0=0.9*AVDD1 1=0.65*AVVD1 */ 111 /* Microphone biases: 0=0.9*AVDD1 1=0.65*AVVD1 */
107 unsigned int micbias1_lvl:1; 112 unsigned int micbias1_lvl:1;
108 unsigned int micbias2_lvl:1; 113 unsigned int micbias2_lvl:1;
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index b23e91027d64..1ad6e3db7804 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -104,6 +104,7 @@ struct wm8994_priv {
104 void *jack_cb_data; 104 void *jack_cb_data;
105 bool jack_is_mic; 105 bool jack_is_mic;
106 bool jack_is_video; 106 bool jack_is_video;
107 int micdet_irq;
107 108
108 int revision; 109 int revision;
109 struct wm8994_pdata *pdata; 110 struct wm8994_pdata *pdata;
@@ -3102,6 +3103,12 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
3102 wm8994->pdata = dev_get_platdata(codec->dev->parent); 3103 wm8994->pdata = dev_get_platdata(codec->dev->parent);
3103 wm8994->codec = codec; 3104 wm8994->codec = codec;
3104 3105
3106 if (wm8994->pdata && wm8994->pdata->micdet_irq)
3107 wm8994->micdet_irq = wm8994->pdata->micdet_irq;
3108 else if (wm8994->pdata && wm8994->pdata->irq_base)
3109 wm8994->micdet_irq = wm8994->pdata->irq_base +
3110 WM8994_IRQ_MIC1_DET;
3111
3105 pm_runtime_enable(codec->dev); 3112 pm_runtime_enable(codec->dev);
3106 pm_runtime_resume(codec->dev); 3113 pm_runtime_resume(codec->dev);
3107 3114
@@ -3150,14 +3157,17 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
3150 3157
3151 switch (control->type) { 3158 switch (control->type) {
3152 case WM8994: 3159 case WM8994:
3153 ret = wm8994_request_irq(codec->control_data, 3160 if (wm8994->micdet_irq) {
3154 WM8994_IRQ_MIC1_DET, 3161 ret = request_threaded_irq(wm8994->micdet_irq, NULL,
3155 wm8994_mic_irq, "Mic 1 detect", 3162 wm8994_mic_irq,
3156 wm8994); 3163 IRQF_TRIGGER_RISING,
3157 if (ret != 0) 3164 "Mic1 detect",
3158 dev_warn(codec->dev, 3165 wm8994);
3159 "Failed to request Mic1 detect IRQ: %d\n", 3166 if (ret != 0)
3160 ret); 3167 dev_warn(codec->dev,
3168 "Failed to request Mic1 detect IRQ: %d\n",
3169 ret);
3170 }
3161 3171
3162 ret = wm8994_request_irq(codec->control_data, 3172 ret = wm8994_request_irq(codec->control_data,
3163 WM8994_IRQ_MIC1_SHRT, 3173 WM8994_IRQ_MIC1_SHRT,
@@ -3188,15 +3198,17 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
3188 break; 3198 break;
3189 3199
3190 case WM8958: 3200 case WM8958:
3191 ret = wm8994_request_irq(codec->control_data, 3201 if (wm8994->micdet_irq) {
3192 WM8994_IRQ_MIC1_DET, 3202 ret = request_threaded_irq(wm8994->micdet_irq, NULL,
3193 wm8958_mic_irq, "Mic detect", 3203 wm8958_mic_irq,
3194 wm8994); 3204 IRQF_TRIGGER_RISING,
3195 if (ret != 0) 3205 "Mic detect",
3196 dev_warn(codec->dev, 3206 wm8994);
3197 "Failed to request Mic detect IRQ: %d\n", 3207 if (ret != 0)
3198 ret); 3208 dev_warn(codec->dev,
3199 break; 3209 "Failed to request Mic detect IRQ: %d\n",
3210 ret);
3211 }
3200 } 3212 }
3201 3213
3202 /* Remember if AIFnLRCLK is configured as a GPIO. This should be 3214 /* Remember if AIFnLRCLK is configured as a GPIO. This should be
@@ -3328,7 +3340,8 @@ err_irq:
3328 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_SHRT, wm8994); 3340 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_SHRT, wm8994);
3329 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_DET, wm8994); 3341 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_DET, wm8994);
3330 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_SHRT, wm8994); 3342 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_SHRT, wm8994);
3331 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_DET, wm8994); 3343 if (wm8994->micdet_irq)
3344 free_irq(wm8994->micdet_irq, wm8994);
3332err: 3345err:
3333 kfree(wm8994); 3346 kfree(wm8994);
3334 return ret; 3347 return ret;
@@ -3345,8 +3358,8 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec)
3345 3358
3346 switch (control->type) { 3359 switch (control->type) {
3347 case WM8994: 3360 case WM8994:
3348 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_SHRT, 3361 if (wm8994->micdet_irq)
3349 wm8994); 3362 free_irq(wm8994->micdet_irq, wm8994);
3350 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_DET, 3363 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC2_DET,
3351 wm8994); 3364 wm8994);
3352 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_SHRT, 3365 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_SHRT,
@@ -3356,8 +3369,8 @@ static int wm8994_codec_remove(struct snd_soc_codec *codec)
3356 break; 3369 break;
3357 3370
3358 case WM8958: 3371 case WM8958:
3359 wm8994_free_irq(codec->control_data, WM8994_IRQ_MIC1_DET, 3372 if (wm8994->micdet_irq)
3360 wm8994); 3373 free_irq(wm8994->micdet_irq, wm8994);
3361 break; 3374 break;
3362 } 3375 }
3363 kfree(wm8994->retune_mobile_texts); 3376 kfree(wm8994->retune_mobile_texts);