From: Ed Blake <ed.blake@sondrel.com>
To: lgirdwood@gmail.com, broonie@kernel.org
Cc: alsa-devel@alsa-project.org, Ed Blake <ed.blake@sondrel.com>
Subject: [PATCH 3/3] ASoC: img-spdif-out: Add control of sys clock to runtime PM
Date: Mon, 2 Oct 2017 11:01:57 +0100 [thread overview]
Message-ID: <1506938517-810-4-git-send-email-ed.blake@sondrel.com> (raw)
In-Reply-To: <1506938517-810-1-git-send-email-ed.blake@sondrel.com>
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 8123e2a..9b93182 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;
}
@@ -399,21 +407,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);
@@ -440,21 +448,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;
}
--
1.9.1
next prev parent reply other threads:[~2017-10-02 10:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-02 10:01 [PATCH 0/3] dma: img-spdif-out: Add power management Ed Blake
2017-10-02 10:01 ` [PATCH 1/3] ASoC: img-spdif-out: Rename suspend / resume funcs Ed Blake
2017-10-04 11:28 ` Applied "ASoC: img-spdif-out: Rename suspend / resume funcs" to the asoc tree Mark Brown
2017-10-05 13:40 ` Ed Blake
2017-10-05 15:48 ` Mark Brown
2017-10-02 10:01 ` [PATCH 2/3] ASoC: img-spdif-out: Add suspend / resume handling Ed Blake
2017-10-02 10:01 ` Ed Blake [this message]
2017-10-09 8:49 ` Applied "ASoC: img-spdif-out: Add control of sys clock to runtime PM" to the asoc tree Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1506938517-810-4-git-send-email-ed.blake@sondrel.com \
--to=ed.blake@sondrel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox