Commit c51cba47 authored by Mark Brown's avatar Mark Brown

Fix the unbalanced pm_runtime_enable in wcd937x-sdw

Merge series from Mohammad Rafi Shaik <quic_mohs@quicinc.com>:

This patch set change will fix the unbalanced pm_runtime_enable in wcd937x-sdw soundwire slave.

And removed the string compare with widget name in MIC BIAS settings, instead
of string compare use the MIC BIAS id's as value.

Removed separate handling for vdd-buck regulator supply which is not
required. The vdd-buck regulator supply enabled using bulk enable.

Added the error handling in wcd937x_probe() and disable the regulators in error case.
parents 75ed63a5 216d0413
...@@ -1067,13 +1067,15 @@ static int wcd9370_probe(struct sdw_slave *pdev, ...@@ -1067,13 +1067,15 @@ static int wcd9370_probe(struct sdw_slave *pdev,
wcd->ch_info = &wcd937x_sdw_rx_ch_info[0]; wcd->ch_info = &wcd937x_sdw_rx_ch_info[0];
} }
pm_runtime_set_autosuspend_delay(dev, 3000);
pm_runtime_use_autosuspend(dev);
pm_runtime_mark_last_busy(dev);
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
return component_add(dev, &wcd937x_sdw_component_ops); ret = component_add(dev, &wcd937x_sdw_component_ops);
if (ret)
return ret;
/* Set suspended until aggregate device is bind */
pm_runtime_set_suspended(dev);
return 0;
} }
static int wcd9370_remove(struct sdw_slave *pdev) static int wcd9370_remove(struct sdw_slave *pdev)
...@@ -1082,10 +1084,6 @@ static int wcd9370_remove(struct sdw_slave *pdev) ...@@ -1082,10 +1084,6 @@ static int wcd9370_remove(struct sdw_slave *pdev)
component_del(dev, &wcd937x_sdw_component_ops); component_del(dev, &wcd937x_sdw_component_ops);
pm_runtime_disable(dev);
pm_runtime_set_suspended(dev);
pm_runtime_dont_use_autosuspend(dev);
return 0; return 0;
} }
......
...@@ -869,37 +869,6 @@ static int wcd937x_enable_rx3(struct snd_soc_dapm_widget *w, ...@@ -869,37 +869,6 @@ static int wcd937x_enable_rx3(struct snd_soc_dapm_widget *w,
return 0; 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) static int wcd937x_get_micb_vout_ctl_val(u32 micb_mv)
{ {
if (micb_mv < 1000 || micb_mv > 2850) { if (micb_mv < 1000 || micb_mv > 2850) {
...@@ -1164,16 +1133,7 @@ static int __wcd937x_codec_enable_micbias(struct snd_soc_dapm_widget *w, ...@@ -1164,16 +1133,7 @@ static int __wcd937x_codec_enable_micbias(struct snd_soc_dapm_widget *w,
int event) int event)
{ {
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
int micb_num; int micb_num = w->shift;
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;
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
...@@ -1203,16 +1163,7 @@ static int __wcd937x_codec_enable_micbias_pullup(struct snd_soc_dapm_widget *w, ...@@ -1203,16 +1163,7 @@ static int __wcd937x_codec_enable_micbias_pullup(struct snd_soc_dapm_widget *w,
int event) int event)
{ {
struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm); struct snd_soc_component *component = snd_soc_dapm_to_component(w->dapm);
int micb_num; int micb_num = w->shift;
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;
switch (event) { switch (event) {
case SND_SOC_DAPM_PRE_PMU: case SND_SOC_DAPM_PRE_PMU:
...@@ -2231,23 +2182,20 @@ static const struct snd_soc_dapm_widget wcd937x_dapm_widgets[] = { ...@@ -2231,23 +2182,20 @@ static const struct snd_soc_dapm_widget wcd937x_dapm_widgets[] = {
SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_POST_PMD),
/* MIC_BIAS widgets */ /* 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, wcd937x_codec_enable_micbias,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_POST_PMD), 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, wcd937x_codec_enable_micbias,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_POST_PMD), 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, wcd937x_codec_enable_micbias,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_SUPPLY("VDD_BUCK", SND_SOC_NOPM, 0, 0, SND_SOC_DAPM_SUPPLY("VDD_BUCK", SND_SOC_NOPM, 0, 0, NULL, 0),
wcd937x_codec_enable_vdd_buck,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMD),
SND_SOC_DAPM_SUPPLY_S("CLS_H_PORT", 1, 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 */ /* RX widgets */
...@@ -2320,15 +2268,15 @@ static const struct snd_soc_dapm_widget wcd937x_dapm_widgets[] = { ...@@ -2320,15 +2268,15 @@ static const struct snd_soc_dapm_widget wcd937x_dapm_widgets[] = {
SND_SOC_DAPM_OUTPUT("HPHR"), SND_SOC_DAPM_OUTPUT("HPHR"),
/* MIC_BIAS pull up widgets */ /* 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, wcd937x_codec_enable_micbias_pullup,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_POST_PMD), 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, wcd937x_codec_enable_micbias_pullup,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_POST_PMD), 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, wcd937x_codec_enable_micbias_pullup,
SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_PRE_PMU | SND_SOC_DAPM_POST_PMU |
SND_SOC_DAPM_POST_PMD), SND_SOC_DAPM_POST_PMD),
...@@ -2933,24 +2881,17 @@ static int wcd937x_probe(struct platform_device *pdev) ...@@ -2933,24 +2881,17 @@ static int wcd937x_probe(struct platform_device *pdev)
wcd937x->supplies[0].supply = "vdd-rxtx"; wcd937x->supplies[0].supply = "vdd-rxtx";
wcd937x->supplies[1].supply = "vdd-px"; wcd937x->supplies[1].supply = "vdd-px";
wcd937x->supplies[2].supply = "vdd-mic-bias"; 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); ret = devm_regulator_bulk_get(dev, WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies);
if (ret) if (ret)
return dev_err_probe(dev, ret, "Failed to get supplies\n"); return dev_err_probe(dev, ret, "Failed to get supplies\n");
ret = regulator_bulk_enable(WCD937X_MAX_BULK_SUPPLY, wcd937x->supplies); 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"); 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); wcd937x_dt_parse_micbias_info(dev, wcd937x);
...@@ -2967,13 +2908,13 @@ static int wcd937x_probe(struct platform_device *pdev) ...@@ -2967,13 +2908,13 @@ static int wcd937x_probe(struct platform_device *pdev)
ret = wcd937x_add_slave_components(wcd937x, dev, &match); ret = wcd937x_add_slave_components(wcd937x, dev, &match);
if (ret) if (ret)
return ret; goto err_disable_regulators;
wcd937x_reset(wcd937x); wcd937x_reset(wcd937x);
ret = component_master_add_with_match(dev, &wcd937x_comp_ops, match); ret = component_master_add_with_match(dev, &wcd937x_comp_ops, match);
if (ret) if (ret)
return ret; goto err_disable_regulators;
pm_runtime_set_autosuspend_delay(dev, 1000); pm_runtime_set_autosuspend_delay(dev, 1000);
pm_runtime_use_autosuspend(dev); pm_runtime_use_autosuspend(dev);
...@@ -2982,6 +2923,12 @@ static int wcd937x_probe(struct platform_device *pdev) ...@@ -2982,6 +2923,12 @@ static int wcd937x_probe(struct platform_device *pdev)
pm_runtime_enable(dev); pm_runtime_enable(dev);
pm_runtime_idle(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; return ret;
} }
......
...@@ -483,7 +483,7 @@ ...@@ -483,7 +483,7 @@
#define WCD937X_MAX_REGISTER (WCD937X_DIGITAL_EFUSE_REG_31) #define WCD937X_MAX_REGISTER (WCD937X_DIGITAL_EFUSE_REG_31)
#define WCD937X_MAX_MICBIAS 3 #define WCD937X_MAX_MICBIAS 3
#define WCD937X_MAX_BULK_SUPPLY 3 #define WCD937X_MAX_BULK_SUPPLY 4
#define WCD937X_MAX_TX_SWR_PORTS 4 #define WCD937X_MAX_TX_SWR_PORTS 4
#define WCD937X_MAX_SWR_PORTS 5 #define WCD937X_MAX_SWR_PORTS 5
#define WCD937X_MAX_SWR_CH_IDS 15 #define WCD937X_MAX_SWR_CH_IDS 15
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment