aboutsummaryrefslogtreecommitdiff
path: root/sound/soc/zte/zx-i2s.c
diff options
context:
space:
mode:
Diffstat (limited to 'sound/soc/zte/zx-i2s.c')
-rw-r--r--sound/soc/zte/zx-i2s.c43
1 files changed, 30 insertions, 13 deletions
diff --git a/sound/soc/zte/zx-i2s.c b/sound/soc/zte/zx-i2s.c
index 1cad93dc1fcf..a865f37c2a56 100644
--- a/sound/soc/zte/zx-i2s.c
+++ b/sound/soc/zte/zx-i2s.c
@@ -95,7 +95,8 @@
struct zx_i2s_info {
struct snd_dmaengine_dai_dma_data dma_playback;
struct snd_dmaengine_dai_dma_data dma_capture;
- struct clk *dai_clk;
+ struct clk *dai_wclk;
+ struct clk *dai_pclk;
void __iomem *reg_base;
int master;
resource_size_t mapbase;
@@ -225,7 +226,7 @@ static int zx_i2s_hw_params(struct snd_pcm_substream *substream,
struct zx_i2s_info *i2s = snd_soc_dai_get_drvdata(socdai);
struct snd_dmaengine_dai_dma_data *dma_data;
unsigned int lane, ch_num, len, ret = 0;
- unsigned long val, format;
+ unsigned long val;
unsigned long chn_cfg;
dma_data = snd_soc_dai_get_dma_data(socdai, substream);
@@ -238,15 +239,12 @@ static int zx_i2s_hw_params(struct snd_pcm_substream *substream,
switch (params_format(params)) {
case SNDRV_PCM_FORMAT_S16_LE:
- format = 0;
len = 16;
break;
case SNDRV_PCM_FORMAT_S24_LE:
- format = 1;
len = 24;
break;
case SNDRV_PCM_FORMAT_S32_LE:
- format = 2;
len = 32;
break;
default:
@@ -278,8 +276,9 @@ static int zx_i2s_hw_params(struct snd_pcm_substream *substream,
writel_relaxed(val, i2s->reg_base + ZX_I2S_TIMING_CTRL);
if (i2s->master)
- ret = clk_set_rate(i2s->dai_clk,
- params_rate(params) * ch_num * CLK_RAT);
+ ret = clk_set_rate(i2s->dai_wclk,
+ params_rate(params) * ch_num * CLK_RAT);
+
return ret;
}
@@ -331,8 +330,19 @@ static int zx_i2s_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct zx_i2s_info *zx_i2s = dev_get_drvdata(dai->dev);
+ int ret;
- return clk_prepare_enable(zx_i2s->dai_clk);
+ 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 ret;
}
static void zx_i2s_shutdown(struct snd_pcm_substream *substream,
@@ -340,7 +350,8 @@ static void zx_i2s_shutdown(struct snd_pcm_substream *substream,
{
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 = {
@@ -384,10 +395,16 @@ static int zx_i2s_probe(struct platform_device *pdev)
if (!zx_i2s)
return -ENOMEM;
- zx_i2s->dai_clk = devm_clk_get(&pdev->dev, "tx");
- if (IS_ERR(zx_i2s->dai_clk)) {
- dev_err(&pdev->dev, "Fail to get clk\n");
- return PTR_ERR(zx_i2s->dai_clk);
+ zx_i2s->dai_wclk = devm_clk_get(&pdev->dev, "wclk");
+ if (IS_ERR(zx_i2s->dai_wclk)) {
+ dev_err(&pdev->dev, "Fail to get wclk\n");
+ 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);