devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Baoyou Xie <baoyou.xie@linaro.org>
To: lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org,
	mark.rutland@arm.com, jun.nie@linaro.org, baoyou.xie@linaro.org,
	mturquette@baylibre.com, sboyd@codeaurora.org, perex@perex.cz,
	tiwai@suse.com, shawn.guo@linaro.org, vinod.koul@intel.com
Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org,
	shawnguo@kernel.org, xie.baoyou@zte.com.cn,
	chen.chaokai@zte.com.cn, wang.qiang01@zte.com.cn
Subject: [PATCH v2 3/3] ASoC: zx-i2s: support zx296718 SoC for ZTE's i2s  controller driver
Date: Tue,  7 Feb 2017 11:02:51 +0800	[thread overview]
Message-ID: <1486436571-8682-3-git-send-email-baoyou.xie@linaro.org> (raw)
In-Reply-To: <1486436571-8682-1-git-send-email-baoyou.xie@linaro.org>

This patch adds zx296718 SoC support for ZTE's i2s controller driver.

Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org>
---
 sound/soc/zte/zx-i2s.c | 45 +++++++++++++++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 10 deletions(-)

diff --git a/sound/soc/zte/zx-i2s.c b/sound/soc/zte/zx-i2s.c
index ed7a56d..2afac69 100644
--- a/sound/soc/zte/zx-i2s.c
+++ b/sound/soc/zte/zx-i2s.c
@@ -95,12 +95,13 @@
 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, *dai_pclk;
 	void __iomem				*reg_base;
 	int					master;
 	resource_size_t				mapbase;
 };
 
+
 static void zx_i2s_tx_en(void __iomem *base, bool on)
 {
 	unsigned long val;
@@ -274,9 +275,14 @@ static int zx_i2s_hw_params(struct snd_pcm_substream *substream,
 	val |= ZX_I2S_TIMING_CHN(ch_num);
 	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);
+	if (i2s->master) {
+		unsigned long rate = params_rate(params) * ch_num * CLK_RAT;
+
+		ret = clk_set_rate(i2s->dai_wclk, rate);
+		if (!ret && i2s->dai_pclk)
+			ret = clk_set_rate(i2s->dai_pclk, rate);
+	}
+
 	return ret;
 }
 
@@ -328,8 +334,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;
+
+	ret = clk_prepare_enable(zx_i2s->dai_wclk);
+	if (ret)
+		return ret;
 
-	return clk_prepare_enable(zx_i2s->dai_clk);
+	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,
@@ -337,7 +354,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 = {
@@ -381,10 +399,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, "tx");
+	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_info(&pdev->dev, "have no pclk\n");
+		zx_i2s->dai_pclk = NULL;
 	}
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -414,6 +438,7 @@ static int zx_i2s_probe(struct platform_device *pdev)
 
 static const struct of_device_id zx_i2s_dt_ids[] = {
 	{ .compatible = "zte,zx296702-i2s", },
+	{ .compatible = "zte,zx296718-i2s", },
 	{}
 };
 MODULE_DEVICE_TABLE(of, zx_i2s_dt_ids);
-- 
2.7.4


  parent reply	other threads:[~2017-02-07  3:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-07  3:02 [PATCH v2 1/3] clk: zte: add i2s clocks for zx296718 Baoyou Xie
2017-02-07  3:02 ` [PATCH v2 2/3] dt: ASoC: zx-i2s: Document for the ZTE zx296718 I2S controller Baoyou Xie
2017-02-07  8:30   ` Shawn Guo
2017-02-07 12:02   ` Mark Brown
2017-02-07  3:02 ` Baoyou Xie [this message]
2017-02-07  8:26   ` [PATCH v2 3/3] ASoC: zx-i2s: support zx296718 SoC for ZTE's i2s controller driver Shawn Guo
2017-02-07  8:09 ` [PATCH v2 1/3] clk: zte: add i2s clocks for zx296718 Shawn Guo

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=1486436571-8682-3-git-send-email-baoyou.xie@linaro.org \
    --to=baoyou.xie@linaro.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=chen.chaokai@zte.com.cn \
    --cc=devicetree@vger.kernel.org \
    --cc=jun.nie@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mturquette@baylibre.com \
    --cc=perex@perex.cz \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@codeaurora.org \
    --cc=shawn.guo@linaro.org \
    --cc=shawnguo@kernel.org \
    --cc=tiwai@suse.com \
    --cc=vinod.koul@intel.com \
    --cc=wang.qiang01@zte.com.cn \
    --cc=xie.baoyou@zte.com.cn \
    /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;
as well as URLs for NNTP newsgroup(s).