linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/3] clk: zte: add i2s clocks for zx296718
@ 2017-02-06 13:50 Baoyou Xie
  2017-02-06 13:50 ` [PATCH v1 2/3] dt: Document for the ZTE zx296718 I2S controller Baoyou Xie
  2017-02-06 13:50 ` [PATCH v1 3/3] ASoC: zx-i2s: support zx296718 SoC for ZTE's i2s controller driver Baoyou Xie
  0 siblings, 2 replies; 6+ messages in thread
From: Baoyou Xie @ 2017-02-06 13:50 UTC (permalink / raw)
  To: lgirdwood, broonie, robh+dt, mark.rutland, jun.nie, baoyou.xie,
	mturquette, sboyd, perex, tiwai, shawn.guo, vinod.koul
  Cc: alsa-devel, devicetree, linux-kernel, linux-arm-kernel,
	linux-clk, shawnguo, xie.baoyou, chen.chaokai, wang.qiang01

The i2s related clock support is missing from the existing zx296718
clock driver. This patch adds it, so that the upstream ZX I2S driver
can work out.

Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org>
---
 drivers/clk/zte/clk-zx296718.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/clk/zte/clk-zx296718.c b/drivers/clk/zte/clk-zx296718.c
index ad5d1df..f106d40 100644
--- a/drivers/clk/zte/clk-zx296718.c
+++ b/drivers/clk/zte/clk-zx296718.c
@@ -941,6 +941,10 @@ static struct zx_clk_gate audio_gate_clk[] = {
 	GATE(AUDIO_SPDIF1_WCLK, "spdif1_wclk", "spdif1_wclk_div", AUDIO_SPDIF1_CLK, 9, CLK_SET_RATE_PARENT, 0),
 	GATE(AUDIO_TDM_WCLK, "tdm_wclk", "tdm_wclk_div", AUDIO_TDM_CLK, 17, CLK_SET_RATE_PARENT, 0),
 	GATE(AUDIO_TS_PCLK, "tempsensor_pclk", "clk49m5", AUDIO_TS_CLK, 1, 0, 0),
+	GATE(AUDIO_I2S0_PCLK, "i2s0_pclk", "clk49m5", AUDIO_I2S0_CLK, 8, 0, 0),
+	GATE(AUDIO_I2S1_PCLK, "i2s1_pclk", "clk49m5", AUDIO_I2S1_CLK, 8, 0, 0),
+	GATE(AUDIO_I2S2_PCLK, "i2s2_pclk", "clk49m5", AUDIO_I2S2_CLK, 8, 0, 0),
+	GATE(AUDIO_I2S3_PCLK, "i2s3_pclk", "clk49m5", AUDIO_I2S3_CLK, 8, 0, 0),
 };
 
 static struct clk_hw_onecell_data audio_hw_onecell_data = {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 2/3] dt: Document for the ZTE zx296718 I2S controller
  2017-02-06 13:50 [PATCH v1 1/3] clk: zte: add i2s clocks for zx296718 Baoyou Xie
@ 2017-02-06 13:50 ` Baoyou Xie
  2017-02-06 16:30   ` Mark Brown
  2017-02-09  0:43   ` Rob Herring
  2017-02-06 13:50 ` [PATCH v1 3/3] ASoC: zx-i2s: support zx296718 SoC for ZTE's i2s controller driver Baoyou Xie
  1 sibling, 2 replies; 6+ messages in thread
From: Baoyou Xie @ 2017-02-06 13:50 UTC (permalink / raw)
  To: lgirdwood, broonie, robh+dt, mark.rutland, jun.nie, baoyou.xie,
	mturquette, sboyd, perex, tiwai, shawn.guo, vinod.koul
  Cc: alsa-devel, devicetree, linux-kernel, linux-arm-kernel,
	linux-clk, shawnguo, xie.baoyou, chen.chaokai, wang.qiang01

This patch documents the devicetree for the ZTE's zx296718
I2S audio controller.

Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org>
---
 Documentation/devicetree/bindings/sound/zte,zx-i2s.txt | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt b/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt
index 7e5aa6f..c405561 100644
--- a/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt
+++ b/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt
@@ -1,10 +1,12 @@
 ZTE ZX296702 I2S controller
 
 Required properties:
- - compatible : Must be "zte,zx296702-i2s"
+ - compatible : Should include one of the following strings:
+	"zte,zx296702-i2s","zte,zx296718-i2s".
  - reg : Must contain I2S core's registers location and length
  - clocks : Pairs of phandle and specifier referencing the controller's clocks.
- - clock-names: "tx" for the clock to the I2S interface.
+ - clock-names: "tx" for the wclk, "pclk" for the pclk to the I2S interface.
+	must contain pclk for zx296718 SoC.
  - dmas: Pairs of phandle and specifier for the DMA channel that is used by
    the core. The core expects two dma channels for transmit.
  - dma-names : Must be "tx" and "rx"
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v1 3/3] ASoC: zx-i2s: support zx296718 SoC for ZTE's i2s  controller driver
  2017-02-06 13:50 [PATCH v1 1/3] clk: zte: add i2s clocks for zx296718 Baoyou Xie
  2017-02-06 13:50 ` [PATCH v1 2/3] dt: Document for the ZTE zx296718 I2S controller Baoyou Xie
@ 2017-02-06 13:50 ` Baoyou Xie
  2017-02-06 16:28   ` Mark Brown
  1 sibling, 1 reply; 6+ messages in thread
From: Baoyou Xie @ 2017-02-06 13:50 UTC (permalink / raw)
  To: lgirdwood, broonie, robh+dt, mark.rutland, jun.nie, baoyou.xie,
	mturquette, sboyd, perex, tiwai, shawn.guo, vinod.koul
  Cc: alsa-devel, devicetree, linux-kernel, linux-arm-kernel,
	linux-clk, shawnguo, xie.baoyou, chen.chaokai, wang.qiang01

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 | 49 ++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 40 insertions(+), 9 deletions(-)

diff --git a/sound/soc/zte/zx-i2s.c b/sound/soc/zte/zx-i2s.c
index ed7a56d..68d590be 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;
@@ -218,6 +219,17 @@ static int zx_i2s_set_fmt(struct snd_soc_dai *cpu_dai, unsigned int fmt)
 	return 0;
 }
 
+static void zx_i2s_set_clk(struct zx_i2s_info *i2s,
+			   unsigned int ch_num, unsigned int sample_rate)
+{
+	unsigned long val = sample_rate * ch_num * CLK_RAT;
+
+	clk_set_rate(i2s->dai_wclk, val);
+
+	if (i2s->dai_pclk)
+		clk_set_rate(i2s->dai_pclk, val);
+}
+
 static int zx_i2s_hw_params(struct snd_pcm_substream *substream,
 			    struct snd_pcm_hw_params *params,
 			    struct snd_soc_dai *socdai)
@@ -275,8 +287,8 @@ 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);
+		zx_i2s_set_clk(i2s, ch_num, params_rate(params));
+
 	return ret;
 }
 
@@ -328,8 +340,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 +360,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 +405,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 +444,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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 3/3] ASoC: zx-i2s: support zx296718 SoC for ZTE's i2s controller driver
  2017-02-06 13:50 ` [PATCH v1 3/3] ASoC: zx-i2s: support zx296718 SoC for ZTE's i2s controller driver Baoyou Xie
@ 2017-02-06 16:28   ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2017-02-06 16:28 UTC (permalink / raw)
  To: Baoyou Xie
  Cc: lgirdwood, robh+dt, mark.rutland, jun.nie, mturquette, sboyd,
	perex, tiwai, shawn.guo, vinod.koul, alsa-devel, devicetree,
	linux-kernel, linux-arm-kernel, linux-clk, shawnguo, xie.baoyou,
	chen.chaokai, wang.qiang01

[-- Attachment #1: Type: text/plain, Size: 837 bytes --]

On Mon, Feb 06, 2017 at 09:50:20PM +0800, Baoyou Xie wrote:

> +static void zx_i2s_set_clk(struct zx_i2s_info *i2s,
> +			   unsigned int ch_num, unsigned int sample_rate)
> +{
> +	unsigned long val = sample_rate * ch_num * CLK_RAT;
> +
> +	clk_set_rate(i2s->dai_wclk, val);
> +
> +	if (i2s->dai_pclk)
> +		clk_set_rate(i2s->dai_pclk, val);
> +}

There's no error checking here, if we don't care if these calls succeed
we could save some power and not enable the clocks.  This function is
also very small and has exactly one user so it's not clear why it's
split out.

>  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);

This adds a new DT binding but does not update the binding document.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 2/3] dt: Document for the ZTE zx296718 I2S controller
  2017-02-06 13:50 ` [PATCH v1 2/3] dt: Document for the ZTE zx296718 I2S controller Baoyou Xie
@ 2017-02-06 16:30   ` Mark Brown
  2017-02-09  0:43   ` Rob Herring
  1 sibling, 0 replies; 6+ messages in thread
From: Mark Brown @ 2017-02-06 16:30 UTC (permalink / raw)
  To: Baoyou Xie
  Cc: lgirdwood, robh+dt, mark.rutland, jun.nie, mturquette, sboyd,
	perex, tiwai, shawn.guo, vinod.koul, alsa-devel, devicetree,
	linux-kernel, linux-arm-kernel, linux-clk, shawnguo, xie.baoyou,
	chen.chaokai, wang.qiang01

[-- Attachment #1: Type: text/plain, Size: 371 bytes --]

On Mon, Feb 06, 2017 at 09:50:19PM +0800, Baoyou Xie wrote:
> This patch documents the devicetree for the ZTE's zx296718
> I2S audio controller.

Oh, this is the binding document.  Me not seeing this is a perfect
example of why you should always use subject lines matching the style
for the subsystem - if you don't it's more likely people will not see
relevant patches.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v1 2/3] dt: Document for the ZTE zx296718 I2S controller
  2017-02-06 13:50 ` [PATCH v1 2/3] dt: Document for the ZTE zx296718 I2S controller Baoyou Xie
  2017-02-06 16:30   ` Mark Brown
@ 2017-02-09  0:43   ` Rob Herring
  1 sibling, 0 replies; 6+ messages in thread
From: Rob Herring @ 2017-02-09  0:43 UTC (permalink / raw)
  To: Baoyou Xie
  Cc: lgirdwood, broonie, mark.rutland, jun.nie, mturquette, sboyd,
	perex, tiwai, shawn.guo, vinod.koul, alsa-devel, devicetree,
	linux-kernel, linux-arm-kernel, linux-clk, shawnguo, xie.baoyou,
	chen.chaokai, wang.qiang01

On Mon, Feb 06, 2017 at 09:50:19PM +0800, Baoyou Xie wrote:
> This patch documents the devicetree for the ZTE's zx296718
> I2S audio controller.
> 
> Signed-off-by: Baoyou Xie <baoyou.xie@linaro.org>
> ---
>  Documentation/devicetree/bindings/sound/zte,zx-i2s.txt | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt b/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt
> index 7e5aa6f..c405561 100644
> --- a/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt
> +++ b/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt
> @@ -1,10 +1,12 @@
>  ZTE ZX296702 I2S controller
>  
>  Required properties:
> - - compatible : Must be "zte,zx296702-i2s"
> + - compatible : Should include one of the following strings:
> +	"zte,zx296702-i2s","zte,zx296718-i2s".

One per line please.

>   - reg : Must contain I2S core's registers location and length
>   - clocks : Pairs of phandle and specifier referencing the controller's clocks.
> - - clock-names: "tx" for the clock to the I2S interface.
> + - clock-names: "tx" for the wclk, "pclk" for the pclk to the I2S interface.
> +	must contain pclk for zx296718 SoC.

I'd reword as "pclk is only present for zte,zx296718-i2s"

>   - dmas: Pairs of phandle and specifier for the DMA channel that is used by
>     the core. The core expects two dma channels for transmit.
>   - dma-names : Must be "tx" and "rx"
> -- 
> 2.7.4
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-02-09  0:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-06 13:50 [PATCH v1 1/3] clk: zte: add i2s clocks for zx296718 Baoyou Xie
2017-02-06 13:50 ` [PATCH v1 2/3] dt: Document for the ZTE zx296718 I2S controller Baoyou Xie
2017-02-06 16:30   ` Mark Brown
2017-02-09  0:43   ` Rob Herring
2017-02-06 13:50 ` [PATCH v1 3/3] ASoC: zx-i2s: support zx296718 SoC for ZTE's i2s controller driver Baoyou Xie
2017-02-06 16:28   ` Mark Brown

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).