mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 05:00:55 +07:00
ASoC: Add pinctrl PM to components of active DAIs
It's quite popular that more drivers are using pinctrl PM, for example: (Documentation/devicetree/bindings/arm/primecell.txt). Just like what runtime PM does, it would deactivate and activate pin group depending on whether it's being used or not. And this pinctrl PM might be also beneficial to cpu dai drivers because they might have actual pinctrl so as to sleep their pins and wake them up as needed. To achieve this goal, this patch sets pins to the default state during resume or startup; While during suspend and shutdown, it would set pins to the sleep state. As pinctrl PM would return zero if there is no such pinctrl sleep state settings, this patch would not break current ASoC subsystem directly. [ However, there is still an exception that the patch can not handle, that is, when cpu dai driver does not have pinctrl property but another device has it. (The AUDMUX <-> SSI on Freescale i.MX6 series for example. SSI as a cpu dai doesn't contain pinctrl property while AUDMUX, an Audio Multiplexer, has it). In this case, this kind of cpu dai driver needs to find a way to obtain the pinctrl property as its own, by moving property from AUDMUX to SSI, or creating a pins link/dependency between these two devices, or using a more decent way after we figure it out. ] Signed-off-by: Nicolin Chen <b42378@freescale.com> Signed-off-by: Mark Brown <broonie@linaro.org>
This commit is contained in:
parent
2062b4c5d2
commit
988e8cc41e
@ -662,6 +662,8 @@ int snd_soc_suspend(struct device *dev)
|
||||
codec->cache_sync = 1;
|
||||
if (codec->using_regmap)
|
||||
regcache_mark_dirty(codec->control_data);
|
||||
/* deactivate pins to sleep state */
|
||||
pinctrl_pm_select_sleep_state(codec->dev);
|
||||
break;
|
||||
default:
|
||||
dev_dbg(codec->dev,
|
||||
@ -679,6 +681,9 @@ int snd_soc_suspend(struct device *dev)
|
||||
|
||||
if (cpu_dai->driver->suspend && cpu_dai->driver->ac97_control)
|
||||
cpu_dai->driver->suspend(cpu_dai);
|
||||
|
||||
/* deactivate pins to sleep state */
|
||||
pinctrl_pm_select_sleep_state(cpu_dai->dev);
|
||||
}
|
||||
|
||||
if (card->suspend_post)
|
||||
@ -807,6 +812,16 @@ int snd_soc_resume(struct device *dev)
|
||||
if (list_empty(&card->codec_dev_list))
|
||||
return 0;
|
||||
|
||||
/* activate pins from sleep state */
|
||||
for (i = 0; i < card->num_rtd; i++) {
|
||||
struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
|
||||
struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai;
|
||||
if (cpu_dai->active)
|
||||
pinctrl_pm_select_default_state(cpu_dai->dev);
|
||||
if (codec_dai->active)
|
||||
pinctrl_pm_select_default_state(codec_dai->dev);
|
||||
}
|
||||
|
||||
/* AC97 devices might have other drivers hanging off them so
|
||||
* need to resume immediately. Other drivers don't have that
|
||||
* problem and may take a substantial amount of time to resume
|
||||
@ -1930,6 +1945,14 @@ int snd_soc_poweroff(struct device *dev)
|
||||
|
||||
snd_soc_dapm_shutdown(card);
|
||||
|
||||
/* deactivate pins to sleep state */
|
||||
for (i = 0; i < card->num_rtd; i++) {
|
||||
struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
|
||||
struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai;
|
||||
pinctrl_pm_select_sleep_state(codec_dai->dev);
|
||||
pinctrl_pm_select_sleep_state(cpu_dai->dev);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_poweroff);
|
||||
@ -3752,6 +3775,16 @@ int snd_soc_register_card(struct snd_soc_card *card)
|
||||
if (ret != 0)
|
||||
soc_cleanup_card_debugfs(card);
|
||||
|
||||
/* deactivate pins to sleep state */
|
||||
for (i = 0; i < card->num_rtd; i++) {
|
||||
struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;
|
||||
struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai;
|
||||
if (!codec_dai->active)
|
||||
pinctrl_pm_select_sleep_state(codec_dai->dev);
|
||||
if (!cpu_dai->active)
|
||||
pinctrl_pm_select_sleep_state(cpu_dai->dev);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(snd_soc_register_card);
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/pinctrl/consumer.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/workqueue.h>
|
||||
@ -183,6 +184,8 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
|
||||
struct snd_soc_dai_driver *codec_dai_drv = codec_dai->driver;
|
||||
int ret = 0;
|
||||
|
||||
pinctrl_pm_select_default_state(cpu_dai->dev);
|
||||
pinctrl_pm_select_default_state(codec_dai->dev);
|
||||
pm_runtime_get_sync(cpu_dai->dev);
|
||||
pm_runtime_get_sync(codec_dai->dev);
|
||||
pm_runtime_get_sync(platform->dev);
|
||||
@ -317,6 +320,10 @@ static int soc_pcm_open(struct snd_pcm_substream *substream)
|
||||
pm_runtime_put(platform->dev);
|
||||
pm_runtime_put(codec_dai->dev);
|
||||
pm_runtime_put(cpu_dai->dev);
|
||||
if (!codec_dai->active)
|
||||
pinctrl_pm_select_sleep_state(codec_dai->dev);
|
||||
if (!cpu_dai->active)
|
||||
pinctrl_pm_select_sleep_state(cpu_dai->dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -426,6 +433,10 @@ static int soc_pcm_close(struct snd_pcm_substream *substream)
|
||||
pm_runtime_put(platform->dev);
|
||||
pm_runtime_put(codec_dai->dev);
|
||||
pm_runtime_put(cpu_dai->dev);
|
||||
if (!codec_dai->active)
|
||||
pinctrl_pm_select_sleep_state(codec_dai->dev);
|
||||
if (!cpu_dai->active)
|
||||
pinctrl_pm_select_sleep_state(cpu_dai->dev);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user