Jetson Xaver NX Jetpack 4.6.2 ADAPTS TLV320AIC3101 audio chip

Hello, I have modified my device tree and kernel source code by referring to the configuration of others in the forum, but the sound cannot be played, could you help me to see where the problem is?

My changes are as follows:
hardware/nvidia/platform/t19x/jakku/kernel-dts/common/tegra194-p3668-common.dtsi
aic3x: tlv320aic3x@18 {
compatible = “ti,tlv320aic3x”;
reg = <0x18>;

        status ="okay";

        gpio-reset = <&tegra_main_gpio TEGRA194_MAIN_GPIO(T, 3) GPIO_ACTIVE_LOW>;   //AUDIO_RST

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

        AVDD-supply = <&p3509_vdd_3v3_cvb>;
        IOVDD-supply = <&p3509_vdd_3v3_cvb>;
        DRVDD-supply = <&p3509_vdd_3v3_cvb>;
        DVDD-supply = <&p3509_vdd_1v8_cvb>;
    };

hardware/nvidia/platform/t19x/jakku/kernel-dts/common/tegra194-audio-p3668.dtsi
tegra_sound: sound {
status = “okay”;
compatible = “nvidia,tegra-audio-t186ref-mobile-rt565x”;
nvidia,model = “jetson-xaviernx-ape”;

    nvidia,num-codec-link = <12>;
    nvidia,num-clk = <8>;

    clocks = <&bpmp_clks TEGRA194_CLK_PLLA>,
         <&bpmp_clks TEGRA194_CLK_PLLA_OUT0>,
         <&bpmp_clks TEGRA194_CLK_AUD_MCLK>;
    clock-names = "pll_a", "pll_a_out0", "extern1";
    assigned-clocks = <&bpmp_clks TEGRA194_CLK_PLLA_OUT0>,
              <&bpmp_clks TEGRA194_CLK_AUD_MCLK>;
    assigned-clock-parents = <&bpmp_clks TEGRA194_CLK_PLLA>,
                 <&bpmp_clks TEGRA194_CLK_PLLA_OUT0>;
    assigned-clock-rates = <0>, <12000000>;     //bxl

    nvidia,audio-routing =
        //"x Headphone",          "x OUT",
        //"x IN",                 "x Mic",
        /*
        "x Headphone",  "x HPL",
        "x Headphone",  "x HPR",
        "x Int Spk",    "x SPK",
        "x MIC1LP",     "x Mic",
        "x MIC1RP",     "x Mic",
        "x MIC1LM",     "x Mic",
        "y Headphone",          "y OUT",
        "y IN",                 "y Mic",
        "z Headphone",          "z OUT",
        "z IN",                 "z Mic",
        "m Headphone",          "m OUT",
        "m IN",                 "m Mic",
        "n Headphone",          "n OUT",
        "n IN",                 "n Mic",
        "o Headphone",          "o OUT",
        "o IN",                 "o Mic",
        "a IN",                 "a Mic",
        "b IN",                 "b Mic",
        "c IN",                 "c Mic",
        "d IN",                 "d Mic",
        "d1 Headphone",         "d1 OUT",
        "d2 Headphone",         "d2 OUT";
        */
        "x IN1_L", "x Line In",
        "x IN1_R", "x Line In",
        "x Line Out", "x LOL",
        "x Line Out", "x LOR",
        "x Left DAC", "x Playback",
        "x Right DAC", "x Playback",
        "x Capture", "x Left ADC",
        "x Capture", "x Right ADC";
    //mclk-fs = <256>;
    nvidia,xbar = <&tegra_axbar>;

    nvidia,dai-link-1 {
        name-prefix = "n";
        status = "disabled";
    };
    nvidia,dai-link-2 { status = "disabled";};
    nvidia,dai-link-3 { status = "disabled";};
    nvidia,dai-link-4 { status = "disabled";};
    nvidia,dai-link-6 { status = "disabled";};
    nvidia,dai-link-7 { status = "disabled";};
    nvidia,dai-link-8 { status = "disabled";};
    nvidia,dai-link-9 { status = "disabled";};
    nvidia,dai-link-10 { status = "disabled";};
    nvidia,dai-link-11 { status = "disabled";};
    nvidia,dai-link-12 { status = "disabled";};

    hdr40_snd_link_i2s: nvidia,dai-link-5 {

        link-name = "tlv320aic3x-codec";
        cpu-dai = <&tegra_i2s5>;
        codec-dai = <&aic3x>;
        cpu-dai-name = "I2S5";
        codec-dai-name = "tlv320aic3x-hifi";
        tx-mask = <0xFF>;
        rx-mask = <0xFF>;
        format = "i2s";
        bitclock-slave;
        frame-slave;
        //bitclock-master;
        //frame-master;
        bitclock-noninversion;
        frame-noninversion;
        bit-format = "s16_le";
        bclk_ratio = <0>;
        srate = <44100>;
        num-channel = <2>;
        ignore_suspend;
        //name-prefix = "z";
        //name-prefix = "n";
        name-prefix = "x";
        status = "okay";
        //name-prefix = "x";
    };

};

kernel/nvidia/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c

static int tegra_machine_dai_init(struct snd_soc_pcm_runtime *runtime,
unsigned int rate, unsigned int channels,
u64 formats)
{

rtd = snd_soc_get_pcm_runtime(card, “tlv320aic3x-codec”);
if (rtd) {
dai_params =
(struct snd_soc_pcm_stream *)rtd->dai_link->params;

    dai_params->rate_min = srate;
    dai_params->channels_min = channels;
    //dai_params->formats = formats;
    dai_params->formats = (machine->fmt_via_kcontrol == 2) ?
        (1ULL << SNDRV_PCM_FORMAT_S32_LE) : formats;

    err = snd_soc_dai_set_sysclk(rtd->codec_dai, 0,
                     12000000, SND_SOC_CLOCK_IN);
    printk("bxlbxl tlv320aic3x-codec%s %s %d\n", __FILE__, __FUNCTION__,__LINE__);
    if (err < 0) {
        dev_err(card->dev, "codec_dai clock not set\n");
        printk("bxlbxl sysclk audmclk%s %s %d\n", __FILE__, __FUNCTION__,__LINE__);
        return err;
    }
}
.....

}

static int tegra_machine_tlv320aic3x_init(struct snd_soc_pcm_runtime *rtd)
{
struct device *dev = rtd->card->dev;
int err;

printk("bxlbxl  %s %s %d\n", __FILE__, __FUNCTION__,__LINE__);
err = snd_soc_dai_set_sysclk(rtd->codec_dai, 0, 12000000,
                             SND_SOC_CLOCK_IN);
if (err) {
        dev_err(dev, "failed to set tlv320aic3x sysclk!\n");
        printk("bxlbxl aic3x sysclk %s %s %d\n", __FILE__, __FUNCTION__,__LINE__);
        return err;
}
printk("bxlbxl  %s %s %d\n", __FILE__, __FUNCTION__,__LINE__);

return 0;

}

static int codec_init(struct tegra_machine *machine)
{
struct snd_soc_dai_link *dai_links = machine->asoc->dai_links;
unsigned int num_links = machine->asoc->num_links, i;

if (!dai_links || !num_links)
    return -EINVAL;

for (i = 0; i < num_links; i++) {
    if (!dai_links[i].name)
        continue;

    if (strstr(dai_links[i].name, "rt565x-playback") ||
        strstr(dai_links[i].name, "rt565x-codec-sysclk-bclk1"))
        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, "respeaker-4-mic-array"))
        dai_links[i].init = tegra_machine_respeaker_init;
    else if (strstr(dai_links[i].name, "tlv320aic3x-codec"))
        dai_links[i].init = tegra_machine_tlv320aic3x_init;
}

return 0;

}

kernel/nvidia/sound/soc/tegra-alt/Kconfig
config SND_SOC_TEGRA210_AUDIO_ALT
tristate “SoC Audio support for Tegra210”
depends on I2C
depends on ARCH_TEGRA_210_SOC || ARCH_TEGRA_18x_SOC
select SND_SOC_TEGRA210_XBAR_ALT
select SND_SOC_TEGRA210_PCM_ALT
select SND_SOC_TEGRA210_ADMA_ALT
select SND_SOC_TEGRA210_ADMAIF_ALT
select SND_SOC_TEGRA210_I2S_ALT
select SND_SOC_TEGRA210_DMIC_ALT
select SND_SOC_TEGRA210_AMX_ALT
select SND_SOC_TEGRA210_ADX_ALT
select SND_SOC_TEGRA210_MIXER_ALT
select SND_SOC_TEGRA210_SFC_ALT
select SND_SOC_TEGRA210_AFC_ALT
select SND_SOC_TEGRA210_MVC_ALT
select SND_SOC_TEGRA210_OPE_ALT
select SND_SOC_TEGRA210_ADSP_ALT if TEGRA_NVADSP && !DISABLE_ADSP_AUDIO
select SND_SOC_TEGRA186_ASRC_ALT if ARCH_TEGRA_18x_SOC
select SND_SOC_TEGRA186_ARAD_ALT if ARCH_TEGRA_18x_SOC
select SND_SOC_TEGRA186_DSPK_ALT if ARCH_TEGRA_18x_SOC
select SND_SOC_SPDIF
select SND_SOC_COMPRESS
select SND_SOC_RT5640
select SND_SOC_RT5659
select SND_SOC_SGTL5000
select SND_SOC_TLV320AIC3X
help
Say Y or M here if you want to enable support for ASoC machine driver on
Tegra210 and successor platforms like Tegra186, Tegra194.

dmesg :
[ 8.824324] bxlbxl /workspace/NVIDIA_Sources/JetPack4.6.2_NX_32.7.2_sources/JetPack_4.6.2_Linux_JETSON_XAVIER_NX_TARGETS/Linux_for_Tegra/sources-AI600-SC/kernel/kernel-4.9/sound/soc/codecs/tlv320aic3x.c aic3x_i2c_probe 1818
[ 8.849006] input: tegra-hda-xnx HDMI/DP,pcm=3 as /devices/3510000.hda/sound/card0/input3
[ 8.849266] input: tegra-hda-xnx HDMI/DP,pcm=7 as /devices/3510000.hda/sound/card0/input4
[ 8.849515] input: tegra-hda-xnx HDMI/DP,pcm=8 as /devices/3510000.hda/sound/card0/input5
[ 8.849709] input: tegra-hda-xnx HDMI/DP,pcm=9 as /devices/3510000.hda/sound/card0/input6
[ 8.857820] OPE platform probe
[ 8.857929] OPE platform probe successful
[ 8.860484] bxlbxl /workspace/NVIDIA_Sources/JetPack4.6.2_NX_32.7.2_sources/JetPack_4.6.2_Linux_JETSON_XAVIER_NX_TARGETS/Linux_for_Tegra/sources-AI600-SC/kernel/nvidia/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c tegra_machine_driver_probe 770
[ 8.926464] bxlbxl /workspace/NVIDIA_Sources/JetPack4.6.2_NX_32.7.2_sources/JetPack_4.6.2_Linux_JETSON_XAVIER_NX_TARGETS/Linux_for_Tegra/sources-AI600-SC/kernel/kernel-4.9/sound/soc/codecs/tlv320aic3x.c aic3x_probe 1671
[ 8.932721] tegra-asoc: sound: ADMAIF1 <-> ADMAIF1 mapping ok
[ 8.932839] tegra-asoc: sound: ADMAIF2 <-> ADMAIF2 mapping ok
[ 8.932953] tegra-asoc: sound: ADMAIF3 <-> ADMAIF3 mapping ok
[ 8.933061] tegra-asoc: sound: ADMAIF4 <-> ADMAIF4 mapping ok
[ 8.933191] tegra-asoc: sound: ADMAIF5 <-> ADMAIF5 mapping ok
[ 8.933324] tegra-asoc: sound: ADMAIF6 <-> ADMAIF6 mapping ok
[ 8.933444] tegra-asoc: sound: ADMAIF7 <-> ADMAIF7 mapping ok
[ 8.933588] tegra-asoc: sound: ADMAIF8 <-> ADMAIF8 mapping ok
[ 8.933707] tegra-asoc: sound: ADMAIF9 <-> ADMAIF9 mapping ok
[ 8.933823] tegra-asoc: sound: ADMAIF10 <-> ADMAIF10 mapping ok
[ 8.933938] tegra-asoc: sound: ADMAIF11 <-> ADMAIF11 mapping ok
[ 8.934051] tegra-asoc: sound: ADMAIF12 <-> ADMAIF12 mapping ok
[ 8.934172] tegra-asoc: sound: ADMAIF13 <-> ADMAIF13 mapping ok
[ 8.934279] tegra-asoc: sound: ADMAIF14 <-> ADMAIF14 mapping ok
[ 8.934381] tegra-asoc: sound: ADMAIF15 <-> ADMAIF15 mapping ok
[ 8.934469] tegra-asoc: sound: ADMAIF16 <-> ADMAIF16 mapping ok
[ 8.934558] tegra-asoc: sound: ADMAIF17 <-> ADMAIF17 mapping ok
[ 8.934645] tegra-asoc: sound: ADMAIF18 <-> ADMAIF18 mapping ok
[ 8.934732] tegra-asoc: sound: ADMAIF19 <-> ADMAIF19 mapping ok
[ 8.934815] tegra-asoc: sound: ADMAIF20 <-> ADMAIF20 mapping ok
[ 8.937950] bxlbxl /workspace/NVIDIA_Sources/JetPack4.6.2_NX_32.7.2_sources/JetPack_4.6.2_Linux_JETSON_XAVIER_NX_TARGETS/Linux_for_Tegra/sources-AI600-SC/kernel/nvidia/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c tegra_machine_tlv320aic3x_init 541
[ 8.937961] bxlbxl /workspace/NVIDIA_Sources/JetPack4.6.2_NX_32.7.2_sources/JetPack_4.6.2_Linux_JETSON_XAVIER_NX_TARGETS/Linux_for_Tegra/sources-AI600-SC/kernel/nvidia/sound/soc/tegra-alt/machine_drivers/tegra_machine_driver_mobile.c tegra_machine_tlv320aic3x_init 549
[ 8.946239] tegra-asoc: sound: ASoC: no sink widget found for x IN1_L
[ 8.946243] tegra-asoc: sound: ASoC: Failed to add route x Line In → direct → x IN1_L
[ 8.946274] tegra-asoc: sound: ASoC: no sink widget found for x IN1_R
[ 8.946277] tegra-asoc: sound: ASoC: Failed to add route x Line In → direct → x IN1_R
[ 8.946309] tegra-asoc: sound: ASoC: no source widget found for x LOL
[ 8.946315] tegra-asoc: sound: ASoC: Failed to add route x LOL → direct → x Line Out
[ 8.946363] tegra-asoc: sound: ASoC: no source widget found for x LOR
[ 8.946365] tegra-asoc: sound: ASoC: Failed to add route x LOR → direct → x Line Out

I don’t know why i2cdump 0x18 always shows XX
root@tegra-ubuntu:~# i2cdetect -y -r 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – – – – – – – – – – – – –
10: – – – – – – – – UU – – – – – – –
20: – – – – – – – – – – – – – – – –
30: – – – – – – – – UU – – – – – – –
40: – – – – – – – – UU – – – – – – –
50: – – – – – – – – – – – – – – – –
60: – – – – – – – – – – – – – – – –
70: – – – – – – – –
root@tegra-ubuntu:~#
root@tegra-ubuntu:~# i2cdump -y -f 1 0x18
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
10: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
20: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
30: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
40: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
50: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
60: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
70: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
80: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
90: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
a0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
b0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
c0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
d0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
e0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
f0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XXXXXXXXXXXXXXXX
root@tegra-ubuntu:~#

Not sure why aic3x_hw_params is not called.

Please check the troubleshooting section: NVIDIA Jetson Linux Driver Package Software Features : Audio Setup and Development | NVIDIA Docs