asoc: codecs: Update LPM voting support in codec supplies

For power saving during RBSC, need to vote for minimum
or zero current on load for respective regulator to
enter LPM mode. Add required support from audio WCD/WSA
to vote accordingly during suspend/resume.

Change-Id: I578195b84ba18a0b69dde3b93a3f6461efa85f7f
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
This commit is contained in:
Laxminath Kasam
2020-04-29 17:57:00 +05:30
förälder 127718f3d9
incheckning ec8a0b507c
6 ändrade filer med 182 tillägg och 7 borttagningar

Visa fil

@@ -72,6 +72,7 @@ enum {
HPH_COMP_DELAY,
HPH_PA_DELAY,
AMIC2_BCS_ENABLE,
WCD_SUPPLIES_LPM_MODE,
};
enum {
@@ -3713,6 +3714,26 @@ static void wcd938x_soc_codec_remove(struct snd_soc_component *component)
false);
}
static int wcd938x_soc_codec_suspend(struct snd_soc_component *component)
{
struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
if (!wcd938x)
return 0;
wcd938x->dapm_bias_off = true;
return 0;
}
static int wcd938x_soc_codec_resume(struct snd_soc_component *component)
{
struct wcd938x_priv *wcd938x = snd_soc_component_get_drvdata(component);
if (!wcd938x)
return 0;
wcd938x->dapm_bias_off = false;
return 0;
}
static struct snd_soc_component_driver soc_codec_dev_wcd938x = {
.name = WCD938X_DRV_NAME,
.probe = wcd938x_soc_codec_probe,
@@ -3723,6 +3744,8 @@ static struct snd_soc_component_driver soc_codec_dev_wcd938x = {
.num_dapm_widgets = ARRAY_SIZE(wcd938x_dapm_widgets),
.dapm_routes = wcd938x_audio_map,
.num_dapm_routes = ARRAY_SIZE(wcd938x_audio_map),
.suspend = wcd938x_soc_codec_suspend,
.resume = wcd938x_soc_codec_resume,
};
static int wcd938x_reset(struct device *dev)
@@ -4242,19 +4265,51 @@ static int wcd938x_suspend(struct device *dev)
}
clear_bit(ALLOW_BUCK_DISABLE, &wcd938x->status_mask);
}
if (wcd938x->dapm_bias_off) {
msm_cdc_set_supplies_lpm_mode(wcd938x->dev,
wcd938x->supplies,
pdata->regulator,
pdata->num_supplies,
true);
set_bit(WCD_SUPPLIES_LPM_MODE, &wcd938x->status_mask);
}
return 0;
}
static int wcd938x_resume(struct device *dev)
{
struct wcd938x_priv *wcd938x = NULL;
struct wcd938x_pdata *pdata = NULL;
if (!dev)
return -ENODEV;
wcd938x = dev_get_drvdata(dev);
if (!wcd938x)
return -EINVAL;
pdata = dev_get_platdata(wcd938x->dev);
if (!pdata) {
dev_err(dev, "%s: pdata is NULL\n", __func__);
return -EINVAL;
}
if (test_bit(WCD_SUPPLIES_LPM_MODE, &wcd938x->status_mask)) {
msm_cdc_set_supplies_lpm_mode(wcd938x->dev,
wcd938x->supplies,
pdata->regulator,
pdata->num_supplies,
false);
clear_bit(WCD_SUPPLIES_LPM_MODE, &wcd938x->status_mask);
}
return 0;
}
static const struct dev_pm_ops wcd938x_dev_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(
wcd938x_suspend,
wcd938x_resume
)
.suspend_late = wcd938x_suspend,
.resume_early = wcd938x_resume,
};
#endif