MLK-11429-6: 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@nxp.com>
Mon, 19 Mar 2018 19:48:10 +0000 (14:48 -0500)
cherry-pick below patch from imx_3.14.y
ENGR00331799-7: ASoC: fsl_ssi: pm_runtime for ssi

ADD pm runtime for ssi.

Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
(cherry picked from commit 09f7a8aa7e417aaf837a4b9b8b15874ad95765c2)

sound/soc/fsl/fsl_ssi.c

index 4b7a006..124ceaf 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Author: Timur Tabi <timur@freescale.com>
  *
- * Copyright 2007-2010 Freescale Semiconductor, Inc.
+ * Copyright 2007-2015 Freescale Semiconductor, Inc.
  *
  * This file is licensed under the terms of the GNU General Public License
  * version 2.  This program is licensed "as is" without any warranty of any
@@ -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-imx.h>
 
 #include <sound/core.h>
 #include <sound/pcm.h>
@@ -676,6 +678,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
@@ -699,6 +703,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);
 
 }
@@ -1196,7 +1202,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,
@@ -1573,6 +1579,8 @@ static int fsl_ssi_probe(struct platform_device *pdev)
                break;
        }
 
+       pm_runtime_enable(&pdev->dev);
+
        dev_set_drvdata(&pdev->dev, ssi_private);
 
        if (ssi_private->soc->imx) {
@@ -1735,8 +1743,24 @@ static int fsl_ssi_resume(struct device *dev)
 }
 #endif /* CONFIG_PM_SLEEP */
 
+#ifdef CONFIG_PM
+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_SYSTEM_SLEEP_PM_OPS(fsl_ssi_suspend, fsl_ssi_resume)
+       SET_RUNTIME_PM_OPS(fsl_ssi_runtime_suspend, fsl_ssi_runtime_resume,
+                          NULL)
 };
 
 static struct platform_driver fsl_ssi_driver = {