Re: [PATCH] ASoC: simple-card: fix possible uninitialized single_cpu local variable

2021-04-07 Thread Sameer Pujar




On 4/7/2021 2:50 PM, Krzysztof Kozlowski wrote:

The 'single_cpu' local variable is assigned by asoc_simple_parse_dai()
and later used in a asoc_simple_canonicalize_cpu() call, assuming the
entire function did not exit on errors.

However the first function returns 0 if passed device_node is NULL,
thus leaving the variable uninitialized and reporting success.

Addresses-Coverity: Uninitialized scalar variable
Fixes: 8f7f298a3337 ("ASoC: simple-card-utils: separate 
asoc_simple_card_parse_dai()")
Signed-off-by: Krzysztof Kozlowski 
---
  sound/soc/generic/audio-graph-card.c | 2 +-
  sound/soc/generic/simple-card.c  | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)



Acked-by: Sameer Pujar 


Re: [PATCH v2] ASoC: dt-bindings: nvidia,tegra210-ahub: Add missing child nodes

2021-03-29 Thread Sameer Pujar




On 3/27/2021 1:20 AM, Rob Herring wrote:

The nvidia,tegra210-ahub binding is missing schema for child nodes. This
results in warnings if 'additionalProperties: false' is set (or when the
tools implement 'unevaluatedProperties' support). Add the child nodes
and reference their schema if one exists.

Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: Thierry Reding 
Cc: Jonathan Hunter 
Cc: Sameer Pujar 
Cc: alsa-de...@alsa-project.org
Cc: linux-te...@vger.kernel.org
Signed-off-by: Rob Herring 
---
v2:
  - Also add 'dspk' child node

This patch ideally should be applied before this series[1].

[1] https://lore.kernel.org/r/20210323163634.877511-1-r...@kernel.org/
---
  .../bindings/sound/nvidia,tegra210-ahub.yaml | 16 
  1 file changed, 16 insertions(+)


Acked-by: Sameer Pujar 


Re: [PATCH] ASoC: dt-bindings: nvidia,tegra210-ahub: Add missing child nodes

2021-03-24 Thread Sameer Pujar




On 3/24/2021 1:30 AM, Rob Herring wrote:

External email: Use caution opening links or attachments


The nvidia,tegra210-ahub binding is missing schema for child nodes. This
results in warnings if 'additionalProperties: false' is set (or when the
tools implement 'unevaluatedProperties' support). Add the child nodes
and reference their schema if one exists.

Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: Thierry Reding 
Cc: Jonathan Hunter 
Cc: Sameer Pujar 
Cc: alsa-de...@alsa-project.org
Cc: linux-te...@vger.kernel.org
Signed-off-by: Rob Herring 
---
This patch ideally should be applied before this series[1].

[1] https://lore.kernel.org/r/20210323163634.877511-1-r...@kernel.org/

  .../bindings/sound/nvidia,tegra210-ahub.yaml | 12 
  1 file changed, 12 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml
index e568d6c7..d7a5eb77ed4f 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml
@@ -69,6 +69,18 @@ properties:
  $ref: audio-graph-port.yaml#
  unevaluatedProperties: false

+patternProperties:
+  '^i2s@[0-9a-f]+$':
+type: object
+
+  '^dmic@[0-9a-f]+$':
+type: object
+$ref: nvidia,tegra210-dmic.yaml#
+
+  '^admaif@[0-9a-f]+$':
+type: object
+$ref: nvidia,tegra210-admaif.yaml#
+


There is "dspk@xxx" child node as well for ahub, though schema example 
does not show this. I am seeing error because of this during 
"dtbs_check". Wondering if we can add following with this patch?


+  '^dspk@[0-9a-f]+$':
+type: object
+$ref: nvidia,tegra186-dspk.yaml#



  required:
- compatible
- reg
--
2.27.0





[PATCH v2] arm64: tegra: Move clocks from RT5658 endpoint to device node

2021-03-15 Thread Sameer Pujar
An endpoint is not a device and it is recommended to use clocks property
in device node. RT5658 Codec binding already specifies the usage of
clocks property. Thus move the clocks from endpoint to device node.

Fixes: 5b4f6323096a ("arm64: tegra: Audio graph sound card for Jetson AGX 
Xavier")
Suggested-by: Rob Herring 
Signed-off-by: Sameer Pujar 
---
 Changelog:
   v1 -> v2: Added "clock-names" property as rt5659 driver specifically looks
 for this clock name.
 
 arch/arm64/boot/dts/nvidia/tegra194-p2972-.dts | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/nvidia/tegra194-p2972-.dts 
b/arch/arm64/boot/dts/nvidia/tegra194-p2972-.dts
index b079420..8dd2871 100644
--- a/arch/arm64/boot/dts/nvidia/tegra194-p2972-.dts
+++ b/arch/arm64/boot/dts/nvidia/tegra194-p2972-.dts
@@ -651,6 +651,8 @@
reg = <0x1a>;
interrupt-parent = <>;
interrupts = ;
+   clocks = < TEGRA194_CLK_AUD_MCLK>;
+   clock-names = "mclk";
realtek,jd-src = <2>;
sound-name-prefix = "CVB-RT";
 
@@ -658,7 +660,6 @@
rt5658_ep: endpoint {
remote-endpoint = 
<_dap_ep>;
mclk-fs = <256>;
-   clocks = < 
TEGRA194_CLK_AUD_MCLK>;
};
};
};
-- 
2.7.4



[PATCH 2/2] ASoC: rt5659: Update MCLK rate in set_sysclk()

2021-03-15 Thread Sameer Pujar
Simple-card/audio-graph-card drivers do not handle MCLK clock when it
is specified in the codec device node. The expectation here is that,
the codec should actually own up the MCLK clock and do necessary setup
in the driver.

Suggested-by: Mark Brown 
Suggested-by: Michael Walle 
Signed-off-by: Sameer Pujar 
---
 sound/soc/codecs/rt5659.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c
index b787515..0af9601 100644
--- a/sound/soc/codecs/rt5659.c
+++ b/sound/soc/codecs/rt5659.c
@@ -3430,12 +3430,17 @@ static int rt5659_set_component_sysclk(struct 
snd_soc_component *component, int
 {
struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component);
unsigned int reg_val = 0;
+   int ret;
 
if (freq == rt5659->sysclk && clk_id == rt5659->sysclk_src)
return 0;
 
switch (clk_id) {
case RT5659_SCLK_S_MCLK:
+   ret = clk_set_rate(rt5659->mclk, freq);
+   if (ret)
+   return ret;
+
reg_val |= RT5659_SCLK_SRC_MCLK;
break;
case RT5659_SCLK_S_PLL1:
-- 
2.7.4



[PATCH 1/2] ASoC: simple-card-utils: Do not handle device clock

2021-03-15 Thread Sameer Pujar
This reverts commit 1e30f642cf29 ("ASoC: simple-card-utils: Fix device
module clock"). The original patch ended up breaking following platform,
which depends on set_sysclk() to configure internal PLL on wm8904 codec
and expects simple-card-utils to not update the MCLK rate.
 - "arch/arm64/boot/dts/freescale/fsl-ls1028a-kontron-sl28-var3-ads2.dts"

It would be best if codec takes care of setting MCLK clock via DAI
set_sysclk() callback.

Reported-by: Michael Walle 
Suggested-by: Mark Brown 
Suggested-by: Michael Walle 
Fixes: 1e30f642cf29 ("ASoC: simple-card-utils: Fix device module clock")
Signed-off-by: Sameer Pujar 
---
 sound/soc/generic/simple-card-utils.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/sound/soc/generic/simple-card-utils.c 
b/sound/soc/generic/simple-card-utils.c
index ab31045..6cada4c 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -172,15 +172,16 @@ int asoc_simple_parse_clk(struct device *dev,
 *  or device's module clock.
 */
clk = devm_get_clk_from_child(dev, node, NULL);
-   if (IS_ERR(clk))
-   clk = devm_get_clk_from_child(dev, dlc->of_node, NULL);
-
if (!IS_ERR(clk)) {
-   simple_dai->clk = clk;
simple_dai->sysclk = clk_get_rate(clk);
-   } else if (!of_property_read_u32(node, "system-clock-frequency",
-)) {
+
+   simple_dai->clk = clk;
+   } else if (!of_property_read_u32(node, "system-clock-frequency", )) 
{
simple_dai->sysclk = val;
+   } else {
+   clk = devm_get_clk_from_child(dev, dlc->of_node, NULL);
+   if (!IS_ERR(clk))
+   simple_dai->sysclk = clk_get_rate(clk);
}
 
if (of_property_read_bool(node, "system-clock-direction-out"))
-- 
2.7.4



[PATCH 0/2] Do not handle MCLK device clock in simple-card-utils

2021-03-15 Thread Sameer Pujar
With commit 1e30f642cf29 ("ASoC: simple-card-utils: Fix device module clock")
simple-card-utils can control MCLK clock for rate updates or enable/disable.
But this is breaking some platforms where it is expected that codec drivers
would actually handle the MCLK clock. One such example is following platform.
  - "arch/arm64/boot/dts/freescale/fsl-ls1028a-kontron-sl28-var3-ads2.dts"

In above case codec, wm8904, is using internal PLL and configures sysclk
based on fixed MCLK input. In such cases it is expected that, required PLL
output or sysclk, is just passed via set_sysclk() callback and card driver
need not actually update MCLK rate. Instead, codec can take ownership of
this clock and do the necessary configuration.

So the original commit is reverted and codec driver for rt5659 is updated
to fix my board which has this codec.

Sameer Pujar (2):
  ASoC: simple-card-utils: Do not handle device clock
  ASoC: rt5659: Update MCLK rate in set_sysclk()

 sound/soc/codecs/rt5659.c |  5 +
 sound/soc/generic/simple-card-utils.c | 13 +++--
 2 files changed, 12 insertions(+), 6 deletions(-)

-- 
2.7.4



Re: Re: [PATCH 1/3] ASoC: simple-card-utils: Fix device module clock

2021-03-15 Thread Sameer Pujar

Yes this is a problem, unfortunately I missed checking some of the
simple-card examples. I wonder we should be specifically looking for "mclk"
clock here.

That would definitely help mitigate the problem but I really think it's
cleaner and safer to just push this down to set_sysclk().


Understand now. I will push patches based on this. Thanks for the details.


Re: [PATCH 1/3] ASoC: simple-card-utils: Fix device module clock

2021-03-15 Thread Sameer Pujar




On 3/15/2021 9:03 PM, Michael Walle wrote:

Am 2021-03-15 16:19, schrieb Sameer Pujar:

On 3/15/2021 5:35 PM, Michael Walle wrote:

Am 2021-03-12 14:46, schrieb Mark Brown:

On Fri, Mar 12, 2021 at 01:30:02PM +0100, Michael Walle wrote:


The card calls set_sysclk(), which eventually ends up in the codec.
The codec therefore, could figure out if it needs to configure the
clock or if it can use its internal FLL.
Is that what you mean?


Yes.


But the set_sysclk() of the codec isn't even called, because the
card itself already tries to call clk_set_rate() on the Codec's
MCLK,
which returns with an error [0].


OK, so I think we need to push this down a level so that the clock
setting is implemented by the core/CODEC rather than by simple-card,
with the helpers being something the CODEC can opt out of.


Sameer, it looks like the proper fix should be to add the clock
support to your codec.


I agree that complicated clock relationships should be handled within
the codec itself, however MCLK rate setting depends on "mclk-fs"
factor and this property is specified as part of
simple-card/audio-graph-card codec subnode. Right now codec, in
general, does not have a way to know this. The set_sysclk() callback
takes rate argument and not the factor.


Why would you need the factor?


Sorry, you are right. I misread the flow. Fixed rates can use 
"assigned-clocks" binding and runtime updates can depend on "mclk-fs". 
No additional property is required for codec. Something like below 
should help.




diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c
index 67f0ab817135..7fd41f51f856 100644
--- a/sound/soc/codecs/rt5659.c
+++ b/sound/soc/codecs/rt5659.c
@@ -3426,12 +3426,18 @@ static int rt5659_set_component_sysclk(struct
snd_soc_component *component, int
 {
    struct rt5659_priv *rt5659 =
snd_soc_component_get_drvdata(component);
    unsigned int reg_val = 0;
+   int ret;

    if (freq == rt5659->sysclk && clk_id == rt5659->sysclk_src)
    return 0;

    switch (clk_id) {
    case RT5659_SCLK_S_MCLK:
+   ret = clk_set_rate(rt5659->mclk, freq);
+   if (ret)
+   return ret;
    reg_val |= RT5659_SCLK_SRC_MCLK;
    break;
    case RT5659_SCLK_S_PLL1:


Re: [PATCH 1/3] ASoC: simple-card-utils: Fix device module clock

2021-03-15 Thread Sameer Pujar




On 3/15/2021 5:35 PM, Michael Walle wrote:

External email: Use caution opening links or attachments


Am 2021-03-12 14:46, schrieb Mark Brown:

On Fri, Mar 12, 2021 at 01:30:02PM +0100, Michael Walle wrote:


The card calls set_sysclk(), which eventually ends up in the codec.
The codec therefore, could figure out if it needs to configure the
clock or if it can use its internal FLL.
Is that what you mean?


Yes.


But the set_sysclk() of the codec isn't even called, because the
card itself already tries to call clk_set_rate() on the Codec's MCLK,
which returns with an error [0].


OK, so I think we need to push this down a level so that the clock
setting is implemented by the core/CODEC rather than by simple-card,
with the helpers being something the CODEC can opt out of.


Sameer, it looks like the proper fix should be to add the clock
support to your codec.


I agree that complicated clock relationships should be handled within 
the codec itself, however MCLK rate setting depends on "mclk-fs" factor 
and this property is specified as part of simple-card/audio-graph-card 
codec subnode. Right now codec, in general, does not have a way to know 
this. The set_sysclk() callback takes rate argument and not the factor. 
Moreover the same codec is used by other platform vendors too and unless 
a new DT property is added for codec, runtime MCLK update based on the 
scaling factor cannot be supported. This would mean that we will be 
having two methods to specify "mclk-fs" factor, one from 
simple-card/audio-graph-card and one from respective codec nodes, which 
does not seem ideal.


Also it does not seem consistent with the way we handle MCLK clock based 
on where it is specified.


  a) If specified in simple-card/audio-graph-card, MCLK clock 
rate/enable/disable updates are allowed.


  b) If specified in codec device node, it is not expected to touch the 
MCLK clock. This patch tried to treat it the same way as (a) does. 
Advantage of this is, all codec drivers need not explicitly handle MCLK, 
instead it is done at a central place. The platforms which use specific 
machine drivers do the same and that is why probably the codec driver 
patch was never required. It is about just setting MCLK clock as a 
factor of sample rate, whenever the factor is available. I understand 
that it is breaking your use case, but I am not sure if the usage of 
set_sysclk() is consistent. I mean, it takes the "freq" argument. Does 
it refer to MCLK rate or system-clock (sysclk) rate? MCLK and sysclk are 
not really the same when codec PLL is involved. So I would like to 
understand clearly about what "freq" argument means. Also when "mclk-fs" 
factor is specified, is it related to MCLK or sysclk? My understanding 
is that it should be strictly viewed as related to MCLK.



Does it help if a separate helper is used for audio-graph-card with 
current change and reverting the simple-card to its previous state?

Morimoto-san, does it affect any other users of audio-graph-card?



I've also looked at other users of "simple-audio-card" and
it looks like they will break too. For example,
- arch/arm64/boot/dts/rockchip/rk3399.dtsi
    If I'm not mistaken, this will try to set the first clock
    of hdmi@ff94 there, which is "iahb".
- arch/arm/boot/dts/sun8i-a33.dtsi
    There " CLK_BUS_CODEC" of codec@1c22e00 will be changed

And it doesn't stop there, it also sets the first clock
of the CPU endpoint, which I guess just works because .set_rate
is a noop for the most clocks which are used there.


Yes this is a problem, unfortunately I missed checking some of the 
simple-card examples. I wonder we should be specifically looking for 
"mclk" clock here.


Re: [PATCH 1/3] ASoC: simple-card-utils: Fix device module clock

2021-03-11 Thread Sameer Pujar




On 3/11/2021 4:46 PM, Michael Walle wrote:

Am 2021-03-11 12:05, schrieb Sameer Pujar:


It would work and initially I had similar patch, see [0] and related
series. Suggestion is to always use "clocks" property with devices
only.


I see. But again, I don't think it is correct to change the clock of
the codec by default. What happens if this is for example a
compatible = "fixed-clock"?


The codec rate won't be changed unless a corresponding "*mclk-fs" is 
provided.




As you pointed out in the referred thread [0]. simple-audio-card has
that clock and judging from the code it is exactly for this reason:
to either change/enable it or not.





With this patch you'll switch that to "always change it". Therefore,
shouldn't there be a dt flag to indicate wheter simple-audio-card/graph
should be in charge of the codecs clock input?


As mentioned above, it does not change always. Requires "*mclk-fs" to do so.

May be below could be a possible alternative?
- Re-order if-else of clock parsing.

   if (!of_property_read_u32(node, "system-clock-frequency", )) {
   // Since you are fixing rate already via "assigned-clocks" this 
may be a duplication. OR
   // "assigned-clocks" can be parsed to understand if a fixed rate 
is expected.


   simple_dai->sysclk = val;
   } else {
   // fetch MCLK clock from device and setup sysclk
   // a. If "*mclk-fs" is given and "clocks" is found, the rate 
would be updated.
   // b. If "*mclk-fs" is not mentioned and "clocks" is found, then 
simple-card utils won't touch rate. It will just do clock enable/disable.

   }



And its fetching just the first clock, doesn't it? What happens if a
codec has two clock inputs?


Yes, it would have been more descriptive if it were specifically looking 
for clock "mclk". I think the original assumption was codec takes one 
input clock (MCLK) and uses it for sysclk.




-michael

[0]
https://patchwork.kernel.org/project/alsa-devel/patch/1611944866-29373-4-git-send-email-spu...@nvidia.com/ 





Re: [PATCH 1/3] ASoC: simple-card-utils: Fix device module clock

2021-03-11 Thread Sameer Pujar




On 3/11/2021 3:57 PM, Michael Walle wrote:

I've had a closer look at this and it seems you're messing around
with the clock of the codec's node (which is _not_ a subnode of
the simple-audio-card). I don't think this is correct.

I guess you should rather set the clock property in the codec
subnode of the simple-audio-card, which is then picked up by the
simple-audio-card driver and changed accordingly.

For example:
   simple-audio-card,dai-link@0 {
   reg = <0>;
   bitclock-master = <_master>;
   frame-master = <_master>;
   format = "i2s";

   cpu {
   sound-dai = <>;
   };

   dailink0_master: codec {
   sound-dai = <>;
   clocks = <>;
   };
   };

In this case mclk will be enabled and disabled accordingly.

Could you test this?



It would work and initially I had similar patch, see [0] and related 
series. Suggestion is to always use "clocks" property with devices only.



[0] 
https://patchwork.kernel.org/project/alsa-devel/patch/1611944866-29373-4-git-send-email-spu...@nvidia.com/


Re: [PATCH 1/3] ASoC: simple-card-utils: Fix device module clock

2021-03-10 Thread Sameer Pujar




On 3/10/2021 11:44 PM, Michael Walle wrote:


Btw I'm pretty sure, the MCLK was enabled and disabled depending on
whether there was an audio stream, the last time I've measured the
clock.


This may be true in your case because wm8904 driver does an explicit 
clock enable/disable and does not rely on simple-card-utils for this. In 
my case it depends on simple-card-utils.


Re: [PATCH 1/3] ASoC: simple-card-utils: Fix device module clock

2021-03-10 Thread Sameer Pujar




On 3/10/2021 4:00 AM, Michael Walle wrote:

Am 2021-03-09 17:27, schrieb Sameer Pujar:

On 3/9/2021 8:11 PM, Michael Walle wrote:

If "clocks = <>" is specified from the CPU or Codec component
device node, the clock is not getting enabled. Thus audio playback
or capture fails.

Fix this by populating "simple_dai->clk" field when clocks property
is specified from device node as well. Also tidy up by re-organising
conditional statements of parsing logic.

Fixes: bb6fc620c2ed ("ASoC: simple-card-utils: add
asoc_simple_card_parse_clk()")
Cc: Kuninori Morimoto 
Signed-off-by: Sameer Pujar 


This actually breaks sound on my board
(arch/arm64/boot/dts/freescale/fsl-ls1028a-kontron-sl28-var3-ads2.dts).
The codec on this board (wm8904) has a fixed clock input (only
distinct
frequencies are supported) and uses the FLL of the codec to generate
the
desired sample rate.

It seems that after this patch the clock rate of the codecs clock
(rather
than the FLL) is tried to be changed. Which fails, because it doesn't
support arbitrary frequencies.


Yes, after the given change the clock will be updated if "*mclk-fs"
property is specified.

DT you mentioned has property "simple-audio-card,mclk-fs = <256>",
which means you need a clock that is a function of sample rate. But as
per above you want a fixed clock for MCLK. I think if you drop this
property, the clock updates won't happen. Earlier for your case, this
property was not used at all because the clock handle was not
populated.


You mean to drop the mclk-fs property? I can't do that because I
actually need a frequency of 256 * sample rate. But that doesn't
necessarily need to be the MCLK, because the codec itself has a
FLL/PLL which can be used to generate any frequency for a given
MCLK. So that is a valid scenario. See also commit 13409d27cb39
("ASoC: wm8904: configure sysclk/FLL automatically").



If I read this correctly below is the configuration you need,
SoC -> MCLK(fixed rate) -> PLL(wm8904) -> PLL output (256 * fs) -> sysclk

From the doc simple-card.txt, "simple-audio-card,mclk-fs" is a scaling 
factor for MCLK and hence I am not sure if it is correct to have 
"*mclk-fs" property when MCLK is fixed. In simple cases, codec sysclk 
direclty depends on MCLK and set_sysclk() callback helps. Your case 
requires PLL configuration and set_pll() may be a better alternative. 
However simple-card does not offer this yet. But even if this is added, 
there should be a way to suggest PLL output requirement as a function of 
sample rate.





Re: [PATCH 1/3] ASoC: simple-card-utils: Fix device module clock

2021-03-09 Thread Sameer Pujar

Hi Michael,

On 3/9/2021 8:11 PM, Michael Walle wrote:

External email: Use caution opening links or attachments


Hi,


If "clocks = <>" is specified from the CPU or Codec component
device node, the clock is not getting enabled. Thus audio playback
or capture fails.

Fix this by populating "simple_dai->clk" field when clocks property
is specified from device node as well. Also tidy up by re-organising
conditional statements of parsing logic.

Fixes: bb6fc620c2ed ("ASoC: simple-card-utils: add 
asoc_simple_card_parse_clk()")
Cc: Kuninori Morimoto 
Signed-off-by: Sameer Pujar 

This actually breaks sound on my board
(arch/arm64/boot/dts/freescale/fsl-ls1028a-kontron-sl28-var3-ads2.dts).
The codec on this board (wm8904) has a fixed clock input (only distinct
frequencies are supported) and uses the FLL of the codec to generate the
desired sample rate.

It seems that after this patch the clock rate of the codecs clock (rather
than the FLL) is tried to be changed. Which fails, because it doesn't
support arbitrary frequencies.


Yes, after the given change the clock will be updated if "*mclk-fs" 
property is specified.


DT you mentioned has property "simple-audio-card,mclk-fs = <256>", which 
means you need a clock that is a function of sample rate. But as per 
above you want a fixed clock for MCLK. I think if you drop this 
property, the clock updates won't happen. Earlier for your case, this 
property was not used at all because the clock handle was not populated.




-michael


---
  sound/soc/generic/simple-card-utils.c | 13 ++---
  1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/sound/soc/generic/simple-card-utils.c 
b/sound/soc/generic/simple-card-utils.c
index bc0b62e..0754d70 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -173,16 +173,15 @@ int asoc_simple_parse_clk(struct device *dev,
*  or device's module clock.
*/
   clk = devm_get_clk_from_child(dev, node, NULL);
- if (!IS_ERR(clk)) {
- simple_dai->sysclk = clk_get_rate(clk);
+ if (IS_ERR(clk))
+ clk = devm_get_clk_from_child(dev, dlc->of_node, NULL);

+ if (!IS_ERR(clk)) {
   simple_dai->clk = clk;
- } else if (!of_property_read_u32(node, "system-clock-frequency", )) {
+ simple_dai->sysclk = clk_get_rate(clk);
+ } else if (!of_property_read_u32(node, "system-clock-frequency",
+  )) {
   simple_dai->sysclk = val;
- } else {
- clk = devm_get_clk_from_child(dev, dlc->of_node, NULL);
- if (!IS_ERR(clk))
- simple_dai->sysclk = clk_get_rate(clk);
   }

   if (of_property_read_bool(node, "system-clock-direction-out"))
--
2.7.4






Re: [RFC PATCH 3/5] ASoC: audio-graph-card: Add bindings for sysclk and pll

2021-03-02 Thread Sameer Pujar




On 3/2/2021 7:40 AM, Rob Herring wrote:

External email: Use caution opening links or attachments


On Thu, Feb 25, 2021 at 12:06 PM Sameer Pujar  wrote:

ASoC core provides callbacks snd_soc_dai_set_sysclk() and
snd_soc_dai_set_pll() for system clock (sysclk) and pll configurations
respectively. Add bindings for flexible sysclk or pll configurations
which can be driven from CPU/Codec DAI or endpoint subnode from DT.
This in turn helps to avoid hard codings in driver and makes it more
generic.

Also add system-clock related bindings, "system-clock-direction-out"
and "system-clock-frequency", which are already supported.

This all looks like duplication of what the clock binding can provide.
We don't need 2 ways to describe clocks in DT.


This was targetted for external audio codecs. Their internal clock 
management is not exposed with the clock framework. Instead ASoC 
provides callbacks to set this up on Codec side. There are many 
references where this is followed with some hardcoded settings in the 
drivers.


Are you suggesting to instead expose codec internal clocks and manage 
via generic clock bindings? Would this mean each codec driver has to 
implement these clock APIs (for ex: set_rate()) and program registers 
accordingly?
For a platform, different audio cards can be plugged in. In that case, 
each codec has to be updated to follow this. Wouldn't it be simpler to 
use available ASoC callbacks?


Re: [RFC PATCH 0/5] Flexible sysclk/pll configuration

2021-02-25 Thread Sameer Pujar




On 2/25/2021 11:35 PM, Sameer Pujar wrote:

This series attempts to add flexible system clock (sysclk) and pll
configuration for the DAI controller from simple card or audio graph
card.

Sysclk configuration

   Motivation:
   ---
 The problem this tries to address is, some Codecs may have
 multiple clocks and multiple sources for its sysclk. For example
 sysclk may depend on MCLK provided by SoC or it may used an
 internal pll. The simple card or audio graph card driver is
 generic and can be used on multiple platforms. So if a platform
 using this driver needs a generic configuration, then the Codec
 specific stuff cannot be hardcoded in the driver. Hence it would
 be better if the info is driven from DT, especially from a
 Codec DAI or endpoint subnode.

   Solution:
   -
 "system-clock-id" and "system-clock-source" DT properties can be
 exposed for a flexible sysclk configuration. These properties
 go into a Codec DAI or endpoint subnode.

 Please note that other sysclk related properties like
 "system-clock-frequency" and "system-clock-direction-out" are
 already present.

 Currently snd_soc_dai_set_sysclk() does not have an argument
 for source. This series adds this additional field and updates
 all the required drivers. This is needed because ideally sysclk
 "clk_id" and "source" fields are different. Some drivers are
 making use of "clk_id" field to program source information.
 **May be this needs to be corrected going ahead**


Pll configuration
=
   Motivation:
   ---
 Similar to sysclk configuration, pll configuration also needs
 little more flexibility. If a Codec has internal pll and it
 can be sourced from multiple clocks a specific configuration
 may be required for a given platform.

 Some of the cases are:
   - MCLK (supplied by SoC) --> Codec pll -> Codec sysclk
   - SoC I2S bit clock (BCLK) --> Codec pll -> Codec sysclk

   Solution:
   -
 Approach is similar to what is done for extending sysclk
 flexibility. Following DT properties are added to address the
 same.

   "pll-id"
   "pll-source"
   "pll-input-reference"
   "pll-output-reference"
   "pll-input-frequency"
   "pll-output-frequency"

 All these are optional properties. Simple card or audio graph
 card drivers can use above info and call snd_soc_dai_set_pll()
 for necessary configuration.

Sameer Pujar (5):
   ASoC: soc-component: Fix return value of snd_soc_component_set_pll()
   ASoC: soc-dai: Add sysclk source to snd_soc_dai_set_sysclk()
   ASoC: audio-graph-card: Add bindings for sysclk and pll
   ASoC: simple-card-utils: Parse sysclk id and source
   ASoC: simple-card-utils: Support pll configuration

  .../bindings/sound/audio-graph-port.yaml   |  71 +
  include/sound/simple_card_utils.h  |  35 +
  include/sound/soc-dai.h|   4 +-
  sound/soc/amd/acp-da7219-max98357a.c   |   2 +-
  sound/soc/amd/acp-rt5645.c |   2 +-
  sound/soc/amd/acp3x-rt5682-max9836.c   |   4 +-
  sound/soc/atmel/atmel_wm8904.c |   2 +-
  sound/soc/atmel/mchp-i2s-mcc.c |   2 +-


[...]


  sound/soc/ti/omap-mcbsp.c  |   2 +-
  sound/soc/ti/omap3pandora.c|   4 +-
  sound/soc/ti/rx51.c|   2 +-
  sound/soc/uniphier/aio-cpu.c   |   4 +-
  sound/soc/ux500/ux500_msp_dai.c|   2 +-
  271 files changed, 639 insertions(+), 389 deletions(-)



Looks like I missed some files to update which make use of 
snd_soc_dai_set_sysclk(). I will try to fix that. Meanwhile please 
review if the idea is right here.




[RFC PATCH 5/5] ASoC: simple-card-utils: Support pll configuration

2021-02-25 Thread Sameer Pujar
Some CPU/Codec DAI controllers may have an internal pll which can be
used to source its clocking requirements. The ASoC core provides a DAI
or component callback snd_soc_dai_set_pll() to configure this. But
currently simple-card or audio-graph card drivers are not using this.

To configure pll on DAI controller side, following optional DT properties
can be used. These can be specified in CPU/Codec DAI or endpoint subnode.

 - pll-id   : DAI specific pll id.

 - pll-source   : DAI specific pll source. CPU/Codec DAI can
  specify the source that is used for pll
  reference.

 - pll-input-reference  : Depending on the given value, input frequency
  can be calculated at runtime. For example if
  I2S bit clock is used as reference, rate depends
  on the actual PCM parameters (rate, channels and
  bits) during an audio session. If a fixed rate is
  used, then "pll-input-frequency" can be used
  instead.

 - pll-output-reference : Depending on the given value, output frequency
  can be calculated at runtime. If output clock is
  used for MCLK purpose, then it may depend on
  "mclk-fs" scale factor. In such cases it needs to
  be calculated at runtime. If a fixed output
  frequency is needed, then "pll-output-frequency"
  can be used instead.

 - pll-input-frequency  : Specify fixed input frequency in Hz. This is
  checked only when "pll-input-reference" is not
  specified.

 - pll-output-frequency : Specify fixed output frequency in Hz. This is
  checked only when "pll-output-reference" is not
  specified.

Usage examples with RT5658 Codec:

  1. Use MCLK for Codec sysclk

 codec-subnode {
 mclk-fs = <256>;
 system-clock-source = ;
 };

 In above case, the sysclk source is set to MCLK and the sysclk rate
 is set to 256 * fs, where fs is sampling rate of the stream.

  2. Use Codec internal pll to derive Codec sysclk. The pll can use
 SoC I2S bit clock (BCLK) as reference.

 codec-subnode {
 mclk-fs = <256>;

 system-clock-source = ;

 pll-source = ;

 /*
  * SoC I2S BCLK as reference. Based on this pll input rate
  * (sample rate * channels * bits) is calculated at runtime.
  */
 pll-input-reference = <2>;

 /*
  * pll will generate output rate based on MCLK, which is
  * calculated at runtime as (mclk_fs * sample rate).
  */
 pll-output-reference = <1>; /* MCLK as output rate */
 };

Cc: Kuninori Morimoto 
Signed-off-by: Sameer Pujar 
---
 include/sound/simple_card_utils.h |  33 ++
 sound/soc/generic/simple-card-utils.c | 114 ++
 2 files changed, 147 insertions(+)

diff --git a/include/sound/simple_card_utils.h 
b/include/sound/simple_card_utils.h
index e026bf2..0f937eb 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -16,11 +16,44 @@
 #define asoc_simple_init_mic(card, sjack, prefix) \
asoc_simple_init_jack(card, sjack, 0, prefix, NULL)
 
+/*
+ * External audio Codecs for their system clock (sysclk) may use one
+ * of the following:
+ *
+ *   - MCLK provided by SoC (already "system-clock-frequency" or
+ * "mclk-fs" bindings exist)
+ *
+ *   - Codec internal PLL which can take reference from SoC audio
+ * interface bit clock (BCLK) and generate required sysclk for
+ * the Codec.
+ *
+ *   - Codec internal PLL taking reference from onboard crystal and
+ * generate required sysclk for the Codec.
+ *
+ * BCLK depends on PCM parameters (rate, channels and bits) and has
+ * to be calculated at runtime. So is MCLK, sometimes it depends on
+ * sample rate and a scaling factor. So whenever PLL is used for
+ * sysclk, input and output references/rates need to be provided.
+ *
+ * Following macros can be used to setup input/output frequency
+ * requirements for the PLL.
+ */
+
+#define SND_SOC_DAI_PLL_REF_FIXED  0
+#define SND_SOC_DAI_PLL_REF_MCLK   (1 << 0)
+#define SND_SOC_DAI_PLL_REF_BCLK   (1 << 1)
+
 struct asoc_simple_dai {
const char *name;
unsigned int sysclk;
int sysclk_id;
int sysclk_source;
+   unsigned int pll_id;
+   unsigned int pll_source;
+   unsigned int pll_in_freq;
+   unsigned int pll_out_freq;
+   unsigned int pll_in_ref;
+   unsigned int pll_out_ref;
int clk_direction;
int slots;
i

[RFC PATCH 0/5] Flexible sysclk/pll configuration

2021-02-25 Thread Sameer Pujar
This series attempts to add flexible system clock (sysclk) and pll
configuration for the DAI controller from simple card or audio graph
card.

Sysclk configuration

  Motivation:
  ---
The problem this tries to address is, some Codecs may have
multiple clocks and multiple sources for its sysclk. For example
sysclk may depend on MCLK provided by SoC or it may used an
internal pll. The simple card or audio graph card driver is
generic and can be used on multiple platforms. So if a platform
using this driver needs a generic configuration, then the Codec
specific stuff cannot be hardcoded in the driver. Hence it would
be better if the info is driven from DT, especially from a
Codec DAI or endpoint subnode.

  Solution:
  -
"system-clock-id" and "system-clock-source" DT properties can be
exposed for a flexible sysclk configuration. These properties
go into a Codec DAI or endpoint subnode.

Please note that other sysclk related properties like
"system-clock-frequency" and "system-clock-direction-out" are
already present.

Currently snd_soc_dai_set_sysclk() does not have an argument
for source. This series adds this additional field and updates
all the required drivers. This is needed because ideally sysclk
"clk_id" and "source" fields are different. Some drivers are
making use of "clk_id" field to program source information.
**May be this needs to be corrected going ahead**


Pll configuration
=
  Motivation:
  ---
Similar to sysclk configuration, pll configuration also needs
little more flexibility. If a Codec has internal pll and it
can be sourced from multiple clocks a specific configuration
may be required for a given platform.

Some of the cases are:
  - MCLK (supplied by SoC) --> Codec pll -> Codec sysclk
  - SoC I2S bit clock (BCLK) --> Codec pll -> Codec sysclk

  Solution:
  -
Approach is similar to what is done for extending sysclk
flexibility. Following DT properties are added to address the
same.

  "pll-id"
  "pll-source"
  "pll-input-reference"
  "pll-output-reference"
  "pll-input-frequency"
  "pll-output-frequency"

All these are optional properties. Simple card or audio graph
card drivers can use above info and call snd_soc_dai_set_pll()
for necessary configuration.

Sameer Pujar (5):
  ASoC: soc-component: Fix return value of snd_soc_component_set_pll()
  ASoC: soc-dai: Add sysclk source to snd_soc_dai_set_sysclk()
  ASoC: audio-graph-card: Add bindings for sysclk and pll
  ASoC: simple-card-utils: Parse sysclk id and source
  ASoC: simple-card-utils: Support pll configuration

 .../bindings/sound/audio-graph-port.yaml   |  71 +
 include/sound/simple_card_utils.h  |  35 +
 include/sound/soc-dai.h|   4 +-
 sound/soc/amd/acp-da7219-max98357a.c   |   2 +-
 sound/soc/amd/acp-rt5645.c |   2 +-
 sound/soc/amd/acp3x-rt5682-max9836.c   |   4 +-
 sound/soc/atmel/atmel_wm8904.c |   2 +-
 sound/soc/atmel/mchp-i2s-mcc.c |   2 +-
 sound/soc/atmel/mikroe-proto.c |   2 +-
 sound/soc/atmel/sam9g20_wm8731.c   |   2 +-
 sound/soc/atmel/sam9x5_wm8731.c|   2 +-
 sound/soc/bcm/cygnus-ssp.c |   2 +-
 sound/soc/cirrus/edb93xx.c |   2 +-
 sound/soc/cirrus/ep93xx-i2s.c  |   2 +-
 sound/soc/cirrus/snappercl15.c |   4 +-
 sound/soc/codecs/88pm860x-codec.c  |   2 +-
 sound/soc/codecs/ad193x.c  |   2 +-
 sound/soc/codecs/adau1373.c|   2 +-
 sound/soc/codecs/adau17x1.c|   2 +-
 sound/soc/codecs/ak4535.c  |   2 +-
 sound/soc/codecs/ak4613.c  |   2 +-
 sound/soc/codecs/ak4641.c  |   2 +-
 sound/soc/codecs/ak4642.c  |   2 +-
 sound/soc/codecs/ak4671.c  |   2 +-
 sound/soc/codecs/alc5623.c |   2 +-
 sound/soc/codecs/alc5632.c |   2 +-
 sound/soc/codecs/arizona.c |   2 +-
 sound/soc/codecs/cpcap.c   |   4 +-
 sound/soc/codecs/cq93vc.c  |   2 +-
 sound/soc/codecs/cs35l34.c |   2 +-
 sound/soc/codecs/cs35l35.c |   2 +-
 sound/soc/codecs/cs35l36.c |   2 +-
 sound/soc/codecs/cs4265.c  |   2 +-
 sound/soc/codecs/cs4270.c  |   2 +-
 sound/

[RFC PATCH 4/5] ASoC: simple-card-utils: Parse sysclk id and source

2021-02-25 Thread Sameer Pujar
Currently a default value of 0 is used for system clock (sysclk) source
and id. This may not be the case always when a DAI supports multiple
clocks and multiple sources for sysclk. A specific configuration may be
needed depending on the platform.

Use DT properties "system-clock-id" and "system-clock-source" from
CPU/Codec DAI or endpoint subnode to explicitly mention about the sysclk
id and source. The DAI callback can take necessary action depending on
this. In doing so expose a helper function asoc_simple_set_sysclk() to
setup the sysclk. This way configuration can be driven from DT and driver
need not program specific values explicitly.

For example, RT5658 Codec has multiple sources for MCLK. The exact source
can be specified in Codec DAI or endpoint subnode in DT.

  codec-subnode {
  ...
  system-clock-id = <...>;
  system-clock-source = <...>;
  ...
  };

The default sysclk id and source are 0 in the driver and hence nothing
needs to be specified if default values are good enough.

Cc: Kuninori Morimoto 
Signed-off-by: Sameer Pujar 
---
 include/sound/simple_card_utils.h |  2 ++
 sound/soc/generic/simple-card-utils.c | 59 +--
 2 files changed, 45 insertions(+), 16 deletions(-)

diff --git a/include/sound/simple_card_utils.h 
b/include/sound/simple_card_utils.h
index ba4a3e1..e026bf2 100644
--- a/include/sound/simple_card_utils.h
+++ b/include/sound/simple_card_utils.h
@@ -19,6 +19,8 @@
 struct asoc_simple_dai {
const char *name;
unsigned int sysclk;
+   int sysclk_id;
+   int sysclk_source;
int clk_direction;
int slots;
int slot_width;
diff --git a/sound/soc/generic/simple-card-utils.c 
b/sound/soc/generic/simple-card-utils.c
index f1012e9..bbbf891 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -186,10 +186,37 @@ int asoc_simple_parse_clk(struct device *dev,
if (of_property_read_bool(node, "system-clock-direction-out"))
simple_dai->clk_direction = SND_SOC_CLOCK_OUT;
 
+   of_property_read_u32(node, "system-clock-id", _dai->sysclk_id);
+
+   of_property_read_u32(node, "system-clock-source", 
_dai->sysclk_source);
+
return 0;
 }
 EXPORT_SYMBOL_GPL(asoc_simple_parse_clk);
 
+static int asoc_simple_set_sysclk(struct snd_soc_dai *dai,
+ struct asoc_simple_dai *simple_dai,
+ unsigned int sysclk,
+ int dir)
+{
+   int sysclk_id = 0, sysclk_source = 0;
+   int ret;
+
+   if (simple_dai) {
+   sysclk_id = simple_dai->sysclk_id;
+   sysclk_source = simple_dai->sysclk_source;
+   }
+
+   ret = snd_soc_dai_set_sysclk(dai, sysclk_id, sysclk_source, sysclk,
+dir);
+   if (ret && ret != -ENOTSUPP) {
+   dev_err(dai->dev, "set_sysclk error\n");
+   return ret;
+   }
+
+   return 0;
+}
+
 int asoc_simple_startup(struct snd_pcm_substream *substream)
 {
struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
@@ -219,8 +246,10 @@ void asoc_simple_shutdown(struct snd_pcm_substream 
*substream)
simple_priv_to_props(priv, rtd->num);
 
if (dai_props->mclk_fs) {
-   snd_soc_dai_set_sysclk(codec_dai, 0, 0, 0, SND_SOC_CLOCK_IN);
-   snd_soc_dai_set_sysclk(cpu_dai, 0, 0, 0, SND_SOC_CLOCK_OUT);
+   asoc_simple_set_sysclk(codec_dai, dai_props->codec_dai, 0,
+  SND_SOC_CLOCK_IN);
+   asoc_simple_set_sysclk(cpu_dai, dai_props->cpu_dai, 0,
+  SND_SOC_CLOCK_OUT);
}
 
asoc_simple_clk_disable(dai_props->cpu_dai);
@@ -270,19 +299,18 @@ int asoc_simple_hw_params(struct snd_pcm_substream 
*substream,
if (ret < 0)
return ret;
 
-   ret = snd_soc_dai_set_sysclk(codec_dai, 0, 0, mclk,
-SND_SOC_CLOCK_IN);
-   if (ret && ret != -ENOTSUPP)
-   goto err;
+   ret = asoc_simple_set_sysclk(codec_dai, dai_props->codec_dai,
+mclk, SND_SOC_CLOCK_IN);
+   if (ret)
+   return ret;
 
-   ret = snd_soc_dai_set_sysclk(cpu_dai, 0, 0, mclk,
-SND_SOC_CLOCK_OUT);
-   if (ret && ret != -ENOTSUPP)
-   goto err;
+   ret = asoc_simple_set_sysclk(cpu_dai, dai_props->cpu_dai,
+mclk, SND_SOC_CLOCK_OUT);
+   if (ret)
+   return ret;
}
+
return 0;
-err:
- 

[RFC PATCH 1/5] ASoC: soc-component: Fix return value of snd_soc_component_set_pll()

2021-02-25 Thread Sameer Pujar
snd_soc_component_set_pll() returns "-EINVAL" and prints following
error if a component does not implement set_pll() callback exposed
by the component driver. This happens when snd_soc_dai_set_sysclk()
is invoked, which in turn calls snd_soc_component_set_pll().

  "ASoC: error at snd_soc_dai_set_pll on xxx: -22"

Above is not necessary because a component may not need additional
configuration and chooses to not implement this.

Fix this by changing default return value to "-ENOTSUPP" and driver
code which invokes snd_soc_component_set_pll() can ignore this error.

Signed-off-by: Sameer Pujar 
---
 sound/soc/soc-component.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/soc-component.c b/sound/soc/soc-component.c
index 159bf88..fd04e75 100644
--- a/sound/soc/soc-component.c
+++ b/sound/soc/soc-component.c
@@ -109,7 +109,7 @@ int snd_soc_component_set_pll(struct snd_soc_component 
*component, int pll_id,
  int source, unsigned int freq_in,
  unsigned int freq_out)
 {
-   int ret = -EINVAL;
+   int ret = -ENOTSUPP;
 
if (component->driver->set_pll)
ret = component->driver->set_pll(component, pll_id, source,
-- 
2.7.4



[RFC PATCH 3/5] ASoC: audio-graph-card: Add bindings for sysclk and pll

2021-02-25 Thread Sameer Pujar
ASoC core provides callbacks snd_soc_dai_set_sysclk() and
snd_soc_dai_set_pll() for system clock (sysclk) and pll configurations
respectively. Add bindings for flexible sysclk or pll configurations
which can be driven from CPU/Codec DAI or endpoint subnode from DT.
This in turn helps to avoid hard codings in driver and makes it more
generic.

Also add system-clock related bindings, "system-clock-direction-out"
and "system-clock-frequency", which are already supported.

Cc: Kuninori Morimoto 
Cc: Rob Herring 
Signed-off-by: Sameer Pujar 
---
 .../bindings/sound/audio-graph-port.yaml   | 71 ++
 1 file changed, 71 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml 
b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
index 766e910..4f50291 100644
--- a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
+++ b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
@@ -71,6 +71,77 @@ properties:
 description: CPU to Codec rate channels.
 $ref: /schemas/types.yaml#/definitions/uint32
 
+  system-clock-frequency:
+description: |
+  Specify system clock (sysclk) frequency for CPU or Codec
+  component. Or if a clock is specified in the CPU or Codec
+  device node and a scaling factor is given with "mclk-fs",
+  sysclk will be calculated as a multiple of stream sample
+  rate and "mclk-fs". The rate is updated when stream starts.
+$ref: /schemas/types.yaml#/definitions/uint32
+
+  system-clock-direction-out:
+description: |
+  Specifies clock direction as "out" on initialization. It
+  is useful for some CPUs with fixed clocks.
+$ref: /schemas/types.yaml#/definitions/flag
+
+  system-clock-id:
+description: |
+  CPU or Codec component may have multiple clocks. A specific
+  clock may have to be configured. In such cases the clock
+  ID needs to be specified.
+$ref: /schemas/types.yaml#/definitions/uint32
+
+  system-clock-source:
+description: |
+  CPU or Codec component may have multiple sources for its
+  system clock (sysclk). In such cases the sysclk source
+  needs to be specified.
+$ref: /schemas/types.yaml#/definitions/uint32
+
+  pll-id:
+description: |
+  Specify PLL that needs to be configured. This is useful
+  when the CPU or Codec component has multiple PLLs.
+$ref: /schemas/types.yaml#/definitions/uint32
+
+  pll-source:
+description: |
+  When PLL has multiple reference clock sources, the exact
+  source needs to be specified for the required configuration.
+$ref: /schemas/types.yaml#/definitions/uint32
+
+  pll-input-reference:
+description: |
+  Specify how to calculate input frequency for the PLL.
+  Depending on the identifier, input frequency can be
+  calculated at runtime. For example if I2S bit clock is used
+  as reference, rate depends on actual PCM parameters (rate,
+  channels and bits) during an audio session. If a fixed rate
+  is used, then "pll-input-frequency" can be used instead.
+$ref: /schemas/types.yaml#/definitions/uint32
+const: 2
+
+  pll-input-frequency:
+description: Specify fixed input frequency
+$ref: /schemas/types.yaml#/definitions/uint32
+
+  pll-output-reference:
+description: |
+  Specify how to calculate output frequency for the PLL.
+  Depending on the identifier, output frequency can be
+  calculated at runtime. If output clock is used for MCLK purpose,
+  then it may depend on "mclk-fs" scale factor. In such cases it
+  needs to be calculated at runtime. If a fixed output frequency
+  is needed, then "pll-output-frequency" can be used instead.
+$ref: /schemas/types.yaml#/definitions/uint32
+const: 1
+
+  pll-output-frequency:
+description: Specify fixed output frequency
+$ref: /schemas/types.yaml#/definitions/uint32
+
   ports:
 description: multi OF-Graph subnode
 type: object
-- 
2.7.4



Re: [PATCH 1/3] ASoC: simple-card-utils: Fix device module clock

2021-02-14 Thread Sameer Pujar

Hi Morimoto-san,


On 2/12/2021 5:14 AM, Kuninori Morimoto wrote:

diff --git a/sound/soc/generic/simple-card-utils.c 
b/sound/soc/generic/simple-card-utils.c
index bc0b62e..0754d70 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -173,16 +173,15 @@ int asoc_simple_parse_clk(struct device *dev,
*  or device's module clock.
*/
   clk = devm_get_clk_from_child(dev, node, NULL);
- if (!IS_ERR(clk)) {
- simple_dai->sysclk = clk_get_rate(clk);
+ if (IS_ERR(clk))
+ clk = devm_get_clk_from_child(dev, dlc->of_node, NULL);

+ if (!IS_ERR(clk)) {
   simple_dai->clk = clk;
- } else if (!of_property_read_u32(node, "system-clock-frequency", )) {
+ simple_dai->sysclk = clk_get_rate(clk);
+ } else if (!of_property_read_u32(node, "system-clock-frequency",
+  )) {
   simple_dai->sysclk = val;
- } else {
- clk = devm_get_clk_from_child(dev, dlc->of_node, NULL);
- if (!IS_ERR(clk))
- simple_dai->sysclk = clk_get_rate(clk);
   }

The comment is indicating that that the clock parsing order,
but this patch exchanges it.
This comment also should be updated, I think.

 /*
  * Parse dai->sysclk come from "clocks = <>"
  * (if system has common clock)
  *  or "system-clock-frequency = "
  *  or device's module clock.
  */


Yes, this can be rephrased now.


asoc_simple_set_clk_rate() will be called if it has simple_dai->clk.
CPU or Codec component clock rate will be exchanged by this patch, I think.
I'm not sure the effect of this patch to existing boards.


If CPU or Codec node does not specifiy "mclk-fs" factor, 
asoc_simple_set_clk_rate() won't be called. So I don't think there would 
be any effect w.r.t clock rate. With this patch clocks would get 
enabled/disabled.




And also, this patch has too many unneeded exchange,
thus it was difficult to read for me.
I think it can be simply like this ?
It is understandable what it want to do.


I think the patch does exactly the same thing as what you are suggesting 
below. Am I missing anything?




diff --git a/sound/soc/generic/simple-card-utils.c 
b/sound/soc/generic/simple-card-utils.c
index 8c423afb9d2e..d441890de4dc 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -168,16 +168,14 @@ int asoc_simple_parse_clk(struct device *dev,
  *  or device's module clock.
  */
 clk = devm_get_clk_from_child(dev, node, NULL);
+   if (IS_ERR(clk))
+   clk = devm_get_clk_from_child(dev, dlc->of_node, NULL);
+
 if (!IS_ERR(clk)) {
 simple_dai->sysclk = clk_get_rate(clk);
-
 simple_dai->clk = clk;
 } else if (!of_property_read_u32(node, "system-clock-frequency", 
)) {
 simple_dai->sysclk = val;
-   } else {
-   clk = devm_get_clk_from_child(dev, dlc->of_node, NULL);
-   if (!IS_ERR(clk))
-   simple_dai->sysclk = clk_get_rate(clk);
 }

 if (of_property_read_bool(node, "system-clock-direction-out"))


[PATCH 2/3] Revert "ASoC: audio-graph-card: Add clocks property to endpoint node"

2021-02-09 Thread Sameer Pujar
An endpoint is not a device and it is recommended to use clocks property
in the device node. Hence reverting the original change.

Fixes: 531e5b7abbde ("ASoC: audio-graph-card: Add clocks property to endpoint 
node")
Suggested-by: Rob Herring 
Cc: Kuninori Morimoto 
Signed-off-by: Sameer Pujar 
---
 Documentation/devicetree/bindings/sound/audio-graph-port.yaml | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml 
b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
index 08ed8f5..766e910 100644
--- a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
+++ b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
@@ -33,9 +33,6 @@ properties:
 properties:
   remote-endpoint:
 maxItems: 1
-  clocks:
-maxItems: 1
-description: Describes the clock used by audio component.
   mclk-fs:
 description: |
   Multiplication factor between stream rate and codec mclk.
-- 
2.7.4



[PATCH 3/3] arm64: tegra: Move clocks from RT5658 endpoint to device node

2021-02-09 Thread Sameer Pujar
An endpoint is not a device and it is recommended to use clocks property
in device node. RT5658 Codec binding already specifies the usage of
clocks property. Thus move the clocks from endpoint to device node.

Fixes: 5b4f6323096a ("arm64: tegra: Audio graph sound card for Jetson AGX 
Xavier")
Suggested-by: Rob Herring 
Signed-off-by: Sameer Pujar 
---
 arch/arm64/boot/dts/nvidia/tegra194-p2972-.dts | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/nvidia/tegra194-p2972-.dts 
b/arch/arm64/boot/dts/nvidia/tegra194-p2972-.dts
index b079420..ef41349e 100644
--- a/arch/arm64/boot/dts/nvidia/tegra194-p2972-.dts
+++ b/arch/arm64/boot/dts/nvidia/tegra194-p2972-.dts
@@ -651,6 +651,7 @@
reg = <0x1a>;
interrupt-parent = <>;
interrupts = ;
+   clocks = < TEGRA194_CLK_AUD_MCLK>;
realtek,jd-src = <2>;
sound-name-prefix = "CVB-RT";
 
@@ -658,7 +659,6 @@
rt5658_ep: endpoint {
remote-endpoint = 
<_dap_ep>;
mclk-fs = <256>;
-   clocks = < 
TEGRA194_CLK_AUD_MCLK>;
};
};
};
-- 
2.7.4



[PATCH 0/3] Use clocks property in a device node

2021-02-09 Thread Sameer Pujar
It is recommended to not specifiy clocks property in an endpoint subnode.
This series moves clocks to device node.

However after moving the clocks to device node, the audio playback or
capture fails. The specified clock is not actually getting enabled and
hence the failure is seen. There seems to be a bug in simple-card-utils.c
where clock handle is not assigned when parsing clocks from device node.

Fix the same and revert original change which actually added clocks
property in endpoint subnode. Also update Jetson AGX Xavier DT where the
usage is found.


Sameer Pujar (3):
  ASoC: simple-card-utils: Fix device module clock
  Revert "ASoC: audio-graph-card: Add clocks property to endpoint node"
  arm64: tegra: Move clocks from RT5658 endpoint to device node

 .../devicetree/bindings/sound/audio-graph-port.yaml |  3 ---
 arch/arm64/boot/dts/nvidia/tegra194-p2972-.dts  |  2 +-
 sound/soc/generic/simple-card-utils.c   | 13 ++---
 3 files changed, 7 insertions(+), 11 deletions(-)

-- 
2.7.4



[PATCH 1/3] ASoC: simple-card-utils: Fix device module clock

2021-02-09 Thread Sameer Pujar
If "clocks = <>" is specified from the CPU or Codec component
device node, the clock is not getting enabled. Thus audio playback
or capture fails.

Fix this by populating "simple_dai->clk" field when clocks property
is specified from device node as well. Also tidy up by re-organising
conditional statements of parsing logic.

Fixes: bb6fc620c2ed ("ASoC: simple-card-utils: add 
asoc_simple_card_parse_clk()")
Cc: Kuninori Morimoto 
Signed-off-by: Sameer Pujar 
---
 sound/soc/generic/simple-card-utils.c | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/sound/soc/generic/simple-card-utils.c 
b/sound/soc/generic/simple-card-utils.c
index bc0b62e..0754d70 100644
--- a/sound/soc/generic/simple-card-utils.c
+++ b/sound/soc/generic/simple-card-utils.c
@@ -173,16 +173,15 @@ int asoc_simple_parse_clk(struct device *dev,
 *  or device's module clock.
 */
clk = devm_get_clk_from_child(dev, node, NULL);
-   if (!IS_ERR(clk)) {
-   simple_dai->sysclk = clk_get_rate(clk);
+   if (IS_ERR(clk))
+   clk = devm_get_clk_from_child(dev, dlc->of_node, NULL);
 
+   if (!IS_ERR(clk)) {
simple_dai->clk = clk;
-   } else if (!of_property_read_u32(node, "system-clock-frequency", )) 
{
+   simple_dai->sysclk = clk_get_rate(clk);
+   } else if (!of_property_read_u32(node, "system-clock-frequency",
+)) {
simple_dai->sysclk = val;
-   } else {
-   clk = devm_get_clk_from_child(dev, dlc->of_node, NULL);
-   if (!IS_ERR(clk))
-   simple_dai->sysclk = clk_get_rate(clk);
}
 
if (of_property_read_bool(node, "system-clock-direction-out"))
-- 
2.7.4



[PATCH v3 2/2] ASoC: tegra: Add driver remove() callback

2021-02-07 Thread Sameer Pujar
There is cleanup required, related to release of phandles, during driver
removal and hence point remove callback to audio_graph_remove().

Fixes: 202e2f774543 ("ASoC: tegra: Add audio graph based card driver")
Depends-on: "ASoC: audio-graph: Rename functions needed for export"
Signed-off-by: Sameer Pujar 
Acked-by: Kuninori Morimoto 
---
 sound/soc/tegra/tegra_audio_graph_card.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/tegra/tegra_audio_graph_card.c 
b/sound/soc/tegra/tegra_audio_graph_card.c
index 121e572..ddedf18 100644
--- a/sound/soc/tegra/tegra_audio_graph_card.c
+++ b/sound/soc/tegra/tegra_audio_graph_card.c
@@ -2,7 +2,7 @@
 //
 // tegra_audio_graph_card.c - Audio Graph based Tegra Machine Driver
 //
-// Copyright (c) 2020 NVIDIA CORPORATION.  All rights reserved.
+// Copyright (c) 2020-2021 NVIDIA CORPORATION.  All rights reserved.
 
 #include 
 #include 
@@ -243,6 +243,7 @@ static struct platform_driver tegra_audio_graph_card = {
.of_match_table = graph_of_tegra_match,
},
.probe = tegra_audio_graph_probe,
+   .remove = audio_graph_remove,
 };
 module_platform_driver(tegra_audio_graph_card);
 
-- 
2.7.4



[PATCH v3 1/2] ASoC: audio-graph: Rename functions needed for export

2021-02-07 Thread Sameer Pujar
Following functions are renamed for a better global visibility.
  graph_card_probe() --> audio_graph_card_probe()
  graph_parse_of()   --> audio_graph_parse_of()
  graph_remove() --> audio_graph_remove() [exported as well]

The references of these are updated in audio graph and Tegra audio
graph card drivers.

Signed-off-by: Sameer Pujar 
Cc: Kuninori Morimoto 
Acked-by: Kuninori Morimoto 
---
 include/sound/graph_card.h   |  6 --
 sound/soc/generic/audio-graph-card.c | 17 +
 sound/soc/tegra/tegra_audio_graph_card.c |  6 +++---
 3 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/include/sound/graph_card.h b/include/sound/graph_card.h
index bbb5a13..0137844 100644
--- a/include/sound/graph_card.h
+++ b/include/sound/graph_card.h
@@ -9,8 +9,10 @@
 
 #include 
 
-int graph_card_probe(struct snd_soc_card *card);
+int audio_graph_card_probe(struct snd_soc_card *card);
 
-int graph_parse_of(struct asoc_simple_priv *priv, struct device *dev);
+int audio_graph_parse_of(struct asoc_simple_priv *priv, struct device *dev);
+
+int audio_graph_remove(struct platform_device *pdev);
 
 #endif /* __GRAPH_CARD_H */
diff --git a/sound/soc/generic/audio-graph-card.c 
b/sound/soc/generic/audio-graph-card.c
index 16a04a6..8c5cdcd 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -532,7 +532,7 @@ static int graph_for_each_link(struct asoc_simple_priv 
*priv,
 static void graph_get_dais_count(struct asoc_simple_priv *priv,
 struct link_info *li);
 
-int graph_parse_of(struct asoc_simple_priv *priv, struct device *dev)
+int audio_graph_parse_of(struct asoc_simple_priv *priv, struct device *dev)
 {
struct snd_soc_card *card = simple_priv_to_card(priv);
struct link_info li;
@@ -608,7 +608,7 @@ int graph_parse_of(struct asoc_simple_priv *priv, struct 
device *dev)
 
return ret;
 }
-EXPORT_SYMBOL_GPL(graph_parse_of);
+EXPORT_SYMBOL_GPL(audio_graph_parse_of);
 
 static int graph_count_noml(struct asoc_simple_priv *priv,
struct device_node *cpu_ep,
@@ -705,7 +705,7 @@ static void graph_get_dais_count(struct asoc_simple_priv 
*priv,
li->link, li->dais, li->conf);
 }
 
-int graph_card_probe(struct snd_soc_card *card)
+int audio_graph_card_probe(struct snd_soc_card *card)
 {
struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(card);
int ret;
@@ -720,7 +720,7 @@ int graph_card_probe(struct snd_soc_card *card)
 
return 0;
 }
-EXPORT_SYMBOL_GPL(graph_card_probe);
+EXPORT_SYMBOL_GPL(audio_graph_card_probe);
 
 static int graph_probe(struct platform_device *pdev)
 {
@@ -736,20 +736,21 @@ static int graph_probe(struct platform_device *pdev)
card = simple_priv_to_card(priv);
card->dapm_widgets  = graph_dapm_widgets;
card->num_dapm_widgets  = ARRAY_SIZE(graph_dapm_widgets);
-   card->probe = graph_card_probe;
+   card->probe = audio_graph_card_probe;
 
if (of_device_get_match_data(dev))
priv->dpcm_selectable = 1;
 
-   return graph_parse_of(priv, dev);
+   return audio_graph_parse_of(priv, dev);
 }
 
-static int graph_remove(struct platform_device *pdev)
+int audio_graph_remove(struct platform_device *pdev)
 {
struct snd_soc_card *card = platform_get_drvdata(pdev);
 
return asoc_simple_clean_reference(card);
 }
+EXPORT_SYMBOL_GPL(audio_graph_remove);
 
 static const struct of_device_id graph_of_match[] = {
{ .compatible = "audio-graph-card", },
@@ -766,7 +767,7 @@ static struct platform_driver graph_card = {
.of_match_table = graph_of_match,
},
.probe = graph_probe,
-   .remove = graph_remove,
+   .remove = audio_graph_remove,
 };
 module_platform_driver(graph_card);
 
diff --git a/sound/soc/tegra/tegra_audio_graph_card.c 
b/sound/soc/tegra/tegra_audio_graph_card.c
index 9e43f16..121e572 100644
--- a/sound/soc/tegra/tegra_audio_graph_card.c
+++ b/sound/soc/tegra/tegra_audio_graph_card.c
@@ -184,7 +184,7 @@ static int tegra_audio_graph_card_probe(struct snd_soc_card 
*card)
return PTR_ERR(priv->clk_plla_out0);
}
 
-   return graph_card_probe(card);
+   return audio_graph_card_probe(card);
 }
 
 static int tegra_audio_graph_probe(struct platform_device *pdev)
@@ -201,12 +201,12 @@ static int tegra_audio_graph_probe(struct platform_device 
*pdev)
 
card->probe = tegra_audio_graph_card_probe;
 
-   /* graph_parse_of() depends on below */
+   /* audio_graph_parse_of() depends on below */
card->component_chaining = 1;
priv->simple.ops = _audio_graph_ops;
priv->simple.force_dpcm = 1;
 
-   return graph_parse_of(>simple, dev);
+   return audio_graph_parse_of(>simple, dev);
 }
 
 static const struct tegra_audio_cdata tegra210_data = {
-- 
2.7.4



[PATCH v3 0/2] Rename audio graph export functions

2021-02-07 Thread Sameer Pujar
This series renames exported functions from audio graph for a better
global visibility. In doing so update the references in audio graph
and Tegra audio graph card drivers.


Changelog
=

v2 -> v3:
-
 [Patch v3 1/2]:
   - Squashed "patch v2 1/3" and "patch v2 2/3". Updated commit message
 accordingly.
   - Add "Acked-by" tag from Morimoto-san.

 [Patch v3 2/2]:
   - Add "Acked-by" tag from Morimoto-san.

v1 -> v2:
-
 [Patch v2 1/3]:
   - Rename graph_parse_of() to audio_graph_parse_of() and
 graph_card_probe() to audio_graph_card_probe() as well.

   - Update above references in audio graph driver.

 [Patch v2 2/3]: New patch
   - Update references for audio_graph_parse_of() and
 audio_graph_card_probe() in Tegra graph driver.

   - Add "Depends-on" tag

 [Patch v2 3/3]:
   - Update commit message to add "Depends-on" tag.

Sameer Pujar (2):
  ASoC: audio-graph: Rename functions needed for export
  ASoC: tegra: Add driver remove() callback

 include/sound/graph_card.h   |  6 --
 sound/soc/generic/audio-graph-card.c | 17 +
 sound/soc/tegra/tegra_audio_graph_card.c |  9 +
 3 files changed, 18 insertions(+), 14 deletions(-)

-- 
2.7.4



[PATCH v2 1/3] ASoC: audio-graph: Rename functions needed for export

2021-02-04 Thread Sameer Pujar
Following functions are renamed for a better global visibility.
  graph_card_probe() --> audio_graph_card_probe()
  graph_parse_of()   --> audio_graph_parse_of()
  graph_remove() --> audio_graph_remove() [exported as well]

The references in header and source files of audio graph are
updated to make use of above.

Signed-off-by: Sameer Pujar 
Cc: Kuninori Morimoto 
---
 include/sound/graph_card.h   |  6 --
 sound/soc/generic/audio-graph-card.c | 17 +
 2 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/include/sound/graph_card.h b/include/sound/graph_card.h
index bbb5a13..0137844 100644
--- a/include/sound/graph_card.h
+++ b/include/sound/graph_card.h
@@ -9,8 +9,10 @@
 
 #include 
 
-int graph_card_probe(struct snd_soc_card *card);
+int audio_graph_card_probe(struct snd_soc_card *card);
 
-int graph_parse_of(struct asoc_simple_priv *priv, struct device *dev);
+int audio_graph_parse_of(struct asoc_simple_priv *priv, struct device *dev);
+
+int audio_graph_remove(struct platform_device *pdev);
 
 #endif /* __GRAPH_CARD_H */
diff --git a/sound/soc/generic/audio-graph-card.c 
b/sound/soc/generic/audio-graph-card.c
index 16a04a6..8c5cdcd 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -532,7 +532,7 @@ static int graph_for_each_link(struct asoc_simple_priv 
*priv,
 static void graph_get_dais_count(struct asoc_simple_priv *priv,
 struct link_info *li);
 
-int graph_parse_of(struct asoc_simple_priv *priv, struct device *dev)
+int audio_graph_parse_of(struct asoc_simple_priv *priv, struct device *dev)
 {
struct snd_soc_card *card = simple_priv_to_card(priv);
struct link_info li;
@@ -608,7 +608,7 @@ int graph_parse_of(struct asoc_simple_priv *priv, struct 
device *dev)
 
return ret;
 }
-EXPORT_SYMBOL_GPL(graph_parse_of);
+EXPORT_SYMBOL_GPL(audio_graph_parse_of);
 
 static int graph_count_noml(struct asoc_simple_priv *priv,
struct device_node *cpu_ep,
@@ -705,7 +705,7 @@ static void graph_get_dais_count(struct asoc_simple_priv 
*priv,
li->link, li->dais, li->conf);
 }
 
-int graph_card_probe(struct snd_soc_card *card)
+int audio_graph_card_probe(struct snd_soc_card *card)
 {
struct asoc_simple_priv *priv = snd_soc_card_get_drvdata(card);
int ret;
@@ -720,7 +720,7 @@ int graph_card_probe(struct snd_soc_card *card)
 
return 0;
 }
-EXPORT_SYMBOL_GPL(graph_card_probe);
+EXPORT_SYMBOL_GPL(audio_graph_card_probe);
 
 static int graph_probe(struct platform_device *pdev)
 {
@@ -736,20 +736,21 @@ static int graph_probe(struct platform_device *pdev)
card = simple_priv_to_card(priv);
card->dapm_widgets  = graph_dapm_widgets;
card->num_dapm_widgets  = ARRAY_SIZE(graph_dapm_widgets);
-   card->probe = graph_card_probe;
+   card->probe = audio_graph_card_probe;
 
if (of_device_get_match_data(dev))
priv->dpcm_selectable = 1;
 
-   return graph_parse_of(priv, dev);
+   return audio_graph_parse_of(priv, dev);
 }
 
-static int graph_remove(struct platform_device *pdev)
+int audio_graph_remove(struct platform_device *pdev)
 {
struct snd_soc_card *card = platform_get_drvdata(pdev);
 
return asoc_simple_clean_reference(card);
 }
+EXPORT_SYMBOL_GPL(audio_graph_remove);
 
 static const struct of_device_id graph_of_match[] = {
{ .compatible = "audio-graph-card", },
@@ -766,7 +767,7 @@ static struct platform_driver graph_card = {
.of_match_table = graph_of_match,
},
.probe = graph_probe,
-   .remove = graph_remove,
+   .remove = audio_graph_remove,
 };
 module_platform_driver(graph_card);
 
-- 
2.7.4



[PATCH v2 3/3] ASoC: tegra: Add driver remove() callback

2021-02-04 Thread Sameer Pujar
There is cleanup required, related to release of phandles, during driver
removal and hence point remove function pointer to audio_graph_remove().

Fixes: 202e2f774543 ("ASoC: tegra: Add audio graph based card driver")
Depends-on: "ASoC: audio-graph: Rename functions needed for export"
Signed-off-by: Sameer Pujar 
---
 sound/soc/tegra/tegra_audio_graph_card.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/tegra/tegra_audio_graph_card.c 
b/sound/soc/tegra/tegra_audio_graph_card.c
index 121e572..ddedf18 100644
--- a/sound/soc/tegra/tegra_audio_graph_card.c
+++ b/sound/soc/tegra/tegra_audio_graph_card.c
@@ -2,7 +2,7 @@
 //
 // tegra_audio_graph_card.c - Audio Graph based Tegra Machine Driver
 //
-// Copyright (c) 2020 NVIDIA CORPORATION.  All rights reserved.
+// Copyright (c) 2020-2021 NVIDIA CORPORATION.  All rights reserved.
 
 #include 
 #include 
@@ -243,6 +243,7 @@ static struct platform_driver tegra_audio_graph_card = {
.of_match_table = graph_of_tegra_match,
},
.probe = tegra_audio_graph_probe,
+   .remove = audio_graph_remove,
 };
 module_platform_driver(tegra_audio_graph_card);
 
-- 
2.7.4



[PATCH v2 2/3] ASoC: tegra: Update references of audio graph helpers

2021-02-04 Thread Sameer Pujar
The audio graph helper functions are renamed now for a better global
visibility and hence references need to be updated in Tegra audio
graph.

Signed-off-by: Sameer Pujar 
---
 sound/soc/tegra/tegra_audio_graph_card.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/tegra/tegra_audio_graph_card.c 
b/sound/soc/tegra/tegra_audio_graph_card.c
index 9e43f16..121e572 100644
--- a/sound/soc/tegra/tegra_audio_graph_card.c
+++ b/sound/soc/tegra/tegra_audio_graph_card.c
@@ -184,7 +184,7 @@ static int tegra_audio_graph_card_probe(struct snd_soc_card 
*card)
return PTR_ERR(priv->clk_plla_out0);
}
 
-   return graph_card_probe(card);
+   return audio_graph_card_probe(card);
 }
 
 static int tegra_audio_graph_probe(struct platform_device *pdev)
@@ -201,12 +201,12 @@ static int tegra_audio_graph_probe(struct platform_device 
*pdev)
 
card->probe = tegra_audio_graph_card_probe;
 
-   /* graph_parse_of() depends on below */
+   /* audio_graph_parse_of() depends on below */
card->component_chaining = 1;
priv->simple.ops = _audio_graph_ops;
priv->simple.force_dpcm = 1;
 
-   return graph_parse_of(>simple, dev);
+   return audio_graph_parse_of(>simple, dev);
 }
 
 static const struct tegra_audio_cdata tegra210_data = {
-- 
2.7.4



[PATCH v2 0/3] Rename audio graph export functions

2021-02-04 Thread Sameer Pujar
This series renames exported functions from audio graph for a better
global visibility. In doing so update the references in audio graph
and Tegra audio graph card drivers.


Changelog
=

v1 -> v2:
-
 [Patch v2 1/3]:
   - Rename graph_parse_of() to audio_graph_parse_of() and
 graph_card_probe() to audio_graph_card_probe() as well.

   - Update above references in audio graph driver.

 [Patch v2 2/3]: New patch
   - Update references for audio_graph_parse_of() and
 audio_graph_card_probe() in Tegra graph driver.

   - Add "Depends-on" tag

 [Patch v2 3/3]:
   - Update commit message to add "Depends-on" tag.

Sameer Pujar (3):
  ASoC: audio-graph: Rename functions needed for export
  ASoC: tegra: Update references of audio graph helpers
  ASoC: tegra: Add driver remove() callback

 include/sound/graph_card.h   |  6 --
 sound/soc/generic/audio-graph-card.c | 17 +
 sound/soc/tegra/tegra_audio_graph_card.c |  9 +
 3 files changed, 18 insertions(+), 14 deletions(-)

-- 
2.7.4



Re: [PATCH 1/2] ASoC: audio-graph: Export graph_remove() function

2021-02-03 Thread Sameer Pujar




On 2/4/2021 4:03 AM, Kuninori Morimoto wrote:

External email: Use caution opening links or attachments


Hi


+int graph_remove(struct platform_device *pdev);

I think this needs better namespacing if it's going to be exported.

audio_graph_remove() can be a better choice?

Yeah, that looks reasonable.

Nice naming I think.
In such case,  update also graph_parse_of() is nice idea for me.

 - int graph_parse_of(...)
 + int audio_graph_parse_of()


OK, Will update following.

graph_remove() --> audio_graph_remove()
graph_parse_of()   --> audio_graph_parse_of()
graph_card_probe() --> audio_graph_card_probe()




Re: [PATCH 1/2] ASoC: audio-graph: Export graph_remove() function

2021-02-03 Thread Sameer Pujar




On 2/4/2021 4:01 AM, Kuninori Morimoto wrote:

Audio graph based sound card drivers can call graph_remove() function
for cleanups during driver removal. To facilitate this export above
mentioned function.

Signed-off-by: Sameer Pujar 
Cc: Kuninori Morimoto 

(snip)

-static int graph_remove(struct platform_device *pdev)
+int graph_remove(struct platform_device *pdev)
  {
   struct snd_soc_card *card = platform_get_drvdata(pdev);

   return asoc_simple_clean_reference(card);
  }
+EXPORT_SYMBOL_GPL(graph_remove);

Not a big deal, but
it is just calling asoc_simple_clean_reference() which is
already global function.


Yes that is true, but idea was to put dependency on graph_remove() so 
that any additions/changes here in future will be automatically taken 
care for Tegra graph card.


Re: Re: [PATCH 1/2] ASoC: audio-graph: Export graph_remove() function

2021-02-03 Thread Sameer Pujar




On 2/3/2021 9:49 PM, Mark Brown wrote:

On Wed, Feb 03, 2021 at 09:39:34PM +0530, Sameer Pujar wrote:


+int graph_remove(struct platform_device *pdev);

I think this needs better namespacing if it's going to be exported.


audio_graph_remove() can be a better choice?


[PATCH 1/2] ASoC: audio-graph: Export graph_remove() function

2021-02-03 Thread Sameer Pujar
Audio graph based sound card drivers can call graph_remove() function
for cleanups during driver removal. To facilitate this export above
mentioned function.

Signed-off-by: Sameer Pujar 
Cc: Kuninori Morimoto 
---
 include/sound/graph_card.h   | 2 ++
 sound/soc/generic/audio-graph-card.c | 3 ++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/sound/graph_card.h b/include/sound/graph_card.h
index bbb5a13..dfa8e56 100644
--- a/include/sound/graph_card.h
+++ b/include/sound/graph_card.h
@@ -13,4 +13,6 @@ int graph_card_probe(struct snd_soc_card *card);
 
 int graph_parse_of(struct asoc_simple_priv *priv, struct device *dev);
 
+int graph_remove(struct platform_device *pdev);
+
 #endif /* __GRAPH_CARD_H */
diff --git a/sound/soc/generic/audio-graph-card.c 
b/sound/soc/generic/audio-graph-card.c
index 16a04a6..93f6d57f 100644
--- a/sound/soc/generic/audio-graph-card.c
+++ b/sound/soc/generic/audio-graph-card.c
@@ -744,12 +744,13 @@ static int graph_probe(struct platform_device *pdev)
return graph_parse_of(priv, dev);
 }
 
-static int graph_remove(struct platform_device *pdev)
+int graph_remove(struct platform_device *pdev)
 {
struct snd_soc_card *card = platform_get_drvdata(pdev);
 
return asoc_simple_clean_reference(card);
 }
+EXPORT_SYMBOL_GPL(graph_remove);
 
 static const struct of_device_id graph_of_match[] = {
{ .compatible = "audio-graph-card", },
-- 
2.7.4



[PATCH 2/2] ASoC: tegra: Add driver remove() callback

2021-02-03 Thread Sameer Pujar
There is cleanup required, related to release of phandles, during driver
removal and hence point remove function pointer to graph_remove().

Fixes: 202e2f774543 ("ASoC: tegra: Add audio graph based card driver")
Signed-off-by: Sameer Pujar 
---
 sound/soc/tegra/tegra_audio_graph_card.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/tegra/tegra_audio_graph_card.c 
b/sound/soc/tegra/tegra_audio_graph_card.c
index 9e43f16..f43d302 100644
--- a/sound/soc/tegra/tegra_audio_graph_card.c
+++ b/sound/soc/tegra/tegra_audio_graph_card.c
@@ -2,7 +2,7 @@
 //
 // tegra_audio_graph_card.c - Audio Graph based Tegra Machine Driver
 //
-// Copyright (c) 2020 NVIDIA CORPORATION.  All rights reserved.
+// Copyright (c) 2020-2021 NVIDIA CORPORATION.  All rights reserved.
 
 #include 
 #include 
@@ -243,6 +243,7 @@ static struct platform_driver tegra_audio_graph_card = {
.of_match_table = graph_of_tegra_match,
},
.probe = tegra_audio_graph_probe,
+   .remove = graph_remove,
 };
 module_platform_driver(tegra_audio_graph_card);
 
-- 
2.7.4



[PATCH 0/2] Add remove path for Tegra audio graph card

2021-02-03 Thread Sameer Pujar
Audio graph driver cleans up phandle references of CPU/CODEC nodes in
graph_remove() path. As Tegra graph card driver is based on this
populate remove callback for it.

Sameer Pujar (2):
  ASoC: audio-graph: Export graph_remove() function
  ASoC: tegra: Add driver remove() callback

 include/sound/graph_card.h   | 2 ++
 sound/soc/generic/audio-graph-card.c | 3 ++-
 sound/soc/tegra/tegra_audio_graph_card.c | 3 ++-
 3 files changed, 6 insertions(+), 2 deletions(-)

-- 
2.7.4



[RESEND PATCH v2 5/9] arm64: defconfig: Enable RT5659

2021-02-02 Thread Sameer Pujar
Enable the RT5659 audio codec driver.

Signed-off-by: Sameer Pujar 
Cc: Oder Chiou 
Cc: Bard Liao 
---
 Resending this as I missed the maintainer and email groups specifically
 required for this patch. The link for original series can be found here,
 
https://lore.kernel.org/alsa-devel/1611944866-29373-1-git-send-email-spu...@nvidia.com/
 

 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index ec377f7..ea279e8 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -754,6 +754,7 @@ CONFIG_SND_SOC_ES7134=m
 CONFIG_SND_SOC_ES7241=m
 CONFIG_SND_SOC_GTM601=m
 CONFIG_SND_SOC_PCM3168A_I2C=m
+CONFIG_SND_SOC_RT5659=m
 CONFIG_SND_SOC_SIMPLE_AMPLIFIER=m
 CONFIG_SND_SOC_TAS571X=m
 CONFIG_SND_SOC_WCD934X=m
-- 
2.7.4



Re: [PATCH] ASoC: tegra: SND_SOC_TEGRA_AUDIO_GRAPH_CARD should depend on SND_SOC_TEGRA

2021-01-29 Thread Sameer Pujar




On 1/29/2021 6:29 PM, Geert Uytterhoeven wrote:

External email: Use caution opening links or attachments


Audio Graph Card based Tegra driver is only useful on NVIDIA Tegra SoCs.
Hence add a dependency on SND_SOC_TEGRA, to prevent asking the user
about this driver when configuring a kernel without Tegra sound support.

Wrap all Tegra sound config options inside a big if/endif block, instead
of just adding the dependency to the single config option that does not
have it yet, to preventing similar future mistakes.

Fixes: 202e2f7745437aa5 ("ASoC: tegra: Add audio graph based card driver")
Signed-off-by: Geert Uytterhoeven 
---
  sound/soc/tegra/Kconfig | 33 +
  1 file changed, 13 insertions(+), 20 deletions(-)



Acked-by: Sameer Pujar 


Re: Re: Re: [RESEND PATCH v6 5/6] arm64: tegra: Audio graph header for Tegra210

2021-01-19 Thread Sameer Pujar




On 1/19/2021 11:27 PM, Thierry Reding wrote:

On Tue, Jan 19, 2021 at 11:09:32PM +0530, Sameer Pujar wrote:


On 1/19/2021 10:45 PM, Thierry Reding wrote:

On Tue, Jan 19, 2021 at 02:58:15PM +0530, Sameer Pujar wrote:

Expose a header which describes DT bindings required to use audio-graph
based sound card. All Tegra210 based platforms can include this header
and add platform specific information. Currently, from SoC point of view,
all links are exposed for ADMAIF, AHUB, I2S and DMIC components.

Signed-off-by: Sameer Pujar 
Reviewed-by: Jon Hunter 
---
   .../boot/dts/nvidia/tegra210-audio-graph.dtsi  | 153 
+
   1 file changed, 153 insertions(+)
   create mode 100644 arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi

I prefer keeping everything in tegra210.dtsi, but I can do that merge
when I apply, after the DT bindings have been acked, so no need to
resend just because of that.

I think this may be fine for Tegra210 based boards. But for Tegra186 and
Tegra194, whenever we add support for it, can rely on a common audio-graph
dtsi because there is no change w.r.t APE. This can help us to avoid
duplication of the bindings. This most likely applies to future chips as
well (where Tegra186 audio-graph bindings can be considered as base) when
there is no significant change in APE.

Maybe. Although that argument is somewhat extreme because we already
have some of that same duplication throughout the other .dtsi files. By
the same argument we could save a bit of duplication by having something
like tegra-gpio.dtsi and including that in all the SoC .dtsi files and
only update the compatible string, because that's the only significant
change.



Duplication isn't a big problem for DTS files because the data is meant
to be stable anyway. So once it is in place and doesn't have to change,
it really doesn't matter if it comes from an include or it's duplicated.


OK, if there is no issue with duplication then fine with me. Thanks.



Re: Re: [RESEND PATCH v6 5/6] arm64: tegra: Audio graph header for Tegra210

2021-01-19 Thread Sameer Pujar




On 1/19/2021 10:45 PM, Thierry Reding wrote:

On Tue, Jan 19, 2021 at 02:58:15PM +0530, Sameer Pujar wrote:

Expose a header which describes DT bindings required to use audio-graph
based sound card. All Tegra210 based platforms can include this header
and add platform specific information. Currently, from SoC point of view,
all links are exposed for ADMAIF, AHUB, I2S and DMIC components.

Signed-off-by: Sameer Pujar 
Reviewed-by: Jon Hunter 
---
  .../boot/dts/nvidia/tegra210-audio-graph.dtsi  | 153 +
  1 file changed, 153 insertions(+)
  create mode 100644 arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi

I prefer keeping everything in tegra210.dtsi, but I can do that merge
when I apply, after the DT bindings have been acked, so no need to
resend just because of that.


I think this may be fine for Tegra210 based boards. But for Tegra186 and 
Tegra194, whenever we add support for it, can rely on a common 
audio-graph dtsi because there is no change w.r.t APE. This can help us 
to avoid duplication of the bindings. This most likely applies to future 
chips as well (where Tegra186 audio-graph bindings can be considered as 
base) when there is no significant change in APE.


[RESEND PATCH v6 3/6] ASoC: tegra: Add audio graph based card driver

2021-01-19 Thread Sameer Pujar
Add Tegra audio machine driver which is based on generic audio graph card
driver. It re-uses most of the common stuff from audio graph driver and
uses the same DT binding. Required Tegra specific customizations are done
in the driver and additional DT bindings are required for clock handling.

Details on the customizations done:

 - Update PLL rates at runtime: Tegra HW supports multiple sample rates
   (multiples of 8x and 11.025x) and both of these groups require different
   PLL rates. Hence there is a requirement to update this at runtime.
   This is achieved by providing a custom 'snd_soc_ops' and in hw_param()
   callback PLL rate is updated as per the sample rate.

 - Internal structure 'tegra_audio_graph_data' is used to maintain clock
   handles of PLL.

 - The 'force_dpcm' flag is set to use DPCM for all DAI links.

 - The 'component_chaining' flag is set to use DPCM with component model.

Signed-off-by: Sameer Pujar 
Reviewed-by: Jon Hunter 
---
 sound/soc/tegra/Kconfig  |   9 ++
 sound/soc/tegra/Makefile |   2 +
 sound/soc/tegra/tegra_audio_graph_card.c | 251 +++
 3 files changed, 262 insertions(+)
 create mode 100644 sound/soc/tegra/tegra_audio_graph_card.c

diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig
index a62cc87..6dc83ad 100644
--- a/sound/soc/tegra/Kconfig
+++ b/sound/soc/tegra/Kconfig
@@ -117,6 +117,15 @@ config SND_SOC_TEGRA210_ADMAIF
  channel. Buffer size is configurable for each ADMAIIF channel.
  Say Y or M if you want to add support for Tegra210 ADMAIF module.
 
+config SND_SOC_TEGRA_AUDIO_GRAPH_CARD
+   tristate "Audio Graph Card based Tegra driver"
+   depends on SND_AUDIO_GRAPH_CARD
+   help
+ Config to enable Tegra audio machine driver based on generic
+ audio graph driver. It is a thin driver written to customize
+ few things for Tegra audio. Most of the code is re-used from
+ audio graph driver and the same DT bindings are used.
+
 config SND_SOC_TEGRA_RT5640
tristate "SoC Audio support for Tegra boards using an RT5640 codec"
depends on SND_SOC_TEGRA && I2C && GPIOLIB
diff --git a/sound/soc/tegra/Makefile b/sound/soc/tegra/Makefile
index 60040a0..b17dd6e 100644
--- a/sound/soc/tegra/Makefile
+++ b/sound/soc/tegra/Makefile
@@ -38,6 +38,7 @@ snd-soc-tegra-trimslice-objs := trimslice.o
 snd-soc-tegra-alc5632-objs := tegra_alc5632.o
 snd-soc-tegra-max98090-objs := tegra_max98090.o
 snd-soc-tegra-sgtl5000-objs := tegra_sgtl5000.o
+snd-soc-tegra-audio-graph-card-objs := tegra_audio_graph_card.o
 
 obj-$(CONFIG_SND_SOC_TEGRA_RT5640) += snd-soc-tegra-rt5640.o
 obj-$(CONFIG_SND_SOC_TEGRA_RT5677) += snd-soc-tegra-rt5677.o
@@ -48,3 +49,4 @@ obj-$(CONFIG_SND_SOC_TEGRA_TRIMSLICE) += 
snd-soc-tegra-trimslice.o
 obj-$(CONFIG_SND_SOC_TEGRA_ALC5632) += snd-soc-tegra-alc5632.o
 obj-$(CONFIG_SND_SOC_TEGRA_MAX98090) += snd-soc-tegra-max98090.o
 obj-$(CONFIG_SND_SOC_TEGRA_SGTL5000) += snd-soc-tegra-sgtl5000.o
+obj-$(CONFIG_SND_SOC_TEGRA_AUDIO_GRAPH_CARD) += 
snd-soc-tegra-audio-graph-card.o
diff --git a/sound/soc/tegra/tegra_audio_graph_card.c 
b/sound/soc/tegra/tegra_audio_graph_card.c
new file mode 100644
index 000..9e43f16
--- /dev/null
+++ b/sound/soc/tegra/tegra_audio_graph_card.c
@@ -0,0 +1,251 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// tegra_audio_graph_card.c - Audio Graph based Tegra Machine Driver
+//
+// Copyright (c) 2020 NVIDIA CORPORATION.  All rights reserved.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MAX_PLLA_OUT0_DIV 128
+
+#define simple_to_tegra_priv(simple) \
+   container_of(simple, struct tegra_audio_priv, simple)
+
+enum srate_type {
+   /*
+* Sample rates multiple of 8000 Hz and below are supported:
+* ( 8000, 16000, 32000, 48000, 96000, 192000 Hz )
+*/
+   x8_RATE,
+
+   /*
+* Sample rates multiple of 11025 Hz and below are supported:
+* ( 11025, 22050, 44100, 88200, 176400 Hz )
+*/
+   x11_RATE,
+
+   NUM_RATE_TYPE,
+};
+
+struct tegra_audio_priv {
+   struct asoc_simple_priv simple;
+   struct clk *clk_plla_out0;
+   struct clk *clk_plla;
+};
+
+/* Tegra audio chip data */
+struct tegra_audio_cdata {
+   unsigned int plla_rates[NUM_RATE_TYPE];
+   unsigned int plla_out0_rates[NUM_RATE_TYPE];
+};
+
+/* Setup PLL clock as per the given sample rate */
+static int tegra_audio_graph_update_pll(struct snd_pcm_substream *substream,
+   struct snd_pcm_hw_params *params)
+{
+   struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+   struct asoc_simple_priv *simple = snd_soc_card_get_drvdata(rtd->card);
+   struct tegra_audio_priv *priv = simple_to_tegra_priv(simple);
+   struct device *dev = rtd->card->dev;
+   const struct tegra_audio_cdata *data = of_dev

[RESEND PATCH v6 2/6] ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card

2021-01-19 Thread Sameer Pujar
Add YAML schema for Tegra audio graph sound card DT bindings. It uses the
same DT bindings provided by generic audio graph driver. Along with this
few standard clock DT bindings are added which are specifically required
for Tegra audio.

Signed-off-by: Sameer Pujar 
Reviewed-by: Jon Hunter 
---
 .../sound/nvidia,tegra-audio-graph-card.yaml   | 187 +
 1 file changed, 187 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml

diff --git 
a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
new file mode 100644
index 000..fc271f6
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
@@ -0,0 +1,187 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-graph-card.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Audio Graph based Tegra sound card driver
+
+description: |
+  This is based on generic audio graph card driver along with additional
+  customizations for Tegra platforms. It uses the same bindings with
+  additional standard clock DT bindings required for Tegra.
+
+maintainers:
+  - Jon Hunter 
+  - Sameer Pujar 
+
+allOf:
+  - $ref: audio-graph.yaml#
+
+properties:
+  compatible:
+enum:
+  - nvidia,tegra210-audio-graph-card
+  - nvidia,tegra186-audio-graph-card
+
+  clocks:
+minItems: 2
+
+  clock-names:
+minItems: 2
+items:
+  - const: pll_a
+  - const: plla_out0
+
+  assigned-clocks:
+minItems: 1
+maxItems: 3
+
+  assigned-clock-parents:
+minItems: 1
+maxItems: 3
+
+  assigned-clock-rates:
+minItems: 1
+maxItems: 3
+
+required:
+  - clocks
+  - clock-names
+  - assigned-clocks
+  - assigned-clock-parents
+
+unevaluatedProperties: false
+
+examples:
+  - |
+#include
+
+tegra_sound {
+compatible = "nvidia,tegra210-audio-graph-card";
+
+clocks = <_car TEGRA210_CLK_PLL_A>,
+ <_car TEGRA210_CLK_PLL_A_OUT0>;
+clock-names = "pll_a", "plla_out0";
+
+assigned-clocks = <_car TEGRA210_CLK_PLL_A>,
+  <_car TEGRA210_CLK_PLL_A_OUT0>,
+  <_car TEGRA210_CLK_EXTERN1>;
+assigned-clock-parents = <0>, <0>, <_car 
TEGRA210_CLK_PLL_A_OUT0>;
+assigned-clock-rates = <36864>, <49152000>, <12288000>;
+
+dais = /* FE */
+   <_port>,
+   /* Router */
+   <_i2s1_port>,
+   /* I/O DAP Ports */
+   <_port>;
+
+label = "jetson-tx1-ape";
+};
+
+// The ports are defined for AHUB and its child devices.
+ahub@702d0800 {
+compatible = "nvidia,tegra210-ahub";
+reg = <0x702d0800 0x800>;
+clocks = <_car TEGRA210_CLK_D_AUDIO>;
+clock-names = "ahub";
+assigned-clocks = <_car TEGRA210_CLK_D_AUDIO>;
+assigned-clock-parents = <_car TEGRA210_CLK_PLL_A_OUT0>;
+#address-cells = <1>;
+#size-cells = <1>;
+ranges = <0x702d 0x702d 0xe400>;
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+port@0 {
+reg = <0x0>;
+xbar_admaif1_ep: endpoint {
+remote-endpoint = <_ep>;
+};
+};
+
+// ...
+
+xbar_i2s1_port: port@a {
+reg = <0xa>;
+xbar_i2s1_ep: endpoint {
+remote-endpoint = <_cif_ep>;
+};
+};
+};
+
+admaif@702d {
+compatible = "nvidia,tegra210-admaif";
+reg = <0x702d 0x800>;
+dmas = < 1>,  < 1>,
+   < 2>,  < 2>,
+   < 3>,  < 3>,
+   < 4>,  < 4>,
+   < 5>,  < 5>,
+   < 6>,  < 6>,
+   < 7>,  < 7>,
+   < 8>,  < 8>,
+   < 9>,  < 9>,
+   < 10>, < 10>;
+dma-names = "rx1",  "tx1",
+"rx2",  "tx2",
+"rx3",  "tx3",
+"rx4",  "tx4",
+"rx5",  "tx5",
+"rx6",  "tx6",
+"rx7",  "tx7",
+"rx8&

[RESEND PATCH v6 6/6] arm64: tegra: Audio graph sound card for Jetson Nano and TX1

2021-01-19 Thread Sameer Pujar
Enable support for audio-graph based sound card on Jetson-Nano and
Jetson-TX1. Depending on the platform, required I/O interfaces are
enabled.

 * Jetson-Nano: Enable I2S3, I2S4, DMIC1 and DMIC2.
 * Jetson-TX1: Enable all I2S and DMIC interfaces.

Signed-off-by: Sameer Pujar 
Reviewed-by: Jon Hunter 
---
 arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts | 262 +
 arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts | 146 
 2 files changed, 408 insertions(+)

diff --git a/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts 
b/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts
index 69102dc..747ab93 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts
+++ b/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts
@@ -3,6 +3,7 @@
 
 #include "tegra210-p2180.dtsi"
 #include "tegra210-p2597.dtsi"
+#include "tegra210-audio-graph.dtsi"
 
 / {
model = "NVIDIA Jetson TX1 Developer Kit";
@@ -127,4 +128,265 @@
status = "okay";
};
};
+
+   tegra_sound {
+   status = "okay";
+
+   compatible = "nvidia,tegra210-audio-graph-card";
+
+   dais = /* FE */
+  <_port>, <_port>, <_port>,
+  <_port>, <_port>, <_port>,
+  <_port>, <_port>, <_port>,
+  <_port>,
+  /* Router */
+  <_i2s1_port>, <_i2s2_port>, <_i2s3_port>,
+  <_i2s4_port>, <_i2s5_port>, <_dmic1_port>,
+  <_dmic2_port>, <_dmic3_port>,
+  /* I/O DAP Ports */
+  <_port>, <_port>, <_port>, <_port>,
+  <_port>, <_port>, <_port>, 
<_port>;
+
+   label = "jetson-tx1-ape";
+   };
+};
+
+_admaif {
+   status = "okay";
+};
+
+_ahub {
+   status = "okay";
+
+   ports {
+   xbar_i2s1_port: port@a {
+   reg = <0xa>;
+   xbar_i2s1_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_i2s2_port: port@b {
+   reg = <0xb>;
+   xbar_i2s2_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_i2s3_port: port@c {
+   reg = <0xc>;
+   xbar_i2s3_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_i2s4_port: port@d {
+   reg = <0xd>;
+   xbar_i2s4_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_i2s5_port: port@e {
+   reg = <0xe>;
+   xbar_i2s5_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_dmic1_port: port@f {
+   reg = <0xf>;
+   xbar_dmic1_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_dmic2_port: port@10 {
+   reg = <0x10>;
+   xbar_dmic2_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_dmic3_port: port@11 {
+   reg = <0x11>;
+   xbar_dmic3_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   };
+};
+
+_i2s1 {
+   status = "okay";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+   i2s1_cif_ep: endpoint {
+   remote-endpoint = <_i2s1_ep>;
+   };
+   };
+   i2s1_port: port@1 {
+   reg = <1>;
+   i2s1_dap_ep: endpoint {
+   dai-format = "i2s";
+   /* Placeholder for external Codec */
+   };
+   };
+   };
+};
+
+_i2s2 {
+   status = "okay";
+
+   ports {
+   #address-cells = <1>;
+  

[RESEND PATCH v6 5/6] arm64: tegra: Audio graph header for Tegra210

2021-01-19 Thread Sameer Pujar
Expose a header which describes DT bindings required to use audio-graph
based sound card. All Tegra210 based platforms can include this header
and add platform specific information. Currently, from SoC point of view,
all links are exposed for ADMAIF, AHUB, I2S and DMIC components.

Signed-off-by: Sameer Pujar 
Reviewed-by: Jon Hunter 
---
 .../boot/dts/nvidia/tegra210-audio-graph.dtsi  | 153 +
 1 file changed, 153 insertions(+)
 create mode 100644 arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi

diff --git a/arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi 
b/arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi
new file mode 100644
index 000..5c54358
--- /dev/null
+++ b/arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi
@@ -0,0 +1,153 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/ {
+   tegra_sound {
+   status = "disabled";
+
+   clocks = <_car TEGRA210_CLK_PLL_A>,
+<_car TEGRA210_CLK_PLL_A_OUT0>;
+   clock-names = "pll_a", "plla_out0";
+
+   assigned-clocks = <_car TEGRA210_CLK_PLL_A>,
+ <_car TEGRA210_CLK_PLL_A_OUT0>,
+ <_car TEGRA210_CLK_EXTERN1>;
+   assigned-clock-parents = <0>, <0>, <_car 
TEGRA210_CLK_PLL_A_OUT0>;
+   assigned-clock-rates = <36864>, <49152000>, <12288000>;
+   };
+};
+
+_admaif {
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   admaif1_port: port@0 {
+   reg = <0>;
+   admaif1_ep: endpoint {
+   remote-endpoint = <_admaif1_ep>;
+   };
+   };
+   admaif2_port: port@1 {
+   reg = <1>;
+   admaif2_ep: endpoint {
+   remote-endpoint = <_admaif2_ep>;
+   };
+   };
+   admaif3_port: port@2 {
+   reg = <2>;
+   admaif3_ep: endpoint {
+   remote-endpoint = <_admaif3_ep>;
+   };
+   };
+   admaif4_port: port@3 {
+   reg = <3>;
+   admaif4_ep: endpoint {
+   remote-endpoint = <_admaif4_ep>;
+   };
+   };
+   admaif5_port: port@4 {
+   reg = <4>;
+   admaif5_ep: endpoint {
+   remote-endpoint = <_admaif5_ep>;
+   };
+   };
+   admaif6_port: port@5 {
+   reg = <5>;
+   admaif6_ep: endpoint {
+   remote-endpoint = <_admaif6_ep>;
+   };
+   };
+   admaif7_port: port@6 {
+   reg = <6>;
+   admaif7_ep: endpoint {
+   remote-endpoint = <_admaif7_ep>;
+   };
+   };
+   admaif8_port: port@7 {
+   reg = <7>;
+   admaif8_ep: endpoint {
+   remote-endpoint = <_admaif8_ep>;
+   };
+   };
+   admaif9_port: port@8 {
+   reg = <8>;
+   admaif9_ep: endpoint {
+   remote-endpoint = <_admaif9_ep>;
+   };
+   };
+   admaif10_port: port@9 {
+   reg = <9>;
+   admaif10_ep: endpoint {
+   remote-endpoint = <_admaif10_ep>;
+   };
+   };
+   };
+};
+
+_ahub {
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0x0>;
+   xbar_admaif1_ep: endpoint {
+   remote-endpoint = <_ep>;
+   };
+   };
+   port@1 {
+   reg = <0x1>;
+   xbar_admaif2_ep: endpoint {
+   remote-endpoint = <_ep>;
+   };
+   };
+   port@2 {
+   reg = <0x2>;
+   xbar_admaif3_ep: endpoint {
+   remote-endpoint = <_ep>;
+   };
+   };
+   port@3 {
+   reg = <0x3>;
+   xbar_admai

[RESEND PATCH v6 4/6] arm64: defconfig: Enable Tegra audio graph card driver

2021-01-19 Thread Sameer Pujar
This commit enables Tegra audio graph card driver which is based on
the generic audio-graph card driver. This is intended to be used
on platforms based on Tegra210 and later chips.

Signed-off-by: Sameer Pujar 
Reviewed-by: Jon Hunter 
---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index 1cd0106..62763fc 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -747,6 +747,7 @@ CONFIG_SND_SOC_TEGRA210_DMIC=m
 CONFIG_SND_SOC_TEGRA210_I2S=m
 CONFIG_SND_SOC_TEGRA186_DSPK=m
 CONFIG_SND_SOC_TEGRA210_ADMAIF=m
+CONFIG_SND_SOC_TEGRA_AUDIO_GRAPH_CARD=m
 CONFIG_SND_SOC_AK4613=m
 CONFIG_SND_SOC_ES7134=m
 CONFIG_SND_SOC_ES7241=m
-- 
2.7.4



[RESEND PATCH v6 0/6] Tegra210 audio graph card

2021-01-19 Thread Sameer Pujar
This series adds audio graph based sound card support for Tegra210
platforms like Jetson-TX1 an Jetson-Nano. The following preparatory
audio graph enhancement series is already merged.
 * https://patchwork.kernel.org/project/alsa-devel/list/?series=375629=*

Following are the summary of changes:
 * Add graph/audio-graph based schemas or schema updates for Tegra210
   component and machine drivers.
 * Add Tegra audio graph machine driver.
 * Add required DT support for Jetson-TX1/Nano.

This work is based on earlier discussion of DPCM usage for Tegra
and simple card driver updates.
 * https://lkml.org/lkml/2020/4/30/519
 * https://lkml.org/lkml/2020/6/27/4


Original v6 series was sent about 6-7 weeks back. The dependency commit,
https://lore.kernel.org/alsa-devel/1610948585-16286-1-git-send-email-spu...@nvidia.com/
is now merged. Resending this now to appear in the top of the mail list.

Changelog
=

v5 -> v6

 * Added ports or port description in YAML docs for Tegra AHUB
   devices and graph card in patch 1/6 and 2/6. Reference of
   audio-graph-port.yaml is used for AHUB devices.
 * Dropped redundant NULL check return for of_device_get_match_data()
   in patch 3/6.
 * Added 'Reviewed-by' tag from Jon Hunter.
 * No changes in remaining patches.

v4 -> v5

 * Audio graph related changes were sent in separate v5 series as
   mentioned above and are dropped from current series.
 * Graph and audio graph doc patches are dropped from this series
   and are sent separately as mentioned above.
 * Minor change with phandle label for TX1 and Nano platform DT files.
 * No changes in other patches.

v3 -> v4

 * Added new patches to convert graph.txt and audio-graph-card.txt
   to corresponding json-schema files. Later these references
   are used in Tegra audio graph schema.

 * AHUB component binding docs are updated to reflect the usage
   of ports/port/endpoint

 * More common stuff is moved into graph_parse_of() and this is
   used by both generic and Tegra audio graph.

 * DT binding for Tegra audio graph is updated to included "ports { }"

 * As per the suggestion 'void *data' member is dropped from
   'asoc_simple_priv' and instead container method is used to
   maintain required custom data internal to Tegra audio graph. 

v2 -> v3

 * Dropped new compatible addition in generic graph driver
   after reviewing it with Morimoto-san. Instead added Tegra
   audio graph driver and new compatibles are added in the same.
 * Added new patches to expose new members for customization
   in audio graph driver.
 * Added new patch for Tegra audio graph driver and related
   documentation.
 * Minor change in below commit where mutex version of helper is used
   "ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM"
 * DT binding is updated to use the newly exposed compatibles
 * No changes in other patches

v1 -> v2

 * Re-organized ports/endpoints description for ADMAIF and XBAR.
   Updated DT patches accordingly.
 * After above change, multiple Codec endpoint support is not
   required and hence dropped for now. This will be considered
   separately if at all required in future.
 * Re-ordered patches in the series.

Sameer Pujar (6):
  ASoC: dt-bindings: tegra: Add graph bindings
  ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card
  ASoC: tegra: Add audio graph based card driver
  arm64: defconfig: Enable Tegra audio graph card driver
  arm64: tegra: Audio graph header for Tegra210
  arm64: tegra: Audio graph sound card for Jetson Nano and TX1

 .../sound/nvidia,tegra-audio-graph-card.yaml   | 187 +++
 .../bindings/sound/nvidia,tegra186-dspk.yaml   |  18 +-
 .../bindings/sound/nvidia,tegra210-admaif.yaml |  13 +-
 .../bindings/sound/nvidia,tegra210-ahub.yaml   |  13 +-
 .../bindings/sound/nvidia,tegra210-dmic.yaml   |  18 +-
 .../bindings/sound/nvidia,tegra210-i2s.yaml|  18 +-
 .../boot/dts/nvidia/tegra210-audio-graph.dtsi  | 153 
 arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts | 262 +
 arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts | 146 
 arch/arm64/configs/defconfig   |   1 +
 sound/soc/tegra/Kconfig|   9 +
 sound/soc/tegra/Makefile   |   2 +
 sound/soc/tegra/tegra_audio_graph_card.c   | 251 
 13 files changed, 1085 insertions(+), 6 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
 create mode 100644 arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi
 create mode 100644 sound/soc/tegra/tegra_audio_graph_card.c

-- 
2.7.4



[RESEND PATCH v6 1/6] ASoC: dt-bindings: tegra: Add graph bindings

2021-01-19 Thread Sameer Pujar
Add device tree binding properties of generic graph to ASoC component
devices. This allows to define audio ports out of these components or
DAIs and audio graph based sound card can be realised with this.

Signed-off-by: Sameer Pujar 
Reviewed-by: Jon Hunter 
---
 .../bindings/sound/nvidia,tegra186-dspk.yaml   | 18 +-
 .../bindings/sound/nvidia,tegra210-admaif.yaml | 13 -
 .../bindings/sound/nvidia,tegra210-ahub.yaml   | 13 +++--
 .../bindings/sound/nvidia,tegra210-dmic.yaml   | 18 +-
 .../devicetree/bindings/sound/nvidia,tegra210-i2s.yaml | 18 +-
 5 files changed, 74 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
index ed2fb32..b8645d9 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
@@ -17,6 +17,9 @@ maintainers:
   - Jon Hunter 
   - Sameer Pujar 
 
+allOf:
+  - $ref: audio-graph-port.yaml#
+
 properties:
   $nodename:
 pattern: "^dspk@[0-9a-f]*$"
@@ -55,6 +58,19 @@ properties:
   The name can be "DSPK1" or "DSPKx", where x depends on the maximum
   available instances on a Tegra SoC.
 
+  ports:
+type: object
+properties:
+  port@0:
+description: |
+  DSPK ACIF (Audio Client Interface) port connected to the
+  corresponding AHUB (Audio Hub) ACIF port.
+
+  port@1:
+description: |
+  DSPK DAP (Digital Audio Port) interface which can be connected
+  to external audio codec for playback.
+
 required:
   - compatible
   - reg
@@ -64,7 +80,7 @@ required:
   - assigned-clock-parents
   - sound-name-prefix
 
-additionalProperties: false
+unevaluatedProperties: false
 
 examples:
   - |
diff --git 
a/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml
index c028b25..7cee772 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml
@@ -17,6 +17,9 @@ maintainers:
   - Jon Hunter 
   - Sameer Pujar 
 
+allOf:
+  - $ref: audio-graph-port.yaml#
+
 properties:
   $nodename:
 pattern: "^admaif@[0-9a-f]*$"
@@ -37,6 +40,14 @@ properties:
 
   dma-names: true
 
+  ports:
+description: |
+  Contains list of ACIF (Audio CIF) port nodes for ADMAIF channels.
+  The number of port nodes depends on the number of ADMAIF channels
+  that SoC may have. These are interfaced with respective ACIF ports
+  in AHUB (Audio Hub). Each port is capable of data transfers in
+  both directions.
+
 if:
   properties:
 compatible:
@@ -81,7 +92,7 @@ required:
   - dmas
   - dma-names
 
-additionalProperties: false
+unevaluatedProperties: false
 
 examples:
   - |
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml
index d772197..31f3e51 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml
@@ -17,6 +17,9 @@ maintainers:
   - Jon Hunter 
   - Sameer Pujar 
 
+allOf:
+  - $ref: audio-graph-port.yaml#
+
 properties:
   $nodename:
 pattern: "^ahub@[0-9a-f]*$"
@@ -56,6 +59,13 @@ properties:
 
   ranges: true
 
+  ports:
+description: |
+  Contains list of ACIF (Audio CIF) port nodes for AHUB (Audio Hub).
+  These are connected to ACIF interfaces of AHUB clients. Thus the
+  number of port nodes depend on the number of clients that AHUB may
+  have depending on the SoC revision.
+
 required:
   - compatible
   - reg
@@ -67,8 +77,7 @@ required:
   - "#size-cells"
   - ranges
 
-additionalProperties:
-  type: object
+unevaluatedProperties: false
 
 examples:
   - |
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml
index 2a3207b..89f4f47 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml
@@ -16,6 +16,9 @@ maintainers:
   - Jon Hunter 
   - Sameer Pujar 
 
+allOf:
+  - $ref: audio-graph-port.yaml#
+
 properties:
   $nodename:
 pattern: "^dmic@[0-9a-f]*$"
@@ -56,6 +59,19 @@ properties:
   The name can be "DMIC1" or "DMIC2" ... "DMICx", where x depends
   on the maximum available instances on a Tegra SoC.
 
+  ports:
+type: object
+properties:
+  port@0:
+description: |
+  DMIC ACIF (Audio Client Interface) port connected to the
+  corresponding AHUB (Audio Hub) ACIF port.
+
+  port@

[RESEND PATCH] ASoC: audio-graph-card: Drop remote-endpoint as required property

2021-01-17 Thread Sameer Pujar
The remote-endpoint may not be available if it is part of some
pluggable module. One such example would be an audio card, the
Codec endpoint will not be available until it is plugged in.
Hence drop 'remote-endpoint' as a required property.

Cc: Rob Herring 
Cc: Kuninori Morimoto 
Signed-off-by: Sameer Pujar 
---
 Documentation/devicetree/bindings/sound/audio-graph-port.yaml | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml 
b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
index 2005014..766e910 100644
--- a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
+++ b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
@@ -71,9 +71,6 @@ properties:
 description: CPU to Codec rate channels.
 $ref: /schemas/types.yaml#/definitions/uint32
 
-required:
-  - remote-endpoint
-
   ports:
 description: multi OF-Graph subnode
 type: object
-- 
2.7.4



Re: [PATCH] dt-bindings: Remove plain text OF graph binding

2021-01-12 Thread Sameer Pujar




On 1/12/2021 9:16 PM, Rob Herring wrote:

External email: Use caution opening links or attachments


From: Sameer Pujar 

A schema for the OF graph binding has been added to the dt-schema repo
based on graph.txt contents. Let's replace graph.txt now duplicated
contents with a reference to the schema.

For users of the graph binding, they should reference to the graph
schema from either 'ports' or 'port' property:

properties:
   ports:
 $ref: /schemas/graph.yaml#/properties/ports

 properties:
   port@0:
 $ref: /schemas/graph.yaml#/properties/port
 description: What data this port has

   ...

Or:

properties:
   port:
 description: What data this port has
 $ref: /schemas/graph.yaml#/properties/port

Cc: Sameer Pujar 
Acked-by: Philipp Zabel 
Reviewed-by: Sam Ravnborg 
Reviewed-by: Laurent Pinchart 
[robh: moved graph.yaml to dt-schema repo, expanded commit msg]
Signed-off-by: Rob Herring 
---
  Documentation/devicetree/bindings/graph.txt | 129 +---
  1 file changed, 1 insertion(+), 128 deletions(-)


Acked-by: Sameer Pujar 


Re: [PATCH] ASoC: audio-graph-card: Drop remote-endpoint as required property

2021-01-10 Thread Sameer Pujar

Hi Rob,


On 12/10/2020 8:14 PM, Sameer Pujar wrote:

Hi Rob,


The remote-endpoint may not be available if it is part of some
pluggable module. One such example would be an audio card, the
Codec endpoint will not be available until it is plugged in.
Hence drop 'remote-endpoint' as a required property.

Please hold off on this. I have more changes coming.


Sorry to bother you again. Is it possible if we take this patch now and 
your remaining changes can come later? This would help to unblock below 
series, which is pending quite some time now.




OK, I will wait for your patch. Kindly note that this is currently 
blocking series 
https://patchwork.kernel.org/project/alsa-devel/list/?series=391735=*




Re: [PATCH v2 2/2] ALSA: hda/tegra: fix tegra-hda on tegra30 soc

2021-01-08 Thread Sameer Pujar




On 1/8/2021 7:29 PM, Peter Geis wrote:

External email: Use caution opening links or attachments


Currently hda on tegra30 fails to open a stream with an input/output error.

For example:
speaker-test -Dhw:0,3 -c 2

speaker-test 1.2.2

Playback device is hw:0,3
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 64 to 16384
Period size range from 32 to 8192
Using max buffer size 16384
Periods = 4
was set period_size = 4096
was set buffer_size = 16384
  0 - Front Left
Write error: -5,Input/output error
xrun_recovery failed: -5,Input/output error
Transfer failed: Input/output error

The tegra-hda device was introduced in tegra30 but only utilized in
tegra124 until recent chips. Tegra210/186 work only due to a hardware
change. For this reason it is unknown when this issue first manifested.
Discussions with the hardware team show this applies to all current tegra
chips. It has been resolved in the tegra234, which does not have hda
support at this time.

The explanation from the hardware team is this:
Below is the striping formula referenced from HD audio spec.
{ ((num_channels * bits_per_sample) / number of SDOs) >= 8 }

The current issue is seen because Tegra HW has a problem with boundary
condition (= 8) for striping. The reason why it is not seen on
Tegra210/Tegra186 is because it uses max 2SDO lines. Max SDO lines is
read from GCAP register.

For the given stream (channels = 2, bps = 16);
ratio = (channels * bps) / NSDO = 32 / NSDO;

On Tegra30,  ratio = 32/4 = 8  (FAIL)
On Tegra210/186, ratio = 32/2 = 16 (PASS)
On Tegra194, ratio = 32/4 = 8  (FAIL) ==> Earlier workaround was
applied for it

If Tegra210/186 is forced to use 4SDO, it fails there as well. So the
behavior is consistent across all these chips.

Applying the fix in [1] universally resolves this issue on tegra30-hda.
Tested on the Ouya game console and the tf201 tablet.

[1] commit 60019d8c650d ("ALSA: hda/tegra: workaround playback failure on
Tegra194")

Reviewed-by: Jon Hunter 
Tested-by: Ion Agorria 
Signed-off-by: Peter Geis 
---
  sound/pci/hda/hda_tegra.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)


Thanks Peter.

Reviewed-by: Sameer Pujar 


Re: [PATCH v2 1/2] clk: tegra30: Add hda clock default rates to clock driver

2021-01-08 Thread Sameer Pujar




On 1/8/2021 7:29 PM, Peter Geis wrote:

External email: Use caution opening links or attachments


Current implementation defaults the hda clocks to clk_m. This causes hda
to run too slow to operate correctly. Fix this by defaulting to pll_p and
setting the frequency to the correct rate.

This matches upstream t124 and downstream t30.

Acked-by: Jon Hunter 
Tested-by: Ion Agorria 
Signed-off-by: Peter Geis 
---
  drivers/clk/tegra/clk-tegra30.c | 2 ++
  1 file changed, 2 insertions(+)


Acked-by: Sameer Pujar 


Re: [PATCH 2/2] ALSA: hda/tegra: fix tegra-hda on tegra30 soc

2021-01-08 Thread Sameer Pujar




On 1/7/2021 2:51 AM, Peter Geis wrote:

External email: Use caution opening links or attachments


On Tue, Jan 5, 2021 at 1:30 AM Sameer Pujar  wrote:



On 12/25/2020 6:50 AM, Peter Geis wrote:

External email: Use caution opening links or attachments


Currently hda on tegra30 fails to open a stream with an input/output error.
This is similar to the issue referenced in [1].

For example:
speaker-test -Dhw:0,3 -c 2

speaker-test 1.2.2

Playback device is hw:0,3
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 64 to 16384
Period size range from 32 to 8192
Using max buffer size 16384
Periods = 4
was set period_size = 4096
was set buffer_size = 16384
   0 - Front Left
Write error: -5,Input/output error
xrun_recovery failed: -5,Input/output error
Transfer failed: Input/output error

[1] states "Due to a legacy HW design problem", implying the issue applies to 
all previous tegra-hda devices.
The tegra-hda device was introduced in tegra30 but only utilized in tegra124 
until now.
For this reason it is unknown when this issue first manifested.

Applying the fix in [1] universally resolves this issue on tegra30.
Tested on the Ouya game console and the tf201 tablet.

[1] 60019d8c650d ("ALSA: hda/tegra: workaround playback failure on Tegra194")

This issue was never seen on Tegra210/Tegra186 and hence at that time it
was thought to be specific to Tegra194. I never tested this on Tegra30
since I don't have this device. I will clarify this with HW folks if
workaround is safer for all chips.

So this is confirmed to not affect Tegra210 and Tegra186, but it does
affect Tegra194 and Tegra30.
Is it possible for the hardware team to pitch on on where the fix was
implemented?


I discussed this with HW team. The issue is applicable to all Tegra chips.

Below is the striping formula referenced from HD audio spec.
  { ((num_channels * bits_per_sample) / number of SDOs) >= 8 }

The current issue is seen because Tegra HW has a problem with boundary 
condition (= 8) for striping. The reason why it is not seen on 
Tegra210/Tegra186 is because it uses max 2SDO lines. Max SDO lines is 
read from GCAP register.


For the given stream (channels = 2, bps = 16);
ratio = (channels * bps) / NSDO = 32 / NSDO;

On Tegra30,  ratio = 32/4 = 8  (FAIL)
On Tegra210/186, ratio = 32/2 = 16 (PASS)
On Tegra194, ratio = 32/4 = 8  (FAIL) ==> Earlier workaround was 
applied for it


If Tegra210/186 is forced to use 4SDO, it fails there as well. So the 
behavior is consistent across all these chips.



Signed-off-by: Peter Geis 
Tested-by: Ion Agorria 
---
   sound/pci/hda/hda_tegra.c | 3 +--
   1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c
index 70164d1428d4..f8d61e677a09 100644
--- a/sound/pci/hda/hda_tegra.c
+++ b/sound/pci/hda/hda_tegra.c
@@ -388,8 +388,7 @@ static int hda_tegra_first_init(struct azx *chip, struct 
platform_device *pdev)
   * in powers of 2, next available ratio is 16 which can be
   * used as a limiting factor here.
   */
-   if (of_device_is_compatible(np, "nvidia,tegra194-hda"))
-   chip->bus.core.sdo_limit = 16;
+   chip->bus.core.sdo_limit = 16;

Future Tegra chips address this problem and hence cannot be enforced by
default. May be we can have like below:

if (of_device_is_compatible(np, "nvidia,tegra30-hda"))
chip->bus.core.sdo_limit = 16;


It will need to be a bit more complicated than that, since the
tegra186 and tegra210 device trees have "nvidia,tegra30-hda" as a
fallback.
Looking at the generation map, tegra30-hda can be the fallback for the
broken implementation and tegra210-hda can be the fallback for the
working implementation.
Does that work for you?


As per above explanation, it is fine to apply the workaround for 
Tegra210/186 as well. So it simplifies things for all existing chips.



  /* codec detection */
  if (!bus->codec_mask) {
--
2.25.1





[PATCH] arm64: tegra: Add power-domain for Tegra210 HDA

2021-01-06 Thread Sameer Pujar
HDA initialization is failing occasionally on Tegra210 and following
print is observed in the boot log. Because of this probe() fails and
no sound card is registered.

  [16.800802] tegra-hda 7003.hda: no codecs found!

Codecs request a state change and enumeration by the controller. In
failure cases this does not seem to happen as STATETS register reads 0.

The problem seems to be related to the HDA codec dependency on SOR
power domain. If it is gated during HDA probe then the failure is
observed. Building Tegra HDA driver into kernel image avoids this
failure but does not completely address the dependency part. Fix this
problem by adding 'power-domains' DT property for Tegra210 HDA. Note
that Tegra186 and Tegra194 HDA do this already.

Fixes: 742af7e7a0a1 ("arm64: tegra: Add Tegra210 support")
Depends-on: 96d1f078ff0 ("arm64: tegra: Add SOR power-domain for Tegra210")
Cc: 
Signed-off-by: Sameer Pujar 
---
 arch/arm64/boot/dts/nvidia/tegra210.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/boot/dts/nvidia/tegra210.dtsi 
b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
index 4fbf8c1..fd33b4d 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210.dtsi
+++ b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
@@ -997,6 +997,7 @@
 <_car 128>, /* hda2hdmi */
 <_car 111>; /* hda2codec_2x */
reset-names = "hda", "hda2hdmi", "hda2codec_2x";
+   power-domains = <_sor>;
status = "disabled";
};
 
-- 
2.7.4



Re: [PATCH 2/2] ALSA: hda/tegra: fix tegra-hda on tegra30 soc

2021-01-04 Thread Sameer Pujar




On 12/25/2020 6:50 AM, Peter Geis wrote:

External email: Use caution opening links or attachments


Currently hda on tegra30 fails to open a stream with an input/output error.
This is similar to the issue referenced in [1].

For example:
speaker-test -Dhw:0,3 -c 2

speaker-test 1.2.2

Playback device is hw:0,3
Stream parameters are 48000Hz, S16_LE, 2 channels
Using 16 octaves of pink noise
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 64 to 16384
Period size range from 32 to 8192
Using max buffer size 16384
Periods = 4
was set period_size = 4096
was set buffer_size = 16384
  0 - Front Left
Write error: -5,Input/output error
xrun_recovery failed: -5,Input/output error
Transfer failed: Input/output error

[1] states "Due to a legacy HW design problem", implying the issue applies to 
all previous tegra-hda devices.
The tegra-hda device was introduced in tegra30 but only utilized in tegra124 
until now.
For this reason it is unknown when this issue first manifested.

Applying the fix in [1] universally resolves this issue on tegra30.
Tested on the Ouya game console and the tf201 tablet.

[1] 60019d8c650d ("ALSA: hda/tegra: workaround playback failure on Tegra194")


This issue was never seen on Tegra210/Tegra186 and hence at that time it 
was thought to be specific to Tegra194. I never tested this on Tegra30 
since I don't have this device. I will clarify this with HW folks if 
workaround is safer for all chips.




Signed-off-by: Peter Geis 
Tested-by: Ion Agorria 
---
  sound/pci/hda/hda_tegra.c | 3 +--
  1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/pci/hda/hda_tegra.c b/sound/pci/hda/hda_tegra.c
index 70164d1428d4..f8d61e677a09 100644
--- a/sound/pci/hda/hda_tegra.c
+++ b/sound/pci/hda/hda_tegra.c
@@ -388,8 +388,7 @@ static int hda_tegra_first_init(struct azx *chip, struct 
platform_device *pdev)
  * in powers of 2, next available ratio is 16 which can be
  * used as a limiting factor here.
  */
-   if (of_device_is_compatible(np, "nvidia,tegra194-hda"))
-   chip->bus.core.sdo_limit = 16;
+   chip->bus.core.sdo_limit = 16;


Future Tegra chips address this problem and hence cannot be enforced by 
default. May be we can have like below:


if (of_device_is_compatible(np, "nvidia,tegra30-hda"))
chip->bus.core.sdo_limit = 16;



 /* codec detection */
 if (!bus->codec_mask) {
--
2.25.1





Re: [PATCH] ASoC: audio-graph-card: Drop remote-endpoint as required property

2020-12-27 Thread Sameer Pujar

Hi Rob,


The remote-endpoint may not be available if it is part of some
pluggable module. One such example would be an audio card, the
Codec endpoint will not be available until it is plugged in.
Hence drop 'remote-endpoint' as a required property.

Please hold off on this. I have more changes coming.


Is this a good time to push for audio-graph-port changes?



Re: [PATCH] ASoC: audio-graph-card: Drop remote-endpoint as required property

2020-12-10 Thread Sameer Pujar

Hi Rob,


The remote-endpoint may not be available if it is part of some
pluggable module. One such example would be an audio card, the
Codec endpoint will not be available until it is plugged in.
Hence drop 'remote-endpoint' as a required property.

Please hold off on this. I have more changes coming.


OK, I will wait for your patch. Kindly note that this is currently 
blocking series 
https://patchwork.kernel.org/project/alsa-devel/list/?series=391735=*


Thanks,
Sameer.


[PATCH] ASoC: audio-graph-card: Drop remote-endpoint as required property

2020-12-08 Thread Sameer Pujar
The remote-endpoint may not be available if it is part of some
pluggable module. One such example would be an audio card, the
Codec endpoint will not be available until it is plugged in.
Hence drop 'remote-endpoint' as a required property.

Cc: Rob Herring 
Cc: Kuninori Morimoto 
Signed-off-by: Sameer Pujar 
---
 Documentation/devicetree/bindings/sound/audio-graph-port.yaml | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml 
b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
index 2005014..766e910 100644
--- a/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
+++ b/Documentation/devicetree/bindings/sound/audio-graph-port.yaml
@@ -71,9 +71,6 @@ properties:
 description: CPU to Codec rate channels.
 $ref: /schemas/types.yaml#/definitions/uint32
 
-required:
-  - remote-endpoint
-
   ports:
 description: multi OF-Graph subnode
 type: object
-- 
2.7.4



Re: Re: Re: [PATCH v6 0/6] Tegra210 audio graph card

2020-12-08 Thread Sameer Pujar




No, this was sent by a b4 bug - notice the "no commit info" there, they
weren't applied.

Oh I see! I guess review would be still pending then.

I don't seem to have them in my backlog so either there was feedback
from someone else I was expecting to see addressed or some other issue.


I am pretty sure that it is not because of any outstanding comments, 
because I got none on v6 and previous v5 feedback was taken care. May be 
this is because of the doc dependency I listed in the cover letter?


[Sorry I had to resend this reply. I accidentally replied from my 
personal email earlier and many people/DLs were missing on that]


Re: Re: [PATCH v6 0/6] Tegra210 audio graph card

2020-12-07 Thread Sameer Pujar




[1/3] ASoC: dt-bindings: tegra: Add graph bindings
(no commit info)
[2/3] ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card
(no commit info)
[3/3] ASoC: tegra: Add audio graph based card driver
(no commit info)

I don't see above patches in linux-next yet. Should I wait some more time
for this to appear?

No, this was sent by a b4 bug - notice the "no commit info" there, they
weren't applied.


Oh I see! I guess review would be still pending then.


Re: [PATCH v6 0/6] Tegra210 audio graph card

2020-12-06 Thread Sameer Pujar

Hi Mark,


This series adds audio graph based sound card support for Tegra210
platforms like Jetson-TX1 an Jetson-Nano. The following preparatory
audio graph enhancement series is already merged.
  * https://patchwork.kernel.org/project/alsa-devel/list/?series=375629=*

Following are the summary of changes:
  * Add graph/audio-graph based schemas or schema updates for Tegra210
component and machine drivers.
  * Add Tegra audio graph machine driver.
  * Add required DT support for Jetson-TX1/Nano.

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/3] ASoC: dt-bindings: tegra: Add graph bindings
   (no commit info)
[2/3] ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card
   (no commit info)
[3/3] ASoC: tegra: Add audio graph based card driver
   (no commit info)


I don't see above patches in linux-next yet. Should I wait some more 
time for this to appear?



Thanks,
Sameer.


[RESEND PATCH 1/2] dt-bindings: tegra: Convert HDA doc to json-schema

2020-12-03 Thread Sameer Pujar
Convert Tegra HDA doc to YAML format.

Signed-off-by: Sameer Pujar 
---
 .../bindings/sound/nvidia,tegra30-hda.txt  | 35 
 .../bindings/sound/nvidia,tegra30-hda.yaml | 98 ++
 2 files changed, 98 insertions(+), 35 deletions(-)
 delete mode 100644 
Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.txt
 create mode 100644 
Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml

diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.txt 
b/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.txt
deleted file mode 100644
index 21cd310..000
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-NVIDIA Tegra30 HDA controller
-
-Required properties:
-- compatible : For Tegra30, must contain "nvidia,tegra30-hda".  Otherwise,
-  must contain '"nvidia,-hda", "nvidia,tegra30-hda"', where  is
-  tegra114, tegra124, or tegra132.
-- reg : Should contain the HDA registers location and length.
-- interrupts : The interrupt from the HDA controller.
-- clocks : Must contain an entry for each required entry in clock-names.
-  See ../clocks/clock-bindings.txt for details.
-- clock-names : Must include the following entries: hda, hda2hdmi, hda2codec_2x
-- resets : Must contain an entry for each entry in reset-names.
-  See ../reset/reset.txt for details.
-- reset-names : Must include the following entries: hda, hda2hdmi, hda2codec_2x
-
-Optional properties:
-- nvidia,model : The user-visible name of this sound complex. Since the 
property
-  is optional, legacy boards can use default name provided in hda driver.
-
-Example:
-
-hda@7003 {
-   compatible = "nvidia,tegra124-hda", "nvidia,tegra30-hda";
-   reg = <0x0 0x7003 0x0 0x1>;
-   interrupts = ;
-   clocks = <_car TEGRA124_CLK_HDA>,
-<_car TEGRA124_CLK_HDA2HDMI>,
-<_car TEGRA124_CLK_HDA2CODEC_2X>;
-   clock-names = "hda", "hda2hdmi", "hda2codec_2x";
-   resets = <_car 125>, /* hda */
-<_car 128>, /* hda2hdmi */
-<_car 111>; /* hda2codec_2x */
-   reset-names = "hda", "hda2hdmi", "hda2codec_2x";
-   nvidia,model = "jetson-tk1-hda";
-};
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml
new file mode 100644
index 000..3059bc3
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml
@@ -0,0 +1,98 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/nvidia,tegra30-hda.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVIDIA Tegra HDA controller
+
+description: |
+  The High Definition Audio (HDA) block provides a serial interface to
+  audio codec. It supports multiple input and output streams.
+
+maintainers:
+  - Thierry Reding 
+  - Jon Hunter 
+
+properties:
+  $nodename:
+pattern: "^hda@[0-9a-f]*$"
+
+  compatible:
+oneOf:
+  - const: nvidia,tegra30-hda
+  - items:
+  - enum:
+  - nvidia,tegra194-hda
+  - nvidia,tegra186-hda
+  - nvidia,tegra210-hda
+  - nvidia,tegra124-hda
+  - const: nvidia,tegra30-hda
+  - items:
+  - const: nvidia,tegra132-hda
+  - const: nvidia,tegra124-hda
+  - const: nvidia,tegra30-hda
+
+  reg:
+maxItems: 1
+
+  interrupts:
+description: The interrupt from the HDA controller
+maxItems: 1
+
+  clocks:
+maxItems: 3
+
+  clock-names:
+maxItems: 3
+items:
+  - const: hda
+  - const: hda2hdmi
+  - const: hda2codec_2x
+
+  resets:
+maxItems: 3
+
+  reset-names:
+maxItems: 3
+items:
+  - const: hda
+  - const: hda2hdmi
+  - const: hda2codec_2x
+
+  nvidia,model:
+$ref: /schemas/types.yaml#/definitions/string
+description: |
+  The user-visible name of this sound complex. If this property is
+  not specified then boards can use default name provided in hda driver.
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+
+additionalProperties: false
+
+examples:
+  - |
+#include
+#include
+
+hda@7003 {
+compatible = "nvidia,tegra124-hda", "nvidia,tegra30-hda";
+reg = <0x7003 0x1>;
+interrupts = ;
+clocks = <_car TEGRA124_CLK_HDA>,
+ <_car TEGRA124_CLK_HDA2HDMI>,
+ <_car TEGRA124_CLK_HDA2CODEC_2X>;
+clock-names = "hda", "hda2hdmi", "hda2codec_2x";
+resets = <_car 125>, /* hda */
+ <_car 128>, /* hda2hdmi */
+ <_car 111>; /* hda2codec_2x */
+reset-names = "hda", "hda2hdmi", "hda2codec_2x";
+nvidia,model = "jetson-tk1-hda";
+};
+
+...
-- 
2.7.4



[RESEND PATCH 2/2] dt-bindings: tegra: Add missing HDA properties

2020-12-03 Thread Sameer Pujar
Document the missing properties which are currently required for
Tegra186/Tegra194 DT files.

Signed-off-by: Sameer Pujar 
---
 .../devicetree/bindings/sound/nvidia,tegra30-hda.yaml  | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml
index 3059bc3..e543a61 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml
@@ -60,6 +60,20 @@ properties:
   - const: hda2hdmi
   - const: hda2codec_2x
 
+  power-domains:
+maxItems: 1
+
+  interconnects:
+maxItems: 2
+
+  interconnect-names:
+items:
+  - const: dma-mem
+  - const: write
+
+  iommus:
+maxItems: 1
+
   nvidia,model:
 $ref: /schemas/types.yaml#/definitions/string
 description: |
-- 
2.7.4



[RESEND PATCH 0/2] Convert Tegra HDA doc to json-schema

2020-12-03 Thread Sameer Pujar
Convert Tegra HDA doc to YAML format. Ran binding validation checks to
ensure there are no warnings/errors for HDA.

Patch "arm64: tegra: Fix Tegra194 HDA {clock,reset}-names ordering" is
already merged and hence not included here.

Sameer Pujar (2):
  dt-bindings: tegra: Convert HDA doc to json-schema
  dt-bindings: tegra: Add missing HDA properties

 .../bindings/sound/nvidia,tegra30-hda.txt  |  35 ---
 .../bindings/sound/nvidia,tegra30-hda.yaml | 112 +
 2 files changed, 112 insertions(+), 35 deletions(-)
 delete mode 100644 
Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.txt
 create mode 100644 
Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml

-- 
2.7.4



[PATCH v6 0/6] Tegra210 audio graph card

2020-11-26 Thread Sameer Pujar
This series adds audio graph based sound card support for Tegra210
platforms like Jetson-TX1 an Jetson-Nano. The following preparatory
audio graph enhancement series is already merged.
 * https://patchwork.kernel.org/project/alsa-devel/list/?series=375629=*

Following are the summary of changes:
 * Add graph/audio-graph based schemas or schema updates for Tegra210
   component and machine drivers.
 * Add Tegra audio graph machine driver.
 * Add required DT support for Jetson-TX1/Nano.

This work is based on earlier discussion of DPCM usage for Tegra
and simple card driver updates.
 * https://lkml.org/lkml/2020/4/30/519
 * https://lkml.org/lkml/2020/6/27/4

This series depends on following patch from Rob Herring:
https://patchwork.ozlabs.org/project/devicetree-bindings/patch/20201117013349.2458416-3-r...@kernel.org/

Changelog
=

v5 -> v6

 * Added ports or port description in YAML docs for Tegra AHUB
   devices and graph card in patch 1/6 and 2/6. Reference of
   audio-graph-port.yaml is used for AHUB devices.
 * Dropped redundant NULL check return for of_device_get_match_data()
   in patch 3/6.
 * Added 'Reviewed-by' tag from Jon Hunter.
 * No changes in remaining patches.

v4 -> v5

 * Audio graph related changes were sent in separate v5 series as
   mentioned above and are dropped from current series.
 * Graph and audio graph doc patches are dropped from this series
   and are sent separately as mentioned above.
 * Minor change with phandle label for TX1 and Nano platform DT files.
 * No changes in other patches.

v3 -> v4

 * Added new patches to convert graph.txt and audio-graph-card.txt
   to corresponding json-schema files. Later these references
   are used in Tegra audio graph schema.

 * AHUB component binding docs are updated to reflect the usage
   of ports/port/endpoint

 * More common stuff is moved into graph_parse_of() and this is
   used by both generic and Tegra audio graph.

 * DT binding for Tegra audio graph is updated to included "ports { }"

 * As per the suggestion 'void *data' member is dropped from
   'asoc_simple_priv' and instead container method is used to
   maintain required custom data internal to Tegra audio graph. 

v2 -> v3

 * Dropped new compatible addition in generic graph driver
   after reviewing it with Morimoto-san. Instead added Tegra
   audio graph driver and new compatibles are added in the same.
 * Added new patches to expose new members for customization
   in audio graph driver.
 * Added new patch for Tegra audio graph driver and related
   documentation.
 * Minor change in below commit where mutex version of helper is used
   "ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM"
 * DT binding is updated to use the newly exposed compatibles
 * No changes in other patches

v1 -> v2

 * Re-organized ports/endpoints description for ADMAIF and XBAR.
   Updated DT patches accordingly.
 * After above change, multiple Codec endpoint support is not
   required and hence dropped for now. This will be considered
   separately if at all required in future.
 * Re-ordered patches in the series.

Sameer Pujar (6):
  ASoC: dt-bindings: tegra: Add graph bindings
  ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card
  ASoC: tegra: Add audio graph based card driver
  arm64: defconfig: Enable Tegra audio graph card driver
  arm64: tegra: Audio graph header for Tegra210
  arm64: tegra: Audio graph sound card for Jetson Nano and TX1

 .../sound/nvidia,tegra-audio-graph-card.yaml   | 187 +++
 .../bindings/sound/nvidia,tegra186-dspk.yaml   |  18 +-
 .../bindings/sound/nvidia,tegra210-admaif.yaml |  13 +-
 .../bindings/sound/nvidia,tegra210-ahub.yaml   |  13 +-
 .../bindings/sound/nvidia,tegra210-dmic.yaml   |  18 +-
 .../bindings/sound/nvidia,tegra210-i2s.yaml|  18 +-
 .../boot/dts/nvidia/tegra210-audio-graph.dtsi  | 153 
 arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts | 262 +
 arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts | 146 
 arch/arm64/configs/defconfig   |   1 +
 sound/soc/tegra/Kconfig|   9 +
 sound/soc/tegra/Makefile   |   2 +
 sound/soc/tegra/tegra_audio_graph_card.c   | 251 
 13 files changed, 1085 insertions(+), 6 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
 create mode 100644 arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi
 create mode 100644 sound/soc/tegra/tegra_audio_graph_card.c

-- 
2.7.4



[PATCH v6 6/6] arm64: tegra: Audio graph sound card for Jetson Nano and TX1

2020-11-26 Thread Sameer Pujar
Enable support for audio-graph based sound card on Jetson-Nano and
Jetson-TX1. Depending on the platform, required I/O interfaces are
enabled.

 * Jetson-Nano: Enable I2S3, I2S4, DMIC1 and DMIC2.
 * Jetson-TX1: Enable all I2S and DMIC interfaces.

Signed-off-by: Sameer Pujar 
Reviewed-by: Jon Hunter 
---
 arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts | 262 +
 arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts | 146 
 2 files changed, 408 insertions(+)

diff --git a/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts 
b/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts
index 69102dc..747ab93 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts
+++ b/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts
@@ -3,6 +3,7 @@
 
 #include "tegra210-p2180.dtsi"
 #include "tegra210-p2597.dtsi"
+#include "tegra210-audio-graph.dtsi"
 
 / {
model = "NVIDIA Jetson TX1 Developer Kit";
@@ -127,4 +128,265 @@
status = "okay";
};
};
+
+   tegra_sound {
+   status = "okay";
+
+   compatible = "nvidia,tegra210-audio-graph-card";
+
+   dais = /* FE */
+  <_port>, <_port>, <_port>,
+  <_port>, <_port>, <_port>,
+  <_port>, <_port>, <_port>,
+  <_port>,
+  /* Router */
+  <_i2s1_port>, <_i2s2_port>, <_i2s3_port>,
+  <_i2s4_port>, <_i2s5_port>, <_dmic1_port>,
+  <_dmic2_port>, <_dmic3_port>,
+  /* I/O DAP Ports */
+  <_port>, <_port>, <_port>, <_port>,
+  <_port>, <_port>, <_port>, 
<_port>;
+
+   label = "jetson-tx1-ape";
+   };
+};
+
+_admaif {
+   status = "okay";
+};
+
+_ahub {
+   status = "okay";
+
+   ports {
+   xbar_i2s1_port: port@a {
+   reg = <0xa>;
+   xbar_i2s1_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_i2s2_port: port@b {
+   reg = <0xb>;
+   xbar_i2s2_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_i2s3_port: port@c {
+   reg = <0xc>;
+   xbar_i2s3_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_i2s4_port: port@d {
+   reg = <0xd>;
+   xbar_i2s4_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_i2s5_port: port@e {
+   reg = <0xe>;
+   xbar_i2s5_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_dmic1_port: port@f {
+   reg = <0xf>;
+   xbar_dmic1_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_dmic2_port: port@10 {
+   reg = <0x10>;
+   xbar_dmic2_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_dmic3_port: port@11 {
+   reg = <0x11>;
+   xbar_dmic3_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   };
+};
+
+_i2s1 {
+   status = "okay";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+   i2s1_cif_ep: endpoint {
+   remote-endpoint = <_i2s1_ep>;
+   };
+   };
+   i2s1_port: port@1 {
+   reg = <1>;
+   i2s1_dap_ep: endpoint {
+   dai-format = "i2s";
+   /* Placeholder for external Codec */
+   };
+   };
+   };
+};
+
+_i2s2 {
+   status = "okay";
+
+   ports {
+   #address-cells = <1>;
+  

[PATCH v6 5/6] arm64: tegra: Audio graph header for Tegra210

2020-11-26 Thread Sameer Pujar
Expose a header which describes DT bindings required to use audio-graph
based sound card. All Tegra210 based platforms can include this header
and add platform specific information. Currently, from SoC point of view,
all links are exposed for ADMAIF, AHUB, I2S and DMIC components.

Signed-off-by: Sameer Pujar 
Reviewed-by: Jon Hunter 
---
 .../boot/dts/nvidia/tegra210-audio-graph.dtsi  | 153 +
 1 file changed, 153 insertions(+)
 create mode 100644 arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi

diff --git a/arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi 
b/arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi
new file mode 100644
index 000..5c54358
--- /dev/null
+++ b/arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi
@@ -0,0 +1,153 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/ {
+   tegra_sound {
+   status = "disabled";
+
+   clocks = <_car TEGRA210_CLK_PLL_A>,
+<_car TEGRA210_CLK_PLL_A_OUT0>;
+   clock-names = "pll_a", "plla_out0";
+
+   assigned-clocks = <_car TEGRA210_CLK_PLL_A>,
+ <_car TEGRA210_CLK_PLL_A_OUT0>,
+ <_car TEGRA210_CLK_EXTERN1>;
+   assigned-clock-parents = <0>, <0>, <_car 
TEGRA210_CLK_PLL_A_OUT0>;
+   assigned-clock-rates = <36864>, <49152000>, <12288000>;
+   };
+};
+
+_admaif {
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   admaif1_port: port@0 {
+   reg = <0>;
+   admaif1_ep: endpoint {
+   remote-endpoint = <_admaif1_ep>;
+   };
+   };
+   admaif2_port: port@1 {
+   reg = <1>;
+   admaif2_ep: endpoint {
+   remote-endpoint = <_admaif2_ep>;
+   };
+   };
+   admaif3_port: port@2 {
+   reg = <2>;
+   admaif3_ep: endpoint {
+   remote-endpoint = <_admaif3_ep>;
+   };
+   };
+   admaif4_port: port@3 {
+   reg = <3>;
+   admaif4_ep: endpoint {
+   remote-endpoint = <_admaif4_ep>;
+   };
+   };
+   admaif5_port: port@4 {
+   reg = <4>;
+   admaif5_ep: endpoint {
+   remote-endpoint = <_admaif5_ep>;
+   };
+   };
+   admaif6_port: port@5 {
+   reg = <5>;
+   admaif6_ep: endpoint {
+   remote-endpoint = <_admaif6_ep>;
+   };
+   };
+   admaif7_port: port@6 {
+   reg = <6>;
+   admaif7_ep: endpoint {
+   remote-endpoint = <_admaif7_ep>;
+   };
+   };
+   admaif8_port: port@7 {
+   reg = <7>;
+   admaif8_ep: endpoint {
+   remote-endpoint = <_admaif8_ep>;
+   };
+   };
+   admaif9_port: port@8 {
+   reg = <8>;
+   admaif9_ep: endpoint {
+   remote-endpoint = <_admaif9_ep>;
+   };
+   };
+   admaif10_port: port@9 {
+   reg = <9>;
+   admaif10_ep: endpoint {
+   remote-endpoint = <_admaif10_ep>;
+   };
+   };
+   };
+};
+
+_ahub {
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0x0>;
+   xbar_admaif1_ep: endpoint {
+   remote-endpoint = <_ep>;
+   };
+   };
+   port@1 {
+   reg = <0x1>;
+   xbar_admaif2_ep: endpoint {
+   remote-endpoint = <_ep>;
+   };
+   };
+   port@2 {
+   reg = <0x2>;
+   xbar_admaif3_ep: endpoint {
+   remote-endpoint = <_ep>;
+   };
+   };
+   port@3 {
+   reg = <0x3>;
+   xbar_admai

[PATCH v6 3/6] ASoC: tegra: Add audio graph based card driver

2020-11-26 Thread Sameer Pujar
Add Tegra audio machine driver which is based on generic audio graph card
driver. It re-uses most of the common stuff from audio graph driver and
uses the same DT binding. Required Tegra specific customizations are done
in the driver and additional DT bindings are required for clock handling.

Details on the customizations done:

 - Update PLL rates at runtime: Tegra HW supports multiple sample rates
   (multiples of 8x and 11.025x) and both of these groups require different
   PLL rates. Hence there is a requirement to update this at runtime.
   This is achieved by providing a custom 'snd_soc_ops' and in hw_param()
   callback PLL rate is updated as per the sample rate.

 - Internal structure 'tegra_audio_graph_data' is used to maintain clock
   handles of PLL.

 - The 'force_dpcm' flag is set to use DPCM for all DAI links.

 - The 'component_chaining' flag is set to use DPCM with component model.

Signed-off-by: Sameer Pujar 
Reviewed-by: Jon Hunter 
---
 sound/soc/tegra/Kconfig  |   9 ++
 sound/soc/tegra/Makefile |   2 +
 sound/soc/tegra/tegra_audio_graph_card.c | 251 +++
 3 files changed, 262 insertions(+)
 create mode 100644 sound/soc/tegra/tegra_audio_graph_card.c

diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig
index a62cc87..6dc83ad 100644
--- a/sound/soc/tegra/Kconfig
+++ b/sound/soc/tegra/Kconfig
@@ -117,6 +117,15 @@ config SND_SOC_TEGRA210_ADMAIF
  channel. Buffer size is configurable for each ADMAIIF channel.
  Say Y or M if you want to add support for Tegra210 ADMAIF module.
 
+config SND_SOC_TEGRA_AUDIO_GRAPH_CARD
+   tristate "Audio Graph Card based Tegra driver"
+   depends on SND_AUDIO_GRAPH_CARD
+   help
+ Config to enable Tegra audio machine driver based on generic
+ audio graph driver. It is a thin driver written to customize
+ few things for Tegra audio. Most of the code is re-used from
+ audio graph driver and the same DT bindings are used.
+
 config SND_SOC_TEGRA_RT5640
tristate "SoC Audio support for Tegra boards using an RT5640 codec"
depends on SND_SOC_TEGRA && I2C && GPIOLIB
diff --git a/sound/soc/tegra/Makefile b/sound/soc/tegra/Makefile
index 60040a0..b17dd6e 100644
--- a/sound/soc/tegra/Makefile
+++ b/sound/soc/tegra/Makefile
@@ -38,6 +38,7 @@ snd-soc-tegra-trimslice-objs := trimslice.o
 snd-soc-tegra-alc5632-objs := tegra_alc5632.o
 snd-soc-tegra-max98090-objs := tegra_max98090.o
 snd-soc-tegra-sgtl5000-objs := tegra_sgtl5000.o
+snd-soc-tegra-audio-graph-card-objs := tegra_audio_graph_card.o
 
 obj-$(CONFIG_SND_SOC_TEGRA_RT5640) += snd-soc-tegra-rt5640.o
 obj-$(CONFIG_SND_SOC_TEGRA_RT5677) += snd-soc-tegra-rt5677.o
@@ -48,3 +49,4 @@ obj-$(CONFIG_SND_SOC_TEGRA_TRIMSLICE) += 
snd-soc-tegra-trimslice.o
 obj-$(CONFIG_SND_SOC_TEGRA_ALC5632) += snd-soc-tegra-alc5632.o
 obj-$(CONFIG_SND_SOC_TEGRA_MAX98090) += snd-soc-tegra-max98090.o
 obj-$(CONFIG_SND_SOC_TEGRA_SGTL5000) += snd-soc-tegra-sgtl5000.o
+obj-$(CONFIG_SND_SOC_TEGRA_AUDIO_GRAPH_CARD) += 
snd-soc-tegra-audio-graph-card.o
diff --git a/sound/soc/tegra/tegra_audio_graph_card.c 
b/sound/soc/tegra/tegra_audio_graph_card.c
new file mode 100644
index 000..9e43f16
--- /dev/null
+++ b/sound/soc/tegra/tegra_audio_graph_card.c
@@ -0,0 +1,251 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// tegra_audio_graph_card.c - Audio Graph based Tegra Machine Driver
+//
+// Copyright (c) 2020 NVIDIA CORPORATION.  All rights reserved.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MAX_PLLA_OUT0_DIV 128
+
+#define simple_to_tegra_priv(simple) \
+   container_of(simple, struct tegra_audio_priv, simple)
+
+enum srate_type {
+   /*
+* Sample rates multiple of 8000 Hz and below are supported:
+* ( 8000, 16000, 32000, 48000, 96000, 192000 Hz )
+*/
+   x8_RATE,
+
+   /*
+* Sample rates multiple of 11025 Hz and below are supported:
+* ( 11025, 22050, 44100, 88200, 176400 Hz )
+*/
+   x11_RATE,
+
+   NUM_RATE_TYPE,
+};
+
+struct tegra_audio_priv {
+   struct asoc_simple_priv simple;
+   struct clk *clk_plla_out0;
+   struct clk *clk_plla;
+};
+
+/* Tegra audio chip data */
+struct tegra_audio_cdata {
+   unsigned int plla_rates[NUM_RATE_TYPE];
+   unsigned int plla_out0_rates[NUM_RATE_TYPE];
+};
+
+/* Setup PLL clock as per the given sample rate */
+static int tegra_audio_graph_update_pll(struct snd_pcm_substream *substream,
+   struct snd_pcm_hw_params *params)
+{
+   struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+   struct asoc_simple_priv *simple = snd_soc_card_get_drvdata(rtd->card);
+   struct tegra_audio_priv *priv = simple_to_tegra_priv(simple);
+   struct device *dev = rtd->card->dev;
+   const struct tegra_audio_cdata *data = of_dev

[PATCH v6 4/6] arm64: defconfig: Enable Tegra audio graph card driver

2020-11-26 Thread Sameer Pujar
This commit enables Tegra audio graph card driver which is based on
the generic audio-graph card driver. This is intended to be used
on platforms based on Tegra210 and later chips.

Signed-off-by: Sameer Pujar 
Reviewed-by: Jon Hunter 
---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index c9246f5..1949593 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -725,6 +725,7 @@ CONFIG_SND_SOC_TEGRA210_DMIC=m
 CONFIG_SND_SOC_TEGRA210_I2S=m
 CONFIG_SND_SOC_TEGRA186_DSPK=m
 CONFIG_SND_SOC_TEGRA210_ADMAIF=m
+CONFIG_SND_SOC_TEGRA_AUDIO_GRAPH_CARD=m
 CONFIG_SND_SOC_AK4613=m
 CONFIG_SND_SOC_ES7134=m
 CONFIG_SND_SOC_ES7241=m
-- 
2.7.4



[PATCH v6 1/6] ASoC: dt-bindings: tegra: Add graph bindings

2020-11-26 Thread Sameer Pujar
Add device tree binding properties of generic graph to ASoC component
devices. This allows to define audio ports out of these components or
DAIs and audio graph based sound card can be realised with this.

Signed-off-by: Sameer Pujar 
Reviewed-by: Jon Hunter 
---
 .../bindings/sound/nvidia,tegra186-dspk.yaml   | 18 +-
 .../bindings/sound/nvidia,tegra210-admaif.yaml | 13 -
 .../bindings/sound/nvidia,tegra210-ahub.yaml   | 13 +++--
 .../bindings/sound/nvidia,tegra210-dmic.yaml   | 18 +-
 .../devicetree/bindings/sound/nvidia,tegra210-i2s.yaml | 18 +-
 5 files changed, 74 insertions(+), 6 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
index ed2fb32..b8645d9 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
@@ -17,6 +17,9 @@ maintainers:
   - Jon Hunter 
   - Sameer Pujar 
 
+allOf:
+  - $ref: audio-graph-port.yaml#
+
 properties:
   $nodename:
 pattern: "^dspk@[0-9a-f]*$"
@@ -55,6 +58,19 @@ properties:
   The name can be "DSPK1" or "DSPKx", where x depends on the maximum
   available instances on a Tegra SoC.
 
+  ports:
+type: object
+properties:
+  port@0:
+description: |
+  DSPK ACIF (Audio Client Interface) port connected to the
+  corresponding AHUB (Audio Hub) ACIF port.
+
+  port@1:
+description: |
+  DSPK DAP (Digital Audio Port) interface which can be connected
+  to external audio codec for playback.
+
 required:
   - compatible
   - reg
@@ -64,7 +80,7 @@ required:
   - assigned-clock-parents
   - sound-name-prefix
 
-additionalProperties: false
+unevaluatedProperties: false
 
 examples:
   - |
diff --git 
a/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml
index c028b25..7cee772 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml
@@ -17,6 +17,9 @@ maintainers:
   - Jon Hunter 
   - Sameer Pujar 
 
+allOf:
+  - $ref: audio-graph-port.yaml#
+
 properties:
   $nodename:
 pattern: "^admaif@[0-9a-f]*$"
@@ -37,6 +40,14 @@ properties:
 
   dma-names: true
 
+  ports:
+description: |
+  Contains list of ACIF (Audio CIF) port nodes for ADMAIF channels.
+  The number of port nodes depends on the number of ADMAIF channels
+  that SoC may have. These are interfaced with respective ACIF ports
+  in AHUB (Audio Hub). Each port is capable of data transfers in
+  both directions.
+
 if:
   properties:
 compatible:
@@ -81,7 +92,7 @@ required:
   - dmas
   - dma-names
 
-additionalProperties: false
+unevaluatedProperties: false
 
 examples:
   - |
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml
index d772197..31f3e51 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml
@@ -17,6 +17,9 @@ maintainers:
   - Jon Hunter 
   - Sameer Pujar 
 
+allOf:
+  - $ref: audio-graph-port.yaml#
+
 properties:
   $nodename:
 pattern: "^ahub@[0-9a-f]*$"
@@ -56,6 +59,13 @@ properties:
 
   ranges: true
 
+  ports:
+description: |
+  Contains list of ACIF (Audio CIF) port nodes for AHUB (Audio Hub).
+  These are connected to ACIF interfaces of AHUB clients. Thus the
+  number of port nodes depend on the number of clients that AHUB may
+  have depending on the SoC revision.
+
 required:
   - compatible
   - reg
@@ -67,8 +77,7 @@ required:
   - "#size-cells"
   - ranges
 
-additionalProperties:
-  type: object
+unevaluatedProperties: false
 
 examples:
   - |
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml
index 2a3207b..89f4f47 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml
@@ -16,6 +16,9 @@ maintainers:
   - Jon Hunter 
   - Sameer Pujar 
 
+allOf:
+  - $ref: audio-graph-port.yaml#
+
 properties:
   $nodename:
 pattern: "^dmic@[0-9a-f]*$"
@@ -56,6 +59,19 @@ properties:
   The name can be "DMIC1" or "DMIC2" ... "DMICx", where x depends
   on the maximum available instances on a Tegra SoC.
 
+  ports:
+type: object
+properties:
+  port@0:
+description: |
+  DMIC ACIF (Audio Client Interface) port connected to the
+  corresponding AHUB (Audio Hub) ACIF port.
+
+  port@

[PATCH v6 2/6] ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card

2020-11-26 Thread Sameer Pujar
Add YAML schema for Tegra audio graph sound card DT bindings. It uses the
same DT bindings provided by generic audio graph driver. Along with this
few standard clock DT bindings are added which are specifically required
for Tegra audio.

Signed-off-by: Sameer Pujar 
Reviewed-by: Jon Hunter 
---
 .../sound/nvidia,tegra-audio-graph-card.yaml   | 187 +
 1 file changed, 187 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml

diff --git 
a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
new file mode 100644
index 000..fc271f6
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
@@ -0,0 +1,187 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-graph-card.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Audio Graph based Tegra sound card driver
+
+description: |
+  This is based on generic audio graph card driver along with additional
+  customizations for Tegra platforms. It uses the same bindings with
+  additional standard clock DT bindings required for Tegra.
+
+maintainers:
+  - Jon Hunter 
+  - Sameer Pujar 
+
+allOf:
+  - $ref: audio-graph.yaml#
+
+properties:
+  compatible:
+enum:
+  - nvidia,tegra210-audio-graph-card
+  - nvidia,tegra186-audio-graph-card
+
+  clocks:
+minItems: 2
+
+  clock-names:
+minItems: 2
+items:
+  - const: pll_a
+  - const: plla_out0
+
+  assigned-clocks:
+minItems: 1
+maxItems: 3
+
+  assigned-clock-parents:
+minItems: 1
+maxItems: 3
+
+  assigned-clock-rates:
+minItems: 1
+maxItems: 3
+
+required:
+  - clocks
+  - clock-names
+  - assigned-clocks
+  - assigned-clock-parents
+
+unevaluatedProperties: false
+
+examples:
+  - |
+#include
+
+tegra_sound {
+compatible = "nvidia,tegra210-audio-graph-card";
+
+clocks = <_car TEGRA210_CLK_PLL_A>,
+ <_car TEGRA210_CLK_PLL_A_OUT0>;
+clock-names = "pll_a", "plla_out0";
+
+assigned-clocks = <_car TEGRA210_CLK_PLL_A>,
+  <_car TEGRA210_CLK_PLL_A_OUT0>,
+  <_car TEGRA210_CLK_EXTERN1>;
+assigned-clock-parents = <0>, <0>, <_car 
TEGRA210_CLK_PLL_A_OUT0>;
+assigned-clock-rates = <36864>, <49152000>, <12288000>;
+
+dais = /* FE */
+   <_port>,
+   /* Router */
+   <_i2s1_port>,
+   /* I/O DAP Ports */
+   <_port>;
+
+label = "jetson-tx1-ape";
+};
+
+// The ports are defined for AHUB and its child devices.
+ahub@702d0800 {
+compatible = "nvidia,tegra210-ahub";
+reg = <0x702d0800 0x800>;
+clocks = <_car TEGRA210_CLK_D_AUDIO>;
+clock-names = "ahub";
+assigned-clocks = <_car TEGRA210_CLK_D_AUDIO>;
+assigned-clock-parents = <_car TEGRA210_CLK_PLL_A_OUT0>;
+#address-cells = <1>;
+#size-cells = <1>;
+ranges = <0x702d 0x702d 0xe400>;
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+port@0 {
+reg = <0x0>;
+xbar_admaif1_ep: endpoint {
+remote-endpoint = <_ep>;
+};
+};
+
+// ...
+
+xbar_i2s1_port: port@a {
+reg = <0xa>;
+xbar_i2s1_ep: endpoint {
+remote-endpoint = <_cif_ep>;
+};
+};
+};
+
+admaif@702d {
+compatible = "nvidia,tegra210-admaif";
+reg = <0x702d 0x800>;
+dmas = < 1>,  < 1>,
+   < 2>,  < 2>,
+   < 3>,  < 3>,
+   < 4>,  < 4>,
+   < 5>,  < 5>,
+   < 6>,  < 6>,
+   < 7>,  < 7>,
+   < 8>,  < 8>,
+   < 9>,  < 9>,
+   < 10>, < 10>;
+dma-names = "rx1",  "tx1",
+"rx2",  "tx2",
+"rx3",  "tx3",
+"rx4",  "tx4",
+"rx5",  "tx5",
+"rx6",  "tx6",
+"rx7",  "tx7",
+"rx8&

Re: [PATCH v5 3/6] ASoC: tegra: Add audio graph based card driver

2020-11-23 Thread Sameer Pujar




Add Tegra audio machine driver which is based on generic audio graph card
driver. It re-uses most of the common stuff from audio graph driver and
uses the same DT binding. Required Tegra specific customizations are done
in the driver and additional DT bindings are required for clock handling.

Details on the customizations done:

  - Update PLL rates at runtime: Tegra HW supports multiple sample rates
(multiples of 8x and 11.025x) and both of these groups require different
PLL rates. Hence there is a requirement to update this at runtime.
This is achieved by providing a custom 'snd_soc_ops' and in hw_param()
callback PLL rate is updated as per the sample rate.

  - Internal structure 'tegra_audio_graph_data' is used to maintain clock
handles of PLL.

  - The 'force_dpcm' flag is set to use DPCM for all DAI links.

  - The 'component_chaining' flag is set to use DPCM with component model.

Signed-off-by: Sameer Pujar 
---
  sound/soc/tegra/Kconfig  |   9 ++
  sound/soc/tegra/Makefile |   2 +
  sound/soc/tegra/tegra_audio_graph_card.c | 255 +++
  3 files changed, 266 insertions(+)
  create mode 100644 sound/soc/tegra/tegra_audio_graph_card.c

diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig
index a62cc87..6dc83ad 100644
--- a/sound/soc/tegra/Kconfig
+++ b/sound/soc/tegra/Kconfig
@@ -117,6 +117,15 @@ config SND_SOC_TEGRA210_ADMAIF
  channel. Buffer size is configurable for each ADMAIIF channel.
  Say Y or M if you want to add support for Tegra210 ADMAIF module.
  
+config SND_SOC_TEGRA_AUDIO_GRAPH_CARD

+   tristate "Audio Graph Card based Tegra driver"
+   depends on SND_AUDIO_GRAPH_CARD
+   help
+ Config to enable Tegra audio machine driver based on generic
+ audio graph driver. It is a thin driver written to customize
+ few things for Tegra audio. Most of the code is re-used from
+ audio graph driver and the same DT bindings are used.
+
  config SND_SOC_TEGRA_RT5640
tristate "SoC Audio support for Tegra boards using an RT5640 codec"
depends on SND_SOC_TEGRA && I2C && GPIOLIB
diff --git a/sound/soc/tegra/Makefile b/sound/soc/tegra/Makefile
index 60040a0..b17dd6e 100644
--- a/sound/soc/tegra/Makefile
+++ b/sound/soc/tegra/Makefile
@@ -38,6 +38,7 @@ snd-soc-tegra-trimslice-objs := trimslice.o
  snd-soc-tegra-alc5632-objs := tegra_alc5632.o
  snd-soc-tegra-max98090-objs := tegra_max98090.o
  snd-soc-tegra-sgtl5000-objs := tegra_sgtl5000.o
+snd-soc-tegra-audio-graph-card-objs := tegra_audio_graph_card.o
  
  obj-$(CONFIG_SND_SOC_TEGRA_RT5640) += snd-soc-tegra-rt5640.o

  obj-$(CONFIG_SND_SOC_TEGRA_RT5677) += snd-soc-tegra-rt5677.o
@@ -48,3 +49,4 @@ obj-$(CONFIG_SND_SOC_TEGRA_TRIMSLICE) += 
snd-soc-tegra-trimslice.o
  obj-$(CONFIG_SND_SOC_TEGRA_ALC5632) += snd-soc-tegra-alc5632.o
  obj-$(CONFIG_SND_SOC_TEGRA_MAX98090) += snd-soc-tegra-max98090.o
  obj-$(CONFIG_SND_SOC_TEGRA_SGTL5000) += snd-soc-tegra-sgtl5000.o
+obj-$(CONFIG_SND_SOC_TEGRA_AUDIO_GRAPH_CARD) += 
snd-soc-tegra-audio-graph-card.o
diff --git a/sound/soc/tegra/tegra_audio_graph_card.c 
b/sound/soc/tegra/tegra_audio_graph_card.c
new file mode 100644
index 000..f4d826d
--- /dev/null
+++ b/sound/soc/tegra/tegra_audio_graph_card.c
@@ -0,0 +1,255 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// tegra_audio_graph_card.c - Audio Graph based Tegra Machine Driver
+//
+// Copyright (c) 2020 NVIDIA CORPORATION.  All rights reserved.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MAX_PLLA_OUT0_DIV 128
+
+#define simple_to_tegra_priv(simple) \
+   container_of(simple, struct tegra_audio_priv, simple)
+
+enum srate_type {
+   /*
+* Sample rates multiple of 8000 Hz and below are supported:
+* ( 8000, 16000, 32000, 48000, 96000, 192000 Hz )
+*/
+   x8_RATE,
+
+   /*
+* Sample rates multiple of 11025 Hz and below are supported:
+* ( 11025, 22050, 44100, 88200, 176400 Hz )
+*/
+   x11_RATE,
+
+   NUM_RATE_TYPE,
+};
+
+struct tegra_audio_priv {
+   struct asoc_simple_priv simple;
+   struct clk *clk_plla_out0;
+   struct clk *clk_plla;
+};
+
+/* Tegra audio chip data */
+struct tegra_audio_cdata {
+   unsigned int plla_rates[NUM_RATE_TYPE];
+   unsigned int plla_out0_rates[NUM_RATE_TYPE];
+};
+
+/* Setup PLL clock as per the given sample rate */
+static int tegra_audio_graph_update_pll(struct snd_pcm_substream *substream,
+   struct snd_pcm_hw_params *params)
+{
+   struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+   struct asoc_simple_priv *simple = snd_soc_card_get_drvdata(rtd->card);
+   struct tegra_audio_priv *priv = simple_to_tegra_priv(simple);
+   struct device *dev = rtd->card->dev;
+   const struct tegra_audio_cdata *data = of_dev

Re: [PATCH v5 1/6] ASoC: dt-bindings: tegra: Add graph bindings

2020-11-19 Thread Sameer Pujar

Hi Rob,


Add device tree binding properties of generic graph to ASoC component
devices. This allows to define audio ports out of these components or
DAIs and audio graph based sound card can be realised with this.

This is all dependent on graph.yaml being applied which hasn't happened
yet. I guess I'll need to provide a branch as there's multiple
subsystems needing it.


Signed-off-by: Sameer Pujar 
---
  .../devicetree/bindings/sound/nvidia,tegra186-dspk.yaml |  6 ++
  .../devicetree/bindings/sound/nvidia,tegra210-admaif.yaml   |  6 ++
  .../devicetree/bindings/sound/nvidia,tegra210-ahub.yaml | 13 +++--
  .../devicetree/bindings/sound/nvidia,tegra210-dmic.yaml |  6 ++
  .../devicetree/bindings/sound/nvidia,tegra210-i2s.yaml  |  6 ++
  5 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
index ed2fb32..3c9364d 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
@@ -55,6 +55,12 @@ properties:
The name can be "DSPK1" or "DSPKx", where x depends on the maximum
available instances on a Tegra SoC.




+  ports:
+$ref: /schemas/graph.yaml#/properties/ports

If you have 'ports', then that means you have multiple ports and you
have to enumerate what each port is.


+
+  port:
+$ref: /schemas/sound/audio-graph.yaml#/properties/port

If you only have 1 port then, you can use 'port'.


So listing both is an error.


Since "ASoC: graph card schema rework" series is merged now, referencing 
"audio-graph-port.yaml" should be sufficient here?


...


[PATCH 3/3] dt-bindings: tegra: Add missing HDA properties

2020-11-18 Thread Sameer Pujar
Document the missing properties which are currently required for
Tegra186/Tegra194 DT files.

Signed-off-by: Sameer Pujar 
---
 .../devicetree/bindings/sound/nvidia,tegra30-hda.yaml  | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml
index 3059bc3..e543a61 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml
@@ -60,6 +60,20 @@ properties:
   - const: hda2hdmi
   - const: hda2codec_2x
 
+  power-domains:
+maxItems: 1
+
+  interconnects:
+maxItems: 2
+
+  interconnect-names:
+items:
+  - const: dma-mem
+  - const: write
+
+  iommus:
+maxItems: 1
+
   nvidia,model:
 $ref: /schemas/types.yaml#/definitions/string
 description: |
-- 
2.7.4



[PATCH 2/3] dt-bindings: tegra: Convert HDA doc to json-schema

2020-11-18 Thread Sameer Pujar
Convert Tegra HDA doc to YAML format.

Signed-off-by: Sameer Pujar 
---
 .../bindings/sound/nvidia,tegra30-hda.txt  | 35 
 .../bindings/sound/nvidia,tegra30-hda.yaml | 98 ++
 2 files changed, 98 insertions(+), 35 deletions(-)
 delete mode 100644 
Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.txt
 create mode 100644 
Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml

diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.txt 
b/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.txt
deleted file mode 100644
index 21cd310..000
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-NVIDIA Tegra30 HDA controller
-
-Required properties:
-- compatible : For Tegra30, must contain "nvidia,tegra30-hda".  Otherwise,
-  must contain '"nvidia,-hda", "nvidia,tegra30-hda"', where  is
-  tegra114, tegra124, or tegra132.
-- reg : Should contain the HDA registers location and length.
-- interrupts : The interrupt from the HDA controller.
-- clocks : Must contain an entry for each required entry in clock-names.
-  See ../clocks/clock-bindings.txt for details.
-- clock-names : Must include the following entries: hda, hda2hdmi, hda2codec_2x
-- resets : Must contain an entry for each entry in reset-names.
-  See ../reset/reset.txt for details.
-- reset-names : Must include the following entries: hda, hda2hdmi, hda2codec_2x
-
-Optional properties:
-- nvidia,model : The user-visible name of this sound complex. Since the 
property
-  is optional, legacy boards can use default name provided in hda driver.
-
-Example:
-
-hda@7003 {
-   compatible = "nvidia,tegra124-hda", "nvidia,tegra30-hda";
-   reg = <0x0 0x7003 0x0 0x1>;
-   interrupts = ;
-   clocks = <_car TEGRA124_CLK_HDA>,
-<_car TEGRA124_CLK_HDA2HDMI>,
-<_car TEGRA124_CLK_HDA2CODEC_2X>;
-   clock-names = "hda", "hda2hdmi", "hda2codec_2x";
-   resets = <_car 125>, /* hda */
-<_car 128>, /* hda2hdmi */
-<_car 111>; /* hda2codec_2x */
-   reset-names = "hda", "hda2hdmi", "hda2codec_2x";
-   nvidia,model = "jetson-tk1-hda";
-};
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml
new file mode 100644
index 000..3059bc3
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml
@@ -0,0 +1,98 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/nvidia,tegra30-hda.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVIDIA Tegra HDA controller
+
+description: |
+  The High Definition Audio (HDA) block provides a serial interface to
+  audio codec. It supports multiple input and output streams.
+
+maintainers:
+  - Thierry Reding 
+  - Jon Hunter 
+
+properties:
+  $nodename:
+pattern: "^hda@[0-9a-f]*$"
+
+  compatible:
+oneOf:
+  - const: nvidia,tegra30-hda
+  - items:
+  - enum:
+  - nvidia,tegra194-hda
+  - nvidia,tegra186-hda
+  - nvidia,tegra210-hda
+  - nvidia,tegra124-hda
+  - const: nvidia,tegra30-hda
+  - items:
+  - const: nvidia,tegra132-hda
+  - const: nvidia,tegra124-hda
+  - const: nvidia,tegra30-hda
+
+  reg:
+maxItems: 1
+
+  interrupts:
+description: The interrupt from the HDA controller
+maxItems: 1
+
+  clocks:
+maxItems: 3
+
+  clock-names:
+maxItems: 3
+items:
+  - const: hda
+  - const: hda2hdmi
+  - const: hda2codec_2x
+
+  resets:
+maxItems: 3
+
+  reset-names:
+maxItems: 3
+items:
+  - const: hda
+  - const: hda2hdmi
+  - const: hda2codec_2x
+
+  nvidia,model:
+$ref: /schemas/types.yaml#/definitions/string
+description: |
+  The user-visible name of this sound complex. If this property is
+  not specified then boards can use default name provided in hda driver.
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+
+additionalProperties: false
+
+examples:
+  - |
+#include
+#include
+
+hda@7003 {
+compatible = "nvidia,tegra124-hda", "nvidia,tegra30-hda";
+reg = <0x7003 0x1>;
+interrupts = ;
+clocks = <_car TEGRA124_CLK_HDA>,
+ <_car TEGRA124_CLK_HDA2HDMI>,
+ <_car TEGRA124_CLK_HDA2CODEC_2X>;
+clock-names = "hda", "hda2hdmi", "hda2codec_2x";
+resets = <_car 125>, /* hda */
+ <_car 128>, /* hda2hdmi */
+ <_car 111>; /* hda2codec_2x */
+reset-names = "hda", "hda2hdmi", "hda2codec_2x";
+nvidia,model = "jetson-tk1-hda";
+};
+
+...
-- 
2.7.4



[PATCH 1/3] arm64: tegra: Fix Tegra194 HDA {clock,reset}-names ordering

2020-11-18 Thread Sameer Pujar
As per the HDA binding doc reorder {clock,reset}-names entries for
Tegra194. This also serves as a preparation for converting existing
binding doc to json-schema.

Signed-off-by: Sameer Pujar 
---
 arch/arm64/boot/dts/nvidia/tegra194.dtsi | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/boot/dts/nvidia/tegra194.dtsi 
b/arch/arm64/boot/dts/nvidia/tegra194.dtsi
index 6946fb2..e3cab26 100644
--- a/arch/arm64/boot/dts/nvidia/tegra194.dtsi
+++ b/arch/arm64/boot/dts/nvidia/tegra194.dtsi
@@ -782,13 +782,13 @@
reg = <0x351 0x1>;
interrupts = ;
clocks = < TEGRA194_CLK_HDA>,
-< TEGRA194_CLK_HDA2CODEC_2X>,
-< TEGRA194_CLK_HDA2HDMICODEC>;
-   clock-names = "hda", "hda2codec_2x", "hda2hdmi";
+< TEGRA194_CLK_HDA2HDMICODEC>,
+< TEGRA194_CLK_HDA2CODEC_2X>;
+   clock-names = "hda", "hda2hdmi", "hda2codec_2x";
resets = < TEGRA194_RESET_HDA>,
-< TEGRA194_RESET_HDA2CODEC_2X>,
-< TEGRA194_RESET_HDA2HDMICODEC>;
-   reset-names = "hda", "hda2codec_2x", "hda2hdmi";
+< TEGRA194_RESET_HDA2HDMICODEC>,
+< TEGRA194_RESET_HDA2CODEC_2X>;
+   reset-names = "hda", "hda2hdmi", "hda2codec_2x";
power-domains = < TEGRA194_POWER_DOMAIN_DISP>;
interconnects = < TEGRA194_MEMORY_CLIENT_HDAR >,
< TEGRA194_MEMORY_CLIENT_HDAW >;
-- 
2.7.4



[PATCH 0/3] Convert Tegra HDA doc to json-schema

2020-11-18 Thread Sameer Pujar
Fix Tegra194 DT and convert Tegra HDA doc to YAML format. Ran binding
validation checks to ensure there are no warnings/errors for HDA.

Sameer Pujar (3):
  arm64: tegra: Fix Tegra194 HDA {clock,reset}-names ordering
  dt-bindings: tegra: Convert HDA doc to json-schema
  dt-bindings: tegra: Add missing HDA properties

 .../bindings/sound/nvidia,tegra30-hda.txt  |  35 ---
 .../bindings/sound/nvidia,tegra30-hda.yaml | 112 +
 arch/arm64/boot/dts/nvidia/tegra194.dtsi   |  12 +--
 3 files changed, 118 insertions(+), 41 deletions(-)
 delete mode 100644 
Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.txt
 create mode 100644 
Documentation/devicetree/bindings/sound/nvidia,tegra30-hda.yaml

-- 
2.7.4



[PATCH v5 4/6] arm64: defconfig: Enable Tegra audio graph card driver

2020-11-11 Thread Sameer Pujar
This commit enables Tegra audio graph card driver which is based on
the generic audio-graph card driver. This is intended to be used
on platforms based on Tegra210 and later chips.

Signed-off-by: Sameer Pujar 
---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
index c5f404c..e07dea93 100644
--- a/arch/arm64/configs/defconfig
+++ b/arch/arm64/configs/defconfig
@@ -722,6 +722,7 @@ CONFIG_SND_SOC_TEGRA210_DMIC=m
 CONFIG_SND_SOC_TEGRA210_I2S=m
 CONFIG_SND_SOC_TEGRA186_DSPK=m
 CONFIG_SND_SOC_TEGRA210_ADMAIF=m
+CONFIG_SND_SOC_TEGRA_AUDIO_GRAPH_CARD=m
 CONFIG_SND_SOC_AK4613=m
 CONFIG_SND_SOC_ES7134=m
 CONFIG_SND_SOC_ES7241=m
-- 
2.7.4



[PATCH v5 6/6] arm64: tegra: Audio graph sound card for Jetson Nano and TX1

2020-11-11 Thread Sameer Pujar
Enable support for audio-graph based sound card on Jetson-Nano and
Jetson-TX1. Depending on the platform, required I/O interfaces are
enabled.

 * Jetson-Nano: Enable I2S3, I2S4, DMIC1 and DMIC2.
 * Jetson-TX1: Enable all I2S and DMIC interfaces.

Signed-off-by: Sameer Pujar 
---
 arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts | 262 +
 arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts | 146 
 2 files changed, 408 insertions(+)

diff --git a/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts 
b/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts
index 69102dc..747ab93 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts
+++ b/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts
@@ -3,6 +3,7 @@
 
 #include "tegra210-p2180.dtsi"
 #include "tegra210-p2597.dtsi"
+#include "tegra210-audio-graph.dtsi"
 
 / {
model = "NVIDIA Jetson TX1 Developer Kit";
@@ -127,4 +128,265 @@
status = "okay";
};
};
+
+   tegra_sound {
+   status = "okay";
+
+   compatible = "nvidia,tegra210-audio-graph-card";
+
+   dais = /* FE */
+  <_port>, <_port>, <_port>,
+  <_port>, <_port>, <_port>,
+  <_port>, <_port>, <_port>,
+  <_port>,
+  /* Router */
+  <_i2s1_port>, <_i2s2_port>, <_i2s3_port>,
+  <_i2s4_port>, <_i2s5_port>, <_dmic1_port>,
+  <_dmic2_port>, <_dmic3_port>,
+  /* I/O DAP Ports */
+  <_port>, <_port>, <_port>, <_port>,
+  <_port>, <_port>, <_port>, 
<_port>;
+
+   label = "jetson-tx1-ape";
+   };
+};
+
+_admaif {
+   status = "okay";
+};
+
+_ahub {
+   status = "okay";
+
+   ports {
+   xbar_i2s1_port: port@a {
+   reg = <0xa>;
+   xbar_i2s1_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_i2s2_port: port@b {
+   reg = <0xb>;
+   xbar_i2s2_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_i2s3_port: port@c {
+   reg = <0xc>;
+   xbar_i2s3_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_i2s4_port: port@d {
+   reg = <0xd>;
+   xbar_i2s4_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_i2s5_port: port@e {
+   reg = <0xe>;
+   xbar_i2s5_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_dmic1_port: port@f {
+   reg = <0xf>;
+   xbar_dmic1_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_dmic2_port: port@10 {
+   reg = <0x10>;
+   xbar_dmic2_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   xbar_dmic3_port: port@11 {
+   reg = <0x11>;
+   xbar_dmic3_ep: endpoint {
+   remote-endpoint = <_cif_ep>;
+   };
+   };
+   };
+};
+
+_i2s1 {
+   status = "okay";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0>;
+   i2s1_cif_ep: endpoint {
+   remote-endpoint = <_i2s1_ep>;
+   };
+   };
+   i2s1_port: port@1 {
+   reg = <1>;
+   i2s1_dap_ep: endpoint {
+   dai-format = "i2s";
+   /* Placeholder for external Codec */
+   };
+   };
+   };
+};
+
+_i2s2 {
+   status = "okay";
+
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0

[PATCH v5 5/6] arm64: tegra: Audio graph header for Tegra210

2020-11-11 Thread Sameer Pujar
Expose a header which describes DT bindings required to use audio-graph
based sound card. All Tegra210 based platforms can include this header
and add platform specific information. Currently, from SoC point of view,
all links are exposed for ADMAIF, AHUB, I2S and DMIC components.

Signed-off-by: Sameer Pujar 
---
 .../boot/dts/nvidia/tegra210-audio-graph.dtsi  | 153 +
 1 file changed, 153 insertions(+)
 create mode 100644 arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi

diff --git a/arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi 
b/arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi
new file mode 100644
index 000..5c54358
--- /dev/null
+++ b/arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi
@@ -0,0 +1,153 @@
+// SPDX-License-Identifier: GPL-2.0
+
+/ {
+   tegra_sound {
+   status = "disabled";
+
+   clocks = <_car TEGRA210_CLK_PLL_A>,
+<_car TEGRA210_CLK_PLL_A_OUT0>;
+   clock-names = "pll_a", "plla_out0";
+
+   assigned-clocks = <_car TEGRA210_CLK_PLL_A>,
+ <_car TEGRA210_CLK_PLL_A_OUT0>,
+ <_car TEGRA210_CLK_EXTERN1>;
+   assigned-clock-parents = <0>, <0>, <_car 
TEGRA210_CLK_PLL_A_OUT0>;
+   assigned-clock-rates = <36864>, <49152000>, <12288000>;
+   };
+};
+
+_admaif {
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   admaif1_port: port@0 {
+   reg = <0>;
+   admaif1_ep: endpoint {
+   remote-endpoint = <_admaif1_ep>;
+   };
+   };
+   admaif2_port: port@1 {
+   reg = <1>;
+   admaif2_ep: endpoint {
+   remote-endpoint = <_admaif2_ep>;
+   };
+   };
+   admaif3_port: port@2 {
+   reg = <2>;
+   admaif3_ep: endpoint {
+   remote-endpoint = <_admaif3_ep>;
+   };
+   };
+   admaif4_port: port@3 {
+   reg = <3>;
+   admaif4_ep: endpoint {
+   remote-endpoint = <_admaif4_ep>;
+   };
+   };
+   admaif5_port: port@4 {
+   reg = <4>;
+   admaif5_ep: endpoint {
+   remote-endpoint = <_admaif5_ep>;
+   };
+   };
+   admaif6_port: port@5 {
+   reg = <5>;
+   admaif6_ep: endpoint {
+   remote-endpoint = <_admaif6_ep>;
+   };
+   };
+   admaif7_port: port@6 {
+   reg = <6>;
+   admaif7_ep: endpoint {
+   remote-endpoint = <_admaif7_ep>;
+   };
+   };
+   admaif8_port: port@7 {
+   reg = <7>;
+   admaif8_ep: endpoint {
+   remote-endpoint = <_admaif8_ep>;
+   };
+   };
+   admaif9_port: port@8 {
+   reg = <8>;
+   admaif9_ep: endpoint {
+   remote-endpoint = <_admaif9_ep>;
+   };
+   };
+   admaif10_port: port@9 {
+   reg = <9>;
+   admaif10_ep: endpoint {
+   remote-endpoint = <_admaif10_ep>;
+   };
+   };
+   };
+};
+
+_ahub {
+   ports {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   port@0 {
+   reg = <0x0>;
+   xbar_admaif1_ep: endpoint {
+   remote-endpoint = <_ep>;
+   };
+   };
+   port@1 {
+   reg = <0x1>;
+   xbar_admaif2_ep: endpoint {
+   remote-endpoint = <_ep>;
+   };
+   };
+   port@2 {
+   reg = <0x2>;
+   xbar_admaif3_ep: endpoint {
+   remote-endpoint = <_ep>;
+   };
+   };
+   port@3 {
+   reg = <0x3>;
+   xbar_admaif4_ep: 

[PATCH v5 2/6] ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card

2020-11-11 Thread Sameer Pujar
Add YAML schema for Tegra audio graph sound card DT bindings. It uses the
same DT bindings provided by generic audio graph driver. Along with this
few standard clock DT bindings are added which are specifically required
for Tegra audio.

Signed-off-by: Sameer Pujar 
---
 .../sound/nvidia,tegra-audio-graph-card.yaml   | 187 +
 1 file changed, 187 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml

diff --git 
a/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
new file mode 100644
index 000..0987ee5
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
@@ -0,0 +1,187 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/sound/nvidia,tegra-audio-graph-card.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Audio Graph based Tegra sound card driver
+
+description: |
+  This is based on generic audio graph card driver along with additional
+  customizations for Tegra platforms. It uses the same bindings with
+  additional standard clock DT bindings required for Tegra.
+
+maintainers:
+  - Jon Hunter 
+  - Sameer Pujar 
+
+allOf:
+  - $ref: "audio-graph.yaml#"
+
+properties:
+  compatible:
+enum:
+  - nvidia,tegra210-audio-graph-card
+  - nvidia,tegra186-audio-graph-card
+
+  clocks:
+minItems: 2
+
+  clock-names:
+minItems: 2
+items:
+  - const: pll_a
+  - const: plla_out0
+
+  assigned-clocks:
+minItems: 1
+maxItems: 3
+
+  assigned-clock-parents:
+minItems: 1
+maxItems: 3
+
+  assigned-clock-rates:
+minItems: 1
+maxItems: 3
+
+required:
+  - clocks
+  - clock-names
+  - assigned-clocks
+  - assigned-clock-parents
+
+unevaluatedProperties: false
+
+examples:
+  - |
+#include
+
+tegra_sound {
+compatible = "nvidia,tegra210-audio-graph-card";
+
+clocks = <_car TEGRA210_CLK_PLL_A>,
+ <_car TEGRA210_CLK_PLL_A_OUT0>;
+clock-names = "pll_a", "plla_out0";
+
+assigned-clocks = <_car TEGRA210_CLK_PLL_A>,
+  <_car TEGRA210_CLK_PLL_A_OUT0>,
+  <_car TEGRA210_CLK_EXTERN1>;
+assigned-clock-parents = <0>, <0>, <_car 
TEGRA210_CLK_PLL_A_OUT0>;
+assigned-clock-rates = <36864>, <49152000>, <12288000>;
+
+dais = /* FE */
+   <_port>,
+   /* Router */
+   <_i2s1_port>,
+   /* I/O DAP Ports */
+   <_port>;
+
+label = "jetson-tx1-ape";
+};
+
+// The ports are defined for AHUB and its child devices.
+ahub@702d0800 {
+compatible = "nvidia,tegra210-ahub";
+reg = <0x702d0800 0x800>;
+clocks = <_car TEGRA210_CLK_D_AUDIO>;
+clock-names = "ahub";
+assigned-clocks = <_car TEGRA210_CLK_D_AUDIO>;
+assigned-clock-parents = <_car TEGRA210_CLK_PLL_A_OUT0>;
+#address-cells = <1>;
+#size-cells = <1>;
+ranges = <0x702d 0x702d 0xe400>;
+
+ports {
+#address-cells = <1>;
+#size-cells = <0>;
+
+port@0 {
+reg = <0x0>;
+xbar_admaif1_ep: endpoint {
+remote-endpoint = <_ep>;
+};
+};
+
+// ...
+
+xbar_i2s1_port: port@a {
+reg = <0xa>;
+xbar_i2s1_ep: endpoint {
+remote-endpoint = <_cif_ep>;
+};
+};
+};
+
+admaif@702d {
+compatible = "nvidia,tegra210-admaif";
+reg = <0x702d 0x800>;
+dmas = < 1>,  < 1>,
+   < 2>,  < 2>,
+   < 3>,  < 3>,
+   < 4>,  < 4>,
+   < 5>,  < 5>,
+   < 6>,  < 6>,
+   < 7>,  < 7>,
+   < 8>,  < 8>,
+   < 9>,  < 9>,
+   < 10>, < 10>;
+dma-names = "rx1",  "tx1",
+"rx2",  "tx2",
+"rx3",  "tx3",
+"rx4",  "tx4",
+"rx5",  "tx5",
+"rx6",  "tx6",
+"rx7",  "tx7",
+"rx8

[PATCH v5 1/6] ASoC: dt-bindings: tegra: Add graph bindings

2020-11-11 Thread Sameer Pujar
Add device tree binding properties of generic graph to ASoC component
devices. This allows to define audio ports out of these components or
DAIs and audio graph based sound card can be realised with this.

Signed-off-by: Sameer Pujar 
---
 .../devicetree/bindings/sound/nvidia,tegra186-dspk.yaml |  6 ++
 .../devicetree/bindings/sound/nvidia,tegra210-admaif.yaml   |  6 ++
 .../devicetree/bindings/sound/nvidia,tegra210-ahub.yaml | 13 +++--
 .../devicetree/bindings/sound/nvidia,tegra210-dmic.yaml |  6 ++
 .../devicetree/bindings/sound/nvidia,tegra210-i2s.yaml  |  6 ++
 5 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
index ed2fb32..3c9364d 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra186-dspk.yaml
@@ -55,6 +55,12 @@ properties:
   The name can be "DSPK1" or "DSPKx", where x depends on the maximum
   available instances on a Tegra SoC.
 
+  ports:
+$ref: /schemas/graph.yaml#/properties/ports
+
+  port:
+$ref: /schemas/sound/audio-graph.yaml#/properties/port
+
 required:
   - compatible
   - reg
diff --git 
a/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml
index c028b25..162823d 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra210-admaif.yaml
@@ -37,6 +37,12 @@ properties:
 
   dma-names: true
 
+  ports:
+$ref: /schemas/graph.yaml#/properties/ports
+
+  port:
+$ref: /schemas/sound/audio-graph.yaml#/properties/port
+
 if:
   properties:
 compatible:
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml
index d772197..59cd1f1 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra210-ahub.yaml
@@ -56,6 +56,16 @@ properties:
 
   ranges: true
 
+  ports:
+$ref: /schemas/graph.yaml#/properties/ports
+
+  port:
+$ref: /schemas/sound/audio-graph.yaml#/properties/port
+
+patternProperties:
+  "@[0-9a-f]+$":
+type: object
+
 required:
   - compatible
   - reg
@@ -67,8 +77,7 @@ required:
   - "#size-cells"
   - ranges
 
-additionalProperties:
-  type: object
+additionalProperties: false
 
 examples:
   - |
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml
index 2a3207b..b16bf5e 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra210-dmic.yaml
@@ -56,6 +56,12 @@ properties:
   The name can be "DMIC1" or "DMIC2" ... "DMICx", where x depends
   on the maximum available instances on a Tegra SoC.
 
+  ports:
+$ref: /schemas/graph.yaml#/properties/ports
+
+  port:
+$ref: /schemas/sound/audio-graph.yaml#/properties/port
+
 required:
   - compatible
   - reg
diff --git a/Documentation/devicetree/bindings/sound/nvidia,tegra210-i2s.yaml 
b/Documentation/devicetree/bindings/sound/nvidia,tegra210-i2s.yaml
index dfc1bf7..598f763 100644
--- a/Documentation/devicetree/bindings/sound/nvidia,tegra210-i2s.yaml
+++ b/Documentation/devicetree/bindings/sound/nvidia,tegra210-i2s.yaml
@@ -74,6 +74,12 @@ properties:
   The name can be "I2S1" or "I2S2" ... "I2Sx", where x depends
   on the maximum available instances on a Tegra SoC.
 
+  ports:
+$ref: /schemas/graph.yaml#/properties/ports
+
+  port:
+$ref: /schemas/sound/audio-graph.yaml#/properties/port
+
 required:
   - compatible
   - reg
-- 
2.7.4



[PATCH v5 3/6] ASoC: tegra: Add audio graph based card driver

2020-11-11 Thread Sameer Pujar
Add Tegra audio machine driver which is based on generic audio graph card
driver. It re-uses most of the common stuff from audio graph driver and
uses the same DT binding. Required Tegra specific customizations are done
in the driver and additional DT bindings are required for clock handling.

Details on the customizations done:

 - Update PLL rates at runtime: Tegra HW supports multiple sample rates
   (multiples of 8x and 11.025x) and both of these groups require different
   PLL rates. Hence there is a requirement to update this at runtime.
   This is achieved by providing a custom 'snd_soc_ops' and in hw_param()
   callback PLL rate is updated as per the sample rate.

 - Internal structure 'tegra_audio_graph_data' is used to maintain clock
   handles of PLL.

 - The 'force_dpcm' flag is set to use DPCM for all DAI links.

 - The 'component_chaining' flag is set to use DPCM with component model.

Signed-off-by: Sameer Pujar 
---
 sound/soc/tegra/Kconfig  |   9 ++
 sound/soc/tegra/Makefile |   2 +
 sound/soc/tegra/tegra_audio_graph_card.c | 255 +++
 3 files changed, 266 insertions(+)
 create mode 100644 sound/soc/tegra/tegra_audio_graph_card.c

diff --git a/sound/soc/tegra/Kconfig b/sound/soc/tegra/Kconfig
index a62cc87..6dc83ad 100644
--- a/sound/soc/tegra/Kconfig
+++ b/sound/soc/tegra/Kconfig
@@ -117,6 +117,15 @@ config SND_SOC_TEGRA210_ADMAIF
  channel. Buffer size is configurable for each ADMAIIF channel.
  Say Y or M if you want to add support for Tegra210 ADMAIF module.
 
+config SND_SOC_TEGRA_AUDIO_GRAPH_CARD
+   tristate "Audio Graph Card based Tegra driver"
+   depends on SND_AUDIO_GRAPH_CARD
+   help
+ Config to enable Tegra audio machine driver based on generic
+ audio graph driver. It is a thin driver written to customize
+ few things for Tegra audio. Most of the code is re-used from
+ audio graph driver and the same DT bindings are used.
+
 config SND_SOC_TEGRA_RT5640
tristate "SoC Audio support for Tegra boards using an RT5640 codec"
depends on SND_SOC_TEGRA && I2C && GPIOLIB
diff --git a/sound/soc/tegra/Makefile b/sound/soc/tegra/Makefile
index 60040a0..b17dd6e 100644
--- a/sound/soc/tegra/Makefile
+++ b/sound/soc/tegra/Makefile
@@ -38,6 +38,7 @@ snd-soc-tegra-trimslice-objs := trimslice.o
 snd-soc-tegra-alc5632-objs := tegra_alc5632.o
 snd-soc-tegra-max98090-objs := tegra_max98090.o
 snd-soc-tegra-sgtl5000-objs := tegra_sgtl5000.o
+snd-soc-tegra-audio-graph-card-objs := tegra_audio_graph_card.o
 
 obj-$(CONFIG_SND_SOC_TEGRA_RT5640) += snd-soc-tegra-rt5640.o
 obj-$(CONFIG_SND_SOC_TEGRA_RT5677) += snd-soc-tegra-rt5677.o
@@ -48,3 +49,4 @@ obj-$(CONFIG_SND_SOC_TEGRA_TRIMSLICE) += 
snd-soc-tegra-trimslice.o
 obj-$(CONFIG_SND_SOC_TEGRA_ALC5632) += snd-soc-tegra-alc5632.o
 obj-$(CONFIG_SND_SOC_TEGRA_MAX98090) += snd-soc-tegra-max98090.o
 obj-$(CONFIG_SND_SOC_TEGRA_SGTL5000) += snd-soc-tegra-sgtl5000.o
+obj-$(CONFIG_SND_SOC_TEGRA_AUDIO_GRAPH_CARD) += 
snd-soc-tegra-audio-graph-card.o
diff --git a/sound/soc/tegra/tegra_audio_graph_card.c 
b/sound/soc/tegra/tegra_audio_graph_card.c
new file mode 100644
index 000..f4d826d
--- /dev/null
+++ b/sound/soc/tegra/tegra_audio_graph_card.c
@@ -0,0 +1,255 @@
+// SPDX-License-Identifier: GPL-2.0-only
+//
+// tegra_audio_graph_card.c - Audio Graph based Tegra Machine Driver
+//
+// Copyright (c) 2020 NVIDIA CORPORATION.  All rights reserved.
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MAX_PLLA_OUT0_DIV 128
+
+#define simple_to_tegra_priv(simple) \
+   container_of(simple, struct tegra_audio_priv, simple)
+
+enum srate_type {
+   /*
+* Sample rates multiple of 8000 Hz and below are supported:
+* ( 8000, 16000, 32000, 48000, 96000, 192000 Hz )
+*/
+   x8_RATE,
+
+   /*
+* Sample rates multiple of 11025 Hz and below are supported:
+* ( 11025, 22050, 44100, 88200, 176400 Hz )
+*/
+   x11_RATE,
+
+   NUM_RATE_TYPE,
+};
+
+struct tegra_audio_priv {
+   struct asoc_simple_priv simple;
+   struct clk *clk_plla_out0;
+   struct clk *clk_plla;
+};
+
+/* Tegra audio chip data */
+struct tegra_audio_cdata {
+   unsigned int plla_rates[NUM_RATE_TYPE];
+   unsigned int plla_out0_rates[NUM_RATE_TYPE];
+};
+
+/* Setup PLL clock as per the given sample rate */
+static int tegra_audio_graph_update_pll(struct snd_pcm_substream *substream,
+   struct snd_pcm_hw_params *params)
+{
+   struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream);
+   struct asoc_simple_priv *simple = snd_soc_card_get_drvdata(rtd->card);
+   struct tegra_audio_priv *priv = simple_to_tegra_priv(simple);
+   struct device *dev = rtd->card->dev;
+   const struct tegra_audio_cdata *data = of_device_get_match_data(dev);
+  

[PATCH v5 0/6] Tegra210 audio graph card

2020-11-11 Thread Sameer Pujar
This series adds audio graph based sound card support for Tegra210
platforms like Jetson-TX1 an Jetson-Nano. The following preparatory
audio graph enhancement series is already merged.
 * https://patchwork.kernel.org/project/alsa-devel/list/?series=375629=*

Following are the summary of changes:
 * Add graph/audio-graph based schemas or schema updates for Tegra210
   component and machine drivers.
 * Add Tegra audio graph machine driver.
 * Add required DT support for Jetson-TX1/Nano.

This work is based on earlier discussion of DPCM usage for Tegra
and simple card driver updates.
 * https://lkml.org/lkml/2020/4/30/519
 * https://lkml.org/lkml/2020/6/27/4

This series has dependency over following graph and audio-graph series.
 * 
http://patchwork.ozlabs.org/project/devicetree-bindings/patch/20201102203656.220187-2-r...@kernel.org/
 * https://patchwork.kernel.org/project/alsa-devel/list/?series=382009=*

Changelog
=

v4 -> v5

 * Audio graph related changes were sent in separate v5 series as
   mentioned above and are dropped from current series.
 * Graph and audio graph doc patches are dropped from this series
   and are sent separately as mentioned above.
 * Minor change with phandle label for TX1 and Nano platform DT files.
 * No changes in other patches.

v3 -> v4

 * Added new patches to convert graph.txt and audio-graph-card.txt
   to corresponding json-schema files. Later these references
   are used in Tegra audio graph schema.

 * AHUB component binding docs are updated to reflect the usage
   of ports/port/endpoint

 * More common stuff is moved into graph_parse_of() and this is
   used by both generic and Tegra audio graph.

 * DT binding for Tegra audio graph is updated to included "ports { }"

 * As per the suggestion 'void *data' member is dropped from
   'asoc_simple_priv' and instead container method is used to
   maintain required custom data internal to Tegra audio graph. 

v2 -> v3

 * Dropped new compatible addition in generic graph driver
   after reviewing it with Morimoto-san. Instead added Tegra
   audio graph driver and new compatibles are added in the same.
 * Added new patches to expose new members for customization
   in audio graph driver.
 * Added new patch for Tegra audio graph driver and related
   documentation.
 * Minor change in below commit where mutex version of helper is used
   "ASoC: audio-graph: Identify 'no_pcm' DAI links for DPCM"
 * DT binding is updated to use the newly exposed compatibles
 * No changes in other patches

v1 -> v2

 * Re-organized ports/endpoints description for ADMAIF and XBAR.
   Updated DT patches accordingly.
 * After above change, multiple Codec endpoint support is not
   required and hence dropped for now. This will be considered
   separately if at all required in future.
 * Re-ordered patches in the series.


Sameer Pujar (6):
  ASoC: dt-bindings: tegra: Add graph bindings
  ASoC: dt-bindings: tegra: Add json-schema for Tegra audio graph card
  ASoC: tegra: Add audio graph based card driver
  arm64: defconfig: Enable Tegra audio graph card driver
  arm64: tegra: Audio graph header for Tegra210
  arm64: tegra: Audio graph sound card for Jetson Nano and TX1

 .../sound/nvidia,tegra-audio-graph-card.yaml   | 187 +++
 .../bindings/sound/nvidia,tegra186-dspk.yaml   |   6 +
 .../bindings/sound/nvidia,tegra210-admaif.yaml |   6 +
 .../bindings/sound/nvidia,tegra210-ahub.yaml   |  13 +-
 .../bindings/sound/nvidia,tegra210-dmic.yaml   |   6 +
 .../bindings/sound/nvidia,tegra210-i2s.yaml|   6 +
 .../boot/dts/nvidia/tegra210-audio-graph.dtsi  | 153 
 arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts | 262 +
 arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts | 146 
 arch/arm64/configs/defconfig   |   1 +
 sound/soc/tegra/Kconfig|   9 +
 sound/soc/tegra/Makefile   |   2 +
 sound/soc/tegra/tegra_audio_graph_card.c   | 255 
 13 files changed, 1050 insertions(+), 2 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/sound/nvidia,tegra-audio-graph-card.yaml
 create mode 100644 arch/arm64/boot/dts/nvidia/tegra210-audio-graph.dtsi
 create mode 100644 sound/soc/tegra/tegra_audio_graph_card.c

-- 
2.7.4



[PATCH 0/2] Refactor Audio Graph schema

2020-11-11 Thread Sameer Pujar
There can be custom sound cards reusing most of the audio-graph
implementation. To allow this refactor the audio-graph-card schema into
following files.
 * audio-graph.yaml   : defines all common bindings
 * audio-graph-card.yaml  : define compatible property

Custom sound cards can just reference 'audio-graph.yaml' and define its
own compatible and specific properties.

This depends on following series:
http://patchwork.ozlabs.org/project/devicetree-bindings/patch/20201102203656.220187-2-r...@kernel.org/

Sameer Pujar (2):
  ASoC: audio-graph-card: Refactor schema
  ASoC: renesas,rsnd: Update audio graph references

 .../bindings/sound/audio-graph-card.yaml   | 102 +---
 .../devicetree/bindings/sound/audio-graph.yaml | 107 +
 .../devicetree/bindings/sound/renesas,rsnd.yaml|   6 +-
 3 files changed, 112 insertions(+), 103 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/audio-graph.yaml

-- 
2.7.4



[PATCH 1/2] ASoC: audio-graph-card: Refactor schema

2020-11-11 Thread Sameer Pujar
There can be customized sound cards which are based on generic audio
graph. In such cases most of the stuff is reused from generic audio
graph. To facilitate this, refactor audio graph schema into multiple
files and the base schema can be reused for specific sound cards.

Signed-off-by: Sameer Pujar 
Cc: Kuninori Morimoto 
---
 .../bindings/sound/audio-graph-card.yaml   | 102 +---
 .../devicetree/bindings/sound/audio-graph.yaml | 107 +
 2 files changed, 110 insertions(+), 99 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/sound/audio-graph.yaml

diff --git a/Documentation/devicetree/bindings/sound/audio-graph-card.yaml 
b/Documentation/devicetree/bindings/sound/audio-graph-card.yaml
index 2329aeb..e047d7d 100644
--- a/Documentation/devicetree/bindings/sound/audio-graph-card.yaml
+++ b/Documentation/devicetree/bindings/sound/audio-graph-card.yaml
@@ -9,113 +9,17 @@ title: Audio Graph Card Driver Device Tree Bindings
 maintainers:
   - Kuninori Morimoto 
 
+allOf:
+  - $ref: /schemas/sound/audio-graph.yaml#
+
 properties:
   compatible:
 enum:
   - audio-graph-card
   - audio-graph-scu-card
 
-  dais:
-$ref: /schemas/types.yaml#/definitions/phandle-array
-  label:
-maxItems: 1
-  prefix:
-description: "device name prefix"
-$ref: /schemas/types.yaml#/definitions/string
-  routing:
-description: |
-  A list of the connections between audio components.
-  Each entry is a pair of strings, the first being the
-  connection's sink, the second being the connection's source.
-$ref: /schemas/types.yaml#/definitions/non-unique-string-array
-  widgets:
-description: User specified audio sound widgets.
-$ref: /schemas/types.yaml#/definitions/non-unique-string-array
-  convert-rate:
-description: CPU to Codec rate convert.
-$ref: /schemas/types.yaml#/definitions/uint32
-  convert-channels:
-description: CPU to Codec rate channels.
-$ref: /schemas/types.yaml#/definitions/uint32
-  pa-gpios:
-maxItems: 1
-  hp-det-gpio:
-maxItems: 1
-  mic-det-gpio:
-maxItems: 1
-
-  port:
-description: single OF-Graph subnode
-type: object
-properties:
-  reg:
-maxItems: 1
-  prefix:
-description: "device name prefix"
-$ref: /schemas/types.yaml#/definitions/string
-  convert-rate:
-description: CPU to Codec rate convert.
-$ref: /schemas/types.yaml#/definitions/uint32
-  convert-channels:
-description: CPU to Codec rate channels.
-$ref: /schemas/types.yaml#/definitions/uint32
-patternProperties:
-  "^endpoint(@[0-9a-f]+)?":
-type: object
-properties:
-  remote-endpoint:
-maxItems: 1
-  mclk-fs:
-description: |
-  Multiplication factor between stream rate and codec mclk.
-  When defined, mclk-fs property defined in dai-link sub nodes are 
ignored.
-$ref: /schemas/types.yaml#/definitions/uint32
-  frame-inversion:
-description: dai-link uses frame clock inversion
-$ref: /schemas/types.yaml#/definitions/flag
-  bitclock-inversion:
-description: dai-link uses bit clock inversion
-$ref: /schemas/types.yaml#/definitions/flag
-  frame-master:
-description: Indicates dai-link frame master.
-$ref: /schemas/types.yaml#/definitions/phandle-array
-maxItems: 1
-  bitclock-master:
-description: Indicates dai-link bit clock master
-$ref: /schemas/types.yaml#/definitions/phandle-array
-maxItems: 1
-  dai-format:
-description: audio format.
-items:
-  enum:
-- i2s
-- right_j
-- left_j
-- dsp_a
-- dsp_b
-- ac97
-- pdm
-- msb
-- lsb
-  convert-rate:
-description: CPU to Codec rate convert.
-$ref: /schemas/types.yaml#/definitions/uint32
-  convert-channels:
-description: CPU to Codec rate channels.
-$ref: /schemas/types.yaml#/definitions/uint32
-required:
-  - remote-endpoint
-
-  ports:
-description: multi OF-Graph subnode
-type: object
-patternProperties:
-  "^port(@[0-9a-f]+)?":
-$ref: "#/properties/port"
-
 required:
   - compatible
-  - dais
 
 additionalProperties: false
 
diff --git a/Documentation/devicetree/bindings/sound/audio-graph.yaml 
b/Documentation/devicetree/bindings/sound/audio-graph.yaml
new file mode 100644
index 000..1e338d6
--- /dev/null
+++ b/Documentation/devicetree/bindings/sound/audio-graph.yaml
@@ -0,0 +1,107 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.

[PATCH 2/2] ASoC: renesas,rsnd: Update audio graph references

2020-11-11 Thread Sameer Pujar
Since audio graph schema is refactored now update the related
references here.

Signed-off-by: Sameer Pujar 
Cc: Kuninori Morimoto 
---
 Documentation/devicetree/bindings/sound/renesas,rsnd.yaml | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/renesas,rsnd.yaml 
b/Documentation/devicetree/bindings/sound/renesas,rsnd.yaml
index 51f4dca..fc2ae22 100644
--- a/Documentation/devicetree/bindings/sound/renesas,rsnd.yaml
+++ b/Documentation/devicetree/bindings/sound/renesas,rsnd.yaml
@@ -112,12 +112,10 @@ properties:
 - pattern: '^clk_(a|b|c|i)$'
 
   port:
-description: OF-Graph subnode
-$ref: "audio-graph-card.yaml#/properties/port"
+$ref: /schemas/sound/audio-graph.yaml#/properties/port
 
   ports:
-description: multi OF-Graph subnode
-$ref: "audio-graph-card.yaml#/properties/ports"
+$ref: /schemas/graph.yaml#/properties/ports
 
 # use patternProperties to avoid naming "xxx,yyy" issue
 patternProperties:
-- 
2.7.4



Re: [PATCH v3 1/3] dt-bindings: Convert graph bindings to json-schema

2020-11-11 Thread Sameer Pujar

Hi Rob,


From: Sameer Pujar 

Convert device tree bindings of graph to YAML format. Currently graph.txt
doc is referenced in multiple files and all of these need to use schema
references. For now graph.txt is updated to refer to graph.yaml.

For users of the graph binding, they should reference to the graph
schema from either 'ports' or 'port' property:

properties:
   ports:
 type: object
 $ref: graph.yaml#/properties/ports

 properties:
   port@0:
 description: What data this port has

   ...

Or:

properties:
   port:
 description: What data this port has
 type: object
 $ref: graph.yaml#/properties/port

Signed-off-by: Sameer Pujar 
Acked-by: Philipp Zabel 
Signed-off-by: Rob Herring 
---
v3:
  - Move port 'reg' to port@* and make required
  - Make remote-endpoint required
  - Add 'additionalProperties: true' now required
  - Fix yamllint warnings

  Documentation/devicetree/bindings/graph.txt  | 129 +---
  Documentation/devicetree/bindings/graph.yaml | 199 +++
  2 files changed, 200 insertions(+), 128 deletions(-)
  create mode 100644 Documentation/devicetree/bindings/graph.yaml


...

diff --git a/Documentation/devicetree/bindings/graph.yaml 
b/Documentation/devicetree/bindings/graph.yaml
new file mode 100644
index ..b56720c5a13e
--- /dev/null
+++ b/Documentation/devicetree/bindings/graph.yaml
@@ -0,0 +1,199 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/graph.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Common bindings for device graphs
+
+description: |
+  The hierarchical organisation of the device tree is well suited to describe
+  control flow to devices, but there can be more complex connections between
+  devices that work together to form a logical compound device, following an
+  arbitrarily complex graph.
+  There already is a simple directed graph between devices tree nodes using
+  phandle properties pointing to other nodes to describe connections that
+  can not be inferred from device tree parent-child relationships. The device
+  tree graph bindings described herein abstract more complex devices that can
+  have multiple specifiable ports, each of which can be linked to one or more
+  ports of other devices.
+
+  These common bindings do not contain any information about the direction or
+  type of the connections, they just map their existence. Specific properties
+  may be described by specialized bindings depending on the type of connection.
+
+  To see how this binding applies to video pipelines, for example, see
+  Documentation/devicetree/bindings/media/video-interfaces.txt.
+  Here the ports describe data interfaces, and the links between them are
+  the connecting data buses. A single port with multiple connections can
+  correspond to multiple devices being connected to the same physical bus.
+
+maintainers:
+  - Philipp Zabel 
+
+select: false
+
+properties:
+  port:
+type: object
+description:
+  If there is more than one endpoint node or 'reg' property present in
+  endpoint nodes then '#address-cells' and '#size-cells' properties are
+  required.
+
+properties:
+  "#address-cells":
+const: 1
+
+  "#size-cells":
+const: 0
+
+patternProperties:
+  "^endpoint(@[0-9a-f]+)?$":
+type: object
+properties:
+  reg:
+maxItems: 1
+
+  remote-endpoint:
+description: |
+  phandle to an 'endpoint' subnode of a remote device node.
+$ref: /schemas/types.yaml#/definitions/phandle
+
+required:
+  - remote-endpoint


Does 'remote-endpoint' have to be a required property?
In case of pluggable modules, the remote-endpoint may not be available 
unless the module is plugged in. In other words, device-2 in below 
example may not always be available, but still device-1 endpoint 
configuration and usage may be required?


...


+  # Links between endpoints:
+  #
+  # Each endpoint should contain a 'remote-endpoint' phandle property that
+  # points to the corresponding endpoint in the port of the remote device.
+  # In turn, the remote endpoint should contain a 'remote-endpoint' property.
+  # If it has one, it must not point to anything other than the local endpoint.
+  # Two endpoints with their 'remote-endpoint' phandles pointing at each other
+  # form a link between the containing ports.
+  - |
+device-1 {
+port {
+device_1_output: endpoint {
+remote-endpoint = <_2_input>;
+};
+};
+};
+
+device-2 {
+port {
+device_2_input: endpoint {
+remote-endpoint = <_1_output>;
+};
+};
+};
+
+...
--
2.25.1




[PATCH v2 4/4] dt-bindings: bus: Convert ACONNECT doc to json-schema

2020-11-06 Thread Sameer Pujar
Move ACONNECT documentation to YAML format.

Signed-off-by: Sameer Pujar 
---
 .../bindings/bus/nvidia,tegra210-aconnect.txt  | 44 
 .../bindings/bus/nvidia,tegra210-aconnect.yaml | 82 ++
 2 files changed, 82 insertions(+), 44 deletions(-)
 delete mode 100644 
Documentation/devicetree/bindings/bus/nvidia,tegra210-aconnect.txt
 create mode 100644 
Documentation/devicetree/bindings/bus/nvidia,tegra210-aconnect.yaml

diff --git a/Documentation/devicetree/bindings/bus/nvidia,tegra210-aconnect.txt 
b/Documentation/devicetree/bindings/bus/nvidia,tegra210-aconnect.txt
deleted file mode 100644
index 3108d03..000
--- a/Documentation/devicetree/bindings/bus/nvidia,tegra210-aconnect.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-NVIDIA Tegra ACONNECT Bus
-
-The Tegra ACONNECT bus is an AXI switch which is used to connnect various
-components inside the Audio Processing Engine (APE). All CPU accesses to
-the APE subsystem go through the ACONNECT via an APB to AXI wrapper.
-
-Required properties:
-- compatible: Must be "nvidia,tegra210-aconnect".
-- clocks: Must contain the entries for the APE clock (TEGRA210_CLK_APE),
-  and APE interface clock (TEGRA210_CLK_APB2APE).
-- clock-names: Must contain the names "ape" and "apb2ape" for the corresponding
-  'clocks' entries.
-- power-domains: Must contain a phandle that points to the audio powergate
-  (namely 'aud') for Tegra210.
-- #address-cells: The number of cells used to represent physical base addresses
-  in the aconnect address space. Should be 1.
-- #size-cells: The number of cells used to represent the size of an address
-  range in the aconnect address space. Should be 1.
-- ranges: Mapping of the aconnect address space to the CPU address space.
-
-All devices accessed via the ACONNNECT are described by child-nodes.
-
-Example:
-
-   aconnect@702c {
-   compatible = "nvidia,tegra210-aconnect";
-   clocks = <_car TEGRA210_CLK_APE>,
-<_car TEGRA210_CLK_APB2APE>;
-   clock-names = "ape", "apb2ape";
-   power-domains = <_audio>;
-
-   #address-cells = <1>;
-   #size-cells = <1>;
-   ranges = <0x702c 0x0 0x702c 0x0004>;
-
-
-   child1 {
-   ...
-   };
-
-   child2 {
-   ...
-   };
-   };
diff --git 
a/Documentation/devicetree/bindings/bus/nvidia,tegra210-aconnect.yaml 
b/Documentation/devicetree/bindings/bus/nvidia,tegra210-aconnect.yaml
new file mode 100644
index 000..7b1a08c
--- /dev/null
+++ b/Documentation/devicetree/bindings/bus/nvidia,tegra210-aconnect.yaml
@@ -0,0 +1,82 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/bus/nvidia,tegra210-aconnect.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVIDIA Tegra ACONNECT Bus
+
+description: |
+  The Tegra ACONNECT bus is an AXI switch which is used to connnect various
+  components inside the Audio Processing Engine (APE). All CPU accesses to
+  the APE subsystem go through the ACONNECT via an APB to AXI wrapper. All
+  devices accessed via the ACONNNECT are described by child-nodes.
+
+maintainers:
+  - Jon Hunter 
+
+properties:
+  compatible:
+oneOf:
+  - const: nvidia,tegra210-aconnect
+  - items:
+  - enum:
+  - nvidia,tegra186-aconnect
+  - nvidia,tegra194-aconnect
+  - const: nvidia,tegra210-aconnect
+
+  clocks:
+items:
+  - description: Must contain the entry for APE clock
+  - description: Must contain the entry for APE interface clock
+
+  clock-names:
+items:
+  - const: ape
+  - const: apb2ape
+
+  power-domains:
+maxItems: 1
+
+  "#address-cells":
+const: 1
+
+  "#size-cells":
+const: 1
+
+  ranges: true
+
+patternProperties:
+  "@[0-9a-f]+$":
+type: object
+
+required:
+  - compatible
+  - clocks
+  - clock-names
+  - power-domains
+  - "#address-cells"
+  - "#size-cells"
+  - ranges
+
+additionalProperties: false
+
+examples:
+  - |
+#include
+
+aconnect@702c {
+compatible = "nvidia,tegra210-aconnect";
+clocks = <_car TEGRA210_CLK_APE>,
+ <_car TEGRA210_CLK_APB2APE>;
+clock-names = "ape", "apb2ape";
+power-domains = <_audio>;
+
+#address-cells = <1>;
+#size-cells = <1>;
+ranges = <0x702c 0x702c 0x0004>;
+
+// Child device nodes follow ...
+};
+
+...
-- 
2.7.4



[PATCH v2 1/4] arm64: tegra: Rename ADMA device nodes for Tegra210

2020-11-06 Thread Sameer Pujar
DMA device nodes should follow regex pattern of "^dma-controller(@.*)?$".
This is a preparatory patch to use YAML doc format for ADMA.

Signed-off-by: Sameer Pujar 
---
 arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts | 2 +-
 arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts | 2 +-
 arch/arm64/boot/dts/nvidia/tegra210-smaug.dts  | 2 +-
 arch/arm64/boot/dts/nvidia/tegra210.dtsi   | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts 
b/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts
index dab24b4..e9f8410 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts
+++ b/arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts
@@ -120,7 +120,7 @@
aconnect@702c {
status = "okay";
 
-   dma@702e2000 {
+   dma-controller@702e2000 {
status = "okay";
};
 
diff --git a/arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts 
b/arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts
index 1216b65c8..f8e8bcf 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts
+++ b/arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts
@@ -630,7 +630,7 @@
aconnect@702c {
status = "okay";
 
-   dma@702e2000 {
+   dma-controller@702e2000 {
status = "okay";
};
 
diff --git a/arch/arm64/boot/dts/nvidia/tegra210-smaug.dts 
b/arch/arm64/boot/dts/nvidia/tegra210-smaug.dts
index bd78378..131c064 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210-smaug.dts
+++ b/arch/arm64/boot/dts/nvidia/tegra210-smaug.dts
@@ -1717,7 +1717,7 @@
aconnect@702c {
status = "okay";
 
-   dma@702e2000 {
+   dma-controller@702e2000 {
status = "okay";
};
 
diff --git a/arch/arm64/boot/dts/nvidia/tegra210.dtsi 
b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
index d47c889..d41eb12 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210.dtsi
+++ b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
@@ -1344,7 +1344,7 @@
ranges = <0x702c 0x0 0x702c 0x0004>;
status = "disabled";
 
-   adma: dma@702e2000 {
+   adma: dma-controller@702e2000 {
compatible = "nvidia,tegra210-adma";
reg = <0x702e2000 0x2000>;
interrupt-parent = <>;
-- 
2.7.4



[PATCH v2 2/4] dt-bindings: dma: Convert ADMA doc to json-schema

2020-11-06 Thread Sameer Pujar
Move ADMA documentation to YAML format.

Signed-off-by: Sameer Pujar 
---
 .../bindings/dma/nvidia,tegra210-adma.txt  | 56 
 .../bindings/dma/nvidia,tegra210-adma.yaml | 99 ++
 2 files changed, 99 insertions(+), 56 deletions(-)
 delete mode 100644 
Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.txt
 create mode 100644 
Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.yaml

diff --git a/Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.txt 
b/Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.txt
deleted file mode 100644
index 245d306..000
--- a/Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.txt
+++ /dev/null
@@ -1,56 +0,0 @@
-* NVIDIA Tegra Audio DMA (ADMA) controller
-
-The Tegra Audio DMA controller that is used for transferring data
-between system memory and the Audio Processing Engine (APE).
-
-Required properties:
-- compatible: Should contain one of the following:
-  - "nvidia,tegra210-adma": for Tegra210
-  - "nvidia,tegra186-adma": for Tegra186 and Tegra194
-- reg: Should contain DMA registers location and length. This should be
-  a single entry that includes all of the per-channel registers in one
-  contiguous bank.
-- interrupts: Should contain all of the per-channel DMA interrupts in
-  ascending order with respect to the DMA channel index.
-- clocks: Must contain one entry for the ADMA module clock
-  (TEGRA210_CLK_D_AUDIO).
-- clock-names: Must contain the name "d_audio" for the corresponding
-  'clocks' entry.
-- #dma-cells : Must be 1. The first cell denotes the receive/transmit
-  request number and should be between 1 and the maximum number of
-  requests supported. This value corresponds to the RX/TX_REQUEST_SELECT
-  fields in the ADMA_CHn_CTRL register.
-
-
-Example:
-
-adma: dma@702e2000 {
-   compatible = "nvidia,tegra210-adma";
-   reg = <0x0 0x702e2000 0x0 0x2000>;
-   interrupt-parent = <_agic>;
-   interrupts = ,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-;
-   clocks = <_car TEGRA210_CLK_D_AUDIO>;
-   clock-names = "d_audio";
-   #dma-cells = <1>;
-};
diff --git a/Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.yaml 
b/Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.yaml
new file mode 100644
index 000..5c2e2f1
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.yaml
@@ -0,0 +1,99 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dma/nvidia,tegra210-adma.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVIDIA Tegra Audio DMA (ADMA) controller
+
+description: |
+  The Tegra Audio DMA controller is used for transferring data
+  between system memory and the Audio Processing Engine (APE).
+
+maintainers:
+  - Jon Hunter 
+
+allOf:
+  - $ref: "dma-controller.yaml#"
+
+properties:
+  compatible:
+oneOf:
+  - enum:
+  - nvidia,tegra210-adma
+  - nvidia,tegra186-adma
+  - items:
+  - const: nvidia,tegra194-adma
+  - const: nvidia,tegra186-adma
+
+  reg:
+maxItems: 1
+
+  interrupts:
+description: |
+  Should contain all of the per-channel DMA interrupts in
+  ascending order with respect to the DMA channel index.
+minItems: 1
+maxItems: 32
+
+  clocks:
+description: Must contain one entry for the ADMA module clock
+maxItems: 1
+
+  clock-names:
+const: d_audio
+
+  "#dma-cells":
+description: |
+  The first cell denotes the receive/transmit request number and
+  should be between 1 and the maximum number of requests supported.
+  This value corresponds to the RX/TX_REQUEST_SELECT fields in the
+  ADMA_CHn_CTRL register.
+const: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+
+additionalProperties: false
+
+examples:
+  - |
+#include 
+#include
+
+dma-controller@702e2000 {
+compatible = "nvidia,tegra210-

[PATCH v2 3/4] dt-bindings: interrupt-controller: arm,gic: Update Tegra compatibles

2020-11-06 Thread Sameer Pujar
Update Tegra compatibles to support newer Tegra chips and required
combinations.

Signed-off-by: Sameer Pujar 
Reviewed-by: Rob Herring 
---
 .../devicetree/bindings/interrupt-controller/arm,gic.yaml| 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git 
a/Documentation/devicetree/bindings/interrupt-controller/arm,gic.yaml 
b/Documentation/devicetree/bindings/interrupt-controller/arm,gic.yaml
index 0688996..ba282f4 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/arm,gic.yaml
+++ b/Documentation/devicetree/bindings/interrupt-controller/arm,gic.yaml
@@ -35,7 +35,6 @@ properties:
   - arm,gic-400
   - arm,pl390
   - arm,tc11mp-gic
-  - nvidia,tegra210-agic
   - qcom,msm-8660-qgic
   - qcom,msm-qgic2
 
@@ -53,6 +52,14 @@ properties:
   - const: brcm,brahma-b15-gic
   - const: arm,cortex-a15-gic
 
+  - oneOf:
+  - const: nvidia,tegra210-agic
+  - items:
+  - enum:
+  - nvidia,tegra186-agic
+  - nvidia,tegra194-agic
+  - const: nvidia,tegra210-agic
+
   interrupt-controller: true
 
   "#address-cells":
-- 
2.7.4



[PATCH v2 0/4] Convert few Tegra docs to json-schema

2020-11-06 Thread Sameer Pujar
Following are the summary of changes.
* Update ADMA device node names for some of Tegra210 DT files.
* Convert ADMA, AGIC and ACONNECT docs to YAML.

Changelog
=

v1 -> v2:
-
* No change in DT patch.
* Add min/max items for interrupts and clocks in ADMA schema. Add
  required 'additionalProperty' and thus fix errors/warnings in
  the schema.
* Fix indentation warnings in arm,gic.yaml for AGIC documentation.
  With this fix add "Reviewed-by" tag from Rob.
* Drop individual child pattern properties for ACONNECT schema and
  instead use generic pattern property. 

Sameer Pujar (4):
  arm64: tegra: Rename ADMA device nodes for Tegra210
  dt-bindings: dma: Convert ADMA doc to json-schema
  dt-bindings: interrupt-controller: arm,gic: Update Tegra compatibles
  dt-bindings: bus: Convert ACONNECT doc to json-schema

 .../bindings/bus/nvidia,tegra210-aconnect.txt  | 44 --
 .../bindings/bus/nvidia,tegra210-aconnect.yaml | 82 ++
 .../bindings/dma/nvidia,tegra210-adma.txt  | 56 
 .../bindings/dma/nvidia,tegra210-adma.yaml | 99 ++
 .../bindings/interrupt-controller/arm,gic.yaml |  9 +-
 arch/arm64/boot/dts/nvidia/tegra210-p2371-2180.dts |  2 +-
 arch/arm64/boot/dts/nvidia/tegra210-p3450-.dts |  2 +-
 arch/arm64/boot/dts/nvidia/tegra210-smaug.dts  |  2 +-
 arch/arm64/boot/dts/nvidia/tegra210.dtsi   |  2 +-
 9 files changed, 193 insertions(+), 105 deletions(-)
 delete mode 100644 
Documentation/devicetree/bindings/bus/nvidia,tegra210-aconnect.txt
 create mode 100644 
Documentation/devicetree/bindings/bus/nvidia,tegra210-aconnect.yaml
 delete mode 100644 
Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.txt
 create mode 100644 
Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.yaml

-- 
2.7.4



Re: [PATCH 4/4] dt-bindings: bus: Convert ACONNECT doc to json-schema

2020-11-05 Thread Sameer Pujar




Move ACONNECT documentation to YAML format.

Signed-off-by: Sameer Pujar 
---
  .../bindings/bus/nvidia,tegra210-aconnect.txt  | 44 ---
  .../bindings/bus/nvidia,tegra210-aconnect.yaml | 86 ++
  2 files changed, 86 insertions(+), 44 deletions(-)
  delete mode 100644 
Documentation/devicetree/bindings/bus/nvidia,tegra210-aconnect.txt
  create mode 100644 
Documentation/devicetree/bindings/bus/nvidia,tegra210-aconnect.yaml



...


diff --git 
a/Documentation/devicetree/bindings/bus/nvidia,tegra210-aconnect.yaml 
b/Documentation/devicetree/bindings/bus/nvidia,tegra210-aconnect.yaml
new file mode 100644
index 000..f0161bc
--- /dev/null
+++ b/Documentation/devicetree/bindings/bus/nvidia,tegra210-aconnect.yaml
@@ -0,0 +1,86 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/bus/nvidia,tegra210-aconnect.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVIDIA Tegra ACONNECT Bus
+
+description: |
+  The Tegra ACONNECT bus is an AXI switch which is used to connnect various
+  components inside the Audio Processing Engine (APE). All CPU accesses to
+  the APE subsystem go through the ACONNECT via an APB to AXI wrapper. All
+  devices accessed via the ACONNNECT are described by child-nodes.
+


...


+
+patternProperties:
+  "^dma-controller(@[0-9a-f]+)?$":
+$ref: /schemas/dma/nvidia,tegra210-adma.yaml#
+  "^interrupt-controller(@[0-9a-f]+)?$":
+$ref: /schemas/interrupt-controller/arm,gic.yaml#
+  "^ahub(@[0-9a-f]+)?$":
+$ref: /schemas/sound/nvidia,tegra210-ahub.yaml#

These all get applied already since they match on compatible strings. So
having them here means the schema is applied twice. There's maybe some
value to this if it's always going to be these 3 nodes.


1) May be this could be dropped with "additionalProperties = true", but 
that allows any arbitary property to be added for the device. Without 
this 'make dtbs_check' complains about not matching properties in DT files.


2) These may not be the final list of nodes this device can have. In 
future if any new device support gets added under this, above needs to 
be updated. But it will be limited number of devices.


So is [2] fine or you would suggest [1] would be good enough?



Also, the unit-addresses shouldn't be optional.

I'd just do:

"@[0-9a-f]+$":
   type: object


+
+required:
+  - compatible
+  - clocks
+  - clock-names
+  - power-domains
+  - "#address-cells"
+  - "#size-cells"
+  - ranges
+
+additionalProperties: false
+
+examples:
+  - |
+#include
+
+aconnect@702c {
+compatible = "nvidia,tegra210-aconnect";
+clocks = <_car TEGRA210_CLK_APE>,
+ <_car TEGRA210_CLK_APB2APE>;
+clock-names = "ape", "apb2ape";
+power-domains = <_audio>;
+
+#address-cells = <1>;
+#size-cells = <1>;
+ranges = <0x702c 0x702c 0x0004>;
+
+// Child device nodes follow ...
+};
+
+...
--
2.7.4





[PATCH 3/4] dt-bindings: interrupt-controller: arm,gic: Update Tegra compatibles

2020-11-05 Thread Sameer Pujar
Update Tegra compatibles to support newer Tegra chips and required
combinations.

Signed-off-by: Sameer Pujar 
---
 .../devicetree/bindings/interrupt-controller/arm,gic.yaml| 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git 
a/Documentation/devicetree/bindings/interrupt-controller/arm,gic.yaml 
b/Documentation/devicetree/bindings/interrupt-controller/arm,gic.yaml
index 0688996..614018f 100644
--- a/Documentation/devicetree/bindings/interrupt-controller/arm,gic.yaml
+++ b/Documentation/devicetree/bindings/interrupt-controller/arm,gic.yaml
@@ -35,7 +35,6 @@ properties:
   - arm,gic-400
   - arm,pl390
   - arm,tc11mp-gic
-  - nvidia,tegra210-agic
   - qcom,msm-8660-qgic
   - qcom,msm-qgic2
 
@@ -53,6 +52,14 @@ properties:
   - const: brcm,brahma-b15-gic
   - const: arm,cortex-a15-gic
 
+  - oneOf:
+- const: nvidia,tegra210-agic
+- items:
+  - enum:
+- nvidia,tegra186-agic
+- nvidia,tegra194-agic
+  - const: nvidia,tegra210-agic
+
   interrupt-controller: true
 
   "#address-cells":
-- 
2.7.4



[PATCH 2/4] dt-bindings: dma: Convert ADMA doc to json-schema

2020-11-05 Thread Sameer Pujar
Move ADMA documentation to YAML format.

Signed-off-by: Sameer Pujar 
---
 .../bindings/dma/nvidia,tegra210-adma.txt  | 56 -
 .../bindings/dma/nvidia,tegra210-adma.yaml | 95 ++
 2 files changed, 95 insertions(+), 56 deletions(-)
 delete mode 100644 
Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.txt
 create mode 100644 
Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.yaml

diff --git a/Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.txt 
b/Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.txt
deleted file mode 100644
index 245d306..000
--- a/Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.txt
+++ /dev/null
@@ -1,56 +0,0 @@
-* NVIDIA Tegra Audio DMA (ADMA) controller
-
-The Tegra Audio DMA controller that is used for transferring data
-between system memory and the Audio Processing Engine (APE).
-
-Required properties:
-- compatible: Should contain one of the following:
-  - "nvidia,tegra210-adma": for Tegra210
-  - "nvidia,tegra186-adma": for Tegra186 and Tegra194
-- reg: Should contain DMA registers location and length. This should be
-  a single entry that includes all of the per-channel registers in one
-  contiguous bank.
-- interrupts: Should contain all of the per-channel DMA interrupts in
-  ascending order with respect to the DMA channel index.
-- clocks: Must contain one entry for the ADMA module clock
-  (TEGRA210_CLK_D_AUDIO).
-- clock-names: Must contain the name "d_audio" for the corresponding
-  'clocks' entry.
-- #dma-cells : Must be 1. The first cell denotes the receive/transmit
-  request number and should be between 1 and the maximum number of
-  requests supported. This value corresponds to the RX/TX_REQUEST_SELECT
-  fields in the ADMA_CHn_CTRL register.
-
-
-Example:
-
-adma: dma@702e2000 {
-   compatible = "nvidia,tegra210-adma";
-   reg = <0x0 0x702e2000 0x0 0x2000>;
-   interrupt-parent = <_agic>;
-   interrupts = ,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-,
-;
-   clocks = <_car TEGRA210_CLK_D_AUDIO>;
-   clock-names = "d_audio";
-   #dma-cells = <1>;
-};
diff --git a/Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.yaml 
b/Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.yaml
new file mode 100644
index 000..b4e657d
--- /dev/null
+++ b/Documentation/devicetree/bindings/dma/nvidia,tegra210-adma.yaml
@@ -0,0 +1,95 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/dma/nvidia,tegra210-adma.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: NVIDIA Tegra Audio DMA (ADMA) controller
+
+description: |
+  The Tegra Audio DMA controller is used for transferring data
+  between system memory and the Audio Processing Engine (APE).
+
+maintainers:
+  - Jon Hunter 
+
+allOf:
+  - $ref: "dma-controller.yaml#"
+
+properties:
+  compatible:
+oneOf:
+  - enum:
+  - nvidia,tegra210-adma
+  - nvidia,tegra186-adma
+  - items:
+  - const: nvidia,tegra194-adma
+  - const: nvidia,tegra186-adma
+
+  reg:
+maxItems: 1
+
+  interrupts:
+description: |
+  Should contain all of the per-channel DMA interrupts in
+  ascending order with respect to the DMA channel index.
+
+  clocks:
+description: Must contain one entry for the ADMA module clock
+
+  clock-names:
+const: d_audio
+
+  "#dma-cells":
+description: |
+  The first cell denotes the receive/transmit request number and
+  should be between 1 and the maximum number of requests supported.
+  This value corresponds to the RX/TX_REQUEST_SELECT fields in the
+  ADMA_CHn_CTRL register.
+
+const: 1
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - clocks
+  - clock-names
+
+examples:
+  - |
+#include 
+#include
+
+dma-controller@702e2000 {
+compatible = "nvidia,tegra210-

  1   2   3   4   >