linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Codec support on Jetson AGX Orin
@ 2023-02-09 14:36 Sameer Pujar
  2023-02-09 14:36 ` [PATCH 1/2] ASoC: rt5640: Update MCLK rate in set_sysclk() Sameer Pujar
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Sameer Pujar @ 2023-02-09 14:36 UTC (permalink / raw)
  To: robh+dt, krzysztof.kozlowski+dt, thierry.reding, jonathanh,
	oder_chiou, broonie
  Cc: perex, tiwai, lgirdwood, kuninori.morimoto.gx, devicetree,
	linux-tegra, linux-kernel, alsa-devel, Sameer Pujar

Jetson AGX Orin has onboard RT5640 audio codec and uses I2S1 interface.
Add DT bindings to enable codec support. Series also contains a clock
fix in the codec driver.

Sameer Pujar (2):
  ASoC: rt5640: Update MCLK rate in set_sysclk()
  arm64: tegra: Audio codec support on Jetson AGX Orin

 .../dts/nvidia/tegra234-p3737-0000+p3701-0000.dts  | 47 +++++++++++++++++++++-
 sound/soc/codecs/rt5640.c                          |  5 +++
 2 files changed, 51 insertions(+), 1 deletion(-)

-- 
2.7.4


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

* [PATCH 1/2] ASoC: rt5640: Update MCLK rate in set_sysclk()
  2023-02-09 14:36 [PATCH 0/2] Codec support on Jetson AGX Orin Sameer Pujar
@ 2023-02-09 14:36 ` Sameer Pujar
  2023-02-09 23:42   ` Kuninori Morimoto
  2023-02-09 14:36 ` [PATCH 2/2] arm64: tegra: Audio codec support on Jetson AGX Orin Sameer Pujar
  2023-02-09 18:36 ` (subset) [PATCH 0/2] Codec " Mark Brown
  2 siblings, 1 reply; 9+ messages in thread
From: Sameer Pujar @ 2023-02-09 14:36 UTC (permalink / raw)
  To: robh+dt, krzysztof.kozlowski+dt, thierry.reding, jonathanh,
	oder_chiou, broonie
  Cc: perex, tiwai, lgirdwood, kuninori.morimoto.gx, devicetree,
	linux-tegra, linux-kernel, alsa-devel, 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.

This is inspired from,
commit dbf54a953435 ("ASoC: rt5659: Update MCLK rate in set_sysclk()").

Cc: Oder Chiou <oder_chiou@realtek.com>
Signed-off-by: Sameer Pujar <spujar@nvidia.com>
---
 sound/soc/codecs/rt5640.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c
index 9e6341a..1392570 100644
--- a/sound/soc/codecs/rt5640.c
+++ b/sound/soc/codecs/rt5640.c
@@ -1838,9 +1838,14 @@ static int rt5640_set_dai_sysclk(struct snd_soc_dai *dai,
 	struct rt5640_priv *rt5640 = snd_soc_component_get_drvdata(component);
 	unsigned int reg_val = 0;
 	unsigned int pll_bit = 0;
+	int ret;
 
 	switch (clk_id) {
 	case RT5640_SCLK_S_MCLK:
+		ret = clk_set_rate(rt5640->mclk, freq);
+		if (ret)
+			return ret;
+
 		reg_val |= RT5640_SCLK_SRC_MCLK;
 		break;
 	case RT5640_SCLK_S_PLL1:
-- 
2.7.4


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

* [PATCH 2/2] arm64: tegra: Audio codec support on Jetson AGX Orin
  2023-02-09 14:36 [PATCH 0/2] Codec support on Jetson AGX Orin Sameer Pujar
  2023-02-09 14:36 ` [PATCH 1/2] ASoC: rt5640: Update MCLK rate in set_sysclk() Sameer Pujar
@ 2023-02-09 14:36 ` Sameer Pujar
  2023-02-10  8:45   ` Krzysztof Kozlowski
  2023-02-09 18:36 ` (subset) [PATCH 0/2] Codec " Mark Brown
  2 siblings, 1 reply; 9+ messages in thread
From: Sameer Pujar @ 2023-02-09 14:36 UTC (permalink / raw)
  To: robh+dt, krzysztof.kozlowski+dt, thierry.reding, jonathanh,
	oder_chiou, broonie
  Cc: perex, tiwai, lgirdwood, kuninori.morimoto.gx, devicetree,
	linux-tegra, linux-kernel, alsa-devel, Sameer Pujar

Jetson AGX Orin has onboard RT5640 audio codec. This patch adds the
codec device node and the bindings to I2S1 interface.

Signed-off-by: Sameer Pujar <spujar@nvidia.com>
---
 .../dts/nvidia/tegra234-p3737-0000+p3701-0000.dts  | 47 +++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts b/arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts
index 8a97478..5881fbf 100644
--- a/arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts
+++ b/arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts
@@ -3,6 +3,7 @@
 
 #include <dt-bindings/input/linux-event-codes.h>
 #include <dt-bindings/input/gpio-keys.h>
+#include <dt-bindings/sound/rt5640.h>
 
 #include "tegra234-p3701-0000.dtsi"
 #include "tegra234-p3737-0000.dtsi"
@@ -49,7 +50,7 @@
 
 							i2s1_dap: endpoint {
 								dai-format = "i2s";
-								/* placeholder for external codec */
+								remote-endpoint = <&rt5640_ep>;
 							};
 						};
 					};
@@ -2017,6 +2018,32 @@
 			status = "okay";
 		};
 
+		i2c@31e0000 {
+			status = "okay";
+
+			audio-codec@1c {
+				status = "okay";
+
+				compatible = "realtek,rt5640";
+				reg = <0x1c>;
+				interrupt-parent = <&gpio>;
+				interrupts = <TEGRA234_MAIN_GPIO(AC, 5) GPIO_ACTIVE_HIGH>;
+				clocks = <&bpmp TEGRA234_CLK_AUD_MCLK>;
+				clock-names = "mclk";
+				realtek,dmic1-data-pin = <RT5640_DMIC1_DATA_PIN_NONE>;
+				realtek,dmic2-data-pin = <RT5640_DMIC2_DATA_PIN_NONE>;
+				realtek,jack-detect-source = <RT5640_JD_SRC_HDA_HEADER>;
+				sound-name-prefix = "CVB-RT";
+
+				port {
+					rt5640_ep: endpoint {
+						remote-endpoint = <&i2s1_dap>;
+						mclk-fs = <256>;
+					};
+				};
+			};
+		};
+
 		pwm@32a0000 {
 			assigned-clocks = <&bpmp TEGRA234_CLK_PWM3>;
 			assigned-clock-parents = <&bpmp TEGRA234_CLK_PLLP_OUT0>;
@@ -2293,5 +2320,23 @@
 		       <&dmic3_port>;
 
 		label = "NVIDIA Jetson AGX Orin APE";
+
+		widgets = "Microphone",	"CVB-RT MIC Jack",
+			  "Microphone",	"CVB-RT MIC",
+			  "Headphone",	"CVB-RT HP Jack",
+			  "Speaker",	"CVB-RT SPK";
+
+		routing = /* I2S1 <-> RT5640 */
+			  "CVB-RT AIF1 Playback",	"I2S1 DAP-Playback",
+			  "I2S1 DAP-Capture",		"CVB-RT AIF1 Capture",
+			  /* RT5640 codec controls */
+			  "CVB-RT HP Jack",		"CVB-RT HPOL",
+			  "CVB-RT HP Jack",		"CVB-RT HPOR",
+			  "CVB-RT IN1P",		"CVB-RT MIC Jack",
+			  "CVB-RT IN2P",		"CVB-RT MIC Jack",
+			  "CVB-RT SPK",			"CVB-RT SPOLP",
+			  "CVB-RT SPK",			"CVB-RT SPORP",
+			  "CVB-RT DMIC1",		"CVB-RT MIC",
+			  "CVB-RT DMIC2",		"CVB-RT MIC";
 	};
 };
-- 
2.7.4


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

* Re: (subset) [PATCH 0/2] Codec support on Jetson AGX Orin
  2023-02-09 14:36 [PATCH 0/2] Codec support on Jetson AGX Orin Sameer Pujar
  2023-02-09 14:36 ` [PATCH 1/2] ASoC: rt5640: Update MCLK rate in set_sysclk() Sameer Pujar
  2023-02-09 14:36 ` [PATCH 2/2] arm64: tegra: Audio codec support on Jetson AGX Orin Sameer Pujar
@ 2023-02-09 18:36 ` Mark Brown
  2 siblings, 0 replies; 9+ messages in thread
From: Mark Brown @ 2023-02-09 18:36 UTC (permalink / raw)
  To: robh+dt, krzysztof.kozlowski+dt, thierry.reding, jonathanh,
	oder_chiou, Sameer Pujar
  Cc: perex, tiwai, lgirdwood, kuninori.morimoto.gx, devicetree,
	linux-tegra, linux-kernel, alsa-devel

On Thu, 09 Feb 2023 20:06:55 +0530, Sameer Pujar wrote:
> Jetson AGX Orin has onboard RT5640 audio codec and uses I2S1 interface.
> Add DT bindings to enable codec support. Series also contains a clock
> fix in the codec driver.
> 
> Sameer Pujar (2):
>   ASoC: rt5640: Update MCLK rate in set_sysclk()
>   arm64: tegra: Audio codec support on Jetson AGX Orin
> 
> [...]

Applied to

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

Thanks!

[1/2] ASoC: rt5640: Update MCLK rate in set_sysclk()
      commit: 9f138bb2eaf661788df459dfcaf38feb080af41f

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


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

* Re: [PATCH 1/2] ASoC: rt5640: Update MCLK rate in set_sysclk()
  2023-02-09 14:36 ` [PATCH 1/2] ASoC: rt5640: Update MCLK rate in set_sysclk() Sameer Pujar
@ 2023-02-09 23:42   ` Kuninori Morimoto
  2023-02-10  8:30     ` Sameer Pujar
  0 siblings, 1 reply; 9+ messages in thread
From: Kuninori Morimoto @ 2023-02-09 23:42 UTC (permalink / raw)
  To: Sameer Pujar
  Cc: robh+dt, krzysztof.kozlowski+dt, thierry.reding, jonathanh,
	oder_chiou, broonie, perex, tiwai, lgirdwood, devicetree,
	linux-tegra, linux-kernel, alsa-devel


Hi Sameer

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

I have no objection about this patch, but have interesting about this comment.

Simple-card/audio-graph-card both are using asoc_simple_hw_params,
and it calls clk_set_rate() for Codec/CPU if it has mclk.
But am I misunderstanding ?
If it was simple-card-utils side miss, I'm happy to fix it.

Thank you for your help !!

Best regards
---
Kuninori Morimoto

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

* Re: [PATCH 1/2] ASoC: rt5640: Update MCLK rate in set_sysclk()
  2023-02-09 23:42   ` Kuninori Morimoto
@ 2023-02-10  8:30     ` Sameer Pujar
  2023-02-12 23:56       ` Kuninori Morimoto
  0 siblings, 1 reply; 9+ messages in thread
From: Sameer Pujar @ 2023-02-10  8:30 UTC (permalink / raw)
  To: Kuninori Morimoto
  Cc: robh+dt, krzysztof.kozlowski+dt, thierry.reding, jonathanh,
	oder_chiou, broonie, perex, tiwai, lgirdwood, devicetree,
	linux-tegra, linux-kernel, alsa-devel

Hi Morimoto-san,

On 10-02-2023 05:12, Kuninori Morimoto wrote:
>
>> 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.
> I have no objection about this patch, but have interesting about this comment.
>
> Simple-card/audio-graph-card both are using asoc_simple_hw_params,
> and it calls clk_set_rate() for Codec/CPU if it has mclk.
> But am I misunderstanding ?
> If it was simple-card-utils side miss, I'm happy to fix it.

The simple-card-utils driver does not populate the clock handle whenever 
the MCLK clock is parsed from CODEC device node. So 
asoc_simple_set_clk_rate() will not update the rate and clock 
enable/disable won't happen either.Initially I had tried to fix this in 
the simple-card-utils itself and it did break few things on other HW.
Please see [0] for relevant discussion.

Later [1] was pushed to address the issue I was facing that time.

In summary, the suggestion was, clock property should be associated with 
only devices and device driver should own up the clock handling for it. 
The machine driver can just pass the required configuration for it.


[0] 
https://patchwork.ozlabs.org/project/linux-tegra/patch/1612939421-19900-2-git-send-email-spujar@nvidia.com/#2647112
[1] 
https://lore.kernel.org/lkml/1615829492-8972-3-git-send-email-spujar@nvidia.com/

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

* Re: [PATCH 2/2] arm64: tegra: Audio codec support on Jetson AGX Orin
  2023-02-09 14:36 ` [PATCH 2/2] arm64: tegra: Audio codec support on Jetson AGX Orin Sameer Pujar
@ 2023-02-10  8:45   ` Krzysztof Kozlowski
  2023-02-10  9:02     ` Sameer Pujar
  0 siblings, 1 reply; 9+ messages in thread
From: Krzysztof Kozlowski @ 2023-02-10  8:45 UTC (permalink / raw)
  To: Sameer Pujar, robh+dt, krzysztof.kozlowski+dt, thierry.reding,
	jonathanh, oder_chiou, broonie
  Cc: perex, tiwai, lgirdwood, kuninori.morimoto.gx, devicetree,
	linux-tegra, linux-kernel, alsa-devel

On 09/02/2023 15:36, Sameer Pujar wrote:
> Jetson AGX Orin has onboard RT5640 audio codec. This patch adds the
> codec device node and the bindings to I2S1 interface.
> 
> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
> ---
>  .../dts/nvidia/tegra234-p3737-0000+p3701-0000.dts  | 47 +++++++++++++++++++++-
>  1 file changed, 46 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts b/arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts
> index 8a97478..5881fbf 100644
> --- a/arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts
> +++ b/arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts
> @@ -3,6 +3,7 @@
>  
>  #include <dt-bindings/input/linux-event-codes.h>
>  #include <dt-bindings/input/gpio-keys.h>
> +#include <dt-bindings/sound/rt5640.h>
>  
>  #include "tegra234-p3701-0000.dtsi"
>  #include "tegra234-p3737-0000.dtsi"
> @@ -49,7 +50,7 @@
>  
>  							i2s1_dap: endpoint {
>  								dai-format = "i2s";
> -								/* placeholder for external codec */
> +								remote-endpoint = <&rt5640_ep>;
>  							};
>  						};
>  					};
> @@ -2017,6 +2018,32 @@
>  			status = "okay";
>  		};
>  
> +		i2c@31e0000 {
> +			status = "okay";
> +
> +			audio-codec@1c {
> +				status = "okay";

Are you sure you need this?

Best regards,
Krzysztof


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

* Re: [PATCH 2/2] arm64: tegra: Audio codec support on Jetson AGX Orin
  2023-02-10  8:45   ` Krzysztof Kozlowski
@ 2023-02-10  9:02     ` Sameer Pujar
  0 siblings, 0 replies; 9+ messages in thread
From: Sameer Pujar @ 2023-02-10  9:02 UTC (permalink / raw)
  To: Krzysztof Kozlowski, robh+dt, krzysztof.kozlowski+dt,
	thierry.reding, jonathanh, oder_chiou, broonie
  Cc: perex, tiwai, lgirdwood, kuninori.morimoto.gx, devicetree,
	linux-tegra, linux-kernel, alsa-devel



On 10-02-2023 14:15, Krzysztof Kozlowski wrote:
> On 09/02/2023 15:36, Sameer Pujar wrote:
>> Jetson AGX Orin has onboard RT5640 audio codec. This patch adds the
>> codec device node and the bindings to I2S1 interface.
>>
>> Signed-off-by: Sameer Pujar <spujar@nvidia.com>
>> ---
>>   .../dts/nvidia/tegra234-p3737-0000+p3701-0000.dts  | 47 +++++++++++++++++++++-
>>   1 file changed, 46 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts b/arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts
>> index 8a97478..5881fbf 100644
>> --- a/arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts
>> +++ b/arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts
>> @@ -3,6 +3,7 @@
>>
>>   #include <dt-bindings/input/linux-event-codes.h>
>>   #include <dt-bindings/input/gpio-keys.h>
>> +#include <dt-bindings/sound/rt5640.h>
>>
>>   #include "tegra234-p3701-0000.dtsi"
>>   #include "tegra234-p3737-0000.dtsi"
>> @@ -49,7 +50,7 @@
>>
>>                                                        i2s1_dap: endpoint {
>>                                                                dai-format = "i2s";
>> -                                                             /* placeholder for external codec */
>> +                                                             remote-endpoint = <&rt5640_ep>;
>>                                                        };
>>                                                };
>>                                        };
>> @@ -2017,6 +2018,32 @@
>>                        status = "okay";
>>                };
>>
>> +             i2c@31e0000 {
>> +                     status = "okay";
>> +

>> +                     audio-codec@1c {
>> +                             status = "okay";
> Are you sure you need this?
I can drop this in v2 as it would be the default state and it is not 
disabled anywhere else. Thanks.


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

* Re: [PATCH 1/2] ASoC: rt5640: Update MCLK rate in set_sysclk()
  2023-02-10  8:30     ` Sameer Pujar
@ 2023-02-12 23:56       ` Kuninori Morimoto
  0 siblings, 0 replies; 9+ messages in thread
From: Kuninori Morimoto @ 2023-02-12 23:56 UTC (permalink / raw)
  To: Sameer Pujar
  Cc: robh+dt, krzysztof.kozlowski+dt, thierry.reding, jonathanh,
	oder_chiou, broonie, perex, tiwai, lgirdwood, devicetree,
	linux-tegra, linux-kernel, alsa-devel


Hi Sameer

> > Simple-card/audio-graph-card both are using asoc_simple_hw_params,
> > and it calls clk_set_rate() for Codec/CPU if it has mclk.
> > But am I misunderstanding ?
> > If it was simple-card-utils side miss, I'm happy to fix it.
> 
> The simple-card-utils driver does not populate the clock handle whenever 
> the MCLK clock is parsed from CODEC device node. So 
> asoc_simple_set_clk_rate() will not update the rate and clock 
> enable/disable won't happen either.Initially I had tried to fix this in 
> the simple-card-utils itself and it did break few things on other HW.
> Please see [0] for relevant discussion.
> 
> Later [1] was pushed to address the issue I was facing that time.
> 
> In summary, the suggestion was, clock property should be associated with 
> only devices and device driver should own up the clock handling for it. 
> The machine driver can just pass the required configuration for it.

Thank you for explanation about your issue,
I think I could understand it.

Thank you for your help !!

Best regards
---
Kuninori Morimoto

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

end of thread, other threads:[~2023-02-12 23:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09 14:36 [PATCH 0/2] Codec support on Jetson AGX Orin Sameer Pujar
2023-02-09 14:36 ` [PATCH 1/2] ASoC: rt5640: Update MCLK rate in set_sysclk() Sameer Pujar
2023-02-09 23:42   ` Kuninori Morimoto
2023-02-10  8:30     ` Sameer Pujar
2023-02-12 23:56       ` Kuninori Morimoto
2023-02-09 14:36 ` [PATCH 2/2] arm64: tegra: Audio codec support on Jetson AGX Orin Sameer Pujar
2023-02-10  8:45   ` Krzysztof Kozlowski
2023-02-10  9:02     ` Sameer Pujar
2023-02-09 18:36 ` (subset) [PATCH 0/2] Codec " Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).