summaryrefslogtreecommitdiffstats
path: root/sound/soc/img/img-spdif-in.c
diff options
context:
space:
mode:
authorEd Blake <ed.blake@sondrel.com>2017-10-06 15:53:54 +0100
committerMark Brown <broonie@kernel.org>2017-10-09 09:43:44 +0100
commit52eb0ed3ec62d1f22f71332aa2e2de84a0a6c756 (patch)
tree618b2d7e8f2369d2bcc4928d3199a389fe6aa84e /sound/soc/img/img-spdif-in.c
parenta38ced17328bae30dabc15dbc2563860e3921c9c (diff)
downloadlinux-52eb0ed3ec62d1f22f71332aa2e2de84a0a6c756.tar.bz2
ASoC: img-spdif-in: 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/soc/img/img-spdif-in.c')
-rw-r--r--sound/soc/img/img-spdif-in.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/sound/soc/img/img-spdif-in.c b/sound/soc/img/img-spdif-in.c
index 8adfd65d4390..be5a64a44252 100644
--- a/sound/soc/img/img-spdif-in.c
+++ b/sound/soc/img/img-spdif-in.c
@@ -82,6 +82,8 @@ struct img_spdif_in {
unsigned int single_freq;
unsigned int multi_freqs[IMG_SPDIF_IN_NUM_ACLKGEN];
bool active;
+ u32 suspend_clkgen;
+ u32 suspend_ctl;
/* Write-only registers */
unsigned int aclkgen_regs[IMG_SPDIF_IN_NUM_ACLKGEN];
@@ -785,16 +787,51 @@ static int img_spdif_in_dev_remove(struct platform_device *pdev)
return 0;
}
+#ifdef CONFIG_PM_SLEEP
+static int img_spdif_in_suspend(struct device *dev)
+{
+ struct img_spdif_in *spdif = dev_get_drvdata(dev);
+
+ spdif->suspend_clkgen = img_spdif_in_readl(spdif, IMG_SPDIF_IN_CLKGEN);
+ spdif->suspend_ctl = img_spdif_in_readl(spdif, IMG_SPDIF_IN_CTL);
+
+ clk_disable_unprepare(spdif->clk_sys);
+
+ return 0;
+}
+
+static int img_spdif_in_resume(struct device *dev)
+{
+ struct img_spdif_in *spdif = dev_get_drvdata(dev);
+ int i;
+
+ clk_prepare_enable(spdif->clk_sys);
+
+ for (i = 0; i < IMG_SPDIF_IN_NUM_ACLKGEN; i++)
+ img_spdif_in_aclkgen_writel(spdif, i);
+
+ img_spdif_in_writel(spdif, spdif->suspend_clkgen, IMG_SPDIF_IN_CLKGEN);
+ img_spdif_in_writel(spdif, spdif->suspend_ctl, IMG_SPDIF_IN_CTL);
+
+ return 0;
+}
+#endif
+
static const struct of_device_id img_spdif_in_of_match[] = {
{ .compatible = "img,spdif-in" },
{}
};
MODULE_DEVICE_TABLE(of, img_spdif_in_of_match);
+static const struct dev_pm_ops img_spdif_in_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(img_spdif_in_suspend, img_spdif_in_resume)
+};
+
static struct platform_driver img_spdif_in_driver = {
.driver = {
.name = "img-spdif-in",
- .of_match_table = img_spdif_in_of_match
+ .of_match_table = img_spdif_in_of_match,
+ .pm = &img_spdif_in_pm_ops
},
.probe = img_spdif_in_probe,
.remove = img_spdif_in_dev_remove