* [PATCH 0/3] ASoC: img-i2s-out: Add power management
@ 2017-10-02 9:59 Ed Blake
2017-10-02 9:59 ` [PATCH 1/3] ASoC: img-i2s-out: Rename suspend / resume funcs Ed Blake
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Ed Blake @ 2017-10-02 9:59 UTC (permalink / raw)
To: lgirdwood, broonie; +Cc: alsa-devel, Ed Blake
This patch set adds power managment to the img-i2s-out driver. The
first patch renames existing 'suspend' and 'resume' functions to
'runtime_suspend' and 'runtime_resume', which is what they actually
are, the second patch adds system PM suspend / resume handling and the
third patch adds control of the sys clock to runtime PM.
Ed Blake (3):
ASoC: img-i2s-out: Rename suspend / resume funcs
ASoC: img-i2s-out: Add suspend / resume handling
ASoC: img-i2s-out: Add control of sys clock to runtime PM
sound/soc/img/img-i2s-out.c | 116 +++++++++++++++++++++++++++++++++-----------
1 file changed, 87 insertions(+), 29 deletions(-)
--
1.9.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] ASoC: img-i2s-out: Rename suspend / resume funcs
2017-10-02 9:59 [PATCH 0/3] ASoC: img-i2s-out: Add power management Ed Blake
@ 2017-10-02 9:59 ` Ed Blake
2017-10-04 11:28 ` Applied "ASoC: img-i2s-out: Rename suspend / resume funcs" to the asoc tree Mark Brown
2017-10-02 9:59 ` [PATCH 2/3] ASoC: img-i2s-out: Add suspend / resume handling Ed Blake
2017-10-02 9:59 ` [PATCH 3/3] ASoC: img-i2s-out: Add control of sys clock to runtime PM Ed Blake
2 siblings, 1 reply; 5+ messages in thread
From: Ed Blake @ 2017-10-02 9:59 UTC (permalink / raw)
To: lgirdwood, broonie; +Cc: alsa-devel, Ed Blake
Rename suspend and resume functions to runtime_suspend and
runtime_resume, which is what they actually are. This will avoid
confusion when adding suspend and resume functions in a subsequent
patch.
Signed-off-by: Ed Blake <ed.blake@sondrel.com>
---
sound/soc/img/img-i2s-out.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/sound/soc/img/img-i2s-out.c b/sound/soc/img/img-i2s-out.c
index 78b7f6c..adc6902 100644
--- a/sound/soc/img/img-i2s-out.c
+++ b/sound/soc/img/img-i2s-out.c
@@ -65,7 +65,7 @@ struct img_i2s_out {
struct snd_soc_dai_driver dai_driver;
};
-static int img_i2s_out_suspend(struct device *dev)
+static int img_i2s_out_runtime_suspend(struct device *dev)
{
struct img_i2s_out *i2s = dev_get_drvdata(dev);
@@ -75,7 +75,7 @@ static int img_i2s_out_suspend(struct device *dev)
return 0;
}
-static int img_i2s_out_resume(struct device *dev)
+static int img_i2s_out_runtime_resume(struct device *dev)
{
struct img_i2s_out *i2s = dev_get_drvdata(dev);
int ret;
@@ -486,7 +486,7 @@ static int img_i2s_out_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
- ret = img_i2s_out_resume(&pdev->dev);
+ ret = img_i2s_out_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}
@@ -517,7 +517,7 @@ static int img_i2s_out_probe(struct platform_device *pdev)
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
- img_i2s_out_suspend(&pdev->dev);
+ img_i2s_out_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
clk_disable_unprepare(i2s->clk_sys);
@@ -531,7 +531,7 @@ static int img_i2s_out_dev_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
if (!pm_runtime_status_suspended(&pdev->dev))
- img_i2s_out_suspend(&pdev->dev);
+ img_i2s_out_runtime_suspend(&pdev->dev);
clk_disable_unprepare(i2s->clk_sys);
@@ -545,8 +545,8 @@ static int img_i2s_out_dev_remove(struct platform_device *pdev)
MODULE_DEVICE_TABLE(of, img_i2s_out_of_match);
static const struct dev_pm_ops img_i2s_out_pm_ops = {
- SET_RUNTIME_PM_OPS(img_i2s_out_suspend,
- img_i2s_out_resume, NULL)
+ SET_RUNTIME_PM_OPS(img_i2s_out_runtime_suspend,
+ img_i2s_out_runtime_resume, NULL)
};
static struct platform_driver img_i2s_out_driver = {
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] ASoC: img-i2s-out: Add suspend / resume handling
2017-10-02 9:59 [PATCH 0/3] ASoC: img-i2s-out: Add power management Ed Blake
2017-10-02 9:59 ` [PATCH 1/3] ASoC: img-i2s-out: Rename suspend / resume funcs Ed Blake
@ 2017-10-02 9:59 ` Ed Blake
2017-10-02 9:59 ` [PATCH 3/3] ASoC: img-i2s-out: Add control of sys clock to runtime PM Ed Blake
2 siblings, 0 replies; 5+ messages in thread
From: Ed Blake @ 2017-10-02 9:59 UTC (permalink / raw)
To: lgirdwood, broonie; +Cc: alsa-devel, Ed Blake
Implement ASoC suspend and resume callbacks to save and restore
register state, to support platforms where the power is disabled
during suspend.
Signed-off-by: Ed Blake <ed.blake@sondrel.com>
---
sound/soc/img/img-i2s-out.c | 59 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/sound/soc/img/img-i2s-out.c b/sound/soc/img/img-i2s-out.c
index adc6902..f1c3b48 100644
--- a/sound/soc/img/img-i2s-out.c
+++ b/sound/soc/img/img-i2s-out.c
@@ -63,6 +63,8 @@ struct img_i2s_out {
unsigned int active_channels;
struct reset_control *rst;
struct snd_soc_dai_driver dai_driver;
+ u32 suspend_ctl;
+ u32 *suspend_ch_ctl;
};
static int img_i2s_out_runtime_suspend(struct device *dev)
@@ -382,6 +384,53 @@ static int img_i2s_out_dai_probe(struct snd_soc_dai *dai)
return 0;
}
+static int img_i2s_out_dai_suspend(struct snd_soc_dai *dai)
+{
+ struct img_i2s_out *i2s = snd_soc_dai_get_drvdata(dai);
+ int i, ret;
+ u32 reg;
+
+ if (pm_runtime_status_suspended(i2s->dev)) {
+ ret = img_i2s_out_runtime_resume(i2s->dev);
+ if (ret)
+ return ret;
+ }
+
+ for (i = 0; i < i2s->max_i2s_chan; i++) {
+ reg = img_i2s_out_ch_readl(i2s, i, IMG_I2S_OUT_CH_CTL);
+ i2s->suspend_ch_ctl[i] = reg;
+ }
+
+ i2s->suspend_ctl = img_i2s_out_readl(i2s, IMG_I2S_OUT_CTL);
+
+ img_i2s_out_runtime_suspend(i2s->dev);
+
+ return 0;
+}
+
+static int img_i2s_out_dai_resume(struct snd_soc_dai *dai)
+{
+ struct img_i2s_out *i2s = snd_soc_dai_get_drvdata(dai);
+ int i, ret;
+ u32 reg;
+
+ ret = img_i2s_out_runtime_resume(i2s->dev);
+ if (ret)
+ return ret;
+
+ for (i = 0; i < i2s->max_i2s_chan; i++) {
+ reg = i2s->suspend_ch_ctl[i];
+ img_i2s_out_ch_writel(i2s, i, reg, IMG_I2S_OUT_CH_CTL);
+ }
+
+ img_i2s_out_writel(i2s, i2s->suspend_ctl, IMG_I2S_OUT_CTL);
+
+ if (pm_runtime_status_suspended(i2s->dev))
+ img_i2s_out_runtime_suspend(i2s->dev);
+
+ return 0;
+}
+
static const struct snd_soc_component_driver img_i2s_out_component = {
.name = "img-i2s-out"
};
@@ -471,6 +520,13 @@ static int img_i2s_out_probe(struct platform_device *pdev)
if (ret)
return ret;
+ i2s->suspend_ch_ctl = devm_kzalloc(dev,
+ sizeof(*i2s->suspend_ch_ctl) * i2s->max_i2s_chan, GFP_KERNEL);
+ if (!i2s->suspend_ch_ctl) {
+ ret = -ENOMEM;
+ goto err_clk_disable;
+ }
+
reg = IMG_I2S_OUT_CTL_FRM_SIZE_MASK;
img_i2s_out_writel(i2s, reg, IMG_I2S_OUT_CTL);
@@ -497,6 +553,8 @@ static int img_i2s_out_probe(struct platform_device *pdev)
i2s->dma_data.maxburst = 4;
i2s->dai_driver.probe = img_i2s_out_dai_probe;
+ i2s->dai_driver.suspend = img_i2s_out_dai_suspend;
+ i2s->dai_driver.resume = img_i2s_out_dai_resume;
i2s->dai_driver.playback.channels_min = 2;
i2s->dai_driver.playback.channels_max = i2s->max_i2s_chan * 2;
i2s->dai_driver.playback.rates = SNDRV_PCM_RATE_8000_192000;
@@ -520,6 +578,7 @@ static int img_i2s_out_probe(struct platform_device *pdev)
img_i2s_out_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
+err_clk_disable:
clk_disable_unprepare(i2s->clk_sys);
return ret;
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] ASoC: img-i2s-out: Add control of sys clock to runtime PM
2017-10-02 9:59 [PATCH 0/3] ASoC: img-i2s-out: Add power management Ed Blake
2017-10-02 9:59 ` [PATCH 1/3] ASoC: img-i2s-out: Rename suspend / resume funcs Ed Blake
2017-10-02 9:59 ` [PATCH 2/3] ASoC: img-i2s-out: Add suspend / resume handling Ed Blake
@ 2017-10-02 9:59 ` Ed Blake
2 siblings, 0 replies; 5+ messages in thread
From: Ed Blake @ 2017-10-02 9:59 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-i2s-out.c | 55 ++++++++++++++++++++++-----------------------
1 file changed, 27 insertions(+), 28 deletions(-)
diff --git a/sound/soc/img/img-i2s-out.c b/sound/soc/img/img-i2s-out.c
index f1c3b48..7db58d2 100644
--- a/sound/soc/img/img-i2s-out.c
+++ b/sound/soc/img/img-i2s-out.c
@@ -71,8 +71,8 @@ static int img_i2s_out_runtime_suspend(struct device *dev)
{
struct img_i2s_out *i2s = dev_get_drvdata(dev);
- if (!i2s->force_clk_active)
- clk_disable_unprepare(i2s->clk_ref);
+ clk_disable_unprepare(i2s->clk_ref);
+ clk_disable_unprepare(i2s->clk_sys);
return 0;
}
@@ -82,12 +82,17 @@ static int img_i2s_out_runtime_resume(struct device *dev)
struct img_i2s_out *i2s = dev_get_drvdata(dev);
int ret;
- if (!i2s->force_clk_active) {
- ret = clk_prepare_enable(i2s->clk_ref);
- if (ret) {
- dev_err(dev, "clk_enable failed: %d\n", ret);
- return ret;
- }
+ ret = clk_prepare_enable(i2s->clk_sys);
+ if (ret) {
+ dev_err(dev, "clk_enable failed: %d\n", ret);
+ return ret;
+ }
+
+ ret = clk_prepare_enable(i2s->clk_ref);
+ if (ret) {
+ dev_err(dev, "clk_enable failed: %d\n", ret);
+ clk_disable_unprepare(i2s->clk_sys);
+ return ret;
}
return 0;
@@ -344,6 +349,7 @@ static int img_i2s_out_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
chan_control_mask = IMG_I2S_OUT_CHAN_CTL_CLKT_MASK;
+ pm_runtime_get_sync(i2s->dev);
img_i2s_out_disable(i2s);
reg = img_i2s_out_readl(i2s, IMG_I2S_OUT_CTL);
@@ -363,6 +369,7 @@ static int img_i2s_out_set_fmt(struct snd_soc_dai *dai, unsigned int fmt)
img_i2s_out_ch_enable(i2s, i);
img_i2s_out_enable(i2s);
+ pm_runtime_put(i2s->dev);
i2s->force_clk_active = force_clk_active;
@@ -516,16 +523,20 @@ static int img_i2s_out_probe(struct platform_device *pdev)
return PTR_ERR(i2s->clk_ref);
}
- ret = clk_prepare_enable(i2s->clk_sys);
- if (ret)
- return ret;
-
i2s->suspend_ch_ctl = devm_kzalloc(dev,
sizeof(*i2s->suspend_ch_ctl) * i2s->max_i2s_chan, GFP_KERNEL);
- if (!i2s->suspend_ch_ctl) {
- ret = -ENOMEM;
- goto err_clk_disable;
+ if (!i2s->suspend_ch_ctl)
+ return -ENOMEM;
+
+ pm_runtime_enable(&pdev->dev);
+ if (!pm_runtime_enabled(&pdev->dev)) {
+ ret = img_i2s_out_runtime_resume(&pdev->dev);
+ if (ret)
+ goto err_pm_disable;
}
+ ret = pm_runtime_get_sync(&pdev->dev);
+ if (ret < 0)
+ goto err_suspend;
reg = IMG_I2S_OUT_CTL_FRM_SIZE_MASK;
img_i2s_out_writel(i2s, reg, IMG_I2S_OUT_CTL);
@@ -539,13 +550,7 @@ static int img_i2s_out_probe(struct platform_device *pdev)
img_i2s_out_ch_writel(i2s, i, reg, IMG_I2S_OUT_CH_CTL);
img_i2s_out_reset(i2s);
-
- pm_runtime_enable(&pdev->dev);
- if (!pm_runtime_enabled(&pdev->dev)) {
- ret = img_i2s_out_runtime_resume(&pdev->dev);
- if (ret)
- goto err_pm_disable;
- }
+ pm_runtime_put(&pdev->dev);
i2s->active_channels = 1;
i2s->dma_data.addr = res->start + IMG_I2S_OUT_TX_FIFO;
@@ -578,22 +583,16 @@ static int img_i2s_out_probe(struct platform_device *pdev)
img_i2s_out_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
-err_clk_disable:
- clk_disable_unprepare(i2s->clk_sys);
return ret;
}
static int img_i2s_out_dev_remove(struct platform_device *pdev)
{
- struct img_i2s_out *i2s = platform_get_drvdata(pdev);
-
pm_runtime_disable(&pdev->dev);
if (!pm_runtime_status_suspended(&pdev->dev))
img_i2s_out_runtime_suspend(&pdev->dev);
- clk_disable_unprepare(i2s->clk_sys);
-
return 0;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Applied "ASoC: img-i2s-out: Rename suspend / resume funcs" to the asoc tree
2017-10-02 9:59 ` [PATCH 1/3] ASoC: img-i2s-out: Rename suspend / resume funcs Ed Blake
@ 2017-10-04 11:28 ` Mark Brown
0 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2017-10-04 11:28 UTC (permalink / raw)
To: Ed Blake; +Cc: alsa-devel, broonie, lgirdwood
The patch
ASoC: img-i2s-out: Rename suspend / resume funcs
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 6f9dfab7fc5fdd51ed67da370fc83f3b7dbf08da Mon Sep 17 00:00:00 2001
From: Ed Blake <ed.blake@sondrel.com>
Date: Mon, 2 Oct 2017 10:59:45 +0100
Subject: [PATCH] ASoC: img-i2s-out: Rename suspend / resume funcs
Rename suspend and resume functions to runtime_suspend and
runtime_resume, which is what they actually are. This will avoid
confusion when adding suspend and resume functions in a subsequent
patch.
Signed-off-by: Ed Blake <ed.blake@sondrel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
sound/soc/img/img-i2s-out.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/sound/soc/img/img-i2s-out.c b/sound/soc/img/img-i2s-out.c
index 78b7f6cd675b..adc6902fcbd4 100644
--- a/sound/soc/img/img-i2s-out.c
+++ b/sound/soc/img/img-i2s-out.c
@@ -65,7 +65,7 @@ struct img_i2s_out {
struct snd_soc_dai_driver dai_driver;
};
-static int img_i2s_out_suspend(struct device *dev)
+static int img_i2s_out_runtime_suspend(struct device *dev)
{
struct img_i2s_out *i2s = dev_get_drvdata(dev);
@@ -75,7 +75,7 @@ static int img_i2s_out_suspend(struct device *dev)
return 0;
}
-static int img_i2s_out_resume(struct device *dev)
+static int img_i2s_out_runtime_resume(struct device *dev)
{
struct img_i2s_out *i2s = dev_get_drvdata(dev);
int ret;
@@ -486,7 +486,7 @@ static int img_i2s_out_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev);
if (!pm_runtime_enabled(&pdev->dev)) {
- ret = img_i2s_out_resume(&pdev->dev);
+ ret = img_i2s_out_runtime_resume(&pdev->dev);
if (ret)
goto err_pm_disable;
}
@@ -517,7 +517,7 @@ static int img_i2s_out_probe(struct platform_device *pdev)
err_suspend:
if (!pm_runtime_status_suspended(&pdev->dev))
- img_i2s_out_suspend(&pdev->dev);
+ img_i2s_out_runtime_suspend(&pdev->dev);
err_pm_disable:
pm_runtime_disable(&pdev->dev);
clk_disable_unprepare(i2s->clk_sys);
@@ -531,7 +531,7 @@ static int img_i2s_out_dev_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
if (!pm_runtime_status_suspended(&pdev->dev))
- img_i2s_out_suspend(&pdev->dev);
+ img_i2s_out_runtime_suspend(&pdev->dev);
clk_disable_unprepare(i2s->clk_sys);
@@ -545,8 +545,8 @@ static const struct of_device_id img_i2s_out_of_match[] = {
MODULE_DEVICE_TABLE(of, img_i2s_out_of_match);
static const struct dev_pm_ops img_i2s_out_pm_ops = {
- SET_RUNTIME_PM_OPS(img_i2s_out_suspend,
- img_i2s_out_resume, NULL)
+ SET_RUNTIME_PM_OPS(img_i2s_out_runtime_suspend,
+ img_i2s_out_runtime_resume, NULL)
};
static struct platform_driver img_i2s_out_driver = {
--
2.14.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-10-04 11:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-02 9:59 [PATCH 0/3] ASoC: img-i2s-out: Add power management Ed Blake
2017-10-02 9:59 ` [PATCH 1/3] ASoC: img-i2s-out: Rename suspend / resume funcs Ed Blake
2017-10-04 11:28 ` Applied "ASoC: img-i2s-out: Rename suspend / resume funcs" to the asoc tree Mark Brown
2017-10-02 9:59 ` [PATCH 2/3] ASoC: img-i2s-out: Add suspend / resume handling Ed Blake
2017-10-02 9:59 ` [PATCH 3/3] ASoC: img-i2s-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.