* [PATCH v2 0/2] dma: img-spdif-out: Add power management
@ 2017-10-06 14:56 Ed Blake
2017-10-06 14:56 ` [PATCH v2 1/2] ASoC: img-spdif-out: Add suspend / resume handling Ed Blake
2017-10-06 14:56 ` [PATCH v2 2/2] ASoC: img-spdif-out: Add control of sys clock to runtime PM Ed Blake
0 siblings, 2 replies; 4+ messages in thread
From: Ed Blake @ 2017-10-06 14:56 UTC (permalink / raw)
To: lgirdwood, broonie; +Cc: alsa-devel, Ed Blake
This patch set adds power managment to the img-spdif-out driver. The
first patch adds system PM suspend / resume handling and the second
patch adds control of the sys clock to runtime PM.
Changes in v2:
- Changed from ASoC specific pm callbacks to device ones
Ed Blake (2):
ASoC: img-spdif-out: Add suspend / resume handling
ASoC: img-spdif-out: Add control of sys clock to runtime PM
sound/soc/img/img-spdif-out.c | 73 +++++++++++++++++++++++++++++++++++--------
1 file changed, 60 insertions(+), 13 deletions(-)
--
2.11.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] ASoC: img-spdif-out: Add suspend / resume handling
2017-10-06 14:56 [PATCH v2 0/2] dma: img-spdif-out: Add power management Ed Blake
@ 2017-10-06 14:56 ` Ed Blake
2017-10-09 8:49 ` Applied "ASoC: img-spdif-out: Add suspend / resume handling" to the asoc tree Mark Brown
2017-10-06 14:56 ` [PATCH v2 2/2] ASoC: img-spdif-out: Add control of sys clock to runtime PM Ed Blake
1 sibling, 1 reply; 4+ messages in thread
From: Ed Blake @ 2017-10-06 14:56 UTC (permalink / raw)
To: lgirdwood, broonie; +Cc: alsa-devel, Ed Blake
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>
---
Changes in v2:
- Changed from ASoC specific pm callbacks to device ones
---
sound/soc/img/img-spdif-out.c | 44 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/sound/soc/img/img-spdif-out.c b/sound/soc/img/img-spdif-out.c
index 416aa5786b93..1808a5542fd1 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 = {
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] ASoC: img-spdif-out: Add control of sys clock to runtime PM
2017-10-06 14:56 [PATCH v2 0/2] dma: img-spdif-out: Add power management Ed Blake
2017-10-06 14:56 ` [PATCH v2 1/2] ASoC: img-spdif-out: Add suspend / resume handling Ed Blake
@ 2017-10-06 14:56 ` Ed Blake
1 sibling, 0 replies; 4+ messages in thread
From: Ed Blake @ 2017-10-06 14:56 UTC (permalink / raw)
To: lgirdwood, broonie; +Cc: alsa-devel, Ed Blake
Disable sys clock as well as ref clock when runtime suspended.
Signed-off-by: Ed Blake <ed.blake@sondrel.com>
---
sound/soc/img/img-spdif-out.c | 31 +++++++++++++++++--------------
1 file changed, 17 insertions(+), 14 deletions(-)
diff --git a/sound/soc/img/img-spdif-out.c b/sound/soc/img/img-spdif-out.c
index 1808a5542fd1..934ed3df2ebf 100644
--- a/sound/soc/img/img-spdif-out.c
+++ b/sound/soc/img/img-spdif-out.c
@@ -57,6 +57,7 @@ static int img_spdif_out_runtime_suspend(struct device *dev)
struct img_spdif_out *spdif = dev_get_drvdata(dev);
clk_disable_unprepare(spdif->clk_ref);
+ clk_disable_unprepare(spdif->clk_sys);
return 0;
}
@@ -66,9 +67,16 @@ static int img_spdif_out_runtime_resume(struct device *dev)
struct img_spdif_out *spdif = dev_get_drvdata(dev);
int ret;
+ ret = clk_prepare_enable(spdif->clk_sys);
+ if (ret) {
+ dev_err(dev, "clk_enable failed: %d\n", ret);
+ return ret;
+ }
+
ret = clk_prepare_enable(spdif->clk_ref);
if (ret) {
dev_err(dev, "clk_enable failed: %d\n", ret);
+ clk_disable_unprepare(spdif->clk_sys);
return ret;
}
@@ -358,21 +366,21 @@ static int img_spdif_out_probe(struct platform_device *pdev)
return PTR_ERR(spdif->clk_ref);
}
- ret = clk_prepare_enable(spdif->clk_sys);
- if (ret)
- return ret;
-
- img_spdif_out_writel(spdif, IMG_SPDIF_OUT_CTL_FS_MASK,
- IMG_SPDIF_OUT_CTL);
-
- img_spdif_out_reset(spdif);
-
pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
ret = img_spdif_out_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}
+ ret = pm_runtime_get_sync(&pdev->dev);
+ if (ret < 0)
+ goto err_suspend;
+
+ img_spdif_out_writel(spdif, IMG_SPDIF_OUT_CTL_FS_MASK,
+ IMG_SPDIF_OUT_CTL);
+
+ img_spdif_out_reset(spdif);
+ pm_runtime_put(&pdev->dev);
spin_lock_init(&spdif->lock);
@@ -399,21 +407,16 @@ static int img_spdif_out_probe(struct platform_device *pdev)
img_spdif_out_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
- clk_disable_unprepare(spdif->clk_sys);
return ret;
}
static int img_spdif_out_dev_remove(struct platform_device *pdev)
{
- struct img_spdif_out *spdif = platform_get_drvdata(pdev);
-
pm_runtime_disable(&pdev->dev);
if (!pm_runtime_status_suspended(&pdev->dev))
img_spdif_out_runtime_suspend(&pdev->dev);
- clk_disable_unprepare(spdif->clk_sys);
-
return 0;
}
--
2.11.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Applied "ASoC: img-spdif-out: Add suspend / resume handling" to the asoc tree
2017-10-06 14:56 ` [PATCH v2 1/2] ASoC: img-spdif-out: Add suspend / resume handling Ed Blake
@ 2017-10-09 8:49 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2017-10-09 8:49 UTC (permalink / raw)
To: Ed Blake; +Cc: alsa-devel, broonie, lgirdwood
The patch
ASoC: img-spdif-out: Add suspend / resume handling
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
>From 634a09d03753844e9fe1af8298266d0126d73549 Mon Sep 17 00:00:00 2001
From: Ed Blake <ed.blake@sondrel.com>
Date: Fri, 6 Oct 2017 15:56:06 +0100
Subject: [PATCH] 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>
---
sound/soc/img/img-spdif-out.c | 44 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/sound/soc/img/img-spdif-out.c b/sound/soc/img/img-spdif-out.c
index 416aa5786b93..1808a5542fd1 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 = {
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-10-09 8:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-06 14:56 [PATCH v2 0/2] dma: img-spdif-out: Add power management Ed Blake
2017-10-06 14:56 ` [PATCH v2 1/2] ASoC: img-spdif-out: Add suspend / resume handling Ed Blake
2017-10-09 8:49 ` Applied "ASoC: img-spdif-out: Add suspend / resume handling" to the asoc tree Mark Brown
2017-10-06 14:56 ` [PATCH v2 2/2] ASoC: img-spdif-out: Add control of sys clock to runtime PM Ed Blake
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.