]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
ENGR00331799-7: ASoC: fsl_ssi: pm_runtime for ssi
authorShengjiu Wang <shengjiu.wang@freescale.com>
Fri, 19 Sep 2014 06:09:46 +0000 (14:09 +0800)
committerNitin Garg <nitin.garg@freescale.com>
Fri, 16 Jan 2015 03:17:55 +0000 (21:17 -0600)
ADD pm runtime for ssi.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
sound/soc/fsl/fsl_ssi.c

index 2295e4470d6fb16faefa0eb1ce4c102f9396d4b9..0ccc9ebcce55fb220117230b148c518231a08024 100644 (file)
@@ -43,6 +43,8 @@
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
+#include <linux/pm_runtime.h>
+#include <linux/busfreq-imx6.h>
 
 #include <sound/core.h>
 #include <sound/pcm.h>
@@ -532,6 +534,8 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream,
        if (ret)
                return ret;
 
+       pm_runtime_get_sync(dai->dev);
+
        /* When using dual fifo mode, it is safer to ensure an even period
         * size. If appearing to an odd number while DMA always starts its
         * task from fifo0, fifo1 would be neglected at the end of each
@@ -555,6 +559,8 @@ static void fsl_ssi_shutdown(struct snd_pcm_substream *substream,
        struct fsl_ssi_private *ssi_private =
                snd_soc_dai_get_drvdata(rtd->cpu_dai);
 
+       pm_runtime_put_sync(dai->dev);
+
        clk_disable_unprepare(ssi_private->clk);
 
 }
@@ -1041,7 +1047,7 @@ static int fsl_ssi_dai_probe(struct snd_soc_dai *dai)
 
 static const struct snd_soc_dai_ops fsl_ssi_dai_ops = {
        .startup        = fsl_ssi_startup,
-       .shutdown       = fsl_ssi_shutdown,
+       .shutdown       = fsl_ssi_shutdown,
        .hw_params      = fsl_ssi_hw_params,
        .hw_free        = fsl_ssi_hw_free,
        .set_fmt        = fsl_ssi_set_dai_fmt,
@@ -1363,6 +1369,8 @@ static int fsl_ssi_probe(struct platform_device *pdev)
                 /* Older 8610 DTs didn't have the fifo-depth property */
                ssi_private->fifo_depth = 8;
 
+       pm_runtime_enable(&pdev->dev);
+
        dev_set_drvdata(&pdev->dev, ssi_private);
 
        if (ssi_private->soc->imx) {
@@ -1464,11 +1472,32 @@ static int fsl_ssi_remove(struct platform_device *pdev)
        return 0;
 }
 
+#ifdef CONFIG_PM_RUNTIME
+static int fsl_ssi_runtime_resume(struct device *dev)
+{
+       request_bus_freq(BUS_FREQ_AUDIO);
+       return 0;
+}
+
+static int fsl_ssi_runtime_suspend(struct device *dev)
+{
+       release_bus_freq(BUS_FREQ_AUDIO);
+       return 0;
+}
+#endif
+
+static const struct dev_pm_ops fsl_ssi_pm = {
+       SET_RUNTIME_PM_OPS(fsl_ssi_runtime_suspend,
+                       fsl_ssi_runtime_resume,
+                       NULL)
+};
+
 static struct platform_driver fsl_ssi_driver = {
        .driver = {
                .name = "fsl-ssi-dai",
                .owner = THIS_MODULE,
                .of_match_table = fsl_ssi_ids,
+               .pm = &fsl_ssi_pm,
        },
        .probe = fsl_ssi_probe,
        .remove = fsl_ssi_remove,