Lines Matching +full:micd +full:- +full:bias +full:- +full:start +full:- +full:time

1 // SPDX-License-Identifier: GPL-2.0-only
3 * wm8994.c -- WM8994 ALSA SoC Audio driver
5 * Copyright 2009-12 Wolfson Microelectronics plc
114 struct wm8994 *control = wm8994->wm8994; in wm8958_micd_set_rate()
120 idle = !wm8994->jack_mic; in wm8958_micd_set_rate()
124 sysclk = wm8994->aifclk[1]; in wm8958_micd_set_rate()
126 sysclk = wm8994->aifclk[0]; in wm8958_micd_set_rate()
128 if (control->pdata.micd_rates) { in wm8958_micd_set_rate()
129 rates = control->pdata.micd_rates; in wm8958_micd_set_rate()
130 num_rates = control->pdata.num_micd_rates; in wm8958_micd_set_rate()
131 } else if (wm8994->jackdet) { in wm8958_micd_set_rate()
143 if (abs(rates[i].sysclk - sysclk) < in wm8958_micd_set_rate()
144 abs(rates[best].sysclk - sysclk)) in wm8958_micd_set_rate()
150 val = rates[best].start << WM8958_MICD_BIAS_STARTTIME_SHIFT in wm8958_micd_set_rate()
153 dev_dbg(component->dev, "MICD rate %d,%d for %dHz %s\n", in wm8958_micd_set_rate()
154 rates[best].start, rates[best].rate, sysclk, in wm8958_micd_set_rate()
174 switch (wm8994->sysclk[aif]) { in configure_aif_clock()
176 rate = wm8994->mclk_rate[0]; in configure_aif_clock()
181 rate = wm8994->mclk_rate[1]; in configure_aif_clock()
186 rate = wm8994->fll[0].out; in configure_aif_clock()
191 rate = wm8994->fll[1].out; in configure_aif_clock()
195 return -EINVAL; in configure_aif_clock()
202 dev_dbg(component->dev, "Dividing AIF%d clock to %dHz\n", in configure_aif_clock()
206 wm8994->aifclk[aif] = rate; in configure_aif_clock()
232 if (wm8994->aifclk[0] == wm8994->aifclk[1]) { in configure_clock()
237 if (wm8994->aifclk[0] < wm8994->aifclk[1]) in configure_clock()
255 struct snd_soc_component *component = snd_soc_dapm_to_component(source->dapm); in check_clk_sys()
289 static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1);
290 static const DECLARE_TLV_DB_SCALE(st_tlv, -3600, 300, 0);
291 static const DECLARE_TLV_DB_SCALE(wm8994_3d_tlv, -1600, 183, 0);
292 static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
293 static const DECLARE_TLV_DB_SCALE(ng_tlv, -10200, 600, 0);
303 (struct soc_mixer_control *)kcontrol->private_value; in wm8994_put_drc_sw()
308 if (mc->shift == WM8994_AIF1DAC1_DRC_ENA_SHIFT) in wm8994_put_drc_sw()
314 ret = snd_soc_component_read(component, mc->reg); in wm8994_put_drc_sw()
318 return -EINVAL; in wm8994_put_drc_sw()
326 struct wm8994 *control = wm8994->wm8994; in wm8994_set_drc()
327 struct wm8994_pdata *pdata = &control->pdata; in wm8994_set_drc()
329 int cfg = wm8994->drc_cfg[drc]; in wm8994_set_drc()
339 pdata->drc_cfgs[cfg].regs[i]); in wm8994_set_drc()
355 return -EINVAL; in wm8994_get_drc()
363 struct wm8994 *control = wm8994->wm8994; in wm8994_put_drc_enum()
364 struct wm8994_pdata *pdata = &control->pdata; in wm8994_put_drc_enum()
365 int drc = wm8994_get_drc(kcontrol->id.name); in wm8994_put_drc_enum()
366 int value = ucontrol->value.enumerated.item[0]; in wm8994_put_drc_enum()
371 if (value >= pdata->num_drc_cfgs) in wm8994_put_drc_enum()
372 return -EINVAL; in wm8994_put_drc_enum()
374 wm8994->drc_cfg[drc] = value; in wm8994_put_drc_enum()
386 int drc = wm8994_get_drc(kcontrol->id.name); in wm8994_get_drc_enum()
390 ucontrol->value.enumerated.item[0] = wm8994->drc_cfg[drc]; in wm8994_get_drc_enum()
398 struct wm8994 *control = wm8994->wm8994; in wm8994_set_retune_mobile()
399 struct wm8994_pdata *pdata = &control->pdata; in wm8994_set_retune_mobile()
403 if (!pdata || !wm8994->num_retune_mobile_texts) in wm8994_set_retune_mobile()
420 cfg = wm8994->retune_mobile_cfg[block]; in wm8994_set_retune_mobile()
423 for (i = 0; i < pdata->num_retune_mobile_cfgs; i++) { in wm8994_set_retune_mobile()
424 if (strcmp(pdata->retune_mobile_cfgs[i].name, in wm8994_set_retune_mobile()
425 wm8994->retune_mobile_texts[cfg]) == 0 && in wm8994_set_retune_mobile()
426 abs(pdata->retune_mobile_cfgs[i].rate in wm8994_set_retune_mobile()
427 - wm8994->dac_rates[iface]) < best_val) { in wm8994_set_retune_mobile()
429 best_val = abs(pdata->retune_mobile_cfgs[i].rate in wm8994_set_retune_mobile()
430 - wm8994->dac_rates[iface]); in wm8994_set_retune_mobile()
434 dev_dbg(component->dev, "ReTune Mobile %d %s/%dHz for %dHz sample rate\n", in wm8994_set_retune_mobile()
436 pdata->retune_mobile_cfgs[best].name, in wm8994_set_retune_mobile()
437 pdata->retune_mobile_cfgs[best].rate, in wm8994_set_retune_mobile()
438 wm8994->dac_rates[iface]); in wm8994_set_retune_mobile()
448 pdata->retune_mobile_cfgs[best].regs[i]); in wm8994_set_retune_mobile()
462 return -EINVAL; in wm8994_get_retune_mobile_block()
470 struct wm8994 *control = wm8994->wm8994; in wm8994_put_retune_mobile_enum()
471 struct wm8994_pdata *pdata = &control->pdata; in wm8994_put_retune_mobile_enum()
472 int block = wm8994_get_retune_mobile_block(kcontrol->id.name); in wm8994_put_retune_mobile_enum()
473 int value = ucontrol->value.enumerated.item[0]; in wm8994_put_retune_mobile_enum()
478 if (value >= pdata->num_retune_mobile_cfgs) in wm8994_put_retune_mobile_enum()
479 return -EINVAL; in wm8994_put_retune_mobile_enum()
481 wm8994->retune_mobile_cfg[block] = value; in wm8994_put_retune_mobile_enum()
493 int block = wm8994_get_retune_mobile_block(kcontrol->id.name); in wm8994_get_retune_mobile_enum()
498 ucontrol->value.enumerated.item[0] = wm8994->retune_mobile_cfg[block]; in wm8994_get_retune_mobile_enum()
721 SOC_ENUM("AIF1DAC1 Noise Gate Hold Time", wm8958_aif1dac1_ng_hold),
728 SOC_ENUM("AIF1DAC2 Noise Gate Hold Time", wm8958_aif1dac2_ng_hold),
735 SOC_ENUM("AIF2DAC Noise Gate Hold Time", wm8958_aif2dac_ng_hold),
746 if (!wm8994->jackdet || !wm8994->micdet[0].jack) in wm1811_jackdet_set_mode()
749 if (wm8994->active_refcount) in wm1811_jackdet_set_mode()
752 if (mode == wm8994->jackdet_mode) in wm1811_jackdet_set_mode()
755 wm8994->jackdet_mode = mode; in wm1811_jackdet_set_mode()
769 mutex_lock(&wm8994->accdet_lock); in active_reference()
771 wm8994->active_refcount++; in active_reference()
773 dev_dbg(component->dev, "Active refcount incremented, now %d\n", in active_reference()
774 wm8994->active_refcount); in active_reference()
779 mutex_unlock(&wm8994->accdet_lock); in active_reference()
787 mutex_lock(&wm8994->accdet_lock); in active_dereference()
789 wm8994->active_refcount--; in active_dereference()
791 dev_dbg(component->dev, "Active refcount decremented, now %d\n", in active_dereference()
792 wm8994->active_refcount); in active_dereference()
794 if (wm8994->active_refcount == 0) { in active_dereference()
796 if (wm8994->jack_mic || wm8994->mic_detecting) in active_dereference()
804 mutex_unlock(&wm8994->accdet_lock); in active_dereference()
810 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in clk_sys_event()
819 * JACKDET won't run until we start the clock and it in clk_sys_event()
825 if (wm8994->jackdet && !wm8994->clk_has_run) { in clk_sys_event()
827 &wm8994->jackdet_bootstrap, in clk_sys_event()
829 wm8994->clk_has_run = true; in clk_sys_event()
845 pm_runtime_get_sync(component->dev); in vmid_reference()
847 wm8994->vmid_refcount++; in vmid_reference()
849 dev_dbg(component->dev, "Referencing VMID, refcount is now %d\n", in vmid_reference()
850 wm8994->vmid_refcount); in vmid_reference()
852 if (wm8994->vmid_refcount == 1) { in vmid_reference()
859 switch (wm8994->vmid_mode) { in vmid_reference()
864 /* Startup bias, VMID ramp & buffer */ in vmid_reference()
876 /* Main bias enable, VMID=2x40k */ in vmid_reference()
891 /* Startup bias, slow VMID ramp & buffer */ in vmid_reference()
903 /* Main bias enable, VMID=2x40k */ in vmid_reference()
924 wm8994->vmid_refcount--; in vmid_dereference()
926 dev_dbg(component->dev, "Dereferencing VMID, refcount is now %d\n", in vmid_dereference()
927 wm8994->vmid_refcount); in vmid_dereference()
929 if (wm8994->vmid_refcount == 0) { in vmid_dereference()
930 if (wm8994->hubs.lineout1_se) in vmid_dereference()
937 if (wm8994->hubs.lineout2_se) in vmid_dereference()
944 /* Start discharging VMID */ in vmid_dereference()
980 pm_runtime_put(component->dev); in vmid_dereference()
986 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in vmid_event()
1010 dev_vdbg(component->dev, "Class W source AIF2DAC\n"); in wm8994_check_class_w_digital()
1014 dev_vdbg(component->dev, "Class W source AIF1DAC2\n"); in wm8994_check_class_w_digital()
1018 dev_vdbg(component->dev, "Class W source AIF1DAC1\n"); in wm8994_check_class_w_digital()
1022 dev_vdbg(component->dev, "DAC mixer setting: %x\n", reg); in wm8994_check_class_w_digital()
1028 dev_vdbg(component->dev, "Left and right DAC mixers different\n"); in wm8994_check_class_w_digital()
1042 struct wm8994 *control = wm8994->wm8994; in wm8994_update_vu_bits()
1049 if (control->type == WM1811) in wm8994_update_vu_bits()
1085 ret = clk_prepare_enable(wm8994->mclk[clk_idx].clk); in aif_mclk_set()
1087 dev_err(component->dev, "Failed to enable MCLK%d\n", in aif_mclk_set()
1092 clk_disable_unprepare(wm8994->mclk[clk_idx].clk); in aif_mclk_set()
1101 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in aif1clk_ev()
1103 struct wm8994 *control = wm8994->wm8994; in aif1clk_ev()
1110 switch (control->type) { in aif1clk_ev()
1126 if (wm8994->channels[0] <= 2) in aif1clk_ev()
1206 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in aif2clk_ev()
1298 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in aif1clk_late_ev()
1303 wm8994->aif1clk_enable = 1; in aif1clk_late_ev()
1306 wm8994->aif1clk_disable = 1; in aif1clk_late_ev()
1316 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in aif2clk_late_ev()
1321 wm8994->aif2clk_enable = 1; in aif2clk_late_ev()
1324 wm8994->aif2clk_disable = 1; in aif2clk_late_ev()
1334 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in late_enable_ev()
1339 if (wm8994->aif1clk_enable) { in late_enable_ev()
1345 wm8994->aif1clk_enable = 0; in late_enable_ev()
1347 if (wm8994->aif2clk_enable) { in late_enable_ev()
1353 wm8994->aif2clk_enable = 0; in late_enable_ev()
1367 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in late_disable_ev()
1372 if (wm8994->aif1clk_disable) { in late_disable_ev()
1377 wm8994->aif1clk_disable = 0; in late_disable_ev()
1379 if (wm8994->aif2clk_disable) { in late_disable_ev()
1384 wm8994->aif2clk_disable = 0; in late_disable_ev()
1409 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in dac_ev()
1410 unsigned int mask = 1 << w->shift; in dac_ev()
1450 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in post_ev()
1451 dev_dbg(component->dev, "SRC status: %x\n", in post_ev()
2131 fll->clk_ref_div = 0; in wm8994_get_fll_config()
2133 fll->clk_ref_div++; in wm8994_get_fll_config()
2136 if (fll->clk_ref_div > 3) in wm8994_get_fll_config()
2137 return -EINVAL; in wm8994_get_fll_config()
2139 pr_debug("CLK_REF_DIV=%d, Fref=%dHz\n", fll->clk_ref_div, freq_in); in wm8994_get_fll_config()
2142 fll->outdiv = 3; in wm8994_get_fll_config()
2143 while (freq_out * (fll->outdiv + 1) < 90000000) { in wm8994_get_fll_config()
2144 fll->outdiv++; in wm8994_get_fll_config()
2145 if (fll->outdiv > 63) in wm8994_get_fll_config()
2146 return -EINVAL; in wm8994_get_fll_config()
2148 freq_out *= fll->outdiv + 1; in wm8994_get_fll_config()
2149 pr_debug("OUTDIV=%d, Fvco=%dHz\n", fll->outdiv, freq_out); in wm8994_get_fll_config()
2152 fll->fll_fratio = 0; in wm8994_get_fll_config()
2154 fll->fll_fratio = 1; in wm8994_get_fll_config()
2157 fll->fll_fratio = 2; in wm8994_get_fll_config()
2160 fll->fll_fratio = 3; in wm8994_get_fll_config()
2163 fll->fll_fratio = 4; in wm8994_get_fll_config()
2166 pr_debug("FLL_FRATIO=%d, Fref=%dHz\n", fll->fll_fratio, freq_in); in wm8994_get_fll_config()
2171 fll->n = Ndiv; in wm8994_get_fll_config()
2175 switch (control->type) { in wm8994_get_fll_config()
2177 /* Calculate fractional part - scale up so we can round. */ in wm8994_get_fll_config()
2188 fll->k = K / 10; in wm8994_get_fll_config()
2189 fll->lambda = 0; in wm8994_get_fll_config()
2191 pr_debug("N=%x K=%x\n", fll->n, fll->k); in wm8994_get_fll_config()
2197 fll->k = (freq_out - (freq_in * fll->n)) / gcd_fll; in wm8994_get_fll_config()
2198 fll->lambda = freq_in / gcd_fll; in wm8994_get_fll_config()
2209 struct wm8994 *control = wm8994->wm8994; in _wm8994_set_fll()
2229 return -EINVAL; in _wm8994_set_fll()
2239 return -EINVAL; in _wm8994_set_fll()
2240 src = wm8994->fll[id].src; in _wm8994_set_fll()
2252 return -EINVAL; in _wm8994_set_fll()
2256 if (wm8994->fll[id].src == src && in _wm8994_set_fll()
2257 wm8994->fll[id].in == freq_in && wm8994->fll[id].out == freq_out) in _wm8994_set_fll()
2260 /* If we're stopping the FLL redo the old config - no in _wm8994_set_fll()
2267 ret = wm8994_get_fll_config(control, &fll, wm8994->fll[id].in, in _wm8994_set_fll()
2268 wm8994->fll[id].out); in _wm8994_set_fll()
2282 dev_err(component->dev, "FLL%d is currently providing SYSCLK\n", in _wm8994_set_fll()
2284 return -EBUSY; in _wm8994_set_fll()
2300 mclk = wm8994->mclk[WM8994_MCLK1].clk; in _wm8994_set_fll()
2303 mclk = wm8994->mclk[WM8994_MCLK2].clk; in _wm8994_set_fll()
2312 if (wm8994->fll_byp && src == WM8994_FLL_SRC_BCLK && in _wm8994_set_fll()
2314 dev_dbg(component->dev, "Bypassing FLL%d\n", id + 1); in _wm8994_set_fll()
2351 (src - 1)); in _wm8994_set_fll()
2354 try_wait_for_completion(&wm8994->fll_locked[id]); in _wm8994_set_fll()
2358 mclk = wm8994->mclk[WM8994_MCLK1].clk; in _wm8994_set_fll()
2361 mclk = wm8994->mclk[WM8994_MCLK2].clk; in _wm8994_set_fll()
2371 dev_err(component->dev, "Failed to enable MCLK for FLL%d\n", in _wm8994_set_fll()
2381 switch (control->type) { in _wm8994_set_fll()
2386 if (control->revision < 1) in _wm8994_set_fll()
2405 if (wm8994->fll_locked_irq) { in _wm8994_set_fll()
2406 time_left = wait_for_completion_timeout(&wm8994->fll_locked[id], in _wm8994_set_fll()
2409 dev_warn(component->dev, in _wm8994_set_fll()
2416 switch (control->type) { in _wm8994_set_fll()
2421 if (control->revision < 1) in _wm8994_set_fll()
2433 wm8994->fll[id].in = freq_in; in _wm8994_set_fll()
2434 wm8994->fll[id].out = freq_out; in _wm8994_set_fll()
2435 wm8994->fll[id].src = src; in _wm8994_set_fll()
2443 if (max(wm8994->aifclk[0], wm8994->aifclk[1]) < 50000) { in _wm8994_set_fll()
2444 dev_dbg(component->dev, "Configuring AIFs for 128fs\n"); in _wm8994_set_fll()
2446 wm8994->aifdiv[0] = snd_soc_component_read(component, WM8994_AIF1_RATE) in _wm8994_set_fll()
2448 wm8994->aifdiv[1] = snd_soc_component_read(component, WM8994_AIF2_RATE) in _wm8994_set_fll()
2455 } else if (wm8994->aifdiv[0]) { in _wm8994_set_fll()
2458 wm8994->aifdiv[0]); in _wm8994_set_fll()
2461 wm8994->aifdiv[1]); in _wm8994_set_fll()
2463 wm8994->aifdiv[0] = 0; in _wm8994_set_fll()
2464 wm8994->aifdiv[1] = 0; in _wm8994_set_fll()
2484 return _wm8994_set_fll(dai->component, id, src, freq_in, freq_out); in wm8994_set_fll()
2492 if (!wm8994->mclk[id].clk || *freq == wm8994->mclk_rate[id]) in wm8994_set_mclk_rate()
2495 ret = clk_set_rate(wm8994->mclk[id].clk, *freq); in wm8994_set_mclk_rate()
2499 *freq = clk_get_rate(wm8994->mclk[id].clk); in wm8994_set_mclk_rate()
2507 struct snd_soc_component *component = dai->component; in wm8994_set_dai_sysclk()
2511 switch (dai->id) { in wm8994_set_dai_sysclk()
2518 return -EINVAL; in wm8994_set_dai_sysclk()
2523 wm8994->sysclk[dai->id - 1] = WM8994_SYSCLK_MCLK1; in wm8994_set_dai_sysclk()
2525 ret = wm8994_set_mclk_rate(wm8994, dai->id - 1, &freq); in wm8994_set_dai_sysclk()
2529 wm8994->mclk_rate[0] = freq; in wm8994_set_dai_sysclk()
2530 dev_dbg(dai->dev, "AIF%d using MCLK1 at %uHz\n", in wm8994_set_dai_sysclk()
2531 dai->id, freq); in wm8994_set_dai_sysclk()
2536 wm8994->sysclk[dai->id - 1] = WM8994_SYSCLK_MCLK2; in wm8994_set_dai_sysclk()
2538 ret = wm8994_set_mclk_rate(wm8994, dai->id - 1, &freq); in wm8994_set_dai_sysclk()
2542 wm8994->mclk_rate[1] = freq; in wm8994_set_dai_sysclk()
2543 dev_dbg(dai->dev, "AIF%d using MCLK2 at %uHz\n", in wm8994_set_dai_sysclk()
2544 dai->id, freq); in wm8994_set_dai_sysclk()
2548 wm8994->sysclk[dai->id - 1] = WM8994_SYSCLK_FLL1; in wm8994_set_dai_sysclk()
2549 dev_dbg(dai->dev, "AIF%d using FLL1\n", dai->id); in wm8994_set_dai_sysclk()
2553 wm8994->sysclk[dai->id - 1] = WM8994_SYSCLK_FLL2; in wm8994_set_dai_sysclk()
2554 dev_dbg(dai->dev, "AIF%d using FLL2\n", dai->id); in wm8994_set_dai_sysclk()
2558 /* Special case - a division (times 10) is given and in wm8994_set_dai_sysclk()
2566 return -EINVAL; in wm8994_set_dai_sysclk()
2578 return -EINVAL; in wm8994_set_dai_sysclk()
2587 if (max(wm8994->aifclk[0], wm8994->aifclk[1]) < 50000) { in wm8994_set_dai_sysclk()
2588 dev_dbg(component->dev, "Configuring AIFs for 128fs\n"); in wm8994_set_dai_sysclk()
2590 wm8994->aifdiv[0] = snd_soc_component_read(component, WM8994_AIF1_RATE) in wm8994_set_dai_sysclk()
2592 wm8994->aifdiv[1] = snd_soc_component_read(component, WM8994_AIF2_RATE) in wm8994_set_dai_sysclk()
2599 } else if (wm8994->aifdiv[0]) { in wm8994_set_dai_sysclk()
2602 wm8994->aifdiv[0]); in wm8994_set_dai_sysclk()
2605 wm8994->aifdiv[1]); in wm8994_set_dai_sysclk()
2607 wm8994->aifdiv[0] = 0; in wm8994_set_dai_sysclk()
2608 wm8994->aifdiv[1] = 0; in wm8994_set_dai_sysclk()
2618 struct wm8994 *control = wm8994->wm8994; in wm8994_set_bias_level()
2628 switch (control->type) { in wm8994_set_bias_level()
2646 switch (control->type) { in wm8994_set_bias_level()
2648 if (control->revision == 0) { in wm8994_set_bias_level()
2673 switch (control->type) { in wm8994_set_bias_level()
2690 wm8994->cur_fw = NULL; in wm8994_set_bias_level()
2706 if (wm8994->hubs.lineout1_se) { in wm8994_vmid_mode()
2712 if (wm8994->hubs.lineout2_se) { in wm8994_vmid_mode()
2721 wm8994->vmid_mode = mode; in wm8994_vmid_mode()
2729 if (wm8994->hubs.lineout1_se) { in wm8994_vmid_mode()
2735 if (wm8994->hubs.lineout2_se) { in wm8994_vmid_mode()
2742 wm8994->vmid_mode = mode; in wm8994_vmid_mode()
2749 return -EINVAL; in wm8994_vmid_mode()
2757 struct snd_soc_component *component = dai->component; in wm8994_set_dai_fmt()
2759 struct wm8994 *control = wm8994->wm8994; in wm8994_set_dai_fmt()
2768 switch (dai->id) { in wm8994_set_dai_fmt()
2782 return -EINVAL; in wm8994_set_dai_fmt()
2792 return -EINVAL; in wm8994_set_dai_fmt()
2812 return -EINVAL; in wm8994_set_dai_fmt()
2826 return -EINVAL; in wm8994_set_dai_fmt()
2848 return -EINVAL; in wm8994_set_dai_fmt()
2852 return -EINVAL; in wm8994_set_dai_fmt()
2856 * on WM8958 if it's in use so just do it all the time. */ in wm8994_set_dai_fmt()
2857 switch (control->type) { in wm8994_set_dai_fmt()
2860 if (dai->id == 2) in wm8994_set_dai_fmt()
2913 struct snd_soc_component *component = dai->component; in wm8994_hw_params()
2915 struct wm8994 *control = wm8994->wm8994; in wm8994_hw_params()
2916 struct wm8994_pdata *pdata = &control->pdata; in wm8994_hw_params()
2927 int id = dai->id - 1; in wm8994_hw_params()
2931 switch (dai->id) { in wm8994_hw_params()
2937 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || in wm8994_hw_params()
2938 wm8994->lrclk_shared[0]) { in wm8994_hw_params()
2942 dev_dbg(component->dev, "AIF1 using split LRCLK\n"); in wm8994_hw_params()
2950 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK || in wm8994_hw_params()
2951 wm8994->lrclk_shared[1]) { in wm8994_hw_params()
2955 dev_dbg(component->dev, "AIF2 using split LRCLK\n"); in wm8994_hw_params()
2959 return -EINVAL; in wm8994_hw_params()
2980 return -EINVAL; in wm8994_hw_params()
2983 wm8994->channels[id] = params_channels(params); in wm8994_hw_params()
2984 if (pdata->max_channels_clocked[id] && in wm8994_hw_params()
2985 wm8994->channels[id] > pdata->max_channels_clocked[id]) { in wm8994_hw_params()
2986 dev_dbg(dai->dev, "Constraining channels to %d from %d\n", in wm8994_hw_params()
2987 pdata->max_channels_clocked[id], wm8994->channels[id]); in wm8994_hw_params()
2988 wm8994->channels[id] = pdata->max_channels_clocked[id]; in wm8994_hw_params()
2991 switch (wm8994->channels[id]) { in wm8994_hw_params()
3006 return -EINVAL; in wm8994_hw_params()
3009 dev_dbg(dai->dev, "Sample rate is %dHz\n", srs[i].rate); in wm8994_hw_params()
3010 dev_dbg(dai->dev, "AIF%dCLK is %dHz, target BCLK %dHz\n", in wm8994_hw_params()
3011 dai->id, wm8994->aifclk[id], bclk_rate); in wm8994_hw_params()
3013 if (wm8994->channels[id] == 1 && in wm8994_hw_params()
3017 if (wm8994->aifclk[id] == 0) { in wm8994_hw_params()
3018 dev_err(dai->dev, "AIF%dCLK not configured\n", dai->id); in wm8994_hw_params()
3019 return -EINVAL; in wm8994_hw_params()
3025 - wm8994->aifclk[id]); in wm8994_hw_params()
3028 - wm8994->aifclk[id]); in wm8994_hw_params()
3034 dev_dbg(dai->dev, "Selected AIF%dCLK/fs = %d\n", in wm8994_hw_params()
3035 dai->id, fs_ratios[best]); in wm8994_hw_params()
3045 cur_val = (wm8994->aifclk[id] * 10 / bclk_divs[i]) - bclk_rate; in wm8994_hw_params()
3050 bclk_rate = wm8994->aifclk[id] * 10 / bclk_divs[best]; in wm8994_hw_params()
3051 dev_dbg(dai->dev, "Using BCLK_DIV %d for actual BCLK %dHz\n", in wm8994_hw_params()
3057 dev_err(dai->dev, "Unable to generate LRCLK from %dHz BCLK\n", in wm8994_hw_params()
3059 return -EINVAL; in wm8994_hw_params()
3061 dev_dbg(dai->dev, "Using LRCLK rate %d for actual LRCLK %dHz\n", in wm8994_hw_params()
3072 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in wm8994_hw_params()
3073 switch (dai->id) { in wm8994_hw_params()
3075 wm8994->dac_rates[0] = params_rate(params); in wm8994_hw_params()
3080 wm8994->dac_rates[1] = params_rate(params); in wm8994_hw_params()
3093 struct snd_soc_component *component = dai->component; in wm8994_aif3_hw_params()
3095 struct wm8994 *control = wm8994->wm8994; in wm8994_aif3_hw_params()
3099 switch (dai->id) { in wm8994_aif3_hw_params()
3101 switch (control->type) { in wm8994_aif3_hw_params()
3127 return -EINVAL; in wm8994_aif3_hw_params()
3136 struct snd_soc_component *component = codec_dai->component; in wm8994_aif_mute()
3140 switch (codec_dai->id) { in wm8994_aif_mute()
3148 return -EINVAL; in wm8994_aif_mute()
3163 struct snd_soc_component *component = codec_dai->component; in wm8994_set_tristate()
3166 switch (codec_dai->id) { in wm8994_set_tristate()
3176 return -EINVAL; in wm8994_set_tristate()
3189 struct snd_soc_component *component = dai->component; in wm8994_aif2_probe()
3234 .name = "wm8994-aif1",
3255 .name = "wm8994-aif2",
3276 .name = "wm8994-aif3",
3304 for (i = 0; i < ARRAY_SIZE(wm8994->fll); i++) { in wm8994_component_suspend()
3305 memcpy(&wm8994->fll_suspend[i], &wm8994->fll[i], in wm8994_component_suspend()
3309 dev_warn(component->dev, "Failed to stop FLL%d: %d\n", in wm8994_component_suspend()
3323 for (i = 0; i < ARRAY_SIZE(wm8994->fll); i++) { in wm8994_component_resume()
3324 if (!wm8994->fll_suspend[i].out) in wm8994_component_resume()
3328 wm8994->fll_suspend[i].src, in wm8994_component_resume()
3329 wm8994->fll_suspend[i].in, in wm8994_component_resume()
3330 wm8994->fll_suspend[i].out); in wm8994_component_resume()
3332 dev_warn(component->dev, "Failed to restore FLL%d: %d\n", in wm8994_component_resume()
3345 struct snd_soc_component *component = wm8994->hubs.component; in wm8994_handle_retune_mobile_pdata()
3346 struct wm8994 *control = wm8994->wm8994; in wm8994_handle_retune_mobile_pdata()
3347 struct wm8994_pdata *pdata = &control->pdata; in wm8994_handle_retune_mobile_pdata()
3350 wm8994->retune_mobile_enum, in wm8994_handle_retune_mobile_pdata()
3354 wm8994->retune_mobile_enum, in wm8994_handle_retune_mobile_pdata()
3358 wm8994->retune_mobile_enum, in wm8994_handle_retune_mobile_pdata()
3369 wm8994->num_retune_mobile_texts = 0; in wm8994_handle_retune_mobile_pdata()
3370 wm8994->retune_mobile_texts = NULL; in wm8994_handle_retune_mobile_pdata()
3371 for (i = 0; i < pdata->num_retune_mobile_cfgs; i++) { in wm8994_handle_retune_mobile_pdata()
3372 for (j = 0; j < wm8994->num_retune_mobile_texts; j++) { in wm8994_handle_retune_mobile_pdata()
3373 if (strcmp(pdata->retune_mobile_cfgs[i].name, in wm8994_handle_retune_mobile_pdata()
3374 wm8994->retune_mobile_texts[j]) == 0) in wm8994_handle_retune_mobile_pdata()
3378 if (j != wm8994->num_retune_mobile_texts) in wm8994_handle_retune_mobile_pdata()
3382 t = krealloc(wm8994->retune_mobile_texts, in wm8994_handle_retune_mobile_pdata()
3384 (wm8994->num_retune_mobile_texts + 1), in wm8994_handle_retune_mobile_pdata()
3390 t[wm8994->num_retune_mobile_texts] = in wm8994_handle_retune_mobile_pdata()
3391 pdata->retune_mobile_cfgs[i].name; in wm8994_handle_retune_mobile_pdata()
3394 wm8994->num_retune_mobile_texts++; in wm8994_handle_retune_mobile_pdata()
3395 wm8994->retune_mobile_texts = t; in wm8994_handle_retune_mobile_pdata()
3398 dev_dbg(component->dev, "Allocated %d unique ReTune Mobile names\n", in wm8994_handle_retune_mobile_pdata()
3399 wm8994->num_retune_mobile_texts); in wm8994_handle_retune_mobile_pdata()
3401 wm8994->retune_mobile_enum.items = wm8994->num_retune_mobile_texts; in wm8994_handle_retune_mobile_pdata()
3402 wm8994->retune_mobile_enum.texts = wm8994->retune_mobile_texts; in wm8994_handle_retune_mobile_pdata()
3404 ret = snd_soc_add_component_controls(wm8994->hubs.component, controls, in wm8994_handle_retune_mobile_pdata()
3407 dev_err(wm8994->hubs.component->dev, in wm8994_handle_retune_mobile_pdata()
3413 struct snd_soc_component *component = wm8994->hubs.component; in wm8994_handle_pdata()
3414 struct wm8994 *control = wm8994->wm8994; in wm8994_handle_pdata()
3415 struct wm8994_pdata *pdata = &control->pdata; in wm8994_handle_pdata()
3421 wm_hubs_handle_analogue_pdata(component, pdata->lineout1_diff, in wm8994_handle_pdata()
3422 pdata->lineout2_diff, in wm8994_handle_pdata()
3423 pdata->lineout1fb, in wm8994_handle_pdata()
3424 pdata->lineout2fb, in wm8994_handle_pdata()
3425 pdata->jd_scthr, in wm8994_handle_pdata()
3426 pdata->jd_thr, in wm8994_handle_pdata()
3427 pdata->micb1_delay, in wm8994_handle_pdata()
3428 pdata->micb2_delay, in wm8994_handle_pdata()
3429 pdata->micbias1_lvl, in wm8994_handle_pdata()
3430 pdata->micbias2_lvl); in wm8994_handle_pdata()
3432 dev_dbg(component->dev, "%d DRC configurations\n", pdata->num_drc_cfgs); in wm8994_handle_pdata()
3434 if (pdata->num_drc_cfgs) { in wm8994_handle_pdata()
3436 SOC_ENUM_EXT("AIF1DRC1 Mode", wm8994->drc_enum, in wm8994_handle_pdata()
3438 SOC_ENUM_EXT("AIF1DRC2 Mode", wm8994->drc_enum, in wm8994_handle_pdata()
3440 SOC_ENUM_EXT("AIF2DRC Mode", wm8994->drc_enum, in wm8994_handle_pdata()
3445 wm8994->drc_texts = devm_kcalloc(wm8994->hubs.component->dev, in wm8994_handle_pdata()
3446 pdata->num_drc_cfgs, sizeof(char *), GFP_KERNEL); in wm8994_handle_pdata()
3447 if (!wm8994->drc_texts) in wm8994_handle_pdata()
3450 for (i = 0; i < pdata->num_drc_cfgs; i++) in wm8994_handle_pdata()
3451 wm8994->drc_texts[i] = pdata->drc_cfgs[i].name; in wm8994_handle_pdata()
3453 wm8994->drc_enum.items = pdata->num_drc_cfgs; in wm8994_handle_pdata()
3454 wm8994->drc_enum.texts = wm8994->drc_texts; in wm8994_handle_pdata()
3456 ret = snd_soc_add_component_controls(wm8994->hubs.component, controls, in wm8994_handle_pdata()
3461 ret = snd_soc_add_component_controls(wm8994->hubs.component, in wm8994_handle_pdata()
3467 dev_err(wm8994->hubs.component->dev, in wm8994_handle_pdata()
3471 dev_dbg(component->dev, "%d ReTune Mobile configurations\n", in wm8994_handle_pdata()
3472 pdata->num_retune_mobile_cfgs); in wm8994_handle_pdata()
3474 if (pdata->num_retune_mobile_cfgs) in wm8994_handle_pdata()
3477 snd_soc_add_component_controls(wm8994->hubs.component, wm8994_eq_controls, in wm8994_handle_pdata()
3480 for (i = 0; i < ARRAY_SIZE(pdata->micbias); i++) { in wm8994_handle_pdata()
3481 if (pdata->micbias[i]) { in wm8994_handle_pdata()
3483 pdata->micbias[i] & 0xffff); in wm8994_handle_pdata()
3489 * wm8994_mic_detect - Enable microphone detection via the WM8994 IRQ
3493 * @micbias: microphone bias to detect on
3509 struct wm8994 *control = wm8994->wm8994; in wm8994_mic_detect()
3512 if (control->type != WM8994) { in wm8994_mic_detect()
3513 dev_warn(component->dev, "Not a WM8994\n"); in wm8994_mic_detect()
3514 return -EINVAL; in wm8994_mic_detect()
3517 pm_runtime_get_sync(component->dev); in wm8994_mic_detect()
3521 micdet = &wm8994->micdet[0]; in wm8994_mic_detect()
3528 micdet = &wm8994->micdet[1]; in wm8994_mic_detect()
3535 dev_warn(component->dev, "Invalid MICBIAS %d\n", micbias); in wm8994_mic_detect()
3536 return -EINVAL; in wm8994_mic_detect()
3540 dev_warn(component->dev, "Failed to configure MICBIAS%d: %d\n", in wm8994_mic_detect()
3543 dev_dbg(component->dev, "Configuring microphone detection on %d %p\n", in wm8994_mic_detect()
3547 micdet->jack = jack; in wm8994_mic_detect()
3548 micdet->detecting = true; in wm8994_mic_detect()
3551 if (wm8994->micdet[0].jack || wm8994->micdet[1].jack) in wm8994_mic_detect()
3566 pm_runtime_put(component->dev); in wm8994_mic_detect()
3577 struct regmap *regmap = priv->wm8994->regmap; in wm8994_mic_work()
3578 struct device *dev = priv->wm8994->dev; in wm8994_mic_work()
3597 if (priv->micdet[0].detecting) in wm8994_mic_work()
3601 if (priv->micdet[0].detecting) in wm8994_mic_work()
3607 priv->micdet[0].detecting = false; in wm8994_mic_work()
3609 priv->micdet[0].detecting = true; in wm8994_mic_work()
3611 snd_soc_jack_report(priv->micdet[0].jack, report, in wm8994_mic_work()
3616 if (priv->micdet[1].detecting) in wm8994_mic_work()
3620 if (priv->micdet[1].detecting) in wm8994_mic_work()
3626 priv->micdet[1].detecting = false; in wm8994_mic_work()
3628 priv->micdet[1].detecting = true; in wm8994_mic_work()
3630 snd_soc_jack_report(priv->micdet[1].jack, report, in wm8994_mic_work()
3639 struct snd_soc_component *component = priv->hubs.component; in wm8994_mic_irq()
3642 trace_snd_soc_jack_irq(dev_name(component->dev)); in wm8994_mic_irq()
3645 pm_wakeup_event(component->dev, 300); in wm8994_mic_irq()
3648 &priv->mic_work, msecs_to_jiffies(250)); in wm8994_mic_irq()
3659 if (!wm8994->jackdet) in wm1811_micd_stop()
3666 if (wm8994->wm8994->pdata.jd_ext_cap) in wm1811_micd_stop()
3694 snd_soc_jack_report(wm8994->micdet[0].jack, report, in wm8958_button_det()
3695 wm8994->btn_mask); in wm8958_button_det()
3703 struct device *dev = wm8994->wm8994->dev; in wm8958_open_circuit_work()
3705 mutex_lock(&wm8994->accdet_lock); in wm8958_open_circuit_work()
3707 wm1811_micd_stop(wm8994->hubs.component); in wm8958_open_circuit_work()
3711 wm8994->jack_mic = false; in wm8958_open_circuit_work()
3712 wm8994->mic_detecting = true; in wm8958_open_circuit_work()
3714 wm8958_micd_set_rate(wm8994->hubs.component); in wm8958_open_circuit_work()
3716 snd_soc_jack_report(wm8994->micdet[0].jack, 0, in wm8958_open_circuit_work()
3717 wm8994->btn_mask | in wm8958_open_circuit_work()
3720 mutex_unlock(&wm8994->accdet_lock); in wm8958_open_circuit_work()
3731 dev_dbg(component->dev, "Detected open circuit\n"); in wm8958_mic_id()
3734 &wm8994->open_circuit_work, in wm8958_mic_id()
3743 dev_dbg(component->dev, "Detected microphone\n"); in wm8958_mic_id()
3745 wm8994->mic_detecting = false; in wm8958_mic_id()
3746 wm8994->jack_mic = true; in wm8958_mic_id()
3750 snd_soc_jack_report(wm8994->micdet[0].jack, SND_JACK_HEADSET, in wm8958_mic_id()
3756 dev_dbg(component->dev, "Detected headphone\n"); in wm8958_mic_id()
3757 wm8994->mic_detecting = false; in wm8958_mic_id()
3764 snd_soc_jack_report(wm8994->micdet[0].jack, SND_JACK_HEADPHONE, in wm8958_mic_id()
3769 /* Deferred mic detection to allow for extra settling time */
3774 struct wm8994 *control = wm8994->wm8994; in wm1811_mic_work()
3775 struct snd_soc_component *component = wm8994->hubs.component; in wm1811_mic_work()
3778 pm_runtime_get_sync(component->dev); in wm1811_mic_work()
3781 if (control->pdata.jd_ext_cap) { in wm1811_mic_work()
3786 mutex_lock(&wm8994->accdet_lock); in wm1811_mic_work()
3788 dev_dbg(component->dev, "Starting mic detection\n"); in wm1811_mic_work()
3790 /* Use a user-supplied callback if we have one */ in wm1811_mic_work()
3791 if (wm8994->micd_cb) { in wm1811_mic_work()
3792 wm8994->micd_cb(wm8994->micd_cb_data); in wm1811_mic_work()
3795 * Start off measument of microphone impedence to find out in wm1811_mic_work()
3798 wm8994->mic_detecting = true; in wm1811_mic_work()
3805 mutex_unlock(&wm8994->accdet_lock); in wm1811_mic_work()
3807 pm_runtime_put(component->dev); in wm1811_mic_work()
3813 struct wm8994 *control = wm8994->wm8994; in wm1811_jackdet_irq()
3814 struct snd_soc_component *component = wm8994->hubs.component; in wm1811_jackdet_irq()
3819 pm_runtime_get_sync(component->dev); in wm1811_jackdet_irq()
3821 cancel_delayed_work_sync(&wm8994->mic_complete_work); in wm1811_jackdet_irq()
3823 mutex_lock(&wm8994->accdet_lock); in wm1811_jackdet_irq()
3827 dev_err(component->dev, "Failed to read jack status: %d\n", reg); in wm1811_jackdet_irq()
3828 mutex_unlock(&wm8994->accdet_lock); in wm1811_jackdet_irq()
3829 pm_runtime_put(component->dev); in wm1811_jackdet_irq()
3833 dev_dbg(component->dev, "JACKDET %x\n", reg); in wm1811_jackdet_irq()
3838 dev_dbg(component->dev, "Jack detected\n"); in wm1811_jackdet_irq()
3849 delay = control->pdata.micdet_delay; in wm1811_jackdet_irq()
3851 &wm8994->mic_work, in wm1811_jackdet_irq()
3854 dev_dbg(component->dev, "Jack not detected\n"); in wm1811_jackdet_irq()
3856 /* Release wm8994->accdet_lock to avoid deadlock: in wm1811_jackdet_irq()
3857 * cancel_delayed_work_sync() takes wm8994->mic_work internal in wm1811_jackdet_irq()
3858 * lock and wm1811_mic_work takes wm8994->accdet_lock */ in wm1811_jackdet_irq()
3859 mutex_unlock(&wm8994->accdet_lock); in wm1811_jackdet_irq()
3860 cancel_delayed_work_sync(&wm8994->mic_work); in wm1811_jackdet_irq()
3861 mutex_lock(&wm8994->accdet_lock); in wm1811_jackdet_irq()
3870 wm8994->mic_detecting = false; in wm1811_jackdet_irq()
3871 wm8994->jack_mic = false; in wm1811_jackdet_irq()
3877 mutex_unlock(&wm8994->accdet_lock); in wm1811_jackdet_irq()
3880 if (control->pdata.jd_ext_cap && !present) in wm1811_jackdet_irq()
3884 snd_soc_jack_report(wm8994->micdet[0].jack, in wm1811_jackdet_irq()
3887 snd_soc_jack_report(wm8994->micdet[0].jack, 0, in wm1811_jackdet_irq()
3889 wm8994->btn_mask); in wm1811_jackdet_irq()
3893 snd_soc_jack_report(wm8994->micdet[0].jack, 0, 0); in wm1811_jackdet_irq()
3895 pm_runtime_put(component->dev); in wm1811_jackdet_irq()
3908 * wm8958_mic_detect - Enable microphone detection via the WM8958 IRQ
3933 struct wm8994 *control = wm8994->wm8994; in wm8958_mic_detect()
3936 switch (control->type) { in wm8958_mic_detect()
3941 return -EINVAL; in wm8958_mic_detect()
3944 pm_runtime_get_sync(component->dev); in wm8958_mic_detect()
3950 wm8994->micdet[0].jack = jack; in wm8958_mic_detect()
3953 wm8994->micd_cb = det_cb; in wm8958_mic_detect()
3954 wm8994->micd_cb_data = det_cb_data; in wm8958_mic_detect()
3956 wm8994->mic_detecting = true; in wm8958_mic_detect()
3957 wm8994->jack_mic = false; in wm8958_mic_detect()
3961 wm8994->mic_id_cb = id_cb; in wm8958_mic_detect()
3962 wm8994->mic_id_cb_data = id_cb_data; in wm8958_mic_detect()
3964 wm8994->mic_id_cb = wm8958_mic_id; in wm8958_mic_detect()
3965 wm8994->mic_id_cb_data = component; in wm8958_mic_detect()
3971 if (control->pdata.micd_lvl_sel) in wm8958_mic_detect()
3972 micd_lvl_sel = control->pdata.micd_lvl_sel; in wm8958_mic_detect()
3976 wm8994->btn_mask = SND_JACK_BTN_0 | SND_JACK_BTN_1 | in wm8958_mic_detect()
3986 * If we can use jack detection start off with that, in wm8958_mic_detect()
3989 if (wm8994->jackdet) { in wm8958_mic_detect()
4014 pm_runtime_put(component->dev); in wm8958_mic_detect()
4025 struct snd_soc_component *component = wm8994->hubs.component; in wm8958_mic_work()
4027 pm_runtime_get_sync(component->dev); in wm8958_mic_work()
4029 mutex_lock(&wm8994->accdet_lock); in wm8958_mic_work()
4031 wm8994->mic_id_cb(wm8994->mic_id_cb_data, wm8994->mic_status); in wm8958_mic_work()
4033 mutex_unlock(&wm8994->accdet_lock); in wm8958_mic_work()
4035 pm_runtime_put(component->dev); in wm8958_mic_work()
4041 struct snd_soc_component *component = wm8994->hubs.component; in wm8958_mic_irq()
4052 cancel_delayed_work_sync(&wm8994->mic_complete_work); in wm8958_mic_irq()
4053 cancel_delayed_work_sync(&wm8994->open_circuit_work); in wm8958_mic_irq()
4055 pm_runtime_get_sync(component->dev); in wm8958_mic_irq()
4058 * range being provided - if that happens loop again. in wm8958_mic_irq()
4064 dev_err(component->dev, in wm8958_mic_irq()
4067 pm_runtime_put(component->dev); in wm8958_mic_irq()
4072 dev_dbg(component->dev, "Mic detect data not valid\n"); in wm8958_mic_irq()
4080 } while (count--); in wm8958_mic_irq()
4083 dev_warn(component->dev, "No impedance range reported for jack\n"); in wm8958_mic_irq()
4086 trace_snd_soc_jack_irq(dev_name(component->dev)); in wm8958_mic_irq()
4090 if (wm8994->jackdet) { in wm8958_mic_irq()
4093 dev_err(component->dev, "Failed to read jack status: %d\n", in wm8958_mic_irq()
4096 dev_dbg(component->dev, "Ignoring removed jack\n"); in wm8958_mic_irq()
4100 snd_soc_jack_report(wm8994->micdet[0].jack, 0, in wm8958_mic_irq()
4102 wm8994->btn_mask); in wm8958_mic_irq()
4103 wm8994->mic_detecting = true; in wm8958_mic_irq()
4107 wm8994->mic_status = reg; in wm8958_mic_irq()
4108 id_delay = wm8994->wm8994->pdata.mic_id_delay; in wm8958_mic_irq()
4110 if (wm8994->mic_detecting) in wm8958_mic_irq()
4112 &wm8994->mic_complete_work, in wm8958_mic_irq()
4118 pm_runtime_put(component->dev); in wm8958_mic_irq()
4126 dev_err(component->dev, "FIFO error\n"); in wm8994_fifo_error()
4135 dev_err(component->dev, "Thermal warning\n"); in wm8994_temp_warn()
4144 dev_crit(component->dev, "Thermal shutdown\n"); in wm8994_temp_shut()
4152 struct wm8994 *control = dev_get_drvdata(component->dev->parent); in wm8994_component_probe()
4157 snd_soc_component_init_regmap(component, control->regmap); in wm8994_component_probe()
4159 wm8994->hubs.component = component; in wm8994_component_probe()
4161 mutex_init(&wm8994->accdet_lock); in wm8994_component_probe()
4162 INIT_DELAYED_WORK(&wm8994->jackdet_bootstrap, in wm8994_component_probe()
4164 INIT_DELAYED_WORK(&wm8994->open_circuit_work, in wm8994_component_probe()
4167 switch (control->type) { in wm8994_component_probe()
4169 INIT_DELAYED_WORK(&wm8994->mic_work, wm8994_mic_work); in wm8994_component_probe()
4172 INIT_DELAYED_WORK(&wm8994->mic_work, wm1811_mic_work); in wm8994_component_probe()
4178 INIT_DELAYED_WORK(&wm8994->mic_complete_work, wm8958_mic_work); in wm8994_component_probe()
4180 for (i = 0; i < ARRAY_SIZE(wm8994->fll_locked); i++) in wm8994_component_probe()
4181 init_completion(&wm8994->fll_locked[i]); in wm8994_component_probe()
4183 wm8994->micdet_irq = control->pdata.micdet_irq; in wm8994_component_probe()
4186 dapm->idle_bias_off = 1; in wm8994_component_probe()
4188 /* Set revision-specific configuration */ in wm8994_component_probe()
4189 switch (control->type) { in wm8994_component_probe()
4192 if (!control->pdata.lineout1_diff || in wm8994_component_probe()
4193 !control->pdata.lineout2_diff) in wm8994_component_probe()
4194 dapm->idle_bias_off = 0; in wm8994_component_probe()
4196 switch (control->revision) { in wm8994_component_probe()
4199 wm8994->hubs.dcs_codes_l = -5; in wm8994_component_probe()
4200 wm8994->hubs.dcs_codes_r = -5; in wm8994_component_probe()
4201 wm8994->hubs.hp_startup_mode = 1; in wm8994_component_probe()
4202 wm8994->hubs.dcs_readback_mode = 1; in wm8994_component_probe()
4203 wm8994->hubs.series_startup = 1; in wm8994_component_probe()
4206 wm8994->hubs.dcs_readback_mode = 2; in wm8994_component_probe()
4209 wm8994->hubs.micd_scthr = true; in wm8994_component_probe()
4213 wm8994->hubs.dcs_readback_mode = 1; in wm8994_component_probe()
4214 wm8994->hubs.hp_startup_mode = 1; in wm8994_component_probe()
4215 wm8994->hubs.micd_scthr = true; in wm8994_component_probe()
4217 switch (control->revision) { in wm8994_component_probe()
4221 wm8994->fll_byp = true; in wm8994_component_probe()
4227 wm8994->hubs.dcs_readback_mode = 2; in wm8994_component_probe()
4228 wm8994->hubs.no_series_update = 1; in wm8994_component_probe()
4229 wm8994->hubs.hp_startup_mode = 1; in wm8994_component_probe()
4230 wm8994->hubs.no_cache_dac_hp_direct = true; in wm8994_component_probe()
4231 wm8994->fll_byp = true; in wm8994_component_probe()
4233 wm8994->hubs.dcs_codes_l = -9; in wm8994_component_probe()
4234 wm8994->hubs.dcs_codes_r = -7; in wm8994_component_probe()
4244 wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_FIFOS_ERR, in wm8994_component_probe()
4246 wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_TEMP_WARN, in wm8994_component_probe()
4248 wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT, in wm8994_component_probe()
4251 switch (control->type) { in wm8994_component_probe()
4253 if (wm8994->micdet_irq) in wm8994_component_probe()
4254 ret = request_threaded_irq(wm8994->micdet_irq, NULL, in wm8994_component_probe()
4261 ret = wm8994_request_irq(wm8994->wm8994, in wm8994_component_probe()
4267 dev_warn(component->dev, in wm8994_component_probe()
4272 ret = wm8994_request_irq(wm8994->wm8994, in wm8994_component_probe()
4277 dev_warn(component->dev, in wm8994_component_probe()
4281 ret = wm8994_request_irq(wm8994->wm8994, in wm8994_component_probe()
4286 dev_warn(component->dev, in wm8994_component_probe()
4290 ret = wm8994_request_irq(wm8994->wm8994, in wm8994_component_probe()
4295 dev_warn(component->dev, in wm8994_component_probe()
4302 if (wm8994->micdet_irq) { in wm8994_component_probe()
4303 ret = request_threaded_irq(wm8994->micdet_irq, NULL, in wm8994_component_probe()
4310 dev_warn(component->dev, in wm8994_component_probe()
4314 wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_MIC1_DET, in wm8994_component_probe()
4320 switch (control->type) { in wm8994_component_probe()
4322 if (control->cust_id > 1 || control->revision > 1) { in wm8994_component_probe()
4323 ret = wm8994_request_irq(wm8994->wm8994, in wm8994_component_probe()
4328 wm8994->jackdet = true; in wm8994_component_probe()
4335 wm8994->fll_locked_irq = true; in wm8994_component_probe()
4336 for (i = 0; i < ARRAY_SIZE(wm8994->fll_locked); i++) { in wm8994_component_probe()
4337 ret = wm8994_request_irq(wm8994->wm8994, in wm8994_component_probe()
4340 &wm8994->fll_locked[i]); in wm8994_component_probe()
4342 wm8994->fll_locked_irq = false; in wm8994_component_probe()
4346 pm_runtime_get_sync(component->dev); in wm8994_component_probe()
4349 * configured on init - if a system wants to do this dynamically in wm8994_component_probe()
4352 ret = regmap_read(control->regmap, WM8994_GPIO_1, &reg); in wm8994_component_probe()
4354 dev_err(component->dev, "Failed to read GPIO1 state: %d\n", ret); in wm8994_component_probe()
4358 wm8994->lrclk_shared[0] = 1; in wm8994_component_probe()
4361 wm8994->lrclk_shared[0] = 0; in wm8994_component_probe()
4364 ret = regmap_read(control->regmap, WM8994_GPIO_6, &reg); in wm8994_component_probe()
4366 dev_err(component->dev, "Failed to read GPIO6 state: %d\n", ret); in wm8994_component_probe()
4370 wm8994->lrclk_shared[1] = 1; in wm8994_component_probe()
4373 wm8994->lrclk_shared[1] = 0; in wm8994_component_probe()
4376 pm_runtime_put(component->dev); in wm8994_component_probe()
4384 if (control->type != WM1811) { in wm8994_component_probe()
4406 switch (control->type) { in wm8994_component_probe()
4417 switch (control->type) { in wm8994_component_probe()
4429 wm8994->hubs.check_class_w_digital = wm8994_check_class_w_digital; in wm8994_component_probe()
4440 switch (control->type) { in wm8994_component_probe()
4446 if (control->revision < 4) { in wm8994_component_probe()
4469 if (control->revision < 1) { in wm8994_component_probe()
4501 ret = wm8994_request_irq(wm8994->wm8994, WM8994_IRQ_DCS_DONE, in wm8994_component_probe()
4503 &wm8994->hubs); in wm8994_component_probe()
4505 wm8994->hubs.dcs_done_irq = true; in wm8994_component_probe()
4508 switch (control->type) { in wm8994_component_probe()
4513 if (control->revision < 4) { in wm8994_component_probe()
4524 if (control->revision < 1) { in wm8994_component_probe()
4551 if (wm8994->jackdet) in wm8994_component_probe()
4552 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_GPIO(6), wm8994); in wm8994_component_probe()
4553 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_MIC2_SHRT, wm8994); in wm8994_component_probe()
4554 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_MIC2_DET, wm8994); in wm8994_component_probe()
4555 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_MIC1_SHRT, wm8994); in wm8994_component_probe()
4556 if (wm8994->micdet_irq) in wm8994_component_probe()
4557 free_irq(wm8994->micdet_irq, wm8994); in wm8994_component_probe()
4558 for (i = 0; i < ARRAY_SIZE(wm8994->fll_locked); i++) in wm8994_component_probe()
4559 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_FLL1_LOCK + i, in wm8994_component_probe()
4560 &wm8994->fll_locked[i]); in wm8994_component_probe()
4561 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_DCS_DONE, in wm8994_component_probe()
4562 &wm8994->hubs); in wm8994_component_probe()
4563 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_FIFOS_ERR, component); in wm8994_component_probe()
4564 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT, component); in wm8994_component_probe()
4565 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_WARN, component); in wm8994_component_probe()
4573 struct wm8994 *control = wm8994->wm8994; in wm8994_component_remove()
4576 for (i = 0; i < ARRAY_SIZE(wm8994->fll_locked); i++) in wm8994_component_remove()
4577 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_FLL1_LOCK + i, in wm8994_component_remove()
4578 &wm8994->fll_locked[i]); in wm8994_component_remove()
4580 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_DCS_DONE, in wm8994_component_remove()
4581 &wm8994->hubs); in wm8994_component_remove()
4582 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_FIFOS_ERR, component); in wm8994_component_remove()
4583 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_SHUT, component); in wm8994_component_remove()
4584 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_TEMP_WARN, component); in wm8994_component_remove()
4586 if (wm8994->jackdet) in wm8994_component_remove()
4587 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_GPIO(6), wm8994); in wm8994_component_remove()
4589 switch (control->type) { in wm8994_component_remove()
4591 if (wm8994->micdet_irq) in wm8994_component_remove()
4592 free_irq(wm8994->micdet_irq, wm8994); in wm8994_component_remove()
4593 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_MIC2_DET, in wm8994_component_remove()
4595 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_MIC1_SHRT, in wm8994_component_remove()
4597 wm8994_free_irq(wm8994->wm8994, WM8994_IRQ_MIC1_DET, in wm8994_component_remove()
4603 if (wm8994->micdet_irq) in wm8994_component_remove()
4604 free_irq(wm8994->micdet_irq, wm8994); in wm8994_component_remove()
4607 release_firmware(wm8994->mbc); in wm8994_component_remove()
4608 release_firmware(wm8994->mbc_vss); in wm8994_component_remove()
4609 release_firmware(wm8994->enh_eq); in wm8994_component_remove()
4610 kfree(wm8994->retune_mobile_texts); in wm8994_component_remove()
4629 wm8994 = devm_kzalloc(&pdev->dev, sizeof(struct wm8994_priv), in wm8994_probe()
4632 return -ENOMEM; in wm8994_probe()
4635 mutex_init(&wm8994->fw_lock); in wm8994_probe()
4637 wm8994->wm8994 = dev_get_drvdata(pdev->dev.parent); in wm8994_probe()
4639 wm8994->mclk[WM8994_MCLK1].id = "MCLK1"; in wm8994_probe()
4640 wm8994->mclk[WM8994_MCLK2].id = "MCLK2"; in wm8994_probe()
4642 ret = devm_clk_bulk_get_optional(pdev->dev.parent, ARRAY_SIZE(wm8994->mclk), in wm8994_probe()
4643 wm8994->mclk); in wm8994_probe()
4645 dev_err(&pdev->dev, "Failed to get clocks: %d\n", ret); in wm8994_probe()
4649 pm_runtime_enable(&pdev->dev); in wm8994_probe()
4650 pm_runtime_idle(&pdev->dev); in wm8994_probe()
4652 ret = devm_snd_soc_register_component(&pdev->dev, &soc_component_dev_wm8994, in wm8994_probe()
4655 pm_runtime_disable(&pdev->dev); in wm8994_probe()
4662 pm_runtime_disable(&pdev->dev); in wm8994_remove()
4671 if (wm8994->jackdet && !wm8994->active_refcount) in wm8994_suspend()
4672 regmap_update_bits(wm8994->wm8994->regmap, WM8994_ANTIPOP_2, in wm8994_suspend()
4674 wm8994->jackdet_mode); in wm8994_suspend()
4683 if (wm8994->jackdet && wm8994->jackdet_mode) in wm8994_resume()
4684 regmap_update_bits(wm8994->wm8994->regmap, WM8994_ANTIPOP_2, in wm8994_resume()
4698 .name = "wm8994-codec",
4710 MODULE_ALIAS("platform:wm8994-codec");