summaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorEd Blake <ed.blake@sondrel.com>2017-10-06 15:56:06 +0100
committerMark Brown <broonie@kernel.org>2017-10-09 09:43:50 +0100
commit634a09d03753844e9fe1af8298266d0126d73549 (patch)
treee8da5e484451f10bcf41949e6fb5a5095c7e0685 /sound
parent1fac824f0c4fe05924243830fa3b44a5ad0869c7 (diff)
downloadop-kernel-dev-634a09d03753844e9fe1af8298266d0126d73549.zip
op-kernel-dev-634a09d03753844e9fe1af8298266d0126d73549.tar.gz
ASoC: img-spdif-out: Add suspend / resume handling
Implement suspend and resume callbacks to save and restore register state, to support platforms where the power is disabled during suspend. In future the driver could be converted to use regmap which would simplify the suspend and resume code. Signed-off-by: Ed Blake <ed.blake@sondrel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/soc/img/img-spdif-out.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/sound/soc/img/img-spdif-out.c b/sound/soc/img/img-spdif-out.c
index 416aa57..1808a55 100644
--- a/sound/soc/img/img-spdif-out.c
+++ b/sound/soc/img/img-spdif-out.c
@@ -47,6 +47,9 @@ struct img_spdif_out {
struct snd_dmaengine_dai_dma_data dma_data;
struct device *dev;
struct reset_control *rst;
+ u32 suspend_ctl;
+ u32 suspend_csl;
+ u32 suspend_csh;
};
static int img_spdif_out_runtime_suspend(struct device *dev)
@@ -414,6 +417,46 @@ static int img_spdif_out_dev_remove(struct platform_device *pdev)
return 0;
}
+#ifdef CONFIG_PM_SLEEP
+static int img_spdif_out_suspend(struct device *dev)
+{
+ struct img_spdif_out *spdif = dev_get_drvdata(dev);
+ int ret;
+
+ if (pm_runtime_status_suspended(dev)) {
+ ret = img_spdif_out_runtime_resume(dev);
+ if (ret)
+ return ret;
+ }
+
+ spdif->suspend_ctl = img_spdif_out_readl(spdif, IMG_SPDIF_OUT_CTL);
+ spdif->suspend_csl = img_spdif_out_readl(spdif, IMG_SPDIF_OUT_CSL);
+ spdif->suspend_csh = img_spdif_out_readl(spdif, IMG_SPDIF_OUT_CSH_UV);
+
+ img_spdif_out_runtime_suspend(dev);
+
+ return 0;
+}
+
+static int img_spdif_out_resume(struct device *dev)
+{
+ struct img_spdif_out *spdif = dev_get_drvdata(dev);
+ int ret;
+
+ ret = img_spdif_out_runtime_resume(dev);
+ if (ret)
+ return ret;
+
+ img_spdif_out_writel(spdif, spdif->suspend_ctl, IMG_SPDIF_OUT_CTL);
+ img_spdif_out_writel(spdif, spdif->suspend_csl, IMG_SPDIF_OUT_CSL);
+ img_spdif_out_writel(spdif, spdif->suspend_csh, IMG_SPDIF_OUT_CSH_UV);
+
+ if (pm_runtime_status_suspended(dev))
+ img_spdif_out_runtime_suspend(dev);
+
+ return 0;
+}
+#endif
static const struct of_device_id img_spdif_out_of_match[] = {
{ .compatible = "img,spdif-out" },
{}
@@ -423,6 +466,7 @@ MODULE_DEVICE_TABLE(of, img_spdif_out_of_match);
static const struct dev_pm_ops img_spdif_out_pm_ops = {
SET_RUNTIME_PM_OPS(img_spdif_out_runtime_suspend,
img_spdif_out_runtime_resume, NULL)
+ SET_SYSTEM_SLEEP_PM_OPS(img_spdif_out_suspend, img_spdif_out_resume)
};
static struct platform_driver img_spdif_out_driver = {
OpenPOWER on IntegriCloud