Porting Codec from Jetpack 4 to Jetpack 5 (r35.4.1)

Hello,

We are upgrading our AGX Xavier kernel from Jetpack 4 (r32.7.1) to Jetpack 5 (r35.4.1) and I am having trouble with getting our audio codec to work on the new kernel version. It is an ADAU1361 connected via the 40-pin header.

This is what has been working in r32.7.1

	i2c@31e0000 {
		adau1361_codec: adau1361@38 {
			compatible = "adi,adau1361";
			reg = <0x38>;
			clocks = <&bpmp_clks TEGRA194_CLK_EXTPERIPH4>;
			clock-names = "mclk";
		};
	};

	i2s@2901000 {
		status = "okay";
	};

	sound {
		assigned-clocks = <&bpmp_clks TEGRA194_CLK_PLLA_OUT0>, <&bpmp_clks TEGRA194_CLK_EXTPERIPH4>;
		assigned-clock-parents = <&bpmp_clks TEGRA194_CLK_PLLA>, <&bpmp_clks TEGRA194_CLK_PLLP_OUT0>;
		assigned-clock-rates = <0>, <24000000>;
		mclk-fs = <0>;

		nvidia,audio-routing =
			"m Headphone", "m LOUT",
			"m Headphone", "m ROUT",
			"m Mic", "m MICBIAS",
			"m LINP", "m Mic",
			"m LINN", "m Mic",
			"m RINP", "m Mic",
			"m RINN", "m Mic";

		nvidia,dai-link-2 {
			link-name = "adau1361-codec";
			cpu-dai = <&tegra_i2s2>;
			codec-dai = <&adau1361_codec>;
			cpu-dai-name = "I2S2";
			codec-dai-name = "adau-hifi";
			format = "i2s";
			bitclock-slave;
			frame-slave;
			bitclock-noninversion;
			frame-noninversion;
			bit-format = "s32_le";
			bclk_ratio = <1>;
			srate = <48000>;
			num-channel = <2>;
			ignore_suspend;
			name-prefix = "m";
			status = "okay";
		};
	};

This is what I’ve tried so far (following the dev guide) on r35.4.1

#include "../../galen/kernel-dts/common/tegra194-audio-p2822-0000.dtsi"

/ {
	i2c@31e0000 {
		adau1361: adau1361@38 {
			compatible = "adi,adau1361";
			reg = <0x38>;

			clocks = <&bpmp_clks TEGRA194_CLK_EXTPERIPH4>;
			clock-names = "mclk";

			#sound-dai-cells = <1>;
			sound-name-prefix = "m";

			port {
				adau1361_ep: endpoint {
					remote-endpoint = <&i2s2_dap_ep>;
					mclk-fs = <0>;
					link-name = "adau1361-codec";
				};
			};
		};
	};

	i2s@2901000 {
		status = "okay";
	};

	sound {
		assigned-clocks = <&bpmp_clks TEGRA194_CLK_AUD_MCLK>;
		assigned-clock-parents = <&bpmp_clks TEGRA194_CLK_PLLA_OUT0>;
		assigned-clock-rates = <24000000>;
		nvidia-audio-card,mclk-fs = <0>;

		nvidia-audio-card,widgets =
			"Headphone",	"m Headphone",
			"Microphone",	"m Mic",
			"Line",         "m LINP",
			"Line",         "m LINN",
			"Line",         "m RINP",
			"Line",         "m RINN";

		nvidia-audio-card,routing =
			"m Headphone", "m LOUT",
			"m Headphone", "m ROUT",
			"m Mic", "m MICBIAS",
			"m LINP", "m Mic",
			"m LINN", "m Mic",
			"m RINP", "m Mic",
			"m RINN", "m Mic";
	};
};

&i2s2_to_codec {
	link-name = "adau1361-codec";
	bit-format = "s32_le";
	bclk_ratio = <1>;
	srate = <48000>;
	num-channel = <2>;
	ignore_suspend;
	codec {
		sound-dai = <&adau1361 0>;
		prefix = "m";
	};
};

&i2s2_dap_ep {
	remote-endpoint = <&adau1361_ep>;
};

I have applied the following changes to tegra_codecs.c:

diff --git a/sound/soc/tegra/tegra_codecs.c b/sound/soc/tegra/tegra_codecs.c
index 280fa41c74e9..c7d972c1aa75 100644
--- a/sound/soc/tegra/tegra_codecs.c
+++ b/sound/soc/tegra/tegra_codecs.c
@@ -28,6 +28,22 @@ static int tegra_audio_dai_init(struct snd_soc_pcm_runtime *rtd)
 	return 0;
 }
 
+static int tegra_machine_adau136x_init(struct snd_soc_pcm_runtime *rtd)
+{
+	struct device *dev = rtd->card->dev;
+    int err;
+
+	err = snd_soc_dai_set_sysclk(rtd->dais[rtd->num_cpus], 0, 19200000,
+		SND_SOC_CLOCK_IN);
+
+	if (err) {
+		dev_err(dev, "failed to set adau136x sysclk!\n");
+		return err;
+	}
+
+	return 0;
+}
+
 static int tegra_machine_rt56xx_init(struct snd_soc_pcm_runtime *rtd)
 {
 	struct snd_soc_component *cmpnt = rtd->dais[rtd->num_cpus]->component;
@@ -262,6 +278,8 @@ int tegra_codecs_init(struct snd_soc_card *card)
 			dai_links[i].init = tegra_machine_fepi_init;
 		else if (strstr(dai_links[i].name, "respeaker-4-mic-array"))
 			dai_links[i].init = tegra_machine_respeaker_init;
+		else if (strstr(dai_links[i].name, "adau1361-codec"))
+			dai_links[i].init = tegra_machine_adau136x_init;
 	}
 
 	return 0;

The codec probes, but I have no APE sound card at all. Here’s the contents of /proc/asound/cards:

# cat /proc/asound/cards
 0 [HDA            ]: tegra-hda - NVIDIA Jetson AGX Xavier HDA
                      NVIDIA Jetson AGX Xavier HDA at 0x3518000 irq 52

In r32.7.1 my amixer controls showed up under card 1 (amixer -c 1). But in r35.4.1 I can’t see anything with amixer. I’m assuming this is because the APE isn’t loading properly. What am I missing?

Thanks!
Wilkins

I’m thinking I may need to write a platform_driver file (e.g., tegra_sgtl5000.c). My codec only has an i2c_driver

nova@marco:~$ cat /proc/asound/cards 
 0 [HDA            ]: tegra-hda - NVIDIA Jetson AGX Xavier HDA
                      NVIDIA Jetson AGX Xavier HDA at 0x3518000 irq 52
 1 [APE            ]: tegra-ape - NVIDIA Jetson AGX Xavier APE
                      Unknown-Jetson_AGX-NotSpecified

I added the platform driver, APE showed up, and everything seems to be working now

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