[alsa-devel] [PATCH v3 1/3] clk: zte: add i2s clocks for zx296718
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 = {
ZTE's zx2967 I2S controller driver introduces pclk, this patch documents this fact.
Signed-off-by: Baoyou Xie baoyou.xie@linaro.org --- Documentation/devicetree/bindings/sound/zte,zx-i2s.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt b/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt index 7e5aa6f..77390c0 100644 --- a/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt +++ b/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt @@ -4,7 +4,7 @@ Required properties: - compatible : Must be "zte,zx296702-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: "wclk" for the wclk, "pclk" for the pclk to the I2S interface. - 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" @@ -15,13 +15,17 @@ please check: * clock/clock-bindings.txt * dma/dma.txt
+Please note that ZTE ZX296702 I2S controller driver is compatible for zx296702 +and zx296718, so compatible string might be set as follow: + "zte,zx296718-i2s", "zte,zx296702-i2s" + Example: i2s0: i2s0@0b005000 { #sound-dai-cells = <0>; - compatible = "zte,zx296702-i2s"; + compatible = "zte,zx296718-i2s", "zte,zx296702-i2s"; reg = <0x0b005000 0x1000>; - clocks = <&lsp0clk ZX296702_I2S0_DIV>; - clock-names = "tx"; + clocks = <&audiocrm AUDIO_I2S0_WCLK>, <&audiocrm AUDIO_I2S0_PCLK>; + clock-names = "wclk", "pclk"; interrupts = <GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>; dmas = <&dma 5>, <&dma 6>; dma-names = "tx", "rx";
On Wed, Feb 08, 2017 at 11:02:34AM +0800, Baoyou Xie wrote:
ZTE's zx2967 I2S controller driver introduces pclk, this patch documents this fact.
Now we have the same subject for patches 2 and 3.
Personally, I'd prefer "dt-bindings: sound: blah...", but not enough to argue with Mark about it. If that is not the prefix, then it should at least have "binding" in the subject.
Signed-off-by: Baoyou Xie baoyou.xie@linaro.org
Documentation/devicetree/bindings/sound/zte,zx-i2s.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt b/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt index 7e5aa6f..77390c0 100644 --- a/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt +++ b/Documentation/devicetree/bindings/sound/zte,zx-i2s.txt @@ -4,7 +4,7 @@ Required properties:
- compatible : Must be "zte,zx296702-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: "wclk" for the wclk, "pclk" for the pclk to the I2S interface.
- 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"
@@ -15,13 +15,17 @@ please check:
- clock/clock-bindings.txt
- dma/dma.txt
+Please note that ZTE ZX296702 I2S controller driver is compatible for zx296702 +and zx296718, so compatible string might be set as follow:
- "zte,zx296718-i2s", "zte,zx296702-i2s"
Drop this and just make compatible doc above like this:
- compatible : Must be one of: "zte,zx296718-i2s", "zte,zx296702-i2s" "zte,zx296702-i2s"
Example: i2s0: i2s0@0b005000 {
BTW, this should be "i2s@0b005000". No trailing 0 on i2s and no leading 0 on unit-address.
#sound-dai-cells = <0>;
compatible = "zte,zx296702-i2s";
reg = <0x0b005000 0x1000>;compatible = "zte,zx296718-i2s", "zte,zx296702-i2s";
clocks = <&lsp0clk ZX296702_I2S0_DIV>;
clock-names = "tx";
clocks = <&audiocrm AUDIO_I2S0_WCLK>, <&audiocrm AUDIO_I2S0_PCLK>;
interrupts = <GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>; dmas = <&dma 5>, <&dma 6>; dma-names = "tx", "rx";clock-names = "wclk", "pclk";
-- 2.7.4
On Wed, Feb 08, 2017 at 06:52:07PM -0600, Rob Herring wrote:
On Wed, Feb 08, 2017 at 11:02:34AM +0800, Baoyou Xie wrote:
ZTE's zx2967 I2S controller driver introduces pclk, this patch documents this fact.
Now we have the same subject for patches 2 and 3.
Personally, I'd prefer "dt-bindings: sound: blah...", but not enough to argue with Mark about it. If that is not the prefix, then it should at least have "binding" in the subject.
+1
The prefix of sound bindings is quite unique from other subsystems. Looking at the prefix of Documentation/devicetree/bindings/sound/ commits, I'm always confused whether it's a pure binding commit or just submitted as part of the driver patch. I feel that we kinda lose the point of having a prefix.
Just my 2 cents.
Shawn
On Thu, Feb 09, 2017 at 09:48:09AM +0800, Shawn Guo wrote:
On Wed, Feb 08, 2017 at 06:52:07PM -0600, Rob Herring wrote:
Personally, I'd prefer "dt-bindings: sound: blah...", but not enough to argue with Mark about it. If that is not the prefix, then it should at least have "binding" in the subject.
+1
The prefix of sound bindings is quite unique from other subsystems. Looking at the prefix of Documentation/devicetree/bindings/sound/ commits, I'm always confused whether it's a pure binding commit or just submitted as part of the driver patch. I feel that we kinda lose the point of having a prefix.
That's really not what's happening reliably - other subsystems also seem to have a bunch of things prefixed for the subsystem and the DT specific prefixes are all over the shop, people seem to be making them up at random. If DT binding review were something that reliably and consistently happened and didn't affect the subsystem I'd perhaps buy it but for run of the mill stuff it seems like getting things reviewed in the subsystem is more important.
On Thu, Feb 9, 2017 at 6:06 AM, Mark Brown broonie@kernel.org wrote:
On Thu, Feb 09, 2017 at 09:48:09AM +0800, Shawn Guo wrote:
On Wed, Feb 08, 2017 at 06:52:07PM -0600, Rob Herring wrote:
Personally, I'd prefer "dt-bindings: sound: blah...", but not enough to argue with Mark about it. If that is not the prefix, then it should at least have "binding" in the subject.
+1
The prefix of sound bindings is quite unique from other subsystems. Looking at the prefix of Documentation/devicetree/bindings/sound/ commits, I'm always confused whether it's a pure binding commit or just submitted as part of the driver patch. I feel that we kinda lose the point of having a prefix.
That's really not what's happening reliably - other subsystems also seem to have a bunch of things prefixed for the subsystem and the DT specific prefixes are all over the shop, people seem to be making them up at random.
I'm getting more picky about the subject and splitting bindings to a separate patch, but generally only when I have other comments. And I've had to get some maintainers to stop combining commits as they apply them.
Maybe get_maintainers.pl could spit out the desired prefix and checkpatch check it. Evidently, running "git log --oneline" is too hard.
If DT binding review were something that reliably and consistently happened and didn't affect the subsystem I'd perhaps buy it but for run of the mill stuff it seems like getting things reviewed in the subsystem is more important.
I review everything that gets sent to the DT list unless maintainers apply it first. I'll still comment afterwards if there's anything significant (or I missed that it was applied :)).
Rob
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: Baoyou Xie baoyou.xie@linaro.org --- sound/soc/zte/zx-i2s.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-)
diff --git a/sound/soc/zte/zx-i2s.c b/sound/soc/zte/zx-i2s.c index ed7a56d..2d486ea 100644 --- a/sound/soc/zte/zx-i2s.c +++ b/sound/soc/zte/zx-i2s.c @@ -95,7 +95,7 @@ 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; @@ -275,8 +275,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; }
@@ -328,8 +329,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; + + 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, @@ -337,7 +349,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 +394,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_info(&pdev->dev, "have no pclk\n"); + zx_i2s->dai_pclk = NULL; }
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
On Wed, Feb 08, 2017 at 11:02:35AM +0800, Baoyou Xie wrote:
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: Baoyou Xie baoyou.xie@linaro.org
sound/soc/zte/zx-i2s.c | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-)
diff --git a/sound/soc/zte/zx-i2s.c b/sound/soc/zte/zx-i2s.c index ed7a56d..2d486ea 100644 --- a/sound/soc/zte/zx-i2s.c +++ b/sound/soc/zte/zx-i2s.c @@ -95,7 +95,7 @@ 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;
It's better to have them on two lines, I would say.
void __iomem *reg_base; int master; resource_size_t mapbase; @@ -275,8 +275,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;
}
@@ -328,8 +329,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;
- 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, @@ -337,7 +349,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 +394,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_info(&pdev->dev, "have no pclk\n");
zx_i2s->dai_pclk = NULL;
The 'pclk' is actually required instead of optional. Since we haven't got any in-tree DTB with I2S device yet, there is no DT compatibility to maintain. So it should be good to make 'pclk' required right now.
Shawn
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
2.7.4
participants (4)
-
Baoyou Xie
-
Mark Brown
-
Rob Herring
-
Shawn Guo