Lines Matching +full:mic +full:- +full:in +full:- +full:differential
1 // SPDX-License-Identifier: GPL-2.0-only
3 * wm8904.c -- WM8904 ALSA SoC Audio driver
5 * Copyright 2009-12 Wolfson Microelectronics plc
84 /* DC servo configuration - cached offset values */
89 { 4, 0x0018 }, /* R4 - Bias Control 0 */
90 { 5, 0x0000 }, /* R5 - VMID Control 0 */
91 { 6, 0x0000 }, /* R6 - Mic Bias Control 0 */
92 { 7, 0x0000 }, /* R7 - Mic Bias Control 1 */
93 { 8, 0x0001 }, /* R8 - Analogue DAC 0 */
94 { 9, 0x9696 }, /* R9 - mic Filter Control */
95 { 10, 0x0001 }, /* R10 - Analogue ADC 0 */
96 { 12, 0x0000 }, /* R12 - Power Management 0 */
97 { 14, 0x0000 }, /* R14 - Power Management 2 */
98 { 15, 0x0000 }, /* R15 - Power Management 3 */
99 { 18, 0x0000 }, /* R18 - Power Management 6 */
100 { 20, 0x945E }, /* R20 - Clock Rates 0 */
101 { 21, 0x0C05 }, /* R21 - Clock Rates 1 */
102 { 22, 0x0006 }, /* R22 - Clock Rates 2 */
103 { 24, 0x0050 }, /* R24 - Audio Interface 0 */
104 { 25, 0x000A }, /* R25 - Audio Interface 1 */
105 { 26, 0x00E4 }, /* R26 - Audio Interface 2 */
106 { 27, 0x0040 }, /* R27 - Audio Interface 3 */
107 { 30, 0x00C0 }, /* R30 - DAC Digital Volume Left */
108 { 31, 0x00C0 }, /* R31 - DAC Digital Volume Right */
109 { 32, 0x0000 }, /* R32 - DAC Digital 0 */
110 { 33, 0x0008 }, /* R33 - DAC Digital 1 */
111 { 36, 0x00C0 }, /* R36 - ADC Digital Volume Left */
112 { 37, 0x00C0 }, /* R37 - ADC Digital Volume Right */
113 { 38, 0x0010 }, /* R38 - ADC Digital 0 */
114 { 39, 0x0000 }, /* R39 - Digital Microphone 0 */
115 { 40, 0x01AF }, /* R40 - DRC 0 */
116 { 41, 0x3248 }, /* R41 - DRC 1 */
117 { 42, 0x0000 }, /* R42 - DRC 2 */
118 { 43, 0x0000 }, /* R43 - DRC 3 */
119 { 44, 0x0085 }, /* R44 - Analogue Left Input 0 */
120 { 45, 0x0085 }, /* R45 - Analogue Right Input 0 */
121 { 46, 0x0044 }, /* R46 - Analogue Left Input 1 */
122 { 47, 0x0044 }, /* R47 - Analogue Right Input 1 */
123 { 57, 0x002D }, /* R57 - Analogue OUT1 Left */
124 { 58, 0x002D }, /* R58 - Analogue OUT1 Right */
125 { 59, 0x0039 }, /* R59 - Analogue OUT2 Left */
126 { 60, 0x0039 }, /* R60 - Analogue OUT2 Right */
127 { 61, 0x0000 }, /* R61 - Analogue OUT12 ZC */
128 { 67, 0x0000 }, /* R67 - DC Servo 0 */
129 { 69, 0xAAAA }, /* R69 - DC Servo 2 */
130 { 71, 0xAAAA }, /* R71 - DC Servo 4 */
131 { 72, 0xAAAA }, /* R72 - DC Servo 5 */
132 { 90, 0x0000 }, /* R90 - Analogue HP 0 */
133 { 94, 0x0000 }, /* R94 - Analogue Lineout 0 */
134 { 98, 0x0000 }, /* R98 - Charge Pump 0 */
135 { 104, 0x0004 }, /* R104 - Class W 0 */
136 { 108, 0x0000 }, /* R108 - Write Sequencer 0 */
137 { 109, 0x0000 }, /* R109 - Write Sequencer 1 */
138 { 110, 0x0000 }, /* R110 - Write Sequencer 2 */
139 { 111, 0x0000 }, /* R111 - Write Sequencer 3 */
140 { 112, 0x0000 }, /* R112 - Write Sequencer 4 */
141 { 116, 0x0000 }, /* R116 - FLL Control 1 */
142 { 117, 0x0007 }, /* R117 - FLL Control 2 */
143 { 118, 0x0000 }, /* R118 - FLL Control 3 */
144 { 119, 0x2EE0 }, /* R119 - FLL Control 4 */
145 { 120, 0x0004 }, /* R120 - FLL Control 5 */
146 { 121, 0x0014 }, /* R121 - GPIO Control 1 */
147 { 122, 0x0010 }, /* R122 - GPIO Control 2 */
148 { 123, 0x0010 }, /* R123 - GPIO Control 3 */
149 { 124, 0x0000 }, /* R124 - GPIO Control 4 */
150 { 126, 0x0000 }, /* R126 - Digital Pulls */
151 { 128, 0xFFFF }, /* R128 - Interrupt Status Mask */
152 { 129, 0x0000 }, /* R129 - Interrupt Polarity */
153 { 130, 0x0000 }, /* R130 - Interrupt Debounce */
154 { 134, 0x0000 }, /* R134 - EQ1 */
155 { 135, 0x000C }, /* R135 - EQ2 */
156 { 136, 0x000C }, /* R136 - EQ3 */
157 { 137, 0x000C }, /* R137 - EQ4 */
158 { 138, 0x000C }, /* R138 - EQ5 */
159 { 139, 0x000C }, /* R139 - EQ6 */
160 { 140, 0x0FCA }, /* R140 - EQ7 */
161 { 141, 0x0400 }, /* R141 - EQ8 */
162 { 142, 0x00D8 }, /* R142 - EQ9 */
163 { 143, 0x1EB5 }, /* R143 - EQ10 */
164 { 144, 0xF145 }, /* R144 - EQ11 */
165 { 145, 0x0B75 }, /* R145 - EQ12 */
166 { 146, 0x01C5 }, /* R146 - EQ13 */
167 { 147, 0x1C58 }, /* R147 - EQ14 */
168 { 148, 0xF373 }, /* R148 - EQ15 */
169 { 149, 0x0A54 }, /* R149 - EQ16 */
170 { 150, 0x0558 }, /* R150 - EQ17 */
171 { 151, 0x168E }, /* R151 - EQ18 */
172 { 152, 0xF829 }, /* R152 - EQ19 */
173 { 153, 0x07AD }, /* R153 - EQ20 */
174 { 154, 0x1103 }, /* R154 - EQ21 */
175 { 155, 0x0564 }, /* R155 - EQ22 */
176 { 156, 0x0559 }, /* R156 - EQ23 */
177 { 157, 0x4000 }, /* R157 - EQ24 */
178 { 161, 0x0000 }, /* R161 - Control Interface Test 1 */
179 { 204, 0x0000 }, /* R204 - Analogue Output Bias 0 */
180 { 247, 0x0000 }, /* R247 - FLL NCO Test 0 */
181 { 248, 0x0019 }, /* R248 - FLL NCO Test 1 */
325 switch (wm8904->sysclk_src) { in wm8904_configure_clocking()
327 dev_dbg(component->dev, "Using %dHz MCLK\n", wm8904->mclk_rate); in wm8904_configure_clocking()
330 rate = wm8904->mclk_rate; in wm8904_configure_clocking()
338 dev_dbg(component->dev, "Using %dHz FLL clock\n", in wm8904_configure_clocking()
339 wm8904->fll_fout); in wm8904_configure_clocking()
342 rate = wm8904->fll_fout; in wm8904_configure_clocking()
346 dev_err(component->dev, "System clock not configured\n"); in wm8904_configure_clocking()
347 return -EINVAL; in wm8904_configure_clocking()
353 wm8904->sysclk_rate = rate / 2; in wm8904_configure_clocking()
356 wm8904->sysclk_rate = rate; in wm8904_configure_clocking()
365 dev_dbg(component->dev, "CLK_SYS is %dHz\n", wm8904->sysclk_rate); in wm8904_configure_clocking()
373 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_set_drc()
381 pdata->drc_cfgs[wm8904->drc_cfg].regs[i]); in wm8904_set_drc()
393 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_put_drc_enum()
394 int value = ucontrol->value.enumerated.item[0]; in wm8904_put_drc_enum()
396 if (value >= pdata->num_drc_cfgs) in wm8904_put_drc_enum()
397 return -EINVAL; in wm8904_put_drc_enum()
399 wm8904->drc_cfg = value; in wm8904_put_drc_enum()
412 ucontrol->value.enumerated.item[0] = wm8904->drc_cfg; in wm8904_get_drc_enum()
420 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_set_retune_mobile()
423 if (!pdata || !wm8904->num_retune_mobile_texts) in wm8904_set_retune_mobile()
428 cfg = wm8904->retune_mobile_cfg; in wm8904_set_retune_mobile()
431 for (i = 0; i < pdata->num_retune_mobile_cfgs; i++) { in wm8904_set_retune_mobile()
432 if (strcmp(pdata->retune_mobile_cfgs[i].name, in wm8904_set_retune_mobile()
433 wm8904->retune_mobile_texts[cfg]) == 0 && in wm8904_set_retune_mobile()
434 abs(pdata->retune_mobile_cfgs[i].rate in wm8904_set_retune_mobile()
435 - wm8904->fs) < best_val) { in wm8904_set_retune_mobile()
437 best_val = abs(pdata->retune_mobile_cfgs[i].rate in wm8904_set_retune_mobile()
438 - wm8904->fs); in wm8904_set_retune_mobile()
442 dev_dbg(component->dev, "ReTune Mobile %s/%dHz for %dHz sample rate\n", in wm8904_set_retune_mobile()
443 pdata->retune_mobile_cfgs[best].name, in wm8904_set_retune_mobile()
444 pdata->retune_mobile_cfgs[best].rate, in wm8904_set_retune_mobile()
445 wm8904->fs); in wm8904_set_retune_mobile()
454 pdata->retune_mobile_cfgs[best].regs[i]); in wm8904_set_retune_mobile()
464 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_put_retune_mobile_enum()
465 int value = ucontrol->value.enumerated.item[0]; in wm8904_put_retune_mobile_enum()
467 if (value >= pdata->num_retune_mobile_cfgs) in wm8904_put_retune_mobile_enum()
468 return -EINVAL; in wm8904_put_retune_mobile_enum()
470 wm8904->retune_mobile_cfg = value; in wm8904_put_retune_mobile_enum()
483 ucontrol->value.enumerated.item[0] = wm8904->retune_mobile_cfg; in wm8904_get_retune_mobile_enum()
498 if (wm8904->deemph) { in wm8904_set_deemph()
501 if (abs(deemph_settings[i] - wm8904->fs) < in wm8904_set_deemph()
502 abs(deemph_settings[best] - wm8904->fs)) in wm8904_set_deemph()
511 dev_dbg(component->dev, "Set deemphasis %d\n", val); in wm8904_set_deemph()
523 ucontrol->value.integer.value[0] = wm8904->deemph; in wm8904_get_deemph()
532 unsigned int deemph = ucontrol->value.integer.value[0]; in wm8904_put_deemph()
535 return -EINVAL; in wm8904_put_deemph()
537 wm8904->deemph = deemph; in wm8904_put_deemph()
543 static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1);
544 static const DECLARE_TLV_DB_SCALE(out_tlv, -5700, 100, 0);
545 static const DECLARE_TLV_DB_SCALE(sidetone_tlv, -3600, 300, 0);
546 static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
549 "Hi-fi", "Voice 1", "Voice 2", "Voice 3"
566 if (ucontrol->value.integer.value[0]) in wm8904_adc_osr_put()
645 return -EINVAL; in cp_event()
656 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in sysclk_event()
666 switch (wm8904->sysclk_src) { in sysclk_event()
694 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in out_pga_event()
704 * power management in stereo pairs to avoid latency issues so in out_pga_event()
707 reg = w->shift; in out_pga_event()
728 return -EINVAL; in out_pga_event()
756 if (wm8904->dcs_state[dcs_l] || wm8904->dcs_state[dcs_r]) { in out_pga_event()
757 dev_dbg(component->dev, "Restoring DC servo state\n"); in out_pga_event()
760 wm8904->dcs_state[dcs_l]); in out_pga_event()
762 wm8904->dcs_state[dcs_r]); in out_pga_event()
768 dev_dbg(component->dev, "Calibrating DC servo\n"); in out_pga_event()
784 } while (--timeout); in out_pga_event()
787 dev_warn(component->dev, "DC servo timed out\n"); in out_pga_event()
789 dev_dbg(component->dev, "DC servo ready\n"); in out_pga_event()
817 wm8904->dcs_state[dcs_l] = snd_soc_component_read(component, dcs_l_reg); in out_pga_event()
818 wm8904->dcs_state[dcs_r] = snd_soc_component_read(component, dcs_r_reg); in out_pga_event()
841 "Single-Ended", "Differential Line", "Differential Mic"
1065 { "Left Capture Mode", "Single-Ended", "Left Capture Inverting Mux" },
1066 { "Left Capture Mode", "Differential Line", "Left Capture Mux" },
1067 { "Left Capture Mode", "Differential Line", "Left Capture Inverting Mux" },
1068 { "Left Capture Mode", "Differential Mic", "Left Capture Mux" },
1069 { "Left Capture Mode", "Differential Mic", "Left Capture Inverting Mux" },
1079 { "Right Capture Mode", "Single-Ended", "Right Capture Inverting Mux" },
1080 { "Right Capture Mode", "Differential Line", "Right Capture Mux" },
1081 { "Right Capture Mode", "Differential Line", "Right Capture Inverting Mux" },
1082 { "Right Capture Mode", "Differential Mic", "Right Capture Mux" },
1083 { "Right Capture Mode", "Differential Mic", "Right Capture Inverting Mux" },
1187 switch (wm8904->devtype) { in wm8904_add_widgets()
1290 struct snd_soc_component *component = dai->component; in wm8904_hw_params()
1300 wm8904->fs = params_rate(params); in wm8904_hw_params()
1301 if (wm8904->tdm_slots) { in wm8904_hw_params()
1302 dev_dbg(component->dev, "Configuring for %d %d bit TDM slots\n", in wm8904_hw_params()
1303 wm8904->tdm_slots, wm8904->tdm_width); in wm8904_hw_params()
1304 wm8904->bclk = snd_soc_calc_bclk(wm8904->fs, in wm8904_hw_params()
1305 wm8904->tdm_width, 2, in wm8904_hw_params()
1306 wm8904->tdm_slots); in wm8904_hw_params()
1308 wm8904->bclk = snd_soc_params_to_bclk(params); in wm8904_hw_params()
1324 return -EINVAL; in wm8904_hw_params()
1328 dev_dbg(component->dev, "Target BCLK is %dHz\n", wm8904->bclk); in wm8904_hw_params()
1336 best_val = abs((wm8904->sysclk_rate / clk_sys_rates[0].ratio) in wm8904_hw_params()
1337 - wm8904->fs); in wm8904_hw_params()
1339 cur_val = abs((wm8904->sysclk_rate / in wm8904_hw_params()
1340 clk_sys_rates[i].ratio) - wm8904->fs); in wm8904_hw_params()
1346 dev_dbg(component->dev, "Selected CLK_SYS_RATIO of %d\n", in wm8904_hw_params()
1353 best_val = abs(wm8904->fs - sample_rates[0].rate); in wm8904_hw_params()
1356 cur_val = abs(wm8904->fs - sample_rates[i].rate); in wm8904_hw_params()
1362 dev_dbg(component->dev, "Selected SAMPLE_RATE of %dHz\n", in wm8904_hw_params()
1368 if (wm8904->fs <= 24000) in wm8904_hw_params()
1375 cur_val = ((wm8904->sysclk_rate * 10) / bclk_divs[i].div) in wm8904_hw_params()
1376 - wm8904->bclk; in wm8904_hw_params()
1384 wm8904->bclk = (wm8904->sysclk_rate * 10) / bclk_divs[best].div; in wm8904_hw_params()
1385 dev_dbg(component->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n", in wm8904_hw_params()
1386 bclk_divs[best].div, wm8904->bclk); in wm8904_hw_params()
1390 dev_dbg(component->dev, "LRCLK_RATE is %d\n", wm8904->bclk / wm8904->fs); in wm8904_hw_params()
1391 aif3 |= wm8904->bclk / wm8904->fs; in wm8904_hw_params()
1415 struct snd_soc_component *component = dai->component; in wm8904_set_fmt()
1433 return -EINVAL; in wm8904_set_fmt()
1452 return -EINVAL; in wm8904_set_fmt()
1466 return -EINVAL; in wm8904_set_fmt()
1486 return -EINVAL; in wm8904_set_fmt()
1490 return -EINVAL; in wm8904_set_fmt()
1506 struct snd_soc_component *component = dai->component; in wm8904_set_tdm_slot()
1514 /* Note that we allow configurations we can't handle ourselves - in wm8904_set_tdm_slot()
1527 return -EINVAL; in wm8904_set_tdm_slot()
1538 return -EINVAL; in wm8904_set_tdm_slot()
1542 wm8904->tdm_width = slot_width; in wm8904_set_tdm_slot()
1543 wm8904->tdm_slots = slots / 2; in wm8904_set_tdm_slot()
1560 /* The size in bits of the FLL divide multiplied by 10
1587 fll_div->fll_clk_ref_div = 0; in fll_factors()
1590 fll_div->fll_clk_ref_div++; in fll_factors()
1595 return -EINVAL; in fll_factors()
1604 /* Fvco should be 90-100MHz; don't check the upper bound */ in fll_factors()
1611 return -EINVAL; in fll_factors()
1615 fll_div->fll_outdiv = div - 1; in fll_factors()
1622 fll_div->fll_fratio = fll_fratios[i].fll_fratio; in fll_factors()
1629 return -EINVAL; in fll_factors()
1635 fll_div->n = Ndiv; in fll_factors()
1639 /* Calculate fractional part - scale up so we can round. */ in fll_factors()
1650 fll_div->k = K / 10; in fll_factors()
1653 fll_div->n, fll_div->k, in fll_factors()
1654 fll_div->fll_fratio, fll_div->fll_outdiv, in fll_factors()
1655 fll_div->fll_clk_ref_div); in fll_factors()
1663 struct snd_soc_component *component = dai->component; in wm8904_set_fll()
1670 if (source == wm8904->fll_src && Fref == wm8904->fll_fref && in wm8904_set_fll()
1671 Fout == wm8904->fll_fout) in wm8904_set_fll()
1677 dev_dbg(component->dev, "FLL disabled\n"); in wm8904_set_fll()
1679 wm8904->fll_fref = 0; in wm8904_set_fll()
1680 wm8904->fll_fout = 0; in wm8904_set_fll()
1703 dev_dbg(component->dev, "Using free running FLL\n"); in wm8904_set_fll()
1713 dev_err(component->dev, "Unknown FLL ID %d\n", fll_id); in wm8904_set_fll()
1714 return -EINVAL; in wm8904_set_fll()
1779 dev_dbg(component->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); in wm8904_set_fll()
1781 wm8904->fll_fref = Fref; in wm8904_set_fll()
1782 wm8904->fll_fout = Fout; in wm8904_set_fll()
1783 wm8904->fll_src = source; in wm8904_set_fll()
1802 struct snd_soc_component *component = dai->component; in wm8904_set_sysclk()
1815 mclk_freq = clk_get_rate(priv->mclk); in wm8904_set_sysclk()
1818 priv->sysclk_src = WM8904_CLK_FLL; in wm8904_set_sysclk()
1830 priv->sysclk_src = clk_id; in wm8904_set_sysclk()
1831 priv->mclk_rate = freq; in wm8904_set_sysclk()
1835 priv->sysclk_src = clk_id; in wm8904_set_sysclk()
1839 return -EINVAL; in wm8904_set_sysclk()
1842 dev_dbg(dai->dev, "Clock source is %d at %uHz\n", clk_id, freq); in wm8904_set_sysclk()
1851 struct snd_soc_component *component = codec_dai->component; in wm8904_mute()
1887 ret = regulator_bulk_enable(ARRAY_SIZE(wm8904->supplies), in wm8904_set_bias_level()
1888 wm8904->supplies); in wm8904_set_bias_level()
1890 dev_err(component->dev, in wm8904_set_bias_level()
1896 ret = clk_prepare_enable(wm8904->mclk); in wm8904_set_bias_level()
1898 dev_err(component->dev, in wm8904_set_bias_level()
1900 regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), in wm8904_set_bias_level()
1901 wm8904->supplies); in wm8904_set_bias_level()
1905 regcache_cache_only(wm8904->regmap, false); in wm8904_set_bias_level()
1906 regcache_sync(wm8904->regmap); in wm8904_set_bias_level()
1943 regcache_cache_only(wm8904->regmap, true); in wm8904_set_bias_level()
1944 regcache_mark_dirty(wm8904->regmap); in wm8904_set_bias_level()
1946 regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), in wm8904_set_bias_level()
1947 wm8904->supplies); in wm8904_set_bias_level()
1948 clk_disable_unprepare(wm8904->mclk); in wm8904_set_bias_level()
1970 .name = "wm8904-hifi",
1992 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_handle_retune_mobile_pdata()
1995 wm8904->retune_mobile_enum, in wm8904_handle_retune_mobile_pdata()
2005 wm8904->num_retune_mobile_texts = 0; in wm8904_handle_retune_mobile_pdata()
2006 wm8904->retune_mobile_texts = NULL; in wm8904_handle_retune_mobile_pdata()
2007 for (i = 0; i < pdata->num_retune_mobile_cfgs; i++) { in wm8904_handle_retune_mobile_pdata()
2008 for (j = 0; j < wm8904->num_retune_mobile_texts; j++) { in wm8904_handle_retune_mobile_pdata()
2009 if (strcmp(pdata->retune_mobile_cfgs[i].name, in wm8904_handle_retune_mobile_pdata()
2010 wm8904->retune_mobile_texts[j]) == 0) in wm8904_handle_retune_mobile_pdata()
2014 if (j != wm8904->num_retune_mobile_texts) in wm8904_handle_retune_mobile_pdata()
2018 t = krealloc(wm8904->retune_mobile_texts, in wm8904_handle_retune_mobile_pdata()
2020 (wm8904->num_retune_mobile_texts + 1), in wm8904_handle_retune_mobile_pdata()
2026 t[wm8904->num_retune_mobile_texts] = in wm8904_handle_retune_mobile_pdata()
2027 pdata->retune_mobile_cfgs[i].name; in wm8904_handle_retune_mobile_pdata()
2030 wm8904->num_retune_mobile_texts++; in wm8904_handle_retune_mobile_pdata()
2031 wm8904->retune_mobile_texts = t; in wm8904_handle_retune_mobile_pdata()
2034 dev_dbg(component->dev, "Allocated %d unique ReTune Mobile names\n", in wm8904_handle_retune_mobile_pdata()
2035 wm8904->num_retune_mobile_texts); in wm8904_handle_retune_mobile_pdata()
2037 wm8904->retune_mobile_enum.items = wm8904->num_retune_mobile_texts; in wm8904_handle_retune_mobile_pdata()
2038 wm8904->retune_mobile_enum.texts = wm8904->retune_mobile_texts; in wm8904_handle_retune_mobile_pdata()
2042 dev_err(component->dev, in wm8904_handle_retune_mobile_pdata()
2049 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_handle_pdata()
2058 dev_dbg(component->dev, "%d DRC configurations\n", pdata->num_drc_cfgs); in wm8904_handle_pdata()
2060 if (pdata->num_drc_cfgs) { in wm8904_handle_pdata()
2062 SOC_ENUM_EXT("DRC Mode", wm8904->drc_enum, in wm8904_handle_pdata()
2066 wm8904->drc_texts = kmalloc_array(pdata->num_drc_cfgs, in wm8904_handle_pdata()
2069 if (!wm8904->drc_texts) in wm8904_handle_pdata()
2072 for (i = 0; i < pdata->num_drc_cfgs; i++) in wm8904_handle_pdata()
2073 wm8904->drc_texts[i] = pdata->drc_cfgs[i].name; in wm8904_handle_pdata()
2075 wm8904->drc_enum.items = pdata->num_drc_cfgs; in wm8904_handle_pdata()
2076 wm8904->drc_enum.texts = wm8904->drc_texts; in wm8904_handle_pdata()
2080 dev_err(component->dev, in wm8904_handle_pdata()
2086 dev_dbg(component->dev, "%d ReTune Mobile configurations\n", in wm8904_handle_pdata()
2087 pdata->num_retune_mobile_cfgs); in wm8904_handle_pdata()
2089 if (pdata->num_retune_mobile_cfgs) in wm8904_handle_pdata()
2101 switch (wm8904->devtype) { in wm8904_probe()
2108 dev_err(component->dev, "Unknown device type %d\n", in wm8904_probe()
2109 wm8904->devtype); in wm8904_probe()
2110 return -EINVAL; in wm8904_probe()
2124 kfree(wm8904->retune_mobile_texts); in wm8904_remove()
2125 kfree(wm8904->drc_texts); in wm8904_remove()
2172 wm8904 = devm_kzalloc(&i2c->dev, sizeof(struct wm8904_priv), in wm8904_i2c_probe()
2175 return -ENOMEM; in wm8904_i2c_probe()
2177 wm8904->mclk = devm_clk_get(&i2c->dev, "mclk"); in wm8904_i2c_probe()
2178 if (IS_ERR(wm8904->mclk)) { in wm8904_i2c_probe()
2179 ret = PTR_ERR(wm8904->mclk); in wm8904_i2c_probe()
2180 dev_err(&i2c->dev, "Failed to get MCLK\n"); in wm8904_i2c_probe()
2184 wm8904->regmap = devm_regmap_init_i2c(i2c, &wm8904_regmap); in wm8904_i2c_probe()
2185 if (IS_ERR(wm8904->regmap)) { in wm8904_i2c_probe()
2186 ret = PTR_ERR(wm8904->regmap); in wm8904_i2c_probe()
2187 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in wm8904_i2c_probe()
2192 if (i2c->dev.of_node) { in wm8904_i2c_probe()
2195 match = of_match_node(wm8904_of_match, i2c->dev.of_node); in wm8904_i2c_probe()
2197 return -EINVAL; in wm8904_i2c_probe()
2198 wm8904->devtype = (enum wm8904_type)match->data; in wm8904_i2c_probe()
2202 wm8904->devtype = id->driver_data; in wm8904_i2c_probe()
2206 wm8904->pdata = i2c->dev.platform_data; in wm8904_i2c_probe()
2208 for (i = 0; i < ARRAY_SIZE(wm8904->supplies); i++) in wm8904_i2c_probe()
2209 wm8904->supplies[i].supply = wm8904_supply_names[i]; in wm8904_i2c_probe()
2211 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8904->supplies), in wm8904_i2c_probe()
2212 wm8904->supplies); in wm8904_i2c_probe()
2214 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); in wm8904_i2c_probe()
2218 ret = regulator_bulk_enable(ARRAY_SIZE(wm8904->supplies), in wm8904_i2c_probe()
2219 wm8904->supplies); in wm8904_i2c_probe()
2221 dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); in wm8904_i2c_probe()
2225 ret = regmap_read(wm8904->regmap, WM8904_SW_RESET_AND_ID, &val); in wm8904_i2c_probe()
2227 dev_err(&i2c->dev, "Failed to read ID register: %d\n", ret); in wm8904_i2c_probe()
2231 dev_err(&i2c->dev, "Device is not a WM8904, ID is %x\n", val); in wm8904_i2c_probe()
2232 ret = -EINVAL; in wm8904_i2c_probe()
2236 ret = regmap_read(wm8904->regmap, WM8904_REVISION, &val); in wm8904_i2c_probe()
2238 dev_err(&i2c->dev, "Failed to read device revision: %d\n", in wm8904_i2c_probe()
2242 dev_info(&i2c->dev, "revision %c\n", val + 'A'); in wm8904_i2c_probe()
2244 ret = regmap_write(wm8904->regmap, WM8904_SW_RESET_AND_ID, 0); in wm8904_i2c_probe()
2246 dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret); in wm8904_i2c_probe()
2250 /* Change some default settings - latch VU and enable ZC */ in wm8904_i2c_probe()
2251 regmap_update_bits(wm8904->regmap, WM8904_ADC_DIGITAL_VOLUME_LEFT, in wm8904_i2c_probe()
2253 regmap_update_bits(wm8904->regmap, WM8904_ADC_DIGITAL_VOLUME_RIGHT, in wm8904_i2c_probe()
2255 regmap_update_bits(wm8904->regmap, WM8904_DAC_DIGITAL_VOLUME_LEFT, in wm8904_i2c_probe()
2257 regmap_update_bits(wm8904->regmap, WM8904_DAC_DIGITAL_VOLUME_RIGHT, in wm8904_i2c_probe()
2259 regmap_update_bits(wm8904->regmap, WM8904_ANALOGUE_OUT1_LEFT, in wm8904_i2c_probe()
2262 regmap_update_bits(wm8904->regmap, WM8904_ANALOGUE_OUT1_RIGHT, in wm8904_i2c_probe()
2265 regmap_update_bits(wm8904->regmap, WM8904_ANALOGUE_OUT2_LEFT, in wm8904_i2c_probe()
2268 regmap_update_bits(wm8904->regmap, WM8904_ANALOGUE_OUT2_RIGHT, in wm8904_i2c_probe()
2271 regmap_update_bits(wm8904->regmap, WM8904_CLOCK_RATES_0, in wm8904_i2c_probe()
2275 if (wm8904->pdata) { in wm8904_i2c_probe()
2277 if (!wm8904->pdata->gpio_cfg[i]) in wm8904_i2c_probe()
2280 regmap_update_bits(wm8904->regmap, in wm8904_i2c_probe()
2283 wm8904->pdata->gpio_cfg[i]); in wm8904_i2c_probe()
2288 regmap_update_bits(wm8904->regmap, in wm8904_i2c_probe()
2291 wm8904->pdata->mic_cfg[i]); in wm8904_i2c_probe()
2294 /* Set Class W by default - this will be managed by the Class in wm8904_i2c_probe()
2297 regmap_update_bits(wm8904->regmap, WM8904_CLASS_W_0, in wm8904_i2c_probe()
2301 regmap_update_bits(wm8904->regmap, WM8904_BIAS_CONTROL_0, in wm8904_i2c_probe()
2305 regcache_cache_only(wm8904->regmap, true); in wm8904_i2c_probe()
2306 regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), wm8904->supplies); in wm8904_i2c_probe()
2308 ret = devm_snd_soc_register_component(&i2c->dev, in wm8904_i2c_probe()
2316 regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), wm8904->supplies); in wm8904_i2c_probe()