]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
sound: soc: xilinx: codec: Add the PM functions
authorHyun Kwon <hyun.kwon@xilinx.com>
Mon, 24 Jul 2017 03:52:16 +0000 (20:52 -0700)
committerMichal Simek <michal.simek@xilinx.com>
Mon, 24 Jul 2017 11:40:12 +0000 (13:40 +0200)
The audio clock needs to be disabled when going into suspend.

Signed-off-by: Hyun Kwon <hyun.kwon@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
sound/soc/xilinx/xilinx-dp-codec.c

index b61088787fdce03236c59ad216c631091855d2f3..8d251dd29895f0aa77e6e666ea61fe2a21b4df0d 100644 (file)
@@ -127,6 +127,32 @@ static int xilinx_dp_codec_dev_remove(struct platform_device *pdev)
        return 0;
 }
 
+static int __maybe_unused xilinx_dp_codec_pm_suspend(struct device *dev)
+{
+       struct xilinx_dp_codec *codec = dev_get_drvdata(dev);
+
+       clk_disable_unprepare(codec->aud_clk);
+
+       return 0;
+}
+
+static int __maybe_unused xilinx_dp_codec_pm_resume(struct device *dev)
+{
+       struct xilinx_dp_codec *codec = dev_get_drvdata(dev);
+       int ret;
+
+       ret = clk_prepare_enable(codec->aud_clk);
+       if (ret)
+               dev_err(dev, "failed to enable the aud_clk\n");
+
+       return ret;
+}
+
+static const struct dev_pm_ops xilinx_dp_codec_pm_ops = {
+       SET_SYSTEM_SLEEP_PM_OPS(xilinx_dp_codec_pm_suspend,
+                               xilinx_dp_codec_pm_resume)
+};
+
 static const struct of_device_id xilinx_dp_codec_of_match[] = {
        { .compatible = "xlnx,dp-snd-codec", },
        { /* end of table */ },
@@ -137,6 +163,7 @@ static struct platform_driver xilinx_dp_codec_driver = {
        .driver = {
                .name           = "xilinx-dp-snd-codec",
                .of_match_table = xilinx_dp_codec_of_match,
+               .pm             = &xilinx_dp_codec_pm_ops,
        },
        .probe  = xilinx_dp_codec_probe,
        .remove = xilinx_dp_codec_dev_remove,