Lines Matching full:wm8904
3 * wm8904.c -- WM8904 ALSA SoC Audio driver
25 #include <sound/wm8904.h>
27 #include "wm8904.h"
30 WM8904, enumerator
316 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_configure_clocking() local
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()
339 wm8904->fll_fout); in wm8904_configure_clocking()
342 rate = wm8904->fll_fout; 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()
372 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_set_drc() local
373 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_set_drc()
381 pdata->drc_cfgs[wm8904->drc_cfg].regs[i]); in wm8904_set_drc()
392 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_put_drc_enum() local
393 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_put_drc_enum()
399 wm8904->drc_cfg = value; in wm8904_put_drc_enum()
410 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_get_drc_enum() local
412 ucontrol->value.enumerated.item[0] = wm8904->drc_cfg; in wm8904_get_drc_enum()
419 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_set_retune_mobile() local
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()
433 wm8904->retune_mobile_texts[cfg]) == 0 && in wm8904_set_retune_mobile()
435 - wm8904->fs) < best_val) { in wm8904_set_retune_mobile()
438 - wm8904->fs); in wm8904_set_retune_mobile()
445 wm8904->fs); in wm8904_set_retune_mobile()
463 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_put_retune_mobile_enum() local
464 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_put_retune_mobile_enum()
470 wm8904->retune_mobile_cfg = value; in wm8904_put_retune_mobile_enum()
481 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_get_retune_mobile_enum() local
483 ucontrol->value.enumerated.item[0] = wm8904->retune_mobile_cfg; in wm8904_get_retune_mobile_enum()
492 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_set_deemph() local
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()
521 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_get_deemph() local
523 ucontrol->value.integer.value[0] = wm8904->deemph; in wm8904_get_deemph()
531 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_put_deemph() local
537 wm8904->deemph = deemph; in wm8904_put_deemph()
657 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in sysclk_event() local
666 switch (wm8904->sysclk_src) { in sysclk_event()
695 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in out_pga_event() local
759 if (wm8904->dcs_state[dcs_l] || wm8904->dcs_state[dcs_r]) { in out_pga_event()
763 wm8904->dcs_state[dcs_l]); in out_pga_event()
765 wm8904->dcs_state[dcs_r]); in out_pga_event()
824 wm8904->dcs_state[dcs_l] = snd_soc_component_read(component, dcs_l_reg); in out_pga_event()
825 wm8904->dcs_state[dcs_r] = snd_soc_component_read(component, dcs_r_reg); in out_pga_event()
1186 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_add_widgets() local
1194 switch (wm8904->devtype) { in wm8904_add_widgets()
1195 case WM8904: in wm8904_add_widgets()
1298 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_hw_params() local
1307 wm8904->fs = params_rate(params); in wm8904_hw_params()
1308 if (wm8904->tdm_slots) { in wm8904_hw_params()
1310 wm8904->tdm_slots, wm8904->tdm_width); in wm8904_hw_params()
1311 wm8904->bclk = snd_soc_calc_bclk(wm8904->fs, in wm8904_hw_params()
1312 wm8904->tdm_width, 2, in wm8904_hw_params()
1313 wm8904->tdm_slots); in wm8904_hw_params()
1315 wm8904->bclk = snd_soc_params_to_bclk(params); in wm8904_hw_params()
1335 dev_dbg(component->dev, "Target BCLK is %dHz\n", wm8904->bclk); in wm8904_hw_params()
1343 best_val = abs((wm8904->sysclk_rate / clk_sys_rates[0].ratio) in wm8904_hw_params()
1344 - wm8904->fs); in wm8904_hw_params()
1346 cur_val = abs((wm8904->sysclk_rate / in wm8904_hw_params()
1347 clk_sys_rates[i].ratio) - wm8904->fs); in wm8904_hw_params()
1360 best_val = abs(wm8904->fs - sample_rates[0].rate); in wm8904_hw_params()
1363 cur_val = abs(wm8904->fs - sample_rates[i].rate); in wm8904_hw_params()
1375 if (wm8904->fs <= 24000) in wm8904_hw_params()
1382 cur_val = ((wm8904->sysclk_rate * 10) / bclk_divs[i].div) in wm8904_hw_params()
1383 - wm8904->bclk; in wm8904_hw_params()
1391 wm8904->bclk = (wm8904->sysclk_rate * 10) / bclk_divs[best].div; in wm8904_hw_params()
1393 bclk_divs[best].div, wm8904->bclk); in wm8904_hw_params()
1397 dev_dbg(component->dev, "LRCLK_RATE is %d\n", wm8904->bclk / wm8904->fs); in wm8904_hw_params()
1398 aif3 |= wm8904->bclk / wm8904->fs; in wm8904_hw_params()
1514 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_set_tdm_slot() local
1549 wm8904->tdm_width = slot_width; in wm8904_set_tdm_slot()
1550 wm8904->tdm_slots = slots / 2; in wm8904_set_tdm_slot()
1671 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_set_fll() local
1677 if (source == wm8904->fll_src && Fref == wm8904->fll_fref && in wm8904_set_fll()
1678 Fout == wm8904->fll_fout) in wm8904_set_fll()
1686 wm8904->fll_fref = 0; in wm8904_set_fll()
1687 wm8904->fll_fout = 0; in wm8904_set_fll()
1788 wm8904->fll_fref = Fref; in wm8904_set_fll()
1789 wm8904->fll_fout = Fout; in wm8904_set_fll()
1790 wm8904->fll_src = source; in wm8904_set_fll()
1874 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_set_bias_level() local
1894 ret = regulator_bulk_enable(ARRAY_SIZE(wm8904->supplies), in wm8904_set_bias_level()
1895 wm8904->supplies); in wm8904_set_bias_level()
1903 ret = clk_prepare_enable(wm8904->mclk); in wm8904_set_bias_level()
1907 regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), in wm8904_set_bias_level()
1908 wm8904->supplies); in wm8904_set_bias_level()
1912 regcache_cache_only(wm8904->regmap, false); in wm8904_set_bias_level()
1913 regcache_sync(wm8904->regmap); in wm8904_set_bias_level()
1950 regcache_cache_only(wm8904->regmap, true); in wm8904_set_bias_level()
1951 regcache_mark_dirty(wm8904->regmap); in wm8904_set_bias_level()
1953 regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), in wm8904_set_bias_level()
1954 wm8904->supplies); in wm8904_set_bias_level()
1955 clk_disable_unprepare(wm8904->mclk); in wm8904_set_bias_level()
1977 .name = "wm8904-hifi",
1998 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_handle_retune_mobile_pdata() local
1999 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_handle_retune_mobile_pdata()
2002 wm8904->retune_mobile_enum, in wm8904_handle_retune_mobile_pdata()
2012 wm8904->num_retune_mobile_texts = 0; in wm8904_handle_retune_mobile_pdata()
2013 wm8904->retune_mobile_texts = NULL; in wm8904_handle_retune_mobile_pdata()
2015 for (j = 0; j < wm8904->num_retune_mobile_texts; j++) { in wm8904_handle_retune_mobile_pdata()
2017 wm8904->retune_mobile_texts[j]) == 0) in wm8904_handle_retune_mobile_pdata()
2021 if (j != wm8904->num_retune_mobile_texts) in wm8904_handle_retune_mobile_pdata()
2025 t = krealloc(wm8904->retune_mobile_texts, in wm8904_handle_retune_mobile_pdata()
2027 (wm8904->num_retune_mobile_texts + 1), in wm8904_handle_retune_mobile_pdata()
2033 t[wm8904->num_retune_mobile_texts] = in wm8904_handle_retune_mobile_pdata()
2037 wm8904->num_retune_mobile_texts++; in wm8904_handle_retune_mobile_pdata()
2038 wm8904->retune_mobile_texts = t; in wm8904_handle_retune_mobile_pdata()
2042 wm8904->num_retune_mobile_texts); in wm8904_handle_retune_mobile_pdata()
2044 wm8904->retune_mobile_enum.items = wm8904->num_retune_mobile_texts; in wm8904_handle_retune_mobile_pdata()
2045 wm8904->retune_mobile_enum.texts = wm8904->retune_mobile_texts; in wm8904_handle_retune_mobile_pdata()
2055 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_handle_pdata() local
2056 struct wm8904_pdata *pdata = wm8904->pdata; in wm8904_handle_pdata()
2069 SOC_ENUM_EXT("DRC Mode", wm8904->drc_enum, in wm8904_handle_pdata()
2073 wm8904->drc_texts = kmalloc_array(pdata->num_drc_cfgs, in wm8904_handle_pdata()
2076 if (!wm8904->drc_texts) in wm8904_handle_pdata()
2080 wm8904->drc_texts[i] = pdata->drc_cfgs[i].name; in wm8904_handle_pdata()
2082 wm8904->drc_enum.items = pdata->num_drc_cfgs; in wm8904_handle_pdata()
2083 wm8904->drc_enum.texts = wm8904->drc_texts; in wm8904_handle_pdata()
2106 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_probe() local
2108 switch (wm8904->devtype) { in wm8904_probe()
2109 case WM8904: in wm8904_probe()
2116 wm8904->devtype); in wm8904_probe()
2129 struct wm8904_priv *wm8904 = snd_soc_component_get_drvdata(component); in wm8904_remove() local
2131 kfree(wm8904->retune_mobile_texts); in wm8904_remove()
2132 kfree(wm8904->drc_texts); in wm8904_remove()
2159 .compatible = "wlf,wm8904",
2160 .data = (void *)WM8904,
2175 struct wm8904_priv *wm8904; in wm8904_i2c_probe() local
2179 wm8904 = devm_kzalloc(&i2c->dev, sizeof(struct wm8904_priv), in wm8904_i2c_probe()
2181 if (wm8904 == NULL) in wm8904_i2c_probe()
2184 wm8904->mclk = devm_clk_get(&i2c->dev, "mclk"); in wm8904_i2c_probe()
2185 if (IS_ERR(wm8904->mclk)) { in wm8904_i2c_probe()
2186 ret = PTR_ERR(wm8904->mclk); in wm8904_i2c_probe()
2191 wm8904->regmap = devm_regmap_init_i2c(i2c, &wm8904_regmap); in wm8904_i2c_probe()
2192 if (IS_ERR(wm8904->regmap)) { in wm8904_i2c_probe()
2193 ret = PTR_ERR(wm8904->regmap); in wm8904_i2c_probe()
2205 wm8904->devtype = (uintptr_t)match->data; in wm8904_i2c_probe()
2209 wm8904->devtype = id->driver_data; in wm8904_i2c_probe()
2212 i2c_set_clientdata(i2c, wm8904); in wm8904_i2c_probe()
2213 wm8904->pdata = i2c->dev.platform_data; in wm8904_i2c_probe()
2215 for (i = 0; i < ARRAY_SIZE(wm8904->supplies); i++) in wm8904_i2c_probe()
2216 wm8904->supplies[i].supply = wm8904_supply_names[i]; in wm8904_i2c_probe()
2218 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8904->supplies), in wm8904_i2c_probe()
2219 wm8904->supplies); in wm8904_i2c_probe()
2225 ret = regulator_bulk_enable(ARRAY_SIZE(wm8904->supplies), in wm8904_i2c_probe()
2226 wm8904->supplies); in wm8904_i2c_probe()
2232 ret = regmap_read(wm8904->regmap, WM8904_SW_RESET_AND_ID, &val); in wm8904_i2c_probe()
2238 dev_err(&i2c->dev, "Device is not a WM8904, ID is %x\n", val); in wm8904_i2c_probe()
2243 ret = regmap_read(wm8904->regmap, WM8904_REVISION, &val); in wm8904_i2c_probe()
2251 ret = regmap_write(wm8904->regmap, WM8904_SW_RESET_AND_ID, 0); in wm8904_i2c_probe()
2258 regmap_update_bits(wm8904->regmap, WM8904_ADC_DIGITAL_VOLUME_LEFT, in wm8904_i2c_probe()
2260 regmap_update_bits(wm8904->regmap, WM8904_ADC_DIGITAL_VOLUME_RIGHT, in wm8904_i2c_probe()
2262 regmap_update_bits(wm8904->regmap, WM8904_DAC_DIGITAL_VOLUME_LEFT, in wm8904_i2c_probe()
2264 regmap_update_bits(wm8904->regmap, WM8904_DAC_DIGITAL_VOLUME_RIGHT, in wm8904_i2c_probe()
2266 regmap_update_bits(wm8904->regmap, WM8904_ANALOGUE_OUT1_LEFT, in wm8904_i2c_probe()
2269 regmap_update_bits(wm8904->regmap, WM8904_ANALOGUE_OUT1_RIGHT, in wm8904_i2c_probe()
2272 regmap_update_bits(wm8904->regmap, WM8904_ANALOGUE_OUT2_LEFT, in wm8904_i2c_probe()
2275 regmap_update_bits(wm8904->regmap, WM8904_ANALOGUE_OUT2_RIGHT, in wm8904_i2c_probe()
2278 regmap_update_bits(wm8904->regmap, WM8904_CLOCK_RATES_0, in wm8904_i2c_probe()
2282 if (wm8904->pdata) { in wm8904_i2c_probe()
2284 if (!wm8904->pdata->gpio_cfg[i]) in wm8904_i2c_probe()
2287 regmap_update_bits(wm8904->regmap, in wm8904_i2c_probe()
2290 wm8904->pdata->gpio_cfg[i]); in wm8904_i2c_probe()
2295 regmap_update_bits(wm8904->regmap, in wm8904_i2c_probe()
2298 wm8904->pdata->mic_cfg[i]); in wm8904_i2c_probe()
2304 regmap_update_bits(wm8904->regmap, WM8904_CLASS_W_0, in wm8904_i2c_probe()
2308 regmap_update_bits(wm8904->regmap, WM8904_BIAS_CONTROL_0, in wm8904_i2c_probe()
2312 regmap_read(wm8904->regmap, WM8904_ADC_TEST_0, &val); in wm8904_i2c_probe()
2315 regcache_cache_only(wm8904->regmap, true); in wm8904_i2c_probe()
2316 regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), wm8904->supplies); in wm8904_i2c_probe()
2326 regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), wm8904->supplies); in wm8904_i2c_probe()
2331 { "wm8904", WM8904 },
2333 { "wm8918", WM8904 }, /* Actually a subset, updates to follow */
2340 .name = "wm8904",
2349 MODULE_DESCRIPTION("ASoC WM8904 driver");