Skip to contentSkip to conversation

Codec support on Jetson AGX Orin

PATCH Superseded Sameer Pujar 4 participants 9 messages Feb 9, 2023 – Feb 12, 2023

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Codec support on Jetson AGX Orin

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(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/2 ASoC: rt5640: Update MCLK rate in set_sysclk()

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

---
 sound/soc/codecs/rt5640.c | 5 +++++
 1 file changed, 5 insertions(+)
sound/soc/codecs/rt5640.c +5 -0
index 9e6341a..1392570 100644
@@ -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:
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH 1/2] ASoC: rt5640: Update MCLK rate in set_sysclk()

Hi Sameer

Quoted 4 lines

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

#3 lore raw

Re: [PATCH 1/2] ASoC: rt5640: Update MCLK rate in set_sysclk()

Hi Morimoto-san,

Quoted 11 lines · Kuninori Morimoto
Quoted 5 lines

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/[email protected]/#2647112
[1] https://lore.kernel.org/lkml/[email protected]/

#4 lore raw

Re: [PATCH 1/2] ASoC: rt5640: Update MCLK rate in set_sysclk()

Hi Sameer

Quoted 12 lines
Quoted 4 lines

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.

Quoted 5 lines

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

#5 lore raw

PATCH 2/2 arm64: tegra: Audio codec support on Jetson AGX Orin

In reply to Sameer Pujar

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

---
 .../dts/nvidia/tegra234-p3737-0000+p3701-0000.dts  | 47 +++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts +46 -1
index 8a97478..5881fbf 100644
@@ -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";
 	};
 };
Signature · 1 line
2.7.4
#6 lore raw

Re: [PATCH 2/2] arm64: tegra: Audio codec support on Jetson AGX Orin

Quoted 30 lines · Sameer Pujar

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

---
 .../dts/nvidia/tegra234-p3737-0000+p3701-0000.dts  | 47 +++++++++++++++++++++-
 1 file changed, 46 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts +2 -1
index 8a97478..5881fbf 100644
@@ -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>;
 							};
 						};
 					};

arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts line 2025

Quoted 8 lines
arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts +5 -0
@@ -2017,6 +2018,32 @@
 			status = "okay";
 		};
 
+		i2c@31e0000 {
+			status = "okay";
+
+			audio-codec@1c {
+				status = "okay";

Are you sure you need this?

Best regards,
Krzysztof

#7 lore raw

Re: [PATCH 2/2] arm64: tegra: Audio codec support on Jetson AGX Orin

Quoted 34 lines · Krzysztof Kozlowski
Quoted 33 lines · Sameer Pujar

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

---
  .../dts/nvidia/tegra234-p3737-0000+p3701-0000.dts  | 47 +++++++++++++++++++++-
  1 file changed, 46 insertions(+), 1 deletion(-)
arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts +2 -1
index 8a97478..5881fbf 100644
@@ -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";
               };
 
Quoted 7 lines

arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts line 2025

Quoted 6 lines
arch/arm64/boot/dts/nvidia/tegra234-p3737-0000+p3701-0000.dts +5 -0
+             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.

maintainer
#8 lore raw

Re: (subset) [PATCH 0/2] Codec support on Jetson AGX Orin

In reply to Sameer Pujar
Quoted 9 lines · 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

[...]

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