Commit 66ead502 authored by Baoyou Xie's avatar Baoyou Xie Committed by Mark Brown

ASoC: zx-i2s: introduce pclk for zx2967 family

The pclk is necessary for zx2967 I2S controller. the driver
currently doesn't handle it. This is something we need to fix.

In turn, the driver supports zx296718's I2S controller.

By the way, this patch also change the clock name from tx to wclk
to make it clear.
Signed-off-by: default avatarBaoyou Xie <baoyou.xie@linaro.org>
Reviewed-by: default avatarShawn Guo <shawnguo@kernel.org>
Reviewed-by: default avatarJun Nie <jun.nie@linaro.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
parent b5f18ba8
...@@ -95,7 +95,8 @@ ...@@ -95,7 +95,8 @@
struct zx_i2s_info { struct zx_i2s_info {
struct snd_dmaengine_dai_dma_data dma_playback; struct snd_dmaengine_dai_dma_data dma_playback;
struct snd_dmaengine_dai_dma_data dma_capture; struct snd_dmaengine_dai_dma_data dma_capture;
struct clk *dai_clk; struct clk *dai_wclk;
struct clk *dai_pclk;
void __iomem *reg_base; void __iomem *reg_base;
int master; int master;
resource_size_t mapbase; resource_size_t mapbase;
...@@ -275,8 +276,9 @@ static int zx_i2s_hw_params(struct snd_pcm_substream *substream, ...@@ -275,8 +276,9 @@ static int zx_i2s_hw_params(struct snd_pcm_substream *substream,
writel_relaxed(val, i2s->reg_base + ZX_I2S_TIMING_CTRL); writel_relaxed(val, i2s->reg_base + ZX_I2S_TIMING_CTRL);
if (i2s->master) if (i2s->master)
ret = clk_set_rate(i2s->dai_clk, ret = clk_set_rate(i2s->dai_wclk,
params_rate(params) * ch_num * CLK_RAT); params_rate(params) * ch_num * CLK_RAT);
return ret; return ret;
} }
...@@ -328,8 +330,19 @@ static int zx_i2s_startup(struct snd_pcm_substream *substream, ...@@ -328,8 +330,19 @@ static int zx_i2s_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai) struct snd_soc_dai *dai)
{ {
struct zx_i2s_info *zx_i2s = dev_get_drvdata(dai->dev); struct zx_i2s_info *zx_i2s = dev_get_drvdata(dai->dev);
int ret;
ret = clk_prepare_enable(zx_i2s->dai_wclk);
if (ret)
return ret;
ret = clk_prepare_enable(zx_i2s->dai_pclk);
if (ret) {
clk_disable_unprepare(zx_i2s->dai_wclk);
return ret;
}
return clk_prepare_enable(zx_i2s->dai_clk); return ret;
} }
static void zx_i2s_shutdown(struct snd_pcm_substream *substream, static void zx_i2s_shutdown(struct snd_pcm_substream *substream,
...@@ -337,7 +350,8 @@ static void zx_i2s_shutdown(struct snd_pcm_substream *substream, ...@@ -337,7 +350,8 @@ static void zx_i2s_shutdown(struct snd_pcm_substream *substream,
{ {
struct zx_i2s_info *zx_i2s = dev_get_drvdata(dai->dev); struct zx_i2s_info *zx_i2s = dev_get_drvdata(dai->dev);
clk_disable_unprepare(zx_i2s->dai_clk); clk_disable_unprepare(zx_i2s->dai_wclk);
clk_disable_unprepare(zx_i2s->dai_pclk);
} }
static struct snd_soc_dai_ops zx_i2s_dai_ops = { static struct snd_soc_dai_ops zx_i2s_dai_ops = {
...@@ -381,10 +395,16 @@ static int zx_i2s_probe(struct platform_device *pdev) ...@@ -381,10 +395,16 @@ static int zx_i2s_probe(struct platform_device *pdev)
if (!zx_i2s) if (!zx_i2s)
return -ENOMEM; return -ENOMEM;
zx_i2s->dai_clk = devm_clk_get(&pdev->dev, "tx"); zx_i2s->dai_wclk = devm_clk_get(&pdev->dev, "wclk");
if (IS_ERR(zx_i2s->dai_clk)) { if (IS_ERR(zx_i2s->dai_wclk)) {
dev_err(&pdev->dev, "Fail to get clk\n"); dev_err(&pdev->dev, "Fail to get wclk\n");
return PTR_ERR(zx_i2s->dai_clk); return PTR_ERR(zx_i2s->dai_wclk);
}
zx_i2s->dai_pclk = devm_clk_get(&pdev->dev, "pclk");
if (IS_ERR(zx_i2s->dai_pclk)) {
dev_err(&pdev->dev, "Fail to get pclk\n");
return PTR_ERR(zx_i2s->dai_pclk);
} }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment