Add codec AL5658 support on Xavier NX

How to add ALC5658 (which has already worked on AGX Xavier Dev kit) support on Xavier NX Dev Kit via I2S interface ?

Hi kang.pan,

Please refer section to add support for a custom audio card.

It has details about changes required on DT, machine and codec driver. Pinmux configuration is also required for using I2S functionality of the pins.

There are references in the forum where you can find users integrating custom audio cards on Jetson platforms.


Hi spujar,

Thanks for your reply.
I have read this document, but could not find the anwser.

We design a custom board based on Xavier NX dev kit, and add a codec chip ALC5658 on I2S1 and I2C2 of XavierNX.
Attached is our audio part schematic(XavierNX_Audio.pdf (412.9 KB)) and dts audio part(tegra194-audio-p3668.dtsi (3.4 KB)).

Now there is no voice when we connected a speaker, and play a wav with:
aplay xxx.wav

Can you please have a look.

Attatched log(XavierNX_Audio_20220525.log (771.5 KB)) is the below command output on my hardware:

aplay -l(at log line 3)

amixer -c jetsonxaviernxa contents (at log line 88)

amixer -c jetsonxaviernxa controls (at log line 11253)

Hi kang.pan

I believe you are using 40-pin GPIO expander on Xavier NX to interface your ALC5658 codec.
Note that Tegra I2S5 instance is routed to 40-pin. From your DT attachment, I see that you have added ALC5658 details to “nvidia,dai-link-1”. This is not correct because it corresponds to Tegra I2S1. You need to update nvidia,dai-link-5.
You need not modify “nvidia,dai-link-1”.

/* Override with Codec entries */
nvidia,dai-link-5 {
         link-name = "rt565x-playback";
         codec-dai = <&rt5658>;
         codec-dai-name = "rt5659-aif1";
         name-prefix = "x";

Please try above.

Hi @spujar

We are not using the NX dev kit. We designed an OEM board for Xavier NX, and connected ALC5658 to I2S1.
Base below hardware info, you can ignore the TLV320AIC3254, if we want to enable ALC5658, is my device tree correct?

Hi kang.pan

The Xavier NX module exposes DAP3 (I2S3) and DAP5(I2S5) interfaces. So you need to update corresponding DAI links. In the schematic you have mentioned I2S0 and I2S1 on Tegra side as well, so it is not clear which is one which.

Are you sure you are connecting Tegra I2S1 to ALC5658?


Hi @spujar ,

There should be some misunderstands.

In my words “I2S1” means the Xavier NX module pin which named I2S1_xxx (I2S1_SCLK, I2S1_DOUT, I2S1_DIN, I2S1_FS).
These pins is the “DAP3” from the Xavier SOC.

And the “I2S0” in my words is also the XavierNX module pin. They shold be the “DAP5” from the Xavier SOC.

OK. As per your schematic you require DAP3 for ALC5658. DAP3 corresponds to I2S3 of Tegra SoC point of view and you can try following.

/* Override with Codec entries */
nvidia,dai-link-3 {
         link-name = "rt565x-playback";
         codec-dai = <&rt5658>;
         codec-dai-name = "rt5659-aif1";
         name-prefix = "x";

No need to modify other DAI links.


Hi @spujar
Thanks for your reply.

Seems this change is not enough. My diff is as below on the L4T32.7.1 source code:

--- a/hardware/nvidia/platform/t19x/jakku/kernel-dts/common/tegra194-audio-p3668.dtsi
+++ b/hardware/nvidia/platform/t19x/jakku/kernel-dts/common/tegra194-audio-p3668.dtsi
@@ -73,6 +73,14 @@
                hdr40_snd_link_i2s: nvidia,dai-link-5 {
+                       //name-prefix = "x";
+               };
+               /* Override with Codec entries */
+               nvidia,dai-link-3 {
+                       link-name = "rt565x-playback";
+                       codec-dai = <&rt5658>;
+                       codec-dai-name = "rt5659-aif1";
                        name-prefix = "x";

There will be an build error:
"ERROR (phandle_references): Reference to non-existent node or label “rt5658"”.

Due to I have no development experience with audio. Can you share a full patch about this part ?
Or can you share some reference?

Many thanks~

This means you have not added device node for RT5658 audio codec and DT compiler reports error because of this. There is no on-board RT5658 and hence it is not added in tegra194-audio-p3668.dtsi. As I mentioned previously, please go through the steps in section. It captures the DT changes you need to make to interface a card on 40-pin.


Hi @spujar
Yes, I have update the dts as below, now it can build ok.

--- a/hardware/nvidia/platform/t19x/jakku/kernel-dts/common/tegra194-audio-p3668.dtsi
+++ b/hardware/nvidia/platform/t19x/jakku/kernel-dts/common/tegra194-audio-p3668.dtsi
@@ -14,6 +14,8 @@
 #include <audio/tegra-platforms-audio-dai-links.dtsi>
+#include <dt-bindings/gpio/tegra194-gpio.h>
+#include <dt-bindings/sound/rt5659.h>
 / {
        aconnect@2a41000 {
@@ -33,6 +35,18 @@
                status = "okay";
+       i2c@3160000 {
+               rt5658: rt5659.7-001a@1a {
+                       compatible = "realtek,rt5658";
+                       reg = <0x1a>;
+                       realtek,jd-src = <RT5659_JD_NULL>;
+                       realtek,dmic1-data-pin = <RT5659_DMIC1_NULL>;
+                       realtek,dmic2-data-pin = <RT5659_DMIC2_NULL>;
+                       gpios = <&tegra_aon_gpio TEGRA194_AON_GPIO(CC, 2) 0>;
+                       status = "okay";
+               };
+       };
        tegra_sound: sound {
                status = "okay";
                compatible = "nvidia,tegra-audio-t186ref-mobile-rt565x";
@@ -68,13 +82,14 @@
                mclk-fs = <256>;
-               nvidia,dai-link-1 {
-                       name-prefix = "n";
-               };
                hdr40_snd_link_i2s: nvidia,dai-link-5 {
-                       name-prefix = "x";
+               /* Override with Codec entries */
+               nvidia,dai-link-3 {
+                       link-name = "rt565x-playback";
+                       codec-dai = <&rt5658>;
+                       codec-dai-name = "rt5659-aif1";
+               };

After change the pinmux used, I flash the whole image and dtb build from source to device.
but the speaker also not worked, when I paly wav with:

aplay xxx.wav

and the demsg log is as below:

$ dmesg | grep sound
[    0.728081] iommu: Adding device sound to group 19
[    2.173391] input: tegra-hda-xnx HDMI/DP,pcm=3 as /devices/3510000.hda/sound/card0/input0
[    2.173532] input: tegra-hda-xnx HDMI/DP,pcm=7 as /devices/3510000.hda/sound/card0/input1
[    2.173653] input: tegra-hda-xnx HDMI/DP,pcm=8 as /devices/3510000.hda/sound/card0/input2
[    2.173777] input: tegra-hda-xnx HDMI/DP,pcm=9 as /devices/3510000.hda/sound/card0/input3
[    4.221525] tegra-asoc: sound: ADMAIF1 <-> ADMAIF1 mapping ok
[    4.221612] tegra-asoc: sound: ADMAIF2 <-> ADMAIF2 mapping ok
[    4.221709] tegra-asoc: sound: ADMAIF3 <-> ADMAIF3 mapping ok
[    4.221812] tegra-asoc: sound: ADMAIF4 <-> ADMAIF4 mapping ok
[    4.221916] tegra-asoc: sound: ADMAIF5 <-> ADMAIF5 mapping ok
[    4.221994] tegra-asoc: sound: ADMAIF6 <-> ADMAIF6 mapping ok
[    4.222072] tegra-asoc: sound: ADMAIF7 <-> ADMAIF7 mapping ok
[    4.222158] tegra-asoc: sound: ADMAIF8 <-> ADMAIF8 mapping ok
[    4.222238] tegra-asoc: sound: ADMAIF9 <-> ADMAIF9 mapping ok
[    4.222313] tegra-asoc: sound: ADMAIF10 <-> ADMAIF10 mapping ok
[    4.222398] tegra-asoc: sound: ADMAIF11 <-> ADMAIF11 mapping ok
[    4.222498] tegra-asoc: sound: ADMAIF12 <-> ADMAIF12 mapping ok
[    4.222594] tegra-asoc: sound: ADMAIF13 <-> ADMAIF13 mapping ok
[    4.222694] tegra-asoc: sound: ADMAIF14 <-> ADMAIF14 mapping ok
[    4.222773] tegra-asoc: sound: ADMAIF15 <-> ADMAIF15 mapping ok
[    4.222856] tegra-asoc: sound: ADMAIF16 <-> ADMAIF16 mapping ok
[    4.222937] tegra-asoc: sound: ADMAIF17 <-> ADMAIF17 mapping ok
[    4.223018] tegra-asoc: sound: ADMAIF18 <-> ADMAIF18 mapping ok
[    4.223105] tegra-asoc: sound: ADMAIF19 <-> ADMAIF19 mapping ok
[    4.223203] tegra-asoc: sound: ADMAIF20 <-> ADMAIF20 mapping ok
[    4.235351] tegra-asoc: sound: ASoC: no source widget found for z OUT
[    4.235580] tegra-asoc: sound: ASoC: Failed to add route z OUT -> direct -> z Headphone
[    4.235820] tegra-asoc: sound: ASoC: no sink widget found for z IN
[    4.235987] tegra-asoc: sound: ASoC: Failed to add route z Mic -> direct -> z IN
[    4.260908] input: jetson-xaviernx-ape Headset Jack as /devices/sound/sound/card1/input7

Do you have any idea?

Hi kang.pan

“z OUT” and “z IN” widgets are not found for your DAI link. These are related to the Codec driver widgets and you need to update them as per ALC5658 codec driver.

Check with following:

diff --git a/common/tegra194-audio-p3668.dtsi b/common/tegra194-audio-p3668.dtsi
index 32ea0bd..f33774a 100644
--- a/common/tegra194-audio-p3668.dtsi
+++ b/common/tegra194-audio-p3668.dtsi
@@ -51,8 +51,15 @@
                        "x IN",                 "x Mic",
                        "y Headphone",          "y OUT",
                        "y IN",                 "y Mic",
-                       "z Headphone",          "z OUT",
-                       "z IN",                 "z Mic",
+                       /* for ALC5658 speaker */
+                       "z Headphone",          "z SPOL",
+                       "z Headphone",          "z SPOR",
+                       /* for ALC5658 headphone */
+                       "z Headphone",          "z HPOL",
+                       "z Headphone",          "z HPOR",
+                       /* For ALC5658 mic */
+                       "z IN1P",               "z Mic",
+                       "z IN1N",               "z Mic",

You may also need some mixer controls to be set for playback to work:
For headphone playback following mixer controls are required:

# RT565x playback setup
"z Headphone Playback Volume", CTL{value}="31,31"
"z Stereo DAC MIXR DAC R1 Switch", CTL{value}="on"
"z Stereo DAC MIXL DAC L1 Switch", CTL{value}="on"
"z HPO R Playback Switch", CTL{value}="on"
"z HPO L Playback Switch", CTL{value}="on"
"z DAC1 Playback Volume", CTL{value}="175,175"
"z DAC1 Playback Switch", CTL{value}="on"
"z DAC1 MIXR DAC1 Switch", CTL{value}="on"
"z DAC1 MIXL DAC1 Switch", CTL{value}="on"

For speaker playback, you may have to check with ALC5658 vendor. The DAC controls would be same, but for speaker controls may be different.