Commit c0454d31 authored by Samuel Holland's avatar Samuel Holland Committed by Mark Brown

ASoC: sun50i-codec-analog: Move suspend/resume to set_bias_level

With idle_bias_on and suspend_bias_off, there are bias level transitions
that match the suspend/resume callbacks. However, there are also
transitions during probe (OFF => STANDBY) and removal (STANDBY => OFF).

By using the set_bias_level hook, the driver can have one copy of code
that would otherwise be duplicated between the probe/resume and
suspend/remove hooks.
Signed-off-by: default avatarSamuel Holland <samuel@sholland.org>
Signed-off-by: default avatarOndřej Jirman <megi@xff.cz>
Link: https://msgid.link/r/20240302140042.1990256-2-megi@xff.czSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 4cece764
...@@ -471,17 +471,23 @@ static const struct snd_soc_dapm_route sun50i_a64_codec_routes[] = { ...@@ -471,17 +471,23 @@ static const struct snd_soc_dapm_route sun50i_a64_codec_routes[] = {
{ "EARPIECE", NULL, "Earpiece Amp" }, { "EARPIECE", NULL, "Earpiece Amp" },
}; };
static int sun50i_a64_codec_suspend(struct snd_soc_component *component) static int sun50i_a64_codec_set_bias_level(struct snd_soc_component *component,
enum snd_soc_bias_level level)
{ {
return regmap_update_bits(component->regmap, SUN50I_ADDA_HP_CTRL, switch (level) {
BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE), case SND_SOC_BIAS_OFF:
regmap_set_bits(component->regmap, SUN50I_ADDA_HP_CTRL,
BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE)); BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE));
} break;
case SND_SOC_BIAS_STANDBY:
regmap_clear_bits(component->regmap, SUN50I_ADDA_HP_CTRL,
BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE));
break;
default:
break;
}
static int sun50i_a64_codec_resume(struct snd_soc_component *component) return 0;
{
return regmap_update_bits(component->regmap, SUN50I_ADDA_HP_CTRL,
BIT(SUN50I_ADDA_HP_CTRL_PA_CLK_GATE), 0);
} }
static const struct snd_soc_component_driver sun50i_codec_analog_cmpnt_drv = { static const struct snd_soc_component_driver sun50i_codec_analog_cmpnt_drv = {
...@@ -491,8 +497,9 @@ static const struct snd_soc_component_driver sun50i_codec_analog_cmpnt_drv = { ...@@ -491,8 +497,9 @@ static const struct snd_soc_component_driver sun50i_codec_analog_cmpnt_drv = {
.num_dapm_widgets = ARRAY_SIZE(sun50i_a64_codec_widgets), .num_dapm_widgets = ARRAY_SIZE(sun50i_a64_codec_widgets),
.dapm_routes = sun50i_a64_codec_routes, .dapm_routes = sun50i_a64_codec_routes,
.num_dapm_routes = ARRAY_SIZE(sun50i_a64_codec_routes), .num_dapm_routes = ARRAY_SIZE(sun50i_a64_codec_routes),
.suspend = sun50i_a64_codec_suspend, .set_bias_level = sun50i_a64_codec_set_bias_level,
.resume = sun50i_a64_codec_resume, .idle_bias_on = true,
.suspend_bias_off = true,
}; };
static const struct of_device_id sun50i_codec_analog_of_match[] = { static const struct of_device_id sun50i_codec_analog_of_match[] = {
......
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