Commit 76c39e86 authored by Kuninori Morimoto's avatar Kuninori Morimoto Committed by Mark Brown

ASoC: soc-core: do pinctrl_pm_select_xxx() as component

ALSA SoC need to care pinctrl_pm_select_xxx().
It is called at soc-core and soc-pcm.
soc-pcm  is controlling it for activate DAI.
soc-core is controlling it for whole system
(= suspend/resume/probe/poweroff).

If we focus to soc-core side, it need to care about BIAS level.
Then, snd_soc_suspend() only is controlling it by Component base (a).
Other functions are DAI base (b).

(a)	pinctrl_pm_select_xxx(component->dev, xxx);
(b)	pinctrl_pm_select_xxx(dai->dev, xxx);

Because of these unbalance, the code is confusable.
Here, dai->dev and component->dev are same pointer.
Thus, we can replace it component base.

One note here is that it cared DAI (= CPU/Codec) pin before this patch,
after this patch, it cares Component (= CPU/Codec/Platform) pin.
Signed-off-by: default avatarKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Reviewed-By: default avatarRanjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://lore.kernel.org/r/874kx4t4v6.wl-kuninori.morimoto.gx@renesas.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent d7a8cb49
...@@ -727,25 +727,16 @@ int snd_soc_resume(struct device *dev) ...@@ -727,25 +727,16 @@ int snd_soc_resume(struct device *dev)
struct snd_soc_card *card = dev_get_drvdata(dev); struct snd_soc_card *card = dev_get_drvdata(dev);
bool bus_control = false; bool bus_control = false;
struct snd_soc_pcm_runtime *rtd; struct snd_soc_pcm_runtime *rtd;
struct snd_soc_dai *codec_dai; struct snd_soc_component *component;
int i;
/* If the card is not initialized yet there is nothing to do */ /* If the card is not initialized yet there is nothing to do */
if (!card->instantiated) if (!card->instantiated)
return 0; return 0;
/* activate pins from sleep state */ /* activate pins from sleep state */
for_each_card_rtds(card, rtd) { for_each_card_components(card, component)
struct snd_soc_dai *cpu_dai = rtd->cpu_dai; if (component->active)
pinctrl_pm_select_default_state(component->dev);
if (cpu_dai->active)
pinctrl_pm_select_default_state(cpu_dai->dev);
for_each_rtd_codec_dai(rtd, i, codec_dai) {
if (codec_dai->active)
pinctrl_pm_select_default_state(codec_dai->dev);
}
}
/* /*
* DAIs that also act as the control bus master might have other drivers * DAIs that also act as the control bus master might have other drivers
...@@ -1885,6 +1876,7 @@ static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister) ...@@ -1885,6 +1876,7 @@ static void snd_soc_unbind_card(struct snd_soc_card *card, bool unregister)
static int snd_soc_bind_card(struct snd_soc_card *card) static int snd_soc_bind_card(struct snd_soc_card *card)
{ {
struct snd_soc_pcm_runtime *rtd; struct snd_soc_pcm_runtime *rtd;
struct snd_soc_component *component;
struct snd_soc_dai_link *dai_link; struct snd_soc_dai_link *dai_link;
int ret, i, card_probed = 0; int ret, i, card_probed = 0;
...@@ -2036,17 +2028,9 @@ static int snd_soc_bind_card(struct snd_soc_card *card) ...@@ -2036,17 +2028,9 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
snd_soc_dapm_sync(&card->dapm); snd_soc_dapm_sync(&card->dapm);
/* deactivate pins to sleep state */ /* deactivate pins to sleep state */
for_each_card_rtds(card, rtd) { for_each_card_components(card, component)
struct snd_soc_dai *dai; if (!component->active)
pinctrl_pm_select_sleep_state(component->dev);
for_each_rtd_codec_dai(rtd, i, dai) {
if (!dai->active)
pinctrl_pm_select_sleep_state(dai->dev);
}
if (!rtd->cpu_dai->active)
pinctrl_pm_select_sleep_state(rtd->cpu_dai->dev);
}
probe_end: probe_end:
if (ret < 0) if (ret < 0)
...@@ -2092,7 +2076,7 @@ static int soc_remove(struct platform_device *pdev) ...@@ -2092,7 +2076,7 @@ static int soc_remove(struct platform_device *pdev)
int snd_soc_poweroff(struct device *dev) int snd_soc_poweroff(struct device *dev)
{ {
struct snd_soc_card *card = dev_get_drvdata(dev); struct snd_soc_card *card = dev_get_drvdata(dev);
struct snd_soc_pcm_runtime *rtd; struct snd_soc_component *component;
if (!card->instantiated) if (!card->instantiated)
return 0; return 0;
...@@ -2106,16 +2090,8 @@ int snd_soc_poweroff(struct device *dev) ...@@ -2106,16 +2090,8 @@ int snd_soc_poweroff(struct device *dev)
snd_soc_dapm_shutdown(card); snd_soc_dapm_shutdown(card);
/* deactivate pins to sleep state */ /* deactivate pins to sleep state */
for_each_card_rtds(card, rtd) { for_each_card_components(card, component)
struct snd_soc_dai *cpu_dai = rtd->cpu_dai; pinctrl_pm_select_sleep_state(component->dev);
struct snd_soc_dai *codec_dai;
int i;
pinctrl_pm_select_sleep_state(cpu_dai->dev);
for_each_rtd_codec_dai(rtd, i, codec_dai) {
pinctrl_pm_select_sleep_state(codec_dai->dev);
}
}
return 0; return 0;
} }
......
...@@ -487,9 +487,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) ...@@ -487,9 +487,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
const char *codec_dai_name = "multicodec"; const char *codec_dai_name = "multicodec";
int i, ret = 0; int i, ret = 0;
pinctrl_pm_select_default_state(cpu_dai->dev); for_each_rtd_components(rtd, i, component)
for_each_rtd_codec_dai(rtd, i, codec_dai) pinctrl_pm_select_default_state(component->dev);
pinctrl_pm_select_default_state(codec_dai->dev);
for_each_rtd_components(rtd, i, component) for_each_rtd_components(rtd, i, component)
pm_runtime_get_sync(component->dev); pm_runtime_get_sync(component->dev);
...@@ -618,12 +617,9 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) ...@@ -618,12 +617,9 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
pm_runtime_put_autosuspend(component->dev); pm_runtime_put_autosuspend(component->dev);
} }
for_each_rtd_codec_dai(rtd, i, codec_dai) { for_each_rtd_components(rtd, i, component)
if (!codec_dai->active) if (!component->active)
pinctrl_pm_select_sleep_state(codec_dai->dev); pinctrl_pm_select_sleep_state(component->dev);
}
if (!cpu_dai->active)
pinctrl_pm_select_sleep_state(cpu_dai->dev);
return ret; return ret;
} }
...@@ -728,12 +724,9 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) ...@@ -728,12 +724,9 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
pm_runtime_put_autosuspend(component->dev); pm_runtime_put_autosuspend(component->dev);
} }
for_each_rtd_codec_dai(rtd, i, codec_dai) { for_each_rtd_components(rtd, i, component)
if (!codec_dai->active) if (!component->active)
pinctrl_pm_select_sleep_state(codec_dai->dev); pinctrl_pm_select_sleep_state(component->dev);
}
if (!cpu_dai->active)
pinctrl_pm_select_sleep_state(cpu_dai->dev);
return 0; return 0;
} }
......
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