aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSonny Rao <sonnyrao@chromium.org>2016-01-15 21:49:50 +0800
committerLeo Wang <leozwang@google.com>2016-01-28 00:22:49 +0000
commit830f6e2cb2c0d8318b86f992f396afe583c8b300 (patch)
tree00ac98c60fad0f4496fc615e3ba4ac1ba62c6e52
parentc3b2d17d6108e86b636840364b94bebae8ba4ba3 (diff)
downloadv4.1-830f6e2cb2c0d8318b86f992f396afe583c8b300.tar.gz
FROMLIST: ASoC: rockchip: i2s: add support for grabbing output clock to codec
We need to claim the clock which is driving the codec so that when we enable clock gating, we continue to clock the codec when needed. I make this an optional clock since there might be some applications where we don't need it but can still use the I2S block. Signed-off-by: Sonny Rao <sonnyrao@chromium.org> Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com> Signed-off-by: Caesar Wang <wxt@rock-chips.com> Bug: 25923642 Patchset: Support the output clock for codec. (am from https://patchwork.kernel.org/patch/8041001/) Signed-off-by: Caesar Wang <wxt@rock-chips.com> Change-Id: Ib3b44613214ee15f69060bee38b86337afc4d472
-rw-r--r--sound/soc/rockchip/rockchip_i2s.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c
index acb5be53bfb..0c894a814d7 100644
--- a/sound/soc/rockchip/rockchip_i2s.c
+++ b/sound/soc/rockchip/rockchip_i2s.c
@@ -28,6 +28,7 @@ struct rk_i2s_dev {
struct clk *hclk;
struct clk *mclk;
+ struct clk *oclk;
struct snd_dmaengine_dai_dma_data capture_dma_data;
struct snd_dmaengine_dai_dma_data playback_dma_data;
@@ -47,6 +48,9 @@ static int i2s_runtime_suspend(struct device *dev)
{
struct rk_i2s_dev *i2s = dev_get_drvdata(dev);
+ if (i2s->oclk)
+ clk_disable_unprepare(i2s->oclk);
+
clk_disable_unprepare(i2s->mclk);
return 0;
@@ -63,6 +67,14 @@ static int i2s_runtime_resume(struct device *dev)
return ret;
}
+ if (i2s->oclk) {
+ ret = clk_prepare_enable(i2s->oclk);
+ if (ret) {
+ dev_err(i2s->dev, "oclk enable failed %d\n", ret);
+ return ret;
+ }
+ }
+
return 0;
}
@@ -444,6 +456,15 @@ static int rockchip_i2s_probe(struct platform_device *pdev)
return PTR_ERR(i2s->mclk);
}
+ i2s->oclk = devm_clk_get(&pdev->dev, "i2s_clk_out");
+ if (IS_ERR(i2s->oclk)) {
+ dev_dbg(&pdev->dev, "Didn't find output clock\n");
+ i2s->oclk = NULL;
+ }
+
+ if (i2s->oclk)
+ ret = clk_prepare_enable(i2s->oclk);
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
regs = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(regs))
@@ -510,6 +531,9 @@ static int rockchip_i2s_remove(struct platform_device *pdev)
if (!pm_runtime_status_suspended(&pdev->dev))
i2s_runtime_suspend(&pdev->dev);
+ if (i2s->oclk)
+ clk_disable_unprepare(i2s->oclk);
+
clk_disable_unprepare(i2s->mclk);
clk_disable_unprepare(i2s->hclk);
snd_dmaengine_pcm_unregister(&pdev->dev);