aboutsummaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-12-01 23:35:29 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-12-01 23:35:29 -0500
commitfaa9c2a798d4be0d15b1e685c4da4be3e2782089 (patch)
tree95a42ccd673084ecf18b42b33ddb85c52e501357 /sound/soc/codecs
parente041e46907d2abaef8719f33379d3be4886c7088 (diff)
parent72222be39afbd39c16eb180646b0ac44bb1ba460 (diff)
Merge remote-tracking branch 'asoc/topic/wm8994' into asoc-next
Diffstat (limited to 'sound/soc/codecs')
-rw-r--r--sound/soc/codecs/wm8958-dsp2.c79
-rw-r--r--sound/soc/codecs/wm8994.c184
-rw-r--r--sound/soc/codecs/wm8994.h1
3 files changed, 146 insertions, 118 deletions
diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c
index 00121ba36597..b0710d817a65 100644
--- a/sound/soc/codecs/wm8958-dsp2.c
+++ b/sound/soc/codecs/wm8958-dsp2.c
@@ -195,7 +195,7 @@ ok:
195static void wm8958_dsp_start_mbc(struct snd_soc_codec *codec, int path) 195static void wm8958_dsp_start_mbc(struct snd_soc_codec *codec, int path)
196{ 196{
197 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 197 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
198 struct wm8994_pdata *pdata = wm8994->pdata; 198 struct wm8994 *control = wm8994->wm8994;
199 int i; 199 int i;
200 200
201 /* If the DSP is already running then noop */ 201 /* If the DSP is already running then noop */
@@ -210,9 +210,9 @@ static void wm8958_dsp_start_mbc(struct snd_soc_codec *codec, int path)
210 WM8958_DSP2_ENA, WM8958_DSP2_ENA); 210 WM8958_DSP2_ENA, WM8958_DSP2_ENA);
211 211
212 /* If we've got user supplied MBC settings use them */ 212 /* If we've got user supplied MBC settings use them */
213 if (pdata && pdata->num_mbc_cfgs) { 213 if (control->pdata.num_mbc_cfgs) {
214 struct wm8958_mbc_cfg *cfg 214 struct wm8958_mbc_cfg *cfg
215 = &pdata->mbc_cfgs[wm8994->mbc_cfg]; 215 = &control->pdata.mbc_cfgs[wm8994->mbc_cfg];
216 216
217 for (i = 0; i < ARRAY_SIZE(cfg->coeff_regs); i++) 217 for (i = 0; i < ARRAY_SIZE(cfg->coeff_regs); i++)
218 snd_soc_write(codec, i + WM8958_MBC_BAND_1_K_1, 218 snd_soc_write(codec, i + WM8958_MBC_BAND_1_K_1,
@@ -239,7 +239,7 @@ static void wm8958_dsp_start_mbc(struct snd_soc_codec *codec, int path)
239static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path) 239static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path)
240{ 240{
241 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 241 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
242 struct wm8994_pdata *pdata = wm8994->pdata; 242 struct wm8994 *control = wm8994->wm8994;
243 int i, ena; 243 int i, ena;
244 244
245 if (wm8994->mbc_vss) 245 if (wm8994->mbc_vss)
@@ -249,26 +249,26 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path)
249 WM8958_DSP2_ENA, WM8958_DSP2_ENA); 249 WM8958_DSP2_ENA, WM8958_DSP2_ENA);
250 250
251 /* If we've got user supplied settings use them */ 251 /* If we've got user supplied settings use them */
252 if (pdata && pdata->num_mbc_cfgs) { 252 if (control->pdata.num_mbc_cfgs) {
253 struct wm8958_mbc_cfg *cfg 253 struct wm8958_mbc_cfg *cfg
254 = &pdata->mbc_cfgs[wm8994->mbc_cfg]; 254 = &control->pdata.mbc_cfgs[wm8994->mbc_cfg];
255 255
256 for (i = 0; i < ARRAY_SIZE(cfg->combined_regs); i++) 256 for (i = 0; i < ARRAY_SIZE(cfg->combined_regs); i++)
257 snd_soc_write(codec, i + 0x2800, 257 snd_soc_write(codec, i + 0x2800,
258 cfg->combined_regs[i]); 258 cfg->combined_regs[i]);
259 } 259 }
260 260
261 if (pdata && pdata->num_vss_cfgs) { 261 if (control->pdata.num_vss_cfgs) {
262 struct wm8958_vss_cfg *cfg 262 struct wm8958_vss_cfg *cfg
263 = &pdata->vss_cfgs[wm8994->vss_cfg]; 263 = &control->pdata.vss_cfgs[wm8994->vss_cfg];
264 264
265 for (i = 0; i < ARRAY_SIZE(cfg->regs); i++) 265 for (i = 0; i < ARRAY_SIZE(cfg->regs); i++)
266 snd_soc_write(codec, i + 0x2600, cfg->regs[i]); 266 snd_soc_write(codec, i + 0x2600, cfg->regs[i]);
267 } 267 }
268 268
269 if (pdata && pdata->num_vss_hpf_cfgs) { 269 if (control->pdata.num_vss_hpf_cfgs) {
270 struct wm8958_vss_hpf_cfg *cfg 270 struct wm8958_vss_hpf_cfg *cfg
271 = &pdata->vss_hpf_cfgs[wm8994->vss_hpf_cfg]; 271 = &control->pdata.vss_hpf_cfgs[wm8994->vss_hpf_cfg];
272 272
273 for (i = 0; i < ARRAY_SIZE(cfg->regs); i++) 273 for (i = 0; i < ARRAY_SIZE(cfg->regs); i++)
274 snd_soc_write(codec, i + 0x2400, cfg->regs[i]); 274 snd_soc_write(codec, i + 0x2400, cfg->regs[i]);
@@ -300,7 +300,7 @@ static void wm8958_dsp_start_vss(struct snd_soc_codec *codec, int path)
300static void wm8958_dsp_start_enh_eq(struct snd_soc_codec *codec, int path) 300static void wm8958_dsp_start_enh_eq(struct snd_soc_codec *codec, int path)
301{ 301{
302 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 302 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
303 struct wm8994_pdata *pdata = wm8994->pdata; 303 struct wm8994 *control = wm8994->wm8994;
304 int i; 304 int i;
305 305
306 wm8958_dsp2_fw(codec, "ENH_EQ", wm8994->enh_eq, false); 306 wm8958_dsp2_fw(codec, "ENH_EQ", wm8994->enh_eq, false);
@@ -309,9 +309,9 @@ static void wm8958_dsp_start_enh_eq(struct snd_soc_codec *codec, int path)
309 WM8958_DSP2_ENA, WM8958_DSP2_ENA); 309 WM8958_DSP2_ENA, WM8958_DSP2_ENA);
310 310
311 /* If we've got user supplied settings use them */ 311 /* If we've got user supplied settings use them */
312 if (pdata && pdata->num_enh_eq_cfgs) { 312 if (control->pdata.num_enh_eq_cfgs) {
313 struct wm8958_enh_eq_cfg *cfg 313 struct wm8958_enh_eq_cfg *cfg
314 = &pdata->enh_eq_cfgs[wm8994->enh_eq_cfg]; 314 = &control->pdata.enh_eq_cfgs[wm8994->enh_eq_cfg];
315 315
316 for (i = 0; i < ARRAY_SIZE(cfg->regs); i++) 316 for (i = 0; i < ARRAY_SIZE(cfg->regs); i++)
317 snd_soc_write(codec, i + 0x2200, 317 snd_soc_write(codec, i + 0x2200,
@@ -458,7 +458,7 @@ static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol,
458{ 458{
459 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 459 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
460 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 460 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
461 struct wm8994_pdata *pdata = wm8994->pdata; 461 struct wm8994 *control = wm8994->wm8994;
462 int value = ucontrol->value.integer.value[0]; 462 int value = ucontrol->value.integer.value[0];
463 int reg; 463 int reg;
464 464
@@ -467,7 +467,7 @@ static int wm8958_put_mbc_enum(struct snd_kcontrol *kcontrol,
467 if (reg < 0 || reg & WM8958_DSP2CLK_ENA) 467 if (reg < 0 || reg & WM8958_DSP2CLK_ENA)
468 return -EBUSY; 468 return -EBUSY;
469 469
470 if (value >= pdata->num_mbc_cfgs) 470 if (value >= control->pdata.num_mbc_cfgs)
471 return -EINVAL; 471 return -EINVAL;
472 472
473 wm8994->mbc_cfg = value; 473 wm8994->mbc_cfg = value;
@@ -548,7 +548,7 @@ static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol,
548{ 548{
549 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 549 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
550 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 550 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
551 struct wm8994_pdata *pdata = wm8994->pdata; 551 struct wm8994 *control = wm8994->wm8994;
552 int value = ucontrol->value.integer.value[0]; 552 int value = ucontrol->value.integer.value[0];
553 int reg; 553 int reg;
554 554
@@ -557,7 +557,7 @@ static int wm8958_put_vss_enum(struct snd_kcontrol *kcontrol,
557 if (reg < 0 || reg & WM8958_DSP2CLK_ENA) 557 if (reg < 0 || reg & WM8958_DSP2CLK_ENA)
558 return -EBUSY; 558 return -EBUSY;
559 559
560 if (value >= pdata->num_vss_cfgs) 560 if (value >= control->pdata.num_vss_cfgs)
561 return -EINVAL; 561 return -EINVAL;
562 562
563 wm8994->vss_cfg = value; 563 wm8994->vss_cfg = value;
@@ -581,7 +581,7 @@ static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol,
581{ 581{
582 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 582 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
583 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 583 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
584 struct wm8994_pdata *pdata = wm8994->pdata; 584 struct wm8994 *control = wm8994->wm8994;
585 int value = ucontrol->value.integer.value[0]; 585 int value = ucontrol->value.integer.value[0];
586 int reg; 586 int reg;
587 587
@@ -590,7 +590,7 @@ static int wm8958_put_vss_hpf_enum(struct snd_kcontrol *kcontrol,
590 if (reg < 0 || reg & WM8958_DSP2CLK_ENA) 590 if (reg < 0 || reg & WM8958_DSP2CLK_ENA)
591 return -EBUSY; 591 return -EBUSY;
592 592
593 if (value >= pdata->num_vss_hpf_cfgs) 593 if (value >= control->pdata.num_vss_hpf_cfgs)
594 return -EINVAL; 594 return -EINVAL;
595 595
596 wm8994->vss_hpf_cfg = value; 596 wm8994->vss_hpf_cfg = value;
@@ -748,7 +748,7 @@ static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol,
748{ 748{
749 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 749 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
750 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 750 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
751 struct wm8994_pdata *pdata = wm8994->pdata; 751 struct wm8994 *control = wm8994->wm8994;
752 int value = ucontrol->value.integer.value[0]; 752 int value = ucontrol->value.integer.value[0];
753 int reg; 753 int reg;
754 754
@@ -757,7 +757,7 @@ static int wm8958_put_enh_eq_enum(struct snd_kcontrol *kcontrol,
757 if (reg < 0 || reg & WM8958_DSP2CLK_ENA) 757 if (reg < 0 || reg & WM8958_DSP2CLK_ENA)
758 return -EBUSY; 758 return -EBUSY;
759 759
760 if (value >= pdata->num_enh_eq_cfgs) 760 if (value >= control->pdata.num_enh_eq_cfgs)
761 return -EINVAL; 761 return -EINVAL;
762 762
763 wm8994->enh_eq_cfg = value; 763 wm8994->enh_eq_cfg = value;
@@ -883,13 +883,6 @@ static void wm8958_mbc_vss_loaded(const struct firmware *fw, void *context)
883 wm8994->mbc_vss = fw; 883 wm8994->mbc_vss = fw;
884 mutex_unlock(&codec->mutex); 884 mutex_unlock(&codec->mutex);
885 } 885 }
886
887 /* We can't have more than one request outstanding at once so
888 * we daisy chain.
889 */
890 request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
891 "wm8958_enh_eq.wfw", codec->dev, GFP_KERNEL,
892 codec, wm8958_enh_eq_loaded);
893} 886}
894 887
895static void wm8958_mbc_loaded(const struct firmware *fw, void *context) 888static void wm8958_mbc_loaded(const struct firmware *fw, void *context)
@@ -897,25 +890,18 @@ static void wm8958_mbc_loaded(const struct firmware *fw, void *context)
897 struct snd_soc_codec *codec = context; 890 struct snd_soc_codec *codec = context;
898 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 891 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
899 892
900 if (wm8958_dsp2_fw(codec, "MBC", fw, true) != 0) 893 if (fw && (wm8958_dsp2_fw(codec, "MBC", fw, true) == 0)) {
901 return; 894 mutex_lock(&codec->mutex);
902 895 wm8994->mbc = fw;
903 mutex_lock(&codec->mutex); 896 mutex_unlock(&codec->mutex);
904 wm8994->mbc = fw; 897 }
905 mutex_unlock(&codec->mutex);
906
907 /* We can't have more than one request outstanding at once so
908 * we daisy chain.
909 */
910 request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
911 "wm8958_mbc_vss.wfw", codec->dev, GFP_KERNEL,
912 codec, wm8958_mbc_vss_loaded);
913} 898}
914 899
915void wm8958_dsp2_init(struct snd_soc_codec *codec) 900void wm8958_dsp2_init(struct snd_soc_codec *codec)
916{ 901{
917 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 902 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
918 struct wm8994_pdata *pdata = wm8994->pdata; 903 struct wm8994 *control = wm8994->wm8994;
904 struct wm8994_pdata *pdata = &control->pdata;
919 int ret, i; 905 int ret, i;
920 906
921 wm8994->dsp_active = -1; 907 wm8994->dsp_active = -1;
@@ -932,9 +918,12 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec)
932 request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG, 918 request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
933 "wm8958_mbc.wfw", codec->dev, GFP_KERNEL, 919 "wm8958_mbc.wfw", codec->dev, GFP_KERNEL,
934 codec, wm8958_mbc_loaded); 920 codec, wm8958_mbc_loaded);
935 921 request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
936 if (!pdata) 922 "wm8958_mbc_vss.wfw", codec->dev, GFP_KERNEL,
937 return; 923 codec, wm8958_mbc_vss_loaded);
924 request_firmware_nowait(THIS_MODULE, FW_ACTION_HOTPLUG,
925 "wm8958_enh_eq.wfw", codec->dev, GFP_KERNEL,
926 codec, wm8958_enh_eq_loaded);
938 927
939 if (pdata->num_mbc_cfgs) { 928 if (pdata->num_mbc_cfgs) {
940 struct snd_kcontrol_new control[] = { 929 struct snd_kcontrol_new control[] = {
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c
index b2b2b37131bd..302f69a8ac22 100644
--- a/sound/soc/codecs/wm8994.c
+++ b/sound/soc/codecs/wm8994.c
@@ -110,13 +110,13 @@ static const struct wm8958_micd_rate jackdet_rates[] = {
110static void wm8958_micd_set_rate(struct snd_soc_codec *codec) 110static void wm8958_micd_set_rate(struct snd_soc_codec *codec)
111{ 111{
112 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 112 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
113 struct wm8994 *control = wm8994->wm8994;
113 int best, i, sysclk, val; 114 int best, i, sysclk, val;
114 bool idle; 115 bool idle;
115 const struct wm8958_micd_rate *rates; 116 const struct wm8958_micd_rate *rates;
116 int num_rates; 117 int num_rates;
117 118
118 if (!(wm8994->pdata && wm8994->pdata->micd_rates) && 119 if (wm8994->jack_cb != wm8958_default_micdet)
119 wm8994->jack_cb != wm8958_default_micdet)
120 return; 120 return;
121 121
122 idle = !wm8994->jack_mic; 122 idle = !wm8994->jack_mic;
@@ -127,9 +127,9 @@ static void wm8958_micd_set_rate(struct snd_soc_codec *codec)
127 else 127 else
128 sysclk = wm8994->aifclk[0]; 128 sysclk = wm8994->aifclk[0];
129 129
130 if (wm8994->pdata && wm8994->pdata->micd_rates) { 130 if (control->pdata.micd_rates) {
131 rates = wm8994->pdata->micd_rates; 131 rates = control->pdata.micd_rates;
132 num_rates = wm8994->pdata->num_micd_rates; 132 num_rates = control->pdata.num_micd_rates;
133 } else if (wm8994->jackdet) { 133 } else if (wm8994->jackdet) {
134 rates = jackdet_rates; 134 rates = jackdet_rates;
135 num_rates = ARRAY_SIZE(jackdet_rates); 135 num_rates = ARRAY_SIZE(jackdet_rates);
@@ -326,7 +326,8 @@ static int wm8994_put_drc_sw(struct snd_kcontrol *kcontrol,
326static void wm8994_set_drc(struct snd_soc_codec *codec, int drc) 326static void wm8994_set_drc(struct snd_soc_codec *codec, int drc)
327{ 327{
328 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 328 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
329 struct wm8994_pdata *pdata = wm8994->pdata; 329 struct wm8994 *control = wm8994->wm8994;
330 struct wm8994_pdata *pdata = &control->pdata;
330 int base = wm8994_drc_base[drc]; 331 int base = wm8994_drc_base[drc];
331 int cfg = wm8994->drc_cfg[drc]; 332 int cfg = wm8994->drc_cfg[drc];
332 int save, i; 333 int save, i;
@@ -362,7 +363,8 @@ static int wm8994_put_drc_enum(struct snd_kcontrol *kcontrol,
362{ 363{
363 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 364 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
364 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 365 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
365 struct wm8994_pdata *pdata = wm8994->pdata; 366 struct wm8994 *control = wm8994->wm8994;
367 struct wm8994_pdata *pdata = &control->pdata;
366 int drc = wm8994_get_drc(kcontrol->id.name); 368 int drc = wm8994_get_drc(kcontrol->id.name);
367 int value = ucontrol->value.integer.value[0]; 369 int value = ucontrol->value.integer.value[0];
368 370
@@ -394,7 +396,8 @@ static int wm8994_get_drc_enum(struct snd_kcontrol *kcontrol,
394static void wm8994_set_retune_mobile(struct snd_soc_codec *codec, int block) 396static void wm8994_set_retune_mobile(struct snd_soc_codec *codec, int block)
395{ 397{
396 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 398 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
397 struct wm8994_pdata *pdata = wm8994->pdata; 399 struct wm8994 *control = wm8994->wm8994;
400 struct wm8994_pdata *pdata = &control->pdata;
398 int base = wm8994_retune_mobile_base[block]; 401 int base = wm8994_retune_mobile_base[block];
399 int iface, best, best_val, save, i, cfg; 402 int iface, best, best_val, save, i, cfg;
400 403
@@ -465,7 +468,8 @@ static int wm8994_put_retune_mobile_enum(struct snd_kcontrol *kcontrol,
465{ 468{
466 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol); 469 struct snd_soc_codec *codec = snd_kcontrol_chip(kcontrol);
467 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); 470 struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec);
468 struct wm8994_pdata *pdata = wm8994->pdata; 471 struct wm8994 *control = wm8994->wm8994;
472 struct wm8994_pdata *pdata = &control->pdata;
469 int block = wm8994_get_retune_mobile_block(kcontrol->id.name); 473 int block = wm8994_get_retune_mobile_block(kcontrol->id.name);
470 int value = ucontrol->value.integer.value[0]; 474 int value = ucontrol->value.integer.value[0];
471 475
@@ -862,7 +866,7 @@ static void vmid_reference(struct snd_soc_codec *codec)
862 WM8994_BIAS_SRC | 866 WM8994_BIAS_SRC |
863 WM8994_STARTUP_BIAS_ENA | 867 WM8994_STARTUP_BIAS_ENA |
864 WM8994_VMID_BUF_ENA | 868 WM8994_VMID_BUF_ENA |
865 (0x3 << WM8994_VMID_RAMP_SHIFT)); 869 (0x2 << WM8994_VMID_RAMP_SHIFT));
866 870
867 /* Main bias enable, VMID=2x40k */ 871 /* Main bias enable, VMID=2x40k */
868 snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1, 872 snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1,
@@ -870,7 +874,7 @@ static void vmid_reference(struct snd_soc_codec *codec)
870 WM8994_VMID_SEL_MASK, 874 WM8994_VMID_SEL_MASK,
871 WM8994_BIAS_ENA | 0x2); 875 WM8994_BIAS_ENA | 0x2);
872 876
873 msleep(50); 877 msleep(300);
874 878
875 snd_soc_update_bits(codec, WM8994_ANTIPOP_2, 879 snd_soc_update_bits(codec, WM8994_ANTIPOP_2,
876 WM8994_VMID_RAMP_MASK | 880 WM8994_VMID_RAMP_MASK |
@@ -939,16 +943,10 @@ static void vmid_dereference(struct snd_soc_codec *codec)
939 WM8994_BIAS_SRC | 943 WM8994_BIAS_SRC |
940 WM8994_VMID_DISCH); 944 WM8994_VMID_DISCH);
941 945
942 switch (wm8994->vmid_mode) { 946 snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1,
943 case WM8994_VMID_FORCE: 947 WM8994_VMID_SEL_MASK, 0);
944 msleep(350);
945 break;
946 default:
947 break;
948 }
949 948
950 snd_soc_update_bits(codec, WM8994_ADDITIONAL_CONTROL, 949 msleep(400);
951 WM8994_VROI, WM8994_VROI);
952 950
953 /* Active discharge */ 951 /* Active discharge */
954 snd_soc_update_bits(codec, WM8994_ANTIPOP_1, 952 snd_soc_update_bits(codec, WM8994_ANTIPOP_1,
@@ -957,17 +955,12 @@ static void vmid_dereference(struct snd_soc_codec *codec)
957 WM8994_LINEOUT1_DISCH | 955 WM8994_LINEOUT1_DISCH |
958 WM8994_LINEOUT2_DISCH); 956 WM8994_LINEOUT2_DISCH);
959 957
960 msleep(150);
961
962 snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_3, 958 snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_3,
963 WM8994_LINEOUT1N_ENA | 959 WM8994_LINEOUT1N_ENA |
964 WM8994_LINEOUT1P_ENA | 960 WM8994_LINEOUT1P_ENA |
965 WM8994_LINEOUT2N_ENA | 961 WM8994_LINEOUT2N_ENA |
966 WM8994_LINEOUT2P_ENA, 0); 962 WM8994_LINEOUT2P_ENA, 0);
967 963
968 snd_soc_update_bits(codec, WM8994_ADDITIONAL_CONTROL,
969 WM8994_VROI, 0);
970
971 /* Switch off startup biases */ 964 /* Switch off startup biases */
972 snd_soc_update_bits(codec, WM8994_ANTIPOP_2, 965 snd_soc_update_bits(codec, WM8994_ANTIPOP_2,
973 WM8994_BIAS_SRC | 966 WM8994_BIAS_SRC |
@@ -976,10 +969,7 @@ static void vmid_dereference(struct snd_soc_codec *codec)
976 WM8994_VMID_RAMP_MASK, 0); 969 WM8994_VMID_RAMP_MASK, 0);
977 970
978 snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1, 971 snd_soc_update_bits(codec, WM8994_POWER_MANAGEMENT_1,
979 WM8994_BIAS_ENA | WM8994_VMID_SEL_MASK, 0); 972 WM8994_VMID_SEL_MASK, 0);
980
981 snd_soc_update_bits(codec, WM8994_ANTIPOP_2,
982 WM8994_VMID_RAMP_MASK, 0);
983 } 973 }
984 974
985 pm_runtime_put(codec->dev); 975 pm_runtime_put(codec->dev);
@@ -2277,6 +2267,18 @@ out:
2277 2267
2278 configure_clock(codec); 2268 configure_clock(codec);
2279 2269
2270 /*
2271 * If SYSCLK will be less than 50kHz adjust AIFnCLK dividers
2272 * for detection.
2273 */
2274 if (max(wm8994->aifclk[0], wm8994->aifclk[1]) < 50000) {
2275 dev_dbg(codec->dev, "Configuring AIFs for 128fs\n");
2276 snd_soc_update_bits(codec, WM8994_AIF1_RATE,
2277 WM8994_AIF1CLK_RATE_MASK, 0x1);
2278 snd_soc_update_bits(codec, WM8994_AIF2_RATE,
2279 WM8994_AIF2CLK_RATE_MASK, 0x1);
2280 }
2281
2280 return 0; 2282 return 0;
2281} 2283}
2282 2284
@@ -2365,6 +2367,18 @@ static int wm8994_set_dai_sysclk(struct snd_soc_dai *dai,
2365 2367
2366 configure_clock(codec); 2368 configure_clock(codec);
2367 2369
2370 /*
2371 * If SYSCLK will be less than 50kHz adjust AIFnCLK dividers
2372 * for detection.
2373 */
2374 if (max(wm8994->aifclk[0], wm8994->aifclk[1]) < 50000) {
2375 dev_dbg(codec->dev, "Configuring AIFs for 128fs\n");
2376 snd_soc_update_bits(codec, WM8994_AIF1_RATE,
2377 WM8994_AIF1CLK_RATE_MASK, 0x1);
2378 snd_soc_update_bits(codec, WM8994_AIF2_RATE,
2379 WM8994_AIF2CLK_RATE_MASK, 0x1);
2380 }
2381
2368 return 0; 2382 return 0;
2369} 2383}
2370 2384
@@ -3082,7 +3096,8 @@ static int wm8994_codec_resume(struct snd_soc_codec *codec)
3082static void wm8994_handle_retune_mobile_pdata(struct wm8994_priv *wm8994) 3096static void wm8994_handle_retune_mobile_pdata(struct wm8994_priv *wm8994)
3083{ 3097{
3084 struct snd_soc_codec *codec = wm8994->hubs.codec; 3098 struct snd_soc_codec *codec = wm8994->hubs.codec;
3085 struct wm8994_pdata *pdata = wm8994->pdata; 3099 struct wm8994 *control = wm8994->wm8994;
3100 struct wm8994_pdata *pdata = &control->pdata;
3086 struct snd_kcontrol_new controls[] = { 3101 struct snd_kcontrol_new controls[] = {
3087 SOC_ENUM_EXT("AIF1.1 EQ Mode", 3102 SOC_ENUM_EXT("AIF1.1 EQ Mode",
3088 wm8994->retune_mobile_enum, 3103 wm8994->retune_mobile_enum,
@@ -3149,7 +3164,8 @@ static void wm8994_handle_retune_mobile_pdata(struct wm8994_priv *wm8994)
3149static void wm8994_handle_pdata(struct wm8994_priv *wm8994) 3164static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
3150{ 3165{
3151 struct snd_soc_codec *codec = wm8994->hubs.codec; 3166 struct snd_soc_codec *codec = wm8994->hubs.codec;
3152 struct wm8994_pdata *pdata = wm8994->pdata; 3167 struct wm8994 *control = wm8994->wm8994;
3168 struct wm8994_pdata *pdata = &control->pdata;
3153 int ret, i; 3169 int ret, i;
3154 3170
3155 if (!pdata) 3171 if (!pdata)
@@ -3451,7 +3467,7 @@ static void wm8958_default_micdet(u16 status, void *data)
3451 3467
3452 mutex_unlock(&wm8994->accdet_lock); 3468 mutex_unlock(&wm8994->accdet_lock);
3453 3469
3454 if (wm8994->pdata->jd_ext_cap) 3470 if (wm8994->wm8994->pdata.jd_ext_cap)
3455 snd_soc_dapm_disable_pin(&codec->dapm, 3471 snd_soc_dapm_disable_pin(&codec->dapm,
3456 "MICBIAS2"); 3472 "MICBIAS2");
3457 } 3473 }
@@ -3486,11 +3502,48 @@ static void wm8958_default_micdet(u16 status, void *data)
3486 } 3502 }
3487} 3503}
3488 3504
3505/* Deferred mic detection to allow for extra settling time */
3506static void wm1811_mic_work(struct work_struct *work)
3507{
3508 struct wm8994_priv *wm8994 = container_of(work, struct wm8994_priv,
3509 mic_work.work);
3510 struct wm8994 *control = wm8994->wm8994;
3511 struct snd_soc_codec *codec = wm8994->hubs.codec;
3512
3513 pm_runtime_get_sync(codec->dev);
3514
3515 /* If required for an external cap force MICBIAS on */
3516 if (control->pdata.jd_ext_cap) {
3517 snd_soc_dapm_force_enable_pin(&codec->dapm,
3518 "MICBIAS2");
3519 snd_soc_dapm_sync(&codec->dapm);
3520 }
3521
3522 mutex_lock(&wm8994->accdet_lock);
3523
3524 dev_dbg(codec->dev, "Starting mic detection\n");
3525
3526 /*
3527 * Start off measument of microphone impedence to find out
3528 * what's actually there.
3529 */
3530 wm8994->mic_detecting = true;
3531 wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_MIC);
3532
3533 snd_soc_update_bits(codec, WM8958_MIC_DETECT_1,
3534 WM8958_MICD_ENA, WM8958_MICD_ENA);
3535
3536 mutex_unlock(&wm8994->accdet_lock);
3537
3538 pm_runtime_put(codec->dev);
3539}
3540
3489static irqreturn_t wm1811_jackdet_irq(int irq, void *data) 3541static irqreturn_t wm1811_jackdet_irq(int irq, void *data)
3490{ 3542{
3491 struct wm8994_priv *wm8994 = data; 3543 struct wm8994_priv *wm8994 = data;
3544 struct wm8994 *control = wm8994->wm8994;
3492 struct snd_soc_codec *codec = wm8994->hubs.codec; 3545 struct snd_soc_codec *codec = wm8994->hubs.codec;
3493 int reg; 3546 int reg, delay;
3494 bool present; 3547 bool present;
3495 3548
3496 pm_runtime_get_sync(codec->dev); 3549 pm_runtime_get_sync(codec->dev);
@@ -3521,18 +3574,14 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data)
3521 snd_soc_update_bits(codec, WM1811_JACKDET_CTRL, 3574 snd_soc_update_bits(codec, WM1811_JACKDET_CTRL,
3522 WM1811_JACKDET_DB, 0); 3575 WM1811_JACKDET_DB, 0);
3523 3576
3524 /* 3577 delay = control->pdata.micdet_delay;
3525 * Start off measument of microphone impedence to find 3578 schedule_delayed_work(&wm8994->mic_work,
3526 * out what's actually there. 3579 msecs_to_jiffies(delay));
3527 */
3528 wm8994->mic_detecting = true;
3529 wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_MIC);
3530
3531 snd_soc_update_bits(codec, WM8958_MIC_DETECT_1,
3532 WM8958_MICD_ENA, WM8958_MICD_ENA);
3533 } else { 3580 } else {
3534 dev_dbg(codec->dev, "Jack not detected\n"); 3581 dev_dbg(codec->dev, "Jack not detected\n");
3535 3582
3583 cancel_delayed_work_sync(&wm8994->mic_work);
3584
3536 snd_soc_update_bits(codec, WM8958_MICBIAS2, 3585 snd_soc_update_bits(codec, WM8958_MICBIAS2,
3537 WM8958_MICB2_DISCH, WM8958_MICB2_DISCH); 3586 WM8958_MICB2_DISCH, WM8958_MICB2_DISCH);
3538 3587
@@ -3549,14 +3598,9 @@ static irqreturn_t wm1811_jackdet_irq(int irq, void *data)
3549 3598
3550 mutex_unlock(&wm8994->accdet_lock); 3599 mutex_unlock(&wm8994->accdet_lock);
3551 3600
3552 /* If required for an external cap force MICBIAS on */ 3601 /* Turn off MICBIAS if it was on for an external cap */
3553 if (wm8994->pdata->jd_ext_cap) { 3602 if (control->pdata.jd_ext_cap && !present)
3554 if (present) 3603 snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS2");
3555 snd_soc_dapm_force_enable_pin(&codec->dapm,
3556 "MICBIAS2");
3557 else
3558 snd_soc_dapm_disable_pin(&codec->dapm, "MICBIAS2");
3559 }
3560 3604
3561 if (present) 3605 if (present)
3562 snd_soc_jack_report(wm8994->micdet[0].jack, 3606 snd_soc_jack_report(wm8994->micdet[0].jack,
@@ -3633,8 +3677,8 @@ int wm8958_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack,
3633 wm8958_micd_set_rate(codec); 3677 wm8958_micd_set_rate(codec);
3634 3678
3635 /* Detect microphones and short circuits by default */ 3679 /* Detect microphones and short circuits by default */
3636 if (wm8994->pdata->micd_lvl_sel) 3680 if (control->pdata.micd_lvl_sel)
3637 micd_lvl_sel = wm8994->pdata->micd_lvl_sel; 3681 micd_lvl_sel = control->pdata.micd_lvl_sel;
3638 else 3682 else
3639 micd_lvl_sel = 0x41; 3683 micd_lvl_sel = 0x41;
3640 3684
@@ -3779,15 +3823,24 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
3779 snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP); 3823 snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP);
3780 3824
3781 mutex_init(&wm8994->accdet_lock); 3825 mutex_init(&wm8994->accdet_lock);
3782 INIT_DELAYED_WORK(&wm8994->mic_work, wm8994_mic_work);
3783 INIT_DELAYED_WORK(&wm8994->jackdet_bootstrap, 3826 INIT_DELAYED_WORK(&wm8994->jackdet_bootstrap,
3784 wm1811_jackdet_bootstrap); 3827 wm1811_jackdet_bootstrap);
3785 3828
3829 switch (control->type) {
3830 case WM8994:
3831 INIT_DELAYED_WORK(&wm8994->mic_work, wm8994_mic_work);
3832 break;
3833 case WM1811:
3834 INIT_DELAYED_WORK(&wm8994->mic_work, wm1811_mic_work);
3835 break;
3836 default:
3837 break;
3838 }
3839
3786 for (i = 0; i < ARRAY_SIZE(wm8994->fll_locked); i++) 3840 for (i = 0; i < ARRAY_SIZE(wm8994->fll_locked); i++)
3787 init_completion(&wm8994->fll_locked[i]); 3841 init_completion(&wm8994->fll_locked[i]);
3788 3842
3789 if (wm8994->pdata && wm8994->pdata->micdet_irq) 3843 wm8994->micdet_irq = control->pdata.micdet_irq;
3790 wm8994->micdet_irq = wm8994->pdata->micdet_irq;
3791 3844
3792 pm_runtime_enable(codec->dev); 3845 pm_runtime_enable(codec->dev);
3793 pm_runtime_idle(codec->dev); 3846 pm_runtime_idle(codec->dev);
@@ -3800,8 +3853,8 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
3800 switch (control->type) { 3853 switch (control->type) {
3801 case WM8994: 3854 case WM8994:
3802 /* Single ended line outputs should have VMID on. */ 3855 /* Single ended line outputs should have VMID on. */
3803 if (!wm8994->pdata->lineout1_diff || 3856 if (!control->pdata.lineout1_diff ||
3804 !wm8994->pdata->lineout2_diff) 3857 !control->pdata.lineout2_diff)
3805 codec->dapm.idle_bias_off = 0; 3858 codec->dapm.idle_bias_off = 0;
3806 3859
3807 switch (wm8994->revision) { 3860 switch (wm8994->revision) {
@@ -3839,20 +3892,8 @@ static int wm8994_codec_probe(struct snd_soc_codec *codec)
3839 wm8994->hubs.no_cache_dac_hp_direct = true; 3892 wm8994->hubs.no_cache_dac_hp_direct = true;
3840 wm8994->fll_byp = true; 3893 wm8994->fll_byp = true;
3841 3894
3842 switch (control->cust_id) { 3895 wm8994->hubs.dcs_codes_l = -9;
3843 case 0: 3896 wm8994->hubs.dcs_codes_r = -7;
3844 case 2:
3845 wm8994->hubs.dcs_codes_l = -9;
3846 wm8994->hubs.dcs_codes_r = -7;
3847 break;
3848 case 1:
3849 case 3:
3850 wm8994->hubs.dcs_codes_l = -8;
3851 wm8994->hubs.dcs_codes_r = -7;
3852 break;
3853 default:
3854 break;
3855 }
3856 3897
3857 snd_soc_update_bits(codec, WM8994_ANALOGUE_HP_1, 3898 snd_soc_update_bits(codec, WM8994_ANALOGUE_HP_1,
3858 WM1811_HPOUT1_ATTN, WM1811_HPOUT1_ATTN); 3899 WM1811_HPOUT1_ATTN, WM1811_HPOUT1_ATTN);
@@ -4236,7 +4277,6 @@ static int __devinit wm8994_probe(struct platform_device *pdev)
4236 platform_set_drvdata(pdev, wm8994); 4277 platform_set_drvdata(pdev, wm8994);
4237 4278
4238 wm8994->wm8994 = dev_get_drvdata(pdev->dev.parent); 4279 wm8994->wm8994 = dev_get_drvdata(pdev->dev.parent);
4239 wm8994->pdata = dev_get_platdata(pdev->dev.parent);
4240 4280
4241 return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8994, 4281 return snd_soc_register_codec(&pdev->dev, &soc_codec_dev_wm8994,
4242 wm8994_dai, ARRAY_SIZE(wm8994_dai)); 4282 wm8994_dai, ARRAY_SIZE(wm8994_dai));
diff --git a/sound/soc/codecs/wm8994.h b/sound/soc/codecs/wm8994.h
index ccbce5791e95..3120c0f21d4d 100644
--- a/sound/soc/codecs/wm8994.h
+++ b/sound/soc/codecs/wm8994.h
@@ -143,7 +143,6 @@ struct wm8994_priv {
143 int micdet_irq; 143 int micdet_irq;
144 144
145 int revision; 145 int revision;
146 struct wm8994_pdata *pdata;
147 146
148 unsigned int aif1clk_enable:1; 147 unsigned int aif1clk_enable:1;
149 unsigned int aif2clk_enable:1; 148 unsigned int aif2clk_enable:1;