Tegra machine driver source is not compiling with nvbuild.sh script for AGX Orin

Hello,

I have installed JetPack 5.1 and L4T package Jetson Linux 35.2.1 for AGX Orin dev kit and I followed the Kernel Customization wiki and complied and built the kernel successfully.
I’m working on the custom audio codec. now I’m facing the issue tegra machine driver is not compiling with nvbuild.sh script. I have made a few changes in kernel/nvidia/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver.c that are not reflected in the Orin dev kit.
Then later I added an undefined value and ; (syntax error) in tegra_machine_driver.c source and run the nvbuild.sh script but didn’t through any errors.
Please find the scripts.
nvbuild.sh (4.7 KB)
nvcommon_build.sh (1.9 KB)

Any help will be greatly appreciated.

Regards,
Parashuram

Hi,
The code may not be required for audio codec. On Orin we have enabled rt5640. You can check the driver code for reference.

Hello Danelll,

Thank you for your reply.

We are constructing a custom AGX Orin carrier card, and I used the TLV320AIC3204 TI codec in it. I’ve already added Device tree source, Kconfig, Pinmux, and Device driver changes for TI codec in order to connect the codec to the Orin development kit via the i2C and I2S2 connections.
I’m unable to compile after applying TI codec changes to the Tegra machine driver file.
Please let me know what steps in the compilation process I’m missing.

Any help will be greatly appreciated.

Regards,
Parashuram

Hi,

I’m awaiting your response. It would be very grateful if you could let me know.

Thanks,
Parashuram

Hi,
Please also check this section in developer guide:
Audio Setup and Development — Jetson Linux Developer Guide documentation

I have already followed this document and referred steps mentioned there. I am facing trouble in compiling the source code. Any intentional syntax error introduced in this file does not end up in a throwing error. Am I missing something in the compilation steps? Can you please share any document which mentions the build step related to kernel. I have followed the kernel customization steps as mentioned here.
Thanks,
Parashuram

Hi,
It should not be required to building the file. The driver code is tegra_asoc_machine.c and it is built by default. Should only need to modify device tee to fit the hardware. On Jetpack 5.1, RT5640 on Orin developer kit is enabled. Please refer to device tree in tegra234-p3737-audio.dtsi

Hello Danelll,

Thank you for responding.
I understand that RT5640 changes need only the device tree changes. However, in our design, we used a different audio codec (TLV320AIC3204 from TI) instead of the RT5640. I would appreciate it if you could let me know what changes are required to enable TLV320AIC3204 codec with the Orin Platform.

I have gone through this wiki Audio Setup and Development — Jetson Linux Developer Guide documentation
and made necessary changes.

Pinmux changes:

index 06b25b19f..90f6f0293 100644
--- a/bootloader/t186ref/BCT/tegra234-mb1-bct-pinmux-p3701-0000.dtsi
+++ b/bootloader/t186ref/BCT/tegra234-mb1-bct-pinmux-p3701-0000.dtsi
@@ -289,6 +289,16 @@
 				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
 			};
 
+			soc_gpio33_pq6 {
+				nvidia,pins = "soc_gpio33_pq6";
+				nvidia,function = "extperiph4";
+				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
+				nvidia,tristate = <TEGRA_PIN_DISABLE>;
+				nvidia,enable-input = <TEGRA_PIN_DISABLE>;
+				nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
+				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
+			};
+
 			soc_gpio37_pr0 {
 				nvidia,pins = "soc_gpio37_pr0";
 				nvidia,function = "gp";
@@ -449,6 +459,42 @@
 				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
 			};
 
+			soc_gpio41_ph7 {
+				nvidia,pins = "soc_gpio41_ph7";
+				nvidia,function = "i2s2";
+				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
+				nvidia,tristate = <TEGRA_PIN_DISABLE>;
+				nvidia,enable-input = <TEGRA_PIN_DISABLE>;
+				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
+			};
+
+			soc_gpio42_pi0 {
+				nvidia,pins = "soc_gpio42_pi0";
+				nvidia,function = "i2s2";
+				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
+				nvidia,tristate = <TEGRA_PIN_DISABLE>;
+				nvidia,enable-input = <TEGRA_PIN_DISABLE>;
+				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
+			};
+
+			soc_gpio43_pi1 {
+				nvidia,pins = "soc_gpio43_pi1";
+				nvidia,function = "i2s2";
+				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
+				nvidia,tristate = <TEGRA_PIN_ENABLE>;
+				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
+				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
+			};
+
+			soc_gpio44_pi2 {
+				nvidia,pins = "soc_gpio44_pi2";
+				nvidia,function = "i2s2";
+				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
+				nvidia,tristate = <TEGRA_PIN_DISABLE>;
+				nvidia,enable-input = <TEGRA_PIN_DISABLE>;
+				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
+			};
+
 			gen1_i2c_scl_pi3 {
 				nvidia,pins = "gen1_i2c_scl_pi3";
 				nvidia,function = "i2c1";
@@ -1217,16 +1263,6 @@
 				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
 			};
 
-			soc_gpio33_pq6 {
-				nvidia,pins = "soc_gpio33_pq6";
-				nvidia,function = "rsvd0";
-				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
-				nvidia,tristate = <TEGRA_PIN_ENABLE>;
-				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
-				nvidia,io-high-voltage = <TEGRA_PIN_DISABLE>;
-				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
-			};
-
 			soc_gpio35_pq7 {
 				nvidia,pins = "soc_gpio35_pq7";
 				nvidia,function = "rsvd0";
@@ -1375,42 +1411,6 @@
 				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
 			};
 
-			soc_gpio41_ph7 {
-				nvidia,pins = "soc_gpio41_ph7";
-				nvidia,function = "rsvd2";
-				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
-				nvidia,tristate = <TEGRA_PIN_ENABLE>;
-				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
-				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
-			};
-
-			soc_gpio42_pi0 {
-				nvidia,pins = "soc_gpio42_pi0";
-				nvidia,function = "rsvd2";
-				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
-				nvidia,tristate = <TEGRA_PIN_ENABLE>;
-				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
-				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
-			};
-
-			soc_gpio43_pi1 {
-				nvidia,pins = "soc_gpio43_pi1";
-				nvidia,function = "rsvd2";
-				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
-				nvidia,tristate = <TEGRA_PIN_ENABLE>;
-				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
-				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
-			};
-
-			soc_gpio44_pi2 {
-				nvidia,pins = "soc_gpio44_pi2";
-				nvidia,function = "rsvd2";
-				nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
-				nvidia,tristate = <TEGRA_PIN_ENABLE>;
-				nvidia,enable-input = <TEGRA_PIN_ENABLE>;
-				nvidia,lpdr = <TEGRA_PIN_DISABLE>;
-			};
-
 			cpu_pwr_req_pi5 {
 				nvidia,pins = "cpu_pwr_req_pi5";
 				nvidia,function = "rsvd0";

diff --git a/bootloader/tegra234-mb1-bct-gpio-p3701-0000.dtsi b/bootloader/tegra234-mb1-bct-gpio-p3701-0000.dtsi
index 1bc8272b9..c8b380d90 100644
--- a/bootloader/tegra234-mb1-bct-gpio-p3701-0000.dtsi
+++ b/bootloader/tegra234-mb1-bct-gpio-p3701-0000.dtsi
@@ -34,7 +34,6 @@
 				TEGRA234_MAIN_GPIO(Z, 7)
 				TEGRA234_MAIN_GPIO(P, 4)
 				TEGRA234_MAIN_GPIO(P, 6)
-				TEGRA234_MAIN_GPIO(Q, 6)
 				TEGRA234_MAIN_GPIO(Q, 7)
 				TEGRA234_MAIN_GPIO(R, 1)
 				TEGRA234_MAIN_GPIO(N, 4)
@@ -45,10 +44,7 @@
 				TEGRA234_MAIN_GPIO(G, 7)
 				TEGRA234_MAIN_GPIO(H, 0)
 				TEGRA234_MAIN_GPIO(H, 5)
-				TEGRA234_MAIN_GPIO(H, 7)
-				TEGRA234_MAIN_GPIO(I, 0)
 				TEGRA234_MAIN_GPIO(I, 1)
-				TEGRA234_MAIN_GPIO(I, 2)
 				TEGRA234_MAIN_GPIO(AC, 3)
 				TEGRA234_MAIN_GPIO(AC, 4)
 				TEGRA234_MAIN_GPIO(AC, 5)
@@ -84,6 +80,10 @@
 				TEGRA234_MAIN_GPIO(A, 2)
 				>;
 			gpio-output-high = <
+				TEGRA234_MAIN_GPIO(H, 7)
+				TEGRA234_MAIN_GPIO(I, 0)
+				TEGRA234_MAIN_GPIO(I, 2)
+				TEGRA234_MAIN_GPIO(Q, 6)
 				TEGRA234_MAIN_GPIO(Y, 0)
 				TEGRA234_MAIN_GPIO(Y, 1)
 				TEGRA234_MAIN_GPIO(Y, 2)

DTS changes in /sources/hardware/nvidia/platform/t23x/concord/kernel-dts/cvb/tegra234-p3737-audio.dtsi

diff --git a/sources/hardware/nvidia/platform/t23x/concord/kernel-dts/cvb/tegra234-p3737-audio.dtsi b/sources/hardware/nvidia/platform/t23x/concord/kernel-dts/cvb/tegra234-p3737-audio.dtsi
index 3acc0854e..5fca0b78d 100644
--- a/sources/hardware/nvidia/platform/t23x/concord/kernel-dts/cvb/tegra234-p3737-audio.dtsi
+++ b/sources/hardware/nvidia/platform/t23x/concord/kernel-dts/cvb/tegra234-p3737-audio.dtsi
@@ -14,6 +14,35 @@
 #include <audio/tegra-platforms-audio-dmic3-5-switch.dtsi>
 
 / {
+	/*Added Audio codec DT Changes*/
+        i2c@c250000 {
+		fsync-width = <0>;
+                aic32x4: tlv320aic32x4.1-0018@18 {
+                        compatible = "ti,tlv320aic32x4";
+                        status = "okay";
+                        reg = <0x18>;
+                        clocks = <&bpmp TEGRA234_CLK_AUD_MCLK>;
+                        //clocks = <&tegra_car TEGRA186_CLK_AUD_MCLK>; 
+                        clock-names = "mclk";
+                        dv-supply = <&battery_reg>;
+                        av-supply = <&battery_reg>;
+                        iov-supply = <&battery_reg>;
+
+                        #sound-dai-cells = <1>;
+                        sound-name-prefix = "TI-TLV320";
+
+                };
+        };
+	
+	clocks {
+    		aic32x4_mclk: aic32x4_mclk {
+       			 compatible = "fixed-clock";
+        		#clock-cells = <0>;
+        		clock-frequency = <12288000>;
+        		clock-output-names = "aic32x4-mclk";
+        		status = "okay";
+    		};
+	};
 	aconnect@2a41000 {
 		status = "okay";
 
@@ -26,9 +55,16 @@
 		};
 
 		ahub {
+			status = "okay";
 			/* I2S4 in Short frame sync for BT SCO */
 			i2s@2901300 {
-				bclk-ratio = <4>;
+				blck-ratio = <4>;
+				status = "okay";
+				};
+			/*I2S2 in Short frame sync for BT SCO */
+                        i2s@2901100 {
+				//bclk-ratio = <4>;
+			        status = "okay";
 			};
 		};
 	};
@@ -41,7 +77,6 @@
 		nvidia,model = "NVIDIA Jetson AGX Orin HDA";
 		status = "okay";
 	};
-
 	tegra_sound: sound {
 		status = "okay";
 		compatible = "nvidia,tegra186-ape";
@@ -52,6 +87,20 @@
 		clock-names = "pll_a", "pll_a_out0", "extern1";
 		assigned-clocks = <&bpmp_clks TEGRA234_CLK_AUD_MCLK>;
 		assigned-clock-parents = <&bpmp_clks TEGRA234_CLK_PLLA_OUT0>;
+			nvidia-audio-card,widgets =
+    				"Headphone",    "TI-TLV320 Headphone",
+    				"Microphone",   "TI-TLV320 Mic",
+    				"Line",         "TI-TLV320 Line In",
+    				"Line",         "TI-TLV320 Line Out";
+
+			nvidia-audio-card,routing =
+    				"TI-TLV320 Headphone",   "TI-TLV320 HP_OUT",
+    				"TI-TLV320 MIC_IN",      "TI-TLV320 Mic",
+    				"TI-TLV320 ADC",         "TI-TLV320 Mic Bias",
+    				"TI-TLV320 LINE_IN",     "TI-TLV320 Line In",
+    				"TI-TLV320 Line Out",    "TI-TLV320 LINE_OUT";
+                	nvidia-audio-card,mclk-fs = <256>;
+
 	};
 
 	tegra_sound_graph: sound_graph {
@@ -203,16 +252,28 @@
  * platform specific files.
  */
 
-hdr40_snd_link_i2s: &i2s2_to_codec { };
+hdr40_snd_link_i2s: &i2s2_to_codec {
+	link-name = "ti-capture";
+    	bitclock-master;
+    	frame-master;	
+	codec {
+        	sound-dai = <&aic32x4>;
+        	prefix = "TI-TLV320";
+    	};
+};
 
 /* Override with BT SCO entries */
 &i2s4_to_codec {
 	format = "dsp_a";
 	bitclock-inversion;
 };
+&i2s2_to_codec {
+        format = "dsp_a";
+        bitclock-inversion;
+};

Kconfig chages

diff --git a/sources/kernel/nvidia/sound/soc/tegra-alt/Kconfig b/sources/kernel/nvidia/sound/soc/tegra-alt/Kconfig
index eed57b8e5..84ff1bc14 100644
--- a/sources/kernel/nvidia/sound/soc/tegra-alt/Kconfig
+++ b/sources/kernel/nvidia/sound/soc/tegra-alt/Kconfig
@@ -201,6 +201,9 @@ config SND_SOC_TEGRA210_AUDIO_ALT
 	select SND_SOC_RT5640
 	select SND_SOC_RT5659
 	select SND_SOC_SGTL5000
+	select SND_SOC_TLV320AIC32X4
+        select SND_SOC_TLV320AIC32X4_I2C

Tegra machine driver changes

diff --git a/sources/kernel/nvidia/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver.c b/sources/kernel/nvidia/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver.c
index 28dd5f479..a81bad443 100644
--- a/sources/kernel/nvidia/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver.c
+++ b/sources/kernel/nvidia/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver.c
@@ -30,6 +30,7 @@
 #include <dt-bindings/sound/tas2552.h>
 #include "rt5659.h"
 #include "sgtl5000.h"
+#include "tlv320aic32x4.h"
 #include "tegra_asoc_machine_alt.h"
 #include "tegra210_xbar_alt.h"
 
@@ -391,6 +392,21 @@ static int tegra_machine_fepi_init(struct snd_soc_pcm_runtime *rtd)
 
 	return 0;
 }
+/*Added for TLV320AIC32X4 Audio codec changes*/
+static int tegra_machine_aic32x4_init(struct snd_soc_pcm_runtime *rtd)
+{
+        struct device *dev = rtd->card->dev;
+        int err;
+
+        err = snd_soc_dai_set_sysclk(rtd->codec_dai, aic32x4_SYSCLK, 12288000,
+                                     SND_SOC_CLOCK_IN);
+        if (err) {
+                dev_err(dev, "failed to set aic32x4 sysclk!\n");
+                return err;
+        }
+
[components.txt|attachment](upload://8ySRy1fs06izDHbBt81EARhy5iT.txt) (1008 Bytes)
[components.txt|attachment](upload://8ySRy1fs06izDHbBt81EARhy5iT.txt) (1008 Bytes)
[dais.txt.txt|attachment](upload://a1vTO3SlCsonRQoTpYC6v6Ipeaq.txt) (3.9 KB)
[dmesg.log|attachment](upload://m8LtiuVYEjU1sSHE5HqhxzPXXtU.log) (75.3 KB)
[dt.log|attachment](upload://rkdOrMSjbgvEzUD5G3YRfIrvOFC.log) (491.4 KB)

+        return 0;
+}
 
 static int tegra_machine_rt565x_init(struct snd_soc_pcm_runtime *rtd)
 {
@@ -451,6 +467,8 @@ static int codec_init(struct tegra_machine *machine)
 			dai_links[i].init = tegra_machine_rt565x_init;
 		else if (strstr(dai_links[i].name, "fe-pi-audio-z-v2"))
 			dai_links[i].init = tegra_machine_fepi_init;
+		else if (strstr(dai_links[i].name, "ti-capture"))
+                        dai_links[i].init = tegra_machine_aic32x4_init;
 		else if (strstr(dai_links[i].name, "respeaker-4-mic-array"))
 			dai_links[i].init = tegra_machine_respeaker_init;
 	}

Linux kernel configuration:

root@ubuntu:/home/orin# zcat /proc/config.gz | grep "TLV320AIC3"
# CONFIG_SND_SOC_TLV320AIC31XX is not set
CONFIG_SND_SOC_TLV320AIC32X4=y
CONFIG_SND_SOC_TLV320AIC32X4_I2C=y
# CONFIG_SND_SOC_TLV320AIC32X4_SPI is not set
CONFIG_SND_SOC_TLV320AIC3X=y

Please find the attached reference logs.
components.txt (1008 Bytes)
dais.txt.txt (3.9 KB)
dmesg.log (75.3 KB)
dt.log (491.4 KB)
I2c

Regards,
Parashuram

Hi,
Please continue the discussion in the topic thread:
TLV320AIC3204 Driver will support for AGX Orin 64GB SOM?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.