Lines Matching +full:fll1 +full:- +full:clk
2 * wm8904.c -- WM8904 ALSA SoC Audio driver
4 * Copyright 2009-12 Wolfson Microelectronics plc
14 #include <linux/clk.h>
53 struct clk *mclk;
89 /* DC servo configuration - cached offset values */
94 { 4, 0x0018 }, /* R4 - Bias Control 0 */
95 { 5, 0x0000 }, /* R5 - VMID Control 0 */
96 { 6, 0x0000 }, /* R6 - Mic Bias Control 0 */
97 { 7, 0x0000 }, /* R7 - Mic Bias Control 1 */
98 { 8, 0x0001 }, /* R8 - Analogue DAC 0 */
99 { 9, 0x9696 }, /* R9 - mic Filter Control */
100 { 10, 0x0001 }, /* R10 - Analogue ADC 0 */
101 { 12, 0x0000 }, /* R12 - Power Management 0 */
102 { 14, 0x0000 }, /* R14 - Power Management 2 */
103 { 15, 0x0000 }, /* R15 - Power Management 3 */
104 { 18, 0x0000 }, /* R18 - Power Management 6 */
105 { 20, 0x945E }, /* R20 - Clock Rates 0 */
106 { 21, 0x0C05 }, /* R21 - Clock Rates 1 */
107 { 22, 0x0006 }, /* R22 - Clock Rates 2 */
108 { 24, 0x0050 }, /* R24 - Audio Interface 0 */
109 { 25, 0x000A }, /* R25 - Audio Interface 1 */
110 { 26, 0x00E4 }, /* R26 - Audio Interface 2 */
111 { 27, 0x0040 }, /* R27 - Audio Interface 3 */
112 { 30, 0x00C0 }, /* R30 - DAC Digital Volume Left */
113 { 31, 0x00C0 }, /* R31 - DAC Digital Volume Right */
114 { 32, 0x0000 }, /* R32 - DAC Digital 0 */
115 { 33, 0x0008 }, /* R33 - DAC Digital 1 */
116 { 36, 0x00C0 }, /* R36 - ADC Digital Volume Left */
117 { 37, 0x00C0 }, /* R37 - ADC Digital Volume Right */
118 { 38, 0x0010 }, /* R38 - ADC Digital 0 */
119 { 39, 0x0000 }, /* R39 - Digital Microphone 0 */
120 { 40, 0x01AF }, /* R40 - DRC 0 */
121 { 41, 0x3248 }, /* R41 - DRC 1 */
122 { 42, 0x0000 }, /* R42 - DRC 2 */
123 { 43, 0x0000 }, /* R43 - DRC 3 */
124 { 44, 0x0085 }, /* R44 - Analogue Left Input 0 */
125 { 45, 0x0085 }, /* R45 - Analogue Right Input 0 */
126 { 46, 0x0044 }, /* R46 - Analogue Left Input 1 */
127 { 47, 0x0044 }, /* R47 - Analogue Right Input 1 */
128 { 57, 0x002D }, /* R57 - Analogue OUT1 Left */
129 { 58, 0x002D }, /* R58 - Analogue OUT1 Right */
130 { 59, 0x0039 }, /* R59 - Analogue OUT2 Left */
131 { 60, 0x0039 }, /* R60 - Analogue OUT2 Right */
132 { 61, 0x0000 }, /* R61 - Analogue OUT12 ZC */
133 { 67, 0x0000 }, /* R67 - DC Servo 0 */
134 { 69, 0xAAAA }, /* R69 - DC Servo 2 */
135 { 71, 0xAAAA }, /* R71 - DC Servo 4 */
136 { 72, 0xAAAA }, /* R72 - DC Servo 5 */
137 { 90, 0x0000 }, /* R90 - Analogue HP 0 */
138 { 94, 0x0000 }, /* R94 - Analogue Lineout 0 */
139 { 98, 0x0000 }, /* R98 - Charge Pump 0 */
140 { 104, 0x0004 }, /* R104 - Class W 0 */
141 { 108, 0x0000 }, /* R108 - Write Sequencer 0 */
142 { 109, 0x0000 }, /* R109 - Write Sequencer 1 */
143 { 110, 0x0000 }, /* R110 - Write Sequencer 2 */
144 { 111, 0x0000 }, /* R111 - Write Sequencer 3 */
145 { 112, 0x0000 }, /* R112 - Write Sequencer 4 */
146 { 116, 0x0000 }, /* R116 - FLL Control 1 */
147 { 117, 0x0007 }, /* R117 - FLL Control 2 */
148 { 118, 0x0000 }, /* R118 - FLL Control 3 */
149 { 119, 0x2EE0 }, /* R119 - FLL Control 4 */
150 { 120, 0x0004 }, /* R120 - FLL Control 5 */
151 { 121, 0x0014 }, /* R121 - GPIO Control 1 */
152 { 122, 0x0010 }, /* R122 - GPIO Control 2 */
153 { 123, 0x0010 }, /* R123 - GPIO Control 3 */
154 { 124, 0x0000 }, /* R124 - GPIO Control 4 */
155 { 126, 0x0000 }, /* R126 - Digital Pulls */
156 { 128, 0xFFFF }, /* R128 - Interrupt Status Mask */
157 { 129, 0x0000 }, /* R129 - Interrupt Polarity */
158 { 130, 0x0000 }, /* R130 - Interrupt Debounce */
159 { 134, 0x0000 }, /* R134 - EQ1 */
160 { 135, 0x000C }, /* R135 - EQ2 */
161 { 136, 0x000C }, /* R136 - EQ3 */
162 { 137, 0x000C }, /* R137 - EQ4 */
163 { 138, 0x000C }, /* R138 - EQ5 */
164 { 139, 0x000C }, /* R139 - EQ6 */
165 { 140, 0x0FCA }, /* R140 - EQ7 */
166 { 141, 0x0400 }, /* R141 - EQ8 */
167 { 142, 0x00D8 }, /* R142 - EQ9 */
168 { 143, 0x1EB5 }, /* R143 - EQ10 */
169 { 144, 0xF145 }, /* R144 - EQ11 */
170 { 145, 0x0B75 }, /* R145 - EQ12 */
171 { 146, 0x01C5 }, /* R146 - EQ13 */
172 { 147, 0x1C58 }, /* R147 - EQ14 */
173 { 148, 0xF373 }, /* R148 - EQ15 */
174 { 149, 0x0A54 }, /* R149 - EQ16 */
175 { 150, 0x0558 }, /* R150 - EQ17 */
176 { 151, 0x168E }, /* R151 - EQ18 */
177 { 152, 0xF829 }, /* R152 - EQ19 */
178 { 153, 0x07AD }, /* R153 - EQ20 */
179 { 154, 0x1103 }, /* R154 - EQ21 */
180 { 155, 0x0564 }, /* R155 - EQ22 */
181 { 156, 0x0559 }, /* R156 - EQ23 */
182 { 157, 0x4000 }, /* R157 - EQ24 */
183 { 161, 0x0000 }, /* R161 - Control Interface Test 1 */
184 { 204, 0x0000 }, /* R204 - Analogue Output Bias 0 */
185 { 247, 0x0000 }, /* R247 - FLL NCO Test 0 */
186 { 248, 0x0019 }, /* R248 - FLL NCO Test 1 */
330 switch (wm8904->sysclk_src) { in wm8904_configure_clocking()
332 dev_dbg(component->dev, "Using %dHz MCLK\n", wm8904->mclk_rate); in wm8904_configure_clocking()
335 rate = wm8904->mclk_rate; in wm8904_configure_clocking()
343 dev_dbg(component->dev, "Using %dHz FLL clock\n", in wm8904_configure_clocking()
344 wm8904->fll_fout); in wm8904_configure_clocking()
347 rate = wm8904->fll_fout; in wm8904_configure_clocking()
351 dev_err(component->dev, "System clock not configured\n"); in wm8904_configure_clocking()
352 return -EINVAL; in wm8904_configure_clocking()
358 wm8904->sysclk_rate = rate / 2; in wm8904_configure_clocking()
361 wm8904->sysclk_rate = rate; in wm8904_configure_clocking()
370 dev_dbg(component->dev, "CLK_SYS is %dHz\n", wm8904->sysclk_rate); in wm8904_configure_clocking()
378 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_set_drc()
386 pdata->drc_cfgs[wm8904->drc_cfg].regs[i]); in wm8904_set_drc()
398 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_put_drc_enum()
399 int value = ucontrol->value.enumerated.item[0]; in wm8904_put_drc_enum()
401 if (value >= pdata->num_drc_cfgs) in wm8904_put_drc_enum()
402 return -EINVAL; in wm8904_put_drc_enum()
404 wm8904->drc_cfg = value; in wm8904_put_drc_enum()
417 ucontrol->value.enumerated.item[0] = wm8904->drc_cfg; in wm8904_get_drc_enum()
425 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_set_retune_mobile()
428 if (!pdata || !wm8904->num_retune_mobile_texts) in wm8904_set_retune_mobile()
433 cfg = wm8904->retune_mobile_cfg; in wm8904_set_retune_mobile()
436 for (i = 0; i < pdata->num_retune_mobile_cfgs; i++) { in wm8904_set_retune_mobile()
437 if (strcmp(pdata->retune_mobile_cfgs[i].name, in wm8904_set_retune_mobile()
438 wm8904->retune_mobile_texts[cfg]) == 0 && in wm8904_set_retune_mobile()
439 abs(pdata->retune_mobile_cfgs[i].rate in wm8904_set_retune_mobile()
440 - wm8904->fs) < best_val) { in wm8904_set_retune_mobile()
442 best_val = abs(pdata->retune_mobile_cfgs[i].rate in wm8904_set_retune_mobile()
443 - wm8904->fs); in wm8904_set_retune_mobile()
447 dev_dbg(component->dev, "ReTune Mobile %s/%dHz for %dHz sample rate\n", in wm8904_set_retune_mobile()
448 pdata->retune_mobile_cfgs[best].name, in wm8904_set_retune_mobile()
449 pdata->retune_mobile_cfgs[best].rate, in wm8904_set_retune_mobile()
450 wm8904->fs); in wm8904_set_retune_mobile()
459 pdata->retune_mobile_cfgs[best].regs[i]); in wm8904_set_retune_mobile()
469 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_put_retune_mobile_enum()
470 int value = ucontrol->value.enumerated.item[0]; in wm8904_put_retune_mobile_enum()
472 if (value >= pdata->num_retune_mobile_cfgs) in wm8904_put_retune_mobile_enum()
473 return -EINVAL; in wm8904_put_retune_mobile_enum()
475 wm8904->retune_mobile_cfg = value; in wm8904_put_retune_mobile_enum()
488 ucontrol->value.enumerated.item[0] = wm8904->retune_mobile_cfg; in wm8904_get_retune_mobile_enum()
503 if (wm8904->deemph) { in wm8904_set_deemph()
506 if (abs(deemph_settings[i] - wm8904->fs) < in wm8904_set_deemph()
507 abs(deemph_settings[best] - wm8904->fs)) in wm8904_set_deemph()
516 dev_dbg(component->dev, "Set deemphasis %d\n", val); in wm8904_set_deemph()
528 ucontrol->value.integer.value[0] = wm8904->deemph; in wm8904_get_deemph()
537 unsigned int deemph = ucontrol->value.integer.value[0]; in wm8904_put_deemph()
540 return -EINVAL; in wm8904_put_deemph()
542 wm8904->deemph = deemph; in wm8904_put_deemph()
548 static const DECLARE_TLV_DB_SCALE(digital_tlv, -7200, 75, 1);
549 static const DECLARE_TLV_DB_SCALE(out_tlv, -5700, 100, 0);
550 static const DECLARE_TLV_DB_SCALE(sidetone_tlv, -3600, 300, 0);
551 static const DECLARE_TLV_DB_SCALE(eq_tlv, -1200, 100, 0);
554 "Single-Ended", "Differential Line", "Differential Mic"
566 "Hi-fi", "Voice 1", "Voice 2", "Voice 3"
583 if (ucontrol->value.integer.value[0]) in wm8904_adc_osr_put()
665 return -EINVAL; in cp_event()
676 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in sysclk_event()
686 switch (wm8904->sysclk_src) { in sysclk_event()
714 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in out_pga_event()
727 reg = w->shift; in out_pga_event()
748 return -EINVAL; in out_pga_event()
776 if (wm8904->dcs_state[dcs_l] || wm8904->dcs_state[dcs_r]) { in out_pga_event()
777 dev_dbg(component->dev, "Restoring DC servo state\n"); in out_pga_event()
780 wm8904->dcs_state[dcs_l]); in out_pga_event()
782 wm8904->dcs_state[dcs_r]); in out_pga_event()
788 dev_dbg(component->dev, "Calibrating DC servo\n"); in out_pga_event()
804 } while (--timeout); in out_pga_event()
807 dev_warn(component->dev, "DC servo timed out\n"); in out_pga_event()
809 dev_dbg(component->dev, "DC servo ready\n"); in out_pga_event()
837 wm8904->dcs_state[dcs_l] = snd_soc_component_read32(component, dcs_l_reg); in out_pga_event()
838 wm8904->dcs_state[dcs_r] = snd_soc_component_read32(component, dcs_r_reg); in out_pga_event()
1178 switch (wm8904->devtype) { in wm8904_add_widgets()
1281 struct snd_soc_component *component = dai->component; in wm8904_hw_params()
1291 wm8904->fs = params_rate(params); in wm8904_hw_params()
1292 if (wm8904->tdm_slots) { in wm8904_hw_params()
1293 dev_dbg(component->dev, "Configuring for %d %d bit TDM slots\n", in wm8904_hw_params()
1294 wm8904->tdm_slots, wm8904->tdm_width); in wm8904_hw_params()
1295 wm8904->bclk = snd_soc_calc_bclk(wm8904->fs, in wm8904_hw_params()
1296 wm8904->tdm_width, 2, in wm8904_hw_params()
1297 wm8904->tdm_slots); in wm8904_hw_params()
1299 wm8904->bclk = snd_soc_params_to_bclk(params); in wm8904_hw_params()
1315 return -EINVAL; in wm8904_hw_params()
1319 dev_dbg(component->dev, "Target BCLK is %dHz\n", wm8904->bclk); in wm8904_hw_params()
1327 best_val = abs((wm8904->sysclk_rate / clk_sys_rates[0].ratio) in wm8904_hw_params()
1328 - wm8904->fs); in wm8904_hw_params()
1330 cur_val = abs((wm8904->sysclk_rate / in wm8904_hw_params()
1331 clk_sys_rates[i].ratio) - wm8904->fs); in wm8904_hw_params()
1337 dev_dbg(component->dev, "Selected CLK_SYS_RATIO of %d\n", in wm8904_hw_params()
1344 best_val = abs(wm8904->fs - sample_rates[0].rate); in wm8904_hw_params()
1347 cur_val = abs(wm8904->fs - sample_rates[i].rate); in wm8904_hw_params()
1353 dev_dbg(component->dev, "Selected SAMPLE_RATE of %dHz\n", in wm8904_hw_params()
1359 if (wm8904->fs <= 24000) in wm8904_hw_params()
1366 cur_val = ((wm8904->sysclk_rate * 10) / bclk_divs[i].div) in wm8904_hw_params()
1367 - wm8904->bclk; in wm8904_hw_params()
1375 wm8904->bclk = (wm8904->sysclk_rate * 10) / bclk_divs[best].div; in wm8904_hw_params()
1376 dev_dbg(component->dev, "Selected BCLK_DIV of %d for %dHz BCLK\n", in wm8904_hw_params()
1377 bclk_divs[best].div, wm8904->bclk); in wm8904_hw_params()
1381 dev_dbg(component->dev, "LRCLK_RATE is %d\n", wm8904->bclk / wm8904->fs); in wm8904_hw_params()
1382 aif3 |= wm8904->bclk / wm8904->fs; in wm8904_hw_params()
1408 struct snd_soc_component *component = dai->component; in wm8904_set_sysclk()
1413 priv->sysclk_src = clk_id; in wm8904_set_sysclk()
1414 priv->mclk_rate = freq; in wm8904_set_sysclk()
1418 priv->sysclk_src = clk_id; in wm8904_set_sysclk()
1422 return -EINVAL; in wm8904_set_sysclk()
1425 dev_dbg(dai->dev, "Clock source is %d at %uHz\n", clk_id, freq); in wm8904_set_sysclk()
1434 struct snd_soc_component *component = dai->component; in wm8904_set_fmt()
1452 return -EINVAL; in wm8904_set_fmt()
1471 return -EINVAL; in wm8904_set_fmt()
1485 return -EINVAL; in wm8904_set_fmt()
1505 return -EINVAL; in wm8904_set_fmt()
1509 return -EINVAL; in wm8904_set_fmt()
1525 struct snd_soc_component *component = dai->component; in wm8904_set_tdm_slot()
1533 /* Note that we allow configurations we can't handle ourselves - in wm8904_set_tdm_slot()
1546 return -EINVAL; in wm8904_set_tdm_slot()
1557 return -EINVAL; in wm8904_set_tdm_slot()
1561 wm8904->tdm_width = slot_width; in wm8904_set_tdm_slot()
1562 wm8904->tdm_slots = slots / 2; in wm8904_set_tdm_slot()
1606 fll_div->fll_clk_ref_div = 0; in fll_factors()
1609 fll_div->fll_clk_ref_div++; in fll_factors()
1614 return -EINVAL; in fll_factors()
1623 /* Fvco should be 90-100MHz; don't check the upper bound */ in fll_factors()
1630 return -EINVAL; in fll_factors()
1634 fll_div->fll_outdiv = div - 1; in fll_factors()
1641 fll_div->fll_fratio = fll_fratios[i].fll_fratio; in fll_factors()
1648 return -EINVAL; in fll_factors()
1654 fll_div->n = Ndiv; in fll_factors()
1658 /* Calculate fractional part - scale up so we can round. */ in fll_factors()
1669 fll_div->k = K / 10; in fll_factors()
1672 fll_div->n, fll_div->k, in fll_factors()
1673 fll_div->fll_fratio, fll_div->fll_outdiv, in fll_factors()
1674 fll_div->fll_clk_ref_div); in fll_factors()
1682 struct snd_soc_component *component = dai->component; in wm8904_set_fll()
1686 int clock2, fll1; in wm8904_set_fll() local
1689 if (source == wm8904->fll_src && Fref == wm8904->fll_fref && in wm8904_set_fll()
1690 Fout == wm8904->fll_fout) in wm8904_set_fll()
1696 dev_dbg(component->dev, "FLL disabled\n"); in wm8904_set_fll()
1698 wm8904->fll_fref = 0; in wm8904_set_fll()
1699 wm8904->fll_fout = 0; in wm8904_set_fll()
1722 dev_dbg(component->dev, "Using free running FLL\n"); in wm8904_set_fll()
1732 dev_err(component->dev, "Unknown FLL ID %d\n", fll_id); in wm8904_set_fll()
1733 return -EINVAL; in wm8904_set_fll()
1738 fll1 = snd_soc_component_read32(component, WM8904_FLL_CONTROL_1); in wm8904_set_fll()
1798 dev_dbg(component->dev, "FLL configured for %dHz->%dHz\n", Fref, Fout); in wm8904_set_fll()
1800 wm8904->fll_fref = Fref; in wm8904_set_fll()
1801 wm8904->fll_fout = Fout; in wm8904_set_fll()
1802 wm8904->fll_src = source; in wm8904_set_fll()
1806 WM8904_FLL_OSC_ENA, fll1); in wm8904_set_fll()
1808 WM8904_FLL_ENA, fll1); in wm8904_set_fll()
1820 struct snd_soc_component *component = codec_dai->component; in wm8904_digital_mute()
1841 ret = clk_prepare_enable(wm8904->mclk); in wm8904_set_bias_level()
1859 ret = regulator_bulk_enable(ARRAY_SIZE(wm8904->supplies), in wm8904_set_bias_level()
1860 wm8904->supplies); in wm8904_set_bias_level()
1862 dev_err(component->dev, in wm8904_set_bias_level()
1868 regcache_cache_only(wm8904->regmap, false); in wm8904_set_bias_level()
1869 regcache_sync(wm8904->regmap); in wm8904_set_bias_level()
1906 regcache_cache_only(wm8904->regmap, true); in wm8904_set_bias_level()
1907 regcache_mark_dirty(wm8904->regmap); in wm8904_set_bias_level()
1909 regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), in wm8904_set_bias_level()
1910 wm8904->supplies); in wm8904_set_bias_level()
1911 clk_disable_unprepare(wm8904->mclk); in wm8904_set_bias_level()
1932 .name = "wm8904-hifi",
1954 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_handle_retune_mobile_pdata()
1957 wm8904->retune_mobile_enum, in wm8904_handle_retune_mobile_pdata()
1967 wm8904->num_retune_mobile_texts = 0; in wm8904_handle_retune_mobile_pdata()
1968 wm8904->retune_mobile_texts = NULL; in wm8904_handle_retune_mobile_pdata()
1969 for (i = 0; i < pdata->num_retune_mobile_cfgs; i++) { in wm8904_handle_retune_mobile_pdata()
1970 for (j = 0; j < wm8904->num_retune_mobile_texts; j++) { in wm8904_handle_retune_mobile_pdata()
1971 if (strcmp(pdata->retune_mobile_cfgs[i].name, in wm8904_handle_retune_mobile_pdata()
1972 wm8904->retune_mobile_texts[j]) == 0) in wm8904_handle_retune_mobile_pdata()
1976 if (j != wm8904->num_retune_mobile_texts) in wm8904_handle_retune_mobile_pdata()
1980 t = krealloc(wm8904->retune_mobile_texts, in wm8904_handle_retune_mobile_pdata()
1982 (wm8904->num_retune_mobile_texts + 1), in wm8904_handle_retune_mobile_pdata()
1988 t[wm8904->num_retune_mobile_texts] = in wm8904_handle_retune_mobile_pdata()
1989 pdata->retune_mobile_cfgs[i].name; in wm8904_handle_retune_mobile_pdata()
1992 wm8904->num_retune_mobile_texts++; in wm8904_handle_retune_mobile_pdata()
1993 wm8904->retune_mobile_texts = t; in wm8904_handle_retune_mobile_pdata()
1996 dev_dbg(component->dev, "Allocated %d unique ReTune Mobile names\n", in wm8904_handle_retune_mobile_pdata()
1997 wm8904->num_retune_mobile_texts); in wm8904_handle_retune_mobile_pdata()
1999 wm8904->retune_mobile_enum.items = wm8904->num_retune_mobile_texts; in wm8904_handle_retune_mobile_pdata()
2000 wm8904->retune_mobile_enum.texts = wm8904->retune_mobile_texts; in wm8904_handle_retune_mobile_pdata()
2004 dev_err(component->dev, in wm8904_handle_retune_mobile_pdata()
2011 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_handle_pdata()
2020 dev_dbg(component->dev, "%d DRC configurations\n", pdata->num_drc_cfgs); in wm8904_handle_pdata()
2022 if (pdata->num_drc_cfgs) { in wm8904_handle_pdata()
2024 SOC_ENUM_EXT("DRC Mode", wm8904->drc_enum, in wm8904_handle_pdata()
2028 wm8904->drc_texts = kmalloc_array(pdata->num_drc_cfgs, in wm8904_handle_pdata()
2031 if (!wm8904->drc_texts) in wm8904_handle_pdata()
2034 for (i = 0; i < pdata->num_drc_cfgs; i++) in wm8904_handle_pdata()
2035 wm8904->drc_texts[i] = pdata->drc_cfgs[i].name; in wm8904_handle_pdata()
2037 wm8904->drc_enum.items = pdata->num_drc_cfgs; in wm8904_handle_pdata()
2038 wm8904->drc_enum.texts = wm8904->drc_texts; in wm8904_handle_pdata()
2042 dev_err(component->dev, in wm8904_handle_pdata()
2048 dev_dbg(component->dev, "%d ReTune Mobile configurations\n", in wm8904_handle_pdata()
2049 pdata->num_retune_mobile_cfgs); in wm8904_handle_pdata()
2051 if (pdata->num_retune_mobile_cfgs) in wm8904_handle_pdata()
2063 switch (wm8904->devtype) { in wm8904_probe()
2070 dev_err(component->dev, "Unknown device type %d\n", in wm8904_probe()
2071 wm8904->devtype); in wm8904_probe()
2072 return -EINVAL; in wm8904_probe()
2086 kfree(wm8904->retune_mobile_texts); in wm8904_remove()
2087 kfree(wm8904->drc_texts); in wm8904_remove()
2137 wm8904 = devm_kzalloc(&i2c->dev, sizeof(struct wm8904_priv), in wm8904_i2c_probe()
2140 return -ENOMEM; in wm8904_i2c_probe()
2142 wm8904->mclk = devm_clk_get(&i2c->dev, "mclk"); in wm8904_i2c_probe()
2143 if (IS_ERR(wm8904->mclk)) { in wm8904_i2c_probe()
2144 ret = PTR_ERR(wm8904->mclk); in wm8904_i2c_probe()
2145 dev_err(&i2c->dev, "Failed to get MCLK\n"); in wm8904_i2c_probe()
2149 wm8904->regmap = devm_regmap_init_i2c(i2c, &wm8904_regmap); in wm8904_i2c_probe()
2150 if (IS_ERR(wm8904->regmap)) { in wm8904_i2c_probe()
2151 ret = PTR_ERR(wm8904->regmap); in wm8904_i2c_probe()
2152 dev_err(&i2c->dev, "Failed to allocate register map: %d\n", in wm8904_i2c_probe()
2157 if (i2c->dev.of_node) { in wm8904_i2c_probe()
2160 match = of_match_node(wm8904_of_match, i2c->dev.of_node); in wm8904_i2c_probe()
2162 return -EINVAL; in wm8904_i2c_probe()
2163 wm8904->devtype = *((enum wm8904_type *)match->data); in wm8904_i2c_probe()
2165 wm8904->devtype = id->driver_data; in wm8904_i2c_probe()
2169 wm8904->pdata = i2c->dev.platform_data; in wm8904_i2c_probe()
2171 for (i = 0; i < ARRAY_SIZE(wm8904->supplies); i++) in wm8904_i2c_probe()
2172 wm8904->supplies[i].supply = wm8904_supply_names[i]; in wm8904_i2c_probe()
2174 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8904->supplies), in wm8904_i2c_probe()
2175 wm8904->supplies); in wm8904_i2c_probe()
2177 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); in wm8904_i2c_probe()
2181 ret = regulator_bulk_enable(ARRAY_SIZE(wm8904->supplies), in wm8904_i2c_probe()
2182 wm8904->supplies); in wm8904_i2c_probe()
2184 dev_err(&i2c->dev, "Failed to enable supplies: %d\n", ret); in wm8904_i2c_probe()
2188 ret = regmap_read(wm8904->regmap, WM8904_SW_RESET_AND_ID, &val); in wm8904_i2c_probe()
2190 dev_err(&i2c->dev, "Failed to read ID register: %d\n", ret); in wm8904_i2c_probe()
2194 dev_err(&i2c->dev, "Device is not a WM8904, ID is %x\n", val); in wm8904_i2c_probe()
2195 ret = -EINVAL; in wm8904_i2c_probe()
2199 ret = regmap_read(wm8904->regmap, WM8904_REVISION, &val); in wm8904_i2c_probe()
2201 dev_err(&i2c->dev, "Failed to read device revision: %d\n", in wm8904_i2c_probe()
2205 dev_info(&i2c->dev, "revision %c\n", val + 'A'); in wm8904_i2c_probe()
2207 ret = regmap_write(wm8904->regmap, WM8904_SW_RESET_AND_ID, 0); in wm8904_i2c_probe()
2209 dev_err(&i2c->dev, "Failed to issue reset: %d\n", ret); in wm8904_i2c_probe()
2213 /* Change some default settings - latch VU and enable ZC */ in wm8904_i2c_probe()
2214 regmap_update_bits(wm8904->regmap, WM8904_ADC_DIGITAL_VOLUME_LEFT, in wm8904_i2c_probe()
2216 regmap_update_bits(wm8904->regmap, WM8904_ADC_DIGITAL_VOLUME_RIGHT, in wm8904_i2c_probe()
2218 regmap_update_bits(wm8904->regmap, WM8904_DAC_DIGITAL_VOLUME_LEFT, in wm8904_i2c_probe()
2220 regmap_update_bits(wm8904->regmap, WM8904_DAC_DIGITAL_VOLUME_RIGHT, in wm8904_i2c_probe()
2222 regmap_update_bits(wm8904->regmap, WM8904_ANALOGUE_OUT1_LEFT, in wm8904_i2c_probe()
2225 regmap_update_bits(wm8904->regmap, WM8904_ANALOGUE_OUT1_RIGHT, in wm8904_i2c_probe()
2228 regmap_update_bits(wm8904->regmap, WM8904_ANALOGUE_OUT2_LEFT, in wm8904_i2c_probe()
2231 regmap_update_bits(wm8904->regmap, WM8904_ANALOGUE_OUT2_RIGHT, in wm8904_i2c_probe()
2234 regmap_update_bits(wm8904->regmap, WM8904_CLOCK_RATES_0, in wm8904_i2c_probe()
2238 if (wm8904->pdata) { in wm8904_i2c_probe()
2240 if (!wm8904->pdata->gpio_cfg[i]) in wm8904_i2c_probe()
2243 regmap_update_bits(wm8904->regmap, in wm8904_i2c_probe()
2246 wm8904->pdata->gpio_cfg[i]); in wm8904_i2c_probe()
2251 regmap_update_bits(wm8904->regmap, in wm8904_i2c_probe()
2254 wm8904->pdata->mic_cfg[i]); in wm8904_i2c_probe()
2257 /* Set Class W by default - this will be managed by the Class in wm8904_i2c_probe()
2260 regmap_update_bits(wm8904->regmap, WM8904_CLASS_W_0, in wm8904_i2c_probe()
2264 regmap_update_bits(wm8904->regmap, WM8904_BIAS_CONTROL_0, in wm8904_i2c_probe()
2268 regcache_cache_only(wm8904->regmap, true); in wm8904_i2c_probe()
2269 regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), wm8904->supplies); in wm8904_i2c_probe()
2271 ret = devm_snd_soc_register_component(&i2c->dev, in wm8904_i2c_probe()
2279 regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), wm8904->supplies); in wm8904_i2c_probe()