• Home
  • Raw
  • Download

Lines Matching +full:regulator +full:- +full:allow +full:- +full:bypass

1 // SPDX-License-Identifier: GPL-2.0-only
3 * wm8350.c -- WM8350 ALSA SoC audio driver
5 * Copyright (C) 2007-12 Wolfson Microelectronics PLC.
19 #include <linux/regulator/consumer.h>
77 struct wm8350_output *out1 = &wm8350_data->out1; in wm8350_out1_ramp_step()
78 struct wm8350 *wm8350 = wm8350_data->wm8350; in wm8350_out1_ramp_step()
86 if (out1->ramp == WM8350_RAMP_UP) { in wm8350_out1_ramp_step()
88 if (val < out1->left_vol) { in wm8350_out1_ramp_step()
95 } else if (out1->ramp == WM8350_RAMP_DOWN) { in wm8350_out1_ramp_step()
98 val--; in wm8350_out1_ramp_step()
110 if (out1->ramp == WM8350_RAMP_UP) { in wm8350_out1_ramp_step()
112 if (val < out1->right_vol) { in wm8350_out1_ramp_step()
119 } else if (out1->ramp == WM8350_RAMP_DOWN) { in wm8350_out1_ramp_step()
122 val--; in wm8350_out1_ramp_step()
142 struct wm8350_output *out2 = &wm8350_data->out2; in wm8350_out2_ramp_step()
143 struct wm8350 *wm8350 = wm8350_data->wm8350; in wm8350_out2_ramp_step()
150 if (out2->ramp == WM8350_RAMP_UP) { in wm8350_out2_ramp_step()
152 if (val < out2->left_vol) { in wm8350_out2_ramp_step()
159 } else if (out2->ramp == WM8350_RAMP_DOWN) { in wm8350_out2_ramp_step()
162 val--; in wm8350_out2_ramp_step()
174 if (out2->ramp == WM8350_RAMP_UP) { in wm8350_out2_ramp_step()
176 if (val < out2->right_vol) { in wm8350_out2_ramp_step()
183 } else if (out2->ramp == WM8350_RAMP_DOWN) { in wm8350_out2_ramp_step()
186 val--; in wm8350_out2_ramp_step()
211 struct wm8350_output *out1 = &wm8350_data->out1, in wm8350_pga_work()
212 *out2 = &wm8350_data->out2; in wm8350_pga_work()
216 if (out1->ramp == WM8350_RAMP_NONE && out2->ramp == WM8350_RAMP_NONE) in wm8350_pga_work()
222 if (out1->ramp != WM8350_RAMP_NONE) in wm8350_pga_work()
224 if (out2->ramp != WM8350_RAMP_NONE) in wm8350_pga_work()
232 if (out1->ramp == WM8350_RAMP_UP || in wm8350_pga_work()
233 out2->ramp == WM8350_RAMP_UP) { in wm8350_pga_work()
245 out1->ramp = WM8350_RAMP_NONE; in wm8350_pga_work()
246 out2->ramp = WM8350_RAMP_NONE; in wm8350_pga_work()
256 struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); in pga_event()
260 switch (w->shift) { in pga_event()
263 out = &wm8350_data->out1; in pga_event()
267 out = &wm8350_data->out2; in pga_event()
271 WARN(1, "Invalid shift %d\n", w->shift); in pga_event()
272 return -1; in pga_event()
277 out->ramp = WM8350_RAMP_UP; in pga_event()
278 out->active = 1; in pga_event()
280 schedule_delayed_work(&wm8350_data->pga_work, in pga_event()
285 out->ramp = WM8350_RAMP_DOWN; in pga_event()
286 out->active = 0; in pga_event()
288 schedule_delayed_work(&wm8350_data->pga_work, in pga_event()
303 (struct soc_mixer_control *)kcontrol->private_value; in wm8350_put_volsw_2r_vu()
305 unsigned int reg = mc->reg; in wm8350_put_volsw_2r_vu()
313 out = &wm8350_priv->out1; in wm8350_put_volsw_2r_vu()
316 out = &wm8350_priv->out2; in wm8350_put_volsw_2r_vu()
323 out->left_vol = ucontrol->value.integer.value[0]; in wm8350_put_volsw_2r_vu()
324 out->right_vol = ucontrol->value.integer.value[1]; in wm8350_put_volsw_2r_vu()
325 if (!out->active) in wm8350_put_volsw_2r_vu()
344 struct wm8350_output *out1 = &wm8350_priv->out1; in wm8350_get_volsw_2r()
345 struct wm8350_output *out2 = &wm8350_priv->out2; in wm8350_get_volsw_2r()
347 (struct soc_mixer_control *)kcontrol->private_value; in wm8350_get_volsw_2r()
348 unsigned int reg = mc->reg; in wm8350_get_volsw_2r()
353 ucontrol->value.integer.value[0] = out1->left_vol; in wm8350_get_volsw_2r()
354 ucontrol->value.integer.value[1] = out1->right_vol; in wm8350_get_volsw_2r()
358 ucontrol->value.integer.value[0] = out2->left_vol; in wm8350_get_volsw_2r()
359 ucontrol->value.integer.value[1] = out2->right_vol; in wm8350_get_volsw_2r()
388 static DECLARE_TLV_DB_SCALE(pre_amp_tlv, -1200, 3525, 0);
389 static DECLARE_TLV_DB_SCALE(out_pga_tlv, -5700, 600, 0);
390 static DECLARE_TLV_DB_SCALE(dac_pcm_tlv, -7163, 36, 1);
391 static DECLARE_TLV_DB_SCALE(adc_pcm_tlv, -12700, 50, 1);
392 static DECLARE_TLV_DB_SCALE(out_mix_tlv, -1500, 300, 1);
395 0, 12, TLV_DB_SCALE_ITEM(-3600, 300, 1),
433 SOC_SINGLE_TLV("Left Input Bypass Volume",
442 SOC_SINGLE_TLV("Right Input Bypass Volume",
489 SOC_DAPM_SINGLE("Left Bypass Switch",
503 SOC_DAPM_SINGLE("Right Bypass Switch",
673 {"Left Playback Mixer", "Left Bypass Switch", "IN3L PGA"},
680 {"Right Playback Mixer", "Right Bypass Switch", "IN3R PGA"},
753 struct snd_soc_component *component = codec_dai->component; in wm8350_set_dai_sysclk()
755 struct wm8350 *wm8350 = wm8350_data->wm8350; in wm8350_set_dai_sysclk()
788 struct snd_soc_component *component = codec_dai->component; in wm8350_set_clkdiv()
828 return -EINVAL; in wm8350_set_clkdiv()
836 struct snd_soc_component *component = codec_dai->component; in wm8350_set_dai_fmt()
856 return -EINVAL; in wm8350_set_dai_fmt()
876 return -EINVAL; in wm8350_set_dai_fmt()
893 return -EINVAL; in wm8350_set_dai_fmt()
907 struct snd_soc_component *component = codec_dai->component; in wm8350_pcm_hw_params()
909 struct wm8350 *wm8350 = wm8350_data->wm8350; in wm8350_pcm_hw_params()
933 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { in wm8350_pcm_hw_params()
947 struct snd_soc_component *component = dai->component; in wm8350_mute()
969 * to allow rounding later */
979 fll_div->div = 0x4; in fll_factors()
981 fll_div->div = 0x3; in fll_factors()
983 fll_div->div = 0x2; in fll_factors()
985 fll_div->div = 0x1; in fll_factors()
988 return -EINVAL; in fll_factors()
992 fll_div->ratio = 1; in fll_factors()
994 fll_div->ratio = 8; in fll_factors()
996 t1 = output * (1 << (fll_div->div + 1)); in fll_factors()
997 t2 = input * fll_div->ratio; in fll_factors()
999 fll_div->n = t1 / t2; in fll_factors()
1013 fll_div->k = K; in fll_factors()
1015 fll_div->k = 0; in fll_factors()
1024 struct snd_soc_component *component = codec_dai->component; in wm8350_set_fll()
1026 struct wm8350 *wm8350 = priv->wm8350; in wm8350_set_fll()
1031 if (freq_in == priv->fll_freq_in && freq_out == priv->fll_freq_out) in wm8350_set_fll()
1034 /* power down FLL - we need to do this for reconfiguration */ in wm8350_set_fll()
1044 dev_dbg(wm8350->dev, in wm8350_set_fll()
1068 priv->fll_freq_out = freq_out; in wm8350_set_fll()
1069 priv->fll_freq_in = freq_in; in wm8350_set_fll()
1078 struct wm8350 *wm8350 = priv->wm8350; in wm8350_set_bias_level()
1080 wm8350->codec.platform_data; in wm8350_set_bias_level()
1090 platform->codec_current_on << 14); in wm8350_set_bias_level()
1102 ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), in wm8350_set_bias_level()
1103 priv->supplies); in wm8350_set_bias_level()
1117 platform->dis_out1 | in wm8350_set_bias_level()
1118 (platform->dis_out2 << 2) | in wm8350_set_bias_level()
1119 (platform->dis_out3 << 4) | in wm8350_set_bias_level()
1120 (platform->dis_out4 << 6)); in wm8350_set_bias_level()
1124 (platform-> in wm8350_set_bias_level()
1129 (platform->vmid_s_curve << 8)); in wm8350_set_bias_level()
1133 (platform-> in wm8350_set_bias_level()
1140 (platform-> in wm8350_set_bias_level()
1147 (platform->codec_current_standby << 14); in wm8350_set_bias_level()
1165 (platform-> in wm8350_set_bias_level()
1182 (platform->vmid_s_curve << 8)); in wm8350_set_bias_level()
1191 (platform-> in wm8350_set_bias_level()
1195 (platform->vmid_s_curve << 8) | in wm8350_set_bias_level()
1196 platform->dis_out1 | in wm8350_set_bias_level()
1197 (platform->dis_out2 << 2) | in wm8350_set_bias_level()
1198 (platform->dis_out3 << 4) | in wm8350_set_bias_level()
1199 (platform->dis_out4 << 6)); in wm8350_set_bias_level()
1209 (platform->drain_msecs)); in wm8350_set_bias_level()
1214 /* disable anti-pop */ in wm8350_set_bias_level()
1230 regulator_bulk_disable(ARRAY_SIZE(priv->supplies), in wm8350_set_bias_level()
1231 priv->supplies); in wm8350_set_bias_level()
1241 struct wm8350 *wm8350 = priv->wm8350; in wm8350_hp_work()
1247 report = jack->report; in wm8350_hp_work()
1251 snd_soc_jack_report(jack->jack, report, jack->report); in wm8350_hp_work()
1260 wm8350_hp_work(priv, &priv->hpl, WM8350_JACK_L_LVL); in wm8350_hpl_work()
1268 wm8350_hp_work(priv, &priv->hpr, WM8350_JACK_R_LVL); in wm8350_hpr_work()
1274 struct wm8350 *wm8350 = priv->wm8350; in wm8350_hpl_jack_handler()
1280 if (device_may_wakeup(wm8350->dev)) in wm8350_hpl_jack_handler()
1281 pm_wakeup_event(wm8350->dev, 250); in wm8350_hpl_jack_handler()
1284 &priv->hpl.work, msecs_to_jiffies(200)); in wm8350_hpl_jack_handler()
1292 struct wm8350 *wm8350 = priv->wm8350; in wm8350_hpr_jack_handler()
1298 if (device_may_wakeup(wm8350->dev)) in wm8350_hpr_jack_handler()
1299 pm_wakeup_event(wm8350->dev, 250); in wm8350_hpr_jack_handler()
1302 &priv->hpr.work, msecs_to_jiffies(200)); in wm8350_hpr_jack_handler()
1308 * wm8350_hp_jack_detect - Enable headphone jack detection.
1322 struct wm8350 *wm8350 = priv->wm8350; in wm8350_hp_jack_detect()
1327 priv->hpl.jack = jack; in wm8350_hp_jack_detect()
1328 priv->hpl.report = report; in wm8350_hp_jack_detect()
1333 priv->hpr.jack = jack; in wm8350_hp_jack_detect()
1334 priv->hpr.report = report; in wm8350_hp_jack_detect()
1339 return -EINVAL; in wm8350_hp_jack_detect()
1366 struct wm8350 *wm8350 = priv->wm8350; in wm8350_mic_handler()
1376 report |= priv->mic.short_report; in wm8350_mic_handler()
1378 report |= priv->mic.report; in wm8350_mic_handler()
1380 snd_soc_jack_report(priv->mic.jack, report, in wm8350_mic_handler()
1381 priv->mic.report | priv->mic.short_report); in wm8350_mic_handler()
1387 * wm8350_mic_jack_detect - Enable microphone jack detection.
1402 struct wm8350 *wm8350 = priv->wm8350; in wm8350_mic_jack_detect()
1404 priv->mic.jack = jack; in wm8350_mic_jack_detect()
1405 priv->mic.report = detect_report; in wm8350_mic_jack_detect()
1406 priv->mic.short_report = short_report; in wm8350_mic_jack_detect()
1438 .name = "wm8350-hifi",
1458 struct wm8350 *wm8350 = dev_get_platdata(component->dev); in wm8350_component_probe()
1464 if (wm8350->codec.platform_data == NULL) { in wm8350_component_probe()
1465 dev_err(component->dev, "No audio platform data supplied\n"); in wm8350_component_probe()
1466 return -EINVAL; in wm8350_component_probe()
1469 priv = devm_kzalloc(component->dev, sizeof(struct wm8350_data), in wm8350_component_probe()
1472 return -ENOMEM; in wm8350_component_probe()
1474 snd_soc_component_init_regmap(component, wm8350->regmap); in wm8350_component_probe()
1477 priv->wm8350 = wm8350; in wm8350_component_probe()
1480 priv->supplies[i].supply = supply_names[i]; in wm8350_component_probe()
1482 ret = devm_regulator_bulk_get(wm8350->dev, ARRAY_SIZE(priv->supplies), in wm8350_component_probe()
1483 priv->supplies); in wm8350_component_probe()
1490 INIT_DELAYED_WORK(&priv->pga_work, wm8350_pga_work); in wm8350_component_probe()
1491 INIT_DELAYED_WORK(&priv->hpl.work, wm8350_hpl_work); in wm8350_component_probe()
1492 INIT_DELAYED_WORK(&priv->hpr.work, wm8350_hpr_work); in wm8350_component_probe()
1503 out1 = &priv->out1; in wm8350_component_probe()
1504 out2 = &priv->out2; in wm8350_component_probe()
1505 out1->left_vol = (wm8350_reg_read(wm8350, WM8350_LOUT1_VOLUME) & in wm8350_component_probe()
1507 out1->right_vol = (wm8350_reg_read(wm8350, WM8350_ROUT1_VOLUME) & in wm8350_component_probe()
1509 out2->left_vol = (wm8350_reg_read(wm8350, WM8350_LOUT2_VOLUME) & in wm8350_component_probe()
1511 out2->right_vol = (wm8350_reg_read(wm8350, WM8350_ROUT2_VOLUME) & in wm8350_component_probe()
1576 struct wm8350 *wm8350 = dev_get_platdata(component->dev); in wm8350_component_remove()
1587 priv->hpl.jack = NULL; in wm8350_component_remove()
1588 priv->hpr.jack = NULL; in wm8350_component_remove()
1589 priv->mic.jack = NULL; in wm8350_component_remove()
1591 cancel_delayed_work_sync(&priv->hpl.work); in wm8350_component_remove()
1592 cancel_delayed_work_sync(&priv->hpr.work); in wm8350_component_remove()
1596 flush_delayed_work(&priv->pga_work); in wm8350_component_remove()
1620 return devm_snd_soc_register_component(&pdev->dev, in wm8350_probe()
1627 .name = "wm8350-codec",
1637 MODULE_ALIAS("platform:wm8350-codec");