MLK-10337: ASoC: fsl_sai: Enable PM runtime support
authorFabio Estevam <fabio.estevam@freescale.com>
Thu, 26 Feb 2015 06:28:20 +0000 (14:28 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 19:48:07 +0000 (14:48 -0500)
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)

sound/soc/fsl/fsl_sai.c

index e58029f..f1098f6 100644 (file)
  *
  */
 
+#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 <linux/time.h>
@@ -531,6 +533,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);
 
@@ -593,6 +596,7 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd,
                                regmap_write(sai->regmap, FSL_SAI_RCSR, 0);
                        }
                }
+               pm_runtime_put_sync(cpu_dai->dev);
                break;
        default:
                return -EINVAL;
@@ -920,6 +924,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)
@@ -942,6 +948,20 @@ static const struct of_device_id fsl_sai_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, fsl_sai_ids);
 
+#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
+
 #ifdef CONFIG_PM_SLEEP
 static int fsl_sai_suspend(struct device *dev)
 {
@@ -968,6 +988,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)
 };