MLK-10337: ASoC: fsl_sai: Enable PM runtime support

request BUS_FREQ_AUDIO for SAI.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
(cherry picked from commit 2b869e1b16162d752c1345082d5d76b9bf720e88)
This commit is contained in:
Fabio Estevam
2015-02-26 14:28:20 +08:00
committed by Nitin Garg
parent d17e31968b
commit 4af6b7862a

View File

@ -10,13 +10,16 @@
*
*/
#include <linux/busfreq-imx.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/dmaengine.h>
#include <linux/module.h>
#include <linux/of_address.h>
#include <linux/pm_runtime.h>
#include <linux/regmap.h>
#include <linux/slab.h>
#include <sound/core.h>
#include <sound/dmaengine_pcm.h>
#include <sound/pcm_params.h>
@ -481,6 +484,7 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd,
case SNDRV_PCM_TRIGGER_START:
case SNDRV_PCM_TRIGGER_RESUME:
case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
pm_runtime_get_sync(cpu_dai->dev);
regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx),
FSL_SAI_CSR_FRDE, FSL_SAI_CSR_FRDE);
@ -532,6 +536,7 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd,
regmap_write(sai->regmap, FSL_SAI_TCSR, 0);
regmap_write(sai->regmap, FSL_SAI_RCSR, 0);
}
pm_runtime_put_sync(cpu_dai->dev);
break;
default:
return -EINVAL;
@ -827,6 +832,8 @@ static int fsl_sai_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, sai);
pm_runtime_enable(&pdev->dev);
ret = devm_snd_soc_register_component(&pdev->dev, &fsl_component,
&fsl_sai_dai, 1);
if (ret)
@ -848,6 +855,20 @@ static const struct of_device_id fsl_sai_ids[] = {
{ /* sentinel */ }
};
#ifdef CONFIG_PM
static int fsl_sai_runtime_resume(struct device *dev)
{
request_bus_freq(BUS_FREQ_AUDIO);
return 0;
}
static int fsl_sai_runtime_suspend(struct device *dev)
{
release_bus_freq(BUS_FREQ_AUDIO);
return 0;
}
#endif
#if CONFIG_PM_SLEEP
static int fsl_sai_suspend(struct device *dev)
{
@ -874,6 +895,9 @@ static int fsl_sai_resume(struct device *dev)
#endif /* CONFIG_PM_SLEEP */
static const struct dev_pm_ops fsl_sai_pm_ops = {
SET_RUNTIME_PM_OPS(fsl_sai_runtime_suspend,
fsl_sai_runtime_resume,
NULL)
SET_SYSTEM_SLEEP_PM_OPS(fsl_sai_suspend, fsl_sai_resume)
};