summaryrefslogtreecommitdiffstats
path: root/sound/soc/codecs/wcd937x.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/codecs/wcd937x.c')
-rw-r--r--sound/soc/codecs/wcd937x.c95
1 files changed, 21 insertions, 74 deletions
diff --git a/sound/soc/codecs/wcd937x.c b/sound/soc/codecs/wcd937x.c
index 4beb70bc4d8c..13926f4b0d9f 100644
--- a/sound/soc/codecs/wcd937x.c
+++ b/sound/soc/codecs/wcd937x.c
@@ -869,37 +869,6 @@ static int wcd937x_enable_rx3(struct snd_soc_dapm_widget *w,
return 0;
}
-static int wcd937x_codec_enable_vdd_buck(struct snd_soc_dapm_widget *w,
- struct snd_kcontrol *kcontrol,
- int event)
-{
- struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
- struct wcd937x_priv *wcd937x = snd_soc_component_get_drvdata(component);
- int ret = 0;
-
- switch (event) {
- case SND_SOC_DAPM_PRE_PMU:
- if (test_bit(ALLOW_BUCK_DISABLE, &wcd937x->status_mask)) {
- dev_err(component->dev, "buck already in enabled state\n");
- clear_bit(ALLOW_BUCK_DISABLE, &wcd937x->status_mask);
- return 0;
- }
- ret = regulator_enable(wcd937x->buck_supply);
- if (ret) {
- dev_err(component->dev, "VDD_BUCK is not enabled\n");
- return ret;
- }
- clear_bit(ALLOW_BUCK_DISABLE, &wcd937x->status_mask);
- usleep_range(200, 250);
- break;
- case SND_SOC_DAPM_POST_PMD:
- set_bit(ALLOW_BUCK_DISABLE, &wcd937x->status_mask);
- break;
- }
-
- return 0;
-}
-
static int wcd937x_get_micb_vout_ctl_val(u32 micb_mv)
{
if (micb_mv < 1000 || micb_mv > 2850) {
@@ -1164,16 +1133,7 @@ static int __wcd937x_codec_enable_micbias(struct snd_soc_dapm_widget *w,
int event)
{
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
- int micb_num;
-
- if (strnstr(w->name, "MIC BIAS1", sizeof("MIC BIAS1")))
- micb_num = MIC_BIAS_1;
- else if (strnstr(w->name, "MIC BIAS2", sizeof("MIC BIAS2")))
- micb_num = MIC_BIAS_2;
- else if (strnstr(w->name, "MIC BIAS3", sizeof("MIC BIAS3")))
- micb_num = MIC_BIAS_3;
- else
- return -EINVAL;
+ int micb_num = w->shift;
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
@@ -1203,16 +1163,7 @@ static int __wcd937x_codec_enable_micbias_pullup(struct snd_soc_dapm_widget *w,
int event)
{
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
- int micb_num;
-
- if (strnstr(w->name, "VA MIC BIAS1", sizeof("VA MIC BIAS1")))
- micb_num = MIC_BIAS_1;
- else if (strnstr(w->name, "VA MIC BIAS2", sizeof("VA MIC BIAS2")))
- micb_num = MIC_BIAS_2;
- else if (strnstr(w->name, "VA MIC BIAS3", sizeof("VA MIC BIAS3")))
- micb_num = MIC_BIAS_3;
- else
- return -EINVAL;
+ int micb_num = w->shift;
switch (event) {
case SND_SOC_DAPM_PRE_PMU:
@@ -2231,23 +2182,20 @@ static const struct snd_soc_dapm_widget wcd937x_dapm_widgets[] = {
SND_SOC_DAPM_POST_PMD),
/* MIC_BIAS widgets */
- SND_SOC_DAPM_SUPPLY("MIC BIAS1", SND_SOC_NOPM, 0, 0,
+ SND_SOC_DAPM_SUPPLY("MIC BIAS1", SND_SOC_NOPM, MIC_BIAS_1, 0,
wcd937x_codec_enable_micbias,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SUPPLY("MIC BIAS2", SND_SOC_NOPM, 0, 0,
+ SND_SOC_DAPM_SUPPLY("MIC BIAS2", SND_SOC_NOPM, MIC_BIAS_2, 0,
wcd937x_codec_enable_micbias,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SUPPLY("MIC BIAS3", SND_SOC_NOPM, 0, 0,
+ SND_SOC_DAPM_SUPPLY("MIC BIAS3", SND_SOC_NOPM, MIC_BIAS_3, 0,
wcd937x_codec_enable_micbias,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SUPPLY("VDD_BUCK", SND_SOC_NOPM, 0, 0,
- wcd937x_codec_enable_vdd_buck,
- SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
-
+ SND_SOC_DAPM_SUPPLY("VDD_BUCK", SND_SOC_NOPM, 0, 0, NULL, 0),
SND_SOC_DAPM_SUPPLY_S("CLS_H_PORT", 1, SND_SOC_NOPM, 0, 0, NULL, 0),
/* RX widgets */
@@ -2320,15 +2268,15 @@ static const struct snd_soc_dapm_widget wcd937x_dapm_widgets[] = {
SND_SOC_DAPM_OUTPUT("HPHR"),
/* MIC_BIAS pull up widgets */
- SND_SOC_DAPM_SUPPLY("VA MIC BIAS1", SND_SOC_NOPM, 0, 0,
+ SND_SOC_DAPM_SUPPLY("VA MIC BIAS1", SND_SOC_NOPM, MIC_BIAS_1, 0,
wcd937x_codec_enable_micbias_pullup,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SUPPLY("VA MIC BIAS2", SND_SOC_NOPM, 0, 0,
+ SND_SOC_DAPM_SUPPLY("VA MIC BIAS2", SND_SOC_NOPM, MIC_BIAS_2, 0,
wcd937x_codec_enable_micbias_pullup,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_POST_PMD),
- SND_SOC_DAPM_SUPPLY("VA MIC BIAS3", SND_SOC_NOPM, 0, 0,
+ SND_SOC_DAPM_SUPPLY("VA MIC BIAS3", SND_SOC_NOPM, MIC_BIAS_3, 0,
wcd937x_codec_enable_micbias_pullup,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_POST_PMD),
@@ -2933,24 +2881,17 @@ static int wcd937x_probe(struct platform_device *pdev)
wcd937x->supplies[0].supply = "vdd-rxtx";
wcd937x->supplies[1].supply = "vdd-px";
wcd937x->supplies[2].supply = "vdd-mic-bias";
+ wcd937x->supplies[3].supply = "vdd-buck";
ret = devm_regulator_bulk_get(dev, WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies);
if (ret)
return dev_err_probe(dev, ret, "Failed to get supplies\n");
ret = regulator_bulk_enable(WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies);
- if (ret)
+ if (ret) {
+ regulator_bulk_free(WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies);
return dev_err_probe(dev, ret, "Failed to enable supplies\n");
-
- /* Get the buck separately, as it needs special handling */
- wcd937x->buck_supply = devm_regulator_get(dev, "vdd-buck");
- if (IS_ERR(wcd937x->buck_supply))
- return dev_err_probe(dev, PTR_ERR(wcd937x->buck_supply),
- "Failed to get buck supply\n");
-
- ret = regulator_enable(wcd937x->buck_supply);
- if (ret)
- return dev_err_probe(dev, ret, "Failed to enable buck supply\n");
+ }
wcd937x_dt_parse_micbias_info(dev, wcd937x);
@@ -2967,13 +2908,13 @@ static int wcd937x_probe(struct platform_device *pdev)
ret = wcd937x_add_slave_components(wcd937x, dev, &match);
if (ret)
- return ret;
+ goto err_disable_regulators;
wcd937x_reset(wcd937x);
ret = component_master_add_with_match(dev, &wcd937x_comp_ops, match);
if (ret)
- return ret;
+ goto err_disable_regulators;
pm_runtime_set_autosuspend_delay(dev, 1000);
pm_runtime_use_autosuspend(dev);
@@ -2982,6 +2923,12 @@ static int wcd937x_probe(struct platform_device *pdev)
pm_runtime_enable(dev);
pm_runtime_idle(dev);
+ return 0;
+
+err_disable_regulators:
+ regulator_bulk_disable(WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies);
+ regulator_bulk_free(WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies);
+
return ret;
}