Lines Matching +full:warn +full:- +full:soc +full:- +full:level
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * wm8580.c -- WM8580 and WM8581 ALSA Soc Audio driver
5 * Copyright 2008-12 Wolfson Microelectronics PLC.
14 * Currently only the primary audio interface is supported - S/PDIF and
33 #include <sound/soc.h>
116 /* AIF control 1 (registers 9h-bh) */
127 /* AIF control 2 (registers ch-eh) */
254 static const DECLARE_TLV_DB_SCALE(dac_tlv, -12750, 50, 1);
260 (struct soc_mixer_control *)kcontrol->private_value; in wm8580_out_vu()
263 unsigned int reg = mc->reg; in wm8580_out_vu()
264 unsigned int reg2 = mc->rreg; in wm8580_out_vu()
268 regcache_cache_only(wm8580->regmap, true); in wm8580_out_vu()
269 regmap_update_bits(wm8580->regmap, reg, 0x100, 0x000); in wm8580_out_vu()
270 regmap_update_bits(wm8580->regmap, reg2, 0x100, 0x000); in wm8580_out_vu()
271 regcache_cache_only(wm8580->regmap, false); in wm8580_out_vu()
312 SOC_SINGLE("Capture High-Pass Filter Switch", WM8580_ADC_CONTROL1, 4, 1, 0),
407 pr_debug("wm8580: PLL %uHz->%uHz\n", source, target); in pll_factors()
410 * region of 90-100MHz. in pll_factors()
415 pll_div->freqmode = post_table[i].freqmode; in pll_factors()
416 pll_div->postscale = post_table[i].postscale; in pll_factors()
425 return -EINVAL; in pll_factors()
432 pll_div->prescale = 1; in pll_factors()
435 pll_div->prescale = 0; in pll_factors()
440 return -EINVAL; in pll_factors()
443 pll_div->n = Ndiv; in pll_factors()
451 pll_div->k = K; in pll_factors()
454 pll_div->n, pll_div->k, pll_div->prescale, pll_div->freqmode, in pll_factors()
455 pll_div->postscale); in pll_factors()
464 struct snd_soc_component *component = codec_dai->component; in wm8580_set_dai_pll()
479 state = &wm8580->a; in wm8580_set_dai_pll()
484 state = &wm8580->b; in wm8580_set_dai_pll()
489 return -ENODEV; in wm8580_set_dai_pll()
498 state->in = freq_in; in wm8580_set_dai_pll()
499 state->out = freq_out; in wm8580_set_dai_pll()
501 /* Always disable the PLL - it is not safe to leave it running in wm8580_set_dai_pll()
538 struct snd_soc_component *component = dai->component; in wm8580_paif_hw_params()
562 return -EINVAL; in wm8580_paif_hw_params()
566 ratio = wm8580->sysclk[dai->driver->id] / params_rate(params); in wm8580_paif_hw_params()
571 dev_err(component->dev, "Invalid clock ratio %d/%d\n", in wm8580_paif_hw_params()
572 wm8580->sysclk[dai->driver->id], params_rate(params)); in wm8580_paif_hw_params()
573 return -EINVAL; in wm8580_paif_hw_params()
576 dev_dbg(component->dev, "Running at %dfs with %dHz clock\n", in wm8580_paif_hw_params()
577 wm8580_sysclk_ratios[i], wm8580->sysclk[dai->driver->id]); in wm8580_paif_hw_params()
579 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in wm8580_paif_hw_params()
584 dev_dbg(component->dev, "Selecting 64x OSR\n"); in wm8580_paif_hw_params()
588 dev_dbg(component->dev, "Selecting 128x OSR\n"); in wm8580_paif_hw_params()
595 snd_soc_component_update_bits(component, WM8580_PAIF1 + dai->driver->id, in wm8580_paif_hw_params()
598 snd_soc_component_update_bits(component, WM8580_PAIF3 + dai->driver->id, in wm8580_paif_hw_params()
606 struct snd_soc_component *component = codec_dai->component; in wm8580_set_paif_dai_fmt()
611 aifa = snd_soc_component_read(component, WM8580_PAIF1 + codec_dai->driver->id); in wm8580_set_paif_dai_fmt()
612 aifb = snd_soc_component_read(component, WM8580_PAIF3 + codec_dai->driver->id); in wm8580_set_paif_dai_fmt()
624 return -EINVAL; in wm8580_set_paif_dai_fmt()
650 return -EINVAL; in wm8580_set_paif_dai_fmt()
659 return -EINVAL; in wm8580_set_paif_dai_fmt()
670 return -EINVAL; in wm8580_set_paif_dai_fmt()
675 return -EINVAL; in wm8580_set_paif_dai_fmt()
678 snd_soc_component_write(component, WM8580_PAIF1 + codec_dai->driver->id, aifa); in wm8580_set_paif_dai_fmt()
679 snd_soc_component_write(component, WM8580_PAIF3 + codec_dai->driver->id, aifb); in wm8580_set_paif_dai_fmt()
687 struct snd_soc_component *component = codec_dai->component; in wm8580_set_dai_clkdiv()
712 return -EINVAL; in wm8580_set_dai_clkdiv()
738 return -EINVAL; in wm8580_set_dai_clkdiv()
744 return -EINVAL; in wm8580_set_dai_clkdiv()
753 struct snd_soc_component *component = dai->component; in wm8580_set_sysclk()
757 switch (dai->driver->id) { in wm8580_set_sysclk()
769 WARN(1, "Unknown DAI driver ID\n"); in wm8580_set_sysclk()
770 return -EINVAL; in wm8580_set_sysclk()
775 if (dai->driver->id != WM8580_DAI_PAIFTX) in wm8580_set_sysclk()
776 return -EINVAL; in wm8580_set_sysclk()
789 dev_err(component->dev, "Unknown clock %d\n", clk_id); in wm8580_set_sysclk()
790 return -EINVAL; in wm8580_set_sysclk()
794 wm8580->sysclk[dai->driver->id] = freq; in wm8580_set_sysclk()
805 struct snd_soc_component *component = codec_dai->component; in wm8580_mute()
821 enum snd_soc_bias_level level) in wm8580_set_bias_level() argument
823 switch (level) { in wm8580_set_bias_level()
852 struct snd_soc_component *component = dai->component; in wm8580_playback_startup()
855 return snd_pcm_hw_constraint_minmax(substream->runtime, in wm8580_playback_startup()
856 SNDRV_PCM_HW_PARAM_CHANNELS, 1, wm8580->drvdata->num_dacs * 2); in wm8580_playback_startup()
883 .name = "wm8580-hifi-playback",
894 .name = "wm8580-hifi-capture",
913 switch (wm8580->drvdata->num_dacs) { in wm8580_probe()
926 ret = regulator_bulk_enable(ARRAY_SIZE(wm8580->supplies), in wm8580_probe()
927 wm8580->supplies); in wm8580_probe()
929 dev_err(component->dev, "Failed to enable supplies: %d\n", ret); in wm8580_probe()
936 dev_err(component->dev, "Failed to reset component: %d\n", ret); in wm8580_probe()
943 regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies); in wm8580_probe()
953 regulator_bulk_disable(ARRAY_SIZE(wm8580->supplies), wm8580->supplies); in wm8580_remove()
1004 wm8580 = devm_kzalloc(&i2c->dev, sizeof(struct wm8580_priv), in wm8580_i2c_probe()
1007 return -ENOMEM; in wm8580_i2c_probe()
1009 wm8580->regmap = devm_regmap_init_i2c(i2c, &wm8580_regmap); in wm8580_i2c_probe()
1010 if (IS_ERR(wm8580->regmap)) in wm8580_i2c_probe()
1011 return PTR_ERR(wm8580->regmap); in wm8580_i2c_probe()
1013 for (i = 0; i < ARRAY_SIZE(wm8580->supplies); i++) in wm8580_i2c_probe()
1014 wm8580->supplies[i].supply = wm8580_supply_names[i]; in wm8580_i2c_probe()
1016 ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(wm8580->supplies), in wm8580_i2c_probe()
1017 wm8580->supplies); in wm8580_i2c_probe()
1019 dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); in wm8580_i2c_probe()
1025 of_id = of_match_device(wm8580_of_match, &i2c->dev); in wm8580_i2c_probe()
1027 wm8580->drvdata = of_id->data; in wm8580_i2c_probe()
1029 if (!wm8580->drvdata) { in wm8580_i2c_probe()
1030 dev_err(&i2c->dev, "failed to find driver data\n"); in wm8580_i2c_probe()
1031 return -EINVAL; in wm8580_i2c_probe()
1034 ret = devm_snd_soc_register_component(&i2c->dev, in wm8580_i2c_probe()