Sgtl5000 with tx2

hello everyone
I am trying to enable a sound card soc(sgtl5000)on jetson TX2.
now my L4T version is R32.4.3
I changed the kernel and device tree. but it’s not work.
In the dmesg about sgtl5000 as follows:
[ 1.309012] sgtl5000 1-000a: sgtl5000 revision 0x11
[ 1.309530] sgtl5000 1-000a: Using internal LDO instead of VDDD: check ER1
[ 8.889734] sgtl5000 1-000a: sgtl5000_pcm_hw_params: set sysclk first!
[ 8.896389] sgtl5000 1-000a: ASoC: can’t set sgtl5000 hw params: -14
[ 9.881555] sgtl5000 1-000a: sgtl5000_pcm_hw_params: set sysclk first!
[ 9.888194] sgtl5000 1-000a: ASoC: can’t set sgtl5000 hw params: -14
[ 10.870384] sgtl5000 1-000a: sgtl5000_pcm_hw_params: set sysclk first!
[ 10.877092] sgtl5000 1-000a: ASoC: can’t set sgtl5000 hw params: -14

In the dmesg about asoc as follows:
[ 1.446832] tegra-asoc: sound: ADMAIF1 <-> ADMAIF1 mapping ok
[ 1.446911] tegra-asoc: sound: ADMAIF2 <-> ADMAIF2 mapping ok
[ 1.446977] tegra-asoc: sound: ADMAIF3 <-> ADMAIF3 mapping ok
[ 1.447047] tegra-asoc: sound: ADMAIF4 <-> ADMAIF4 mapping ok
[ 1.447111] tegra-asoc: sound: ADMAIF5 <-> ADMAIF5 mapping ok
[ 1.447174] tegra-asoc: sound: ADMAIF6 <-> ADMAIF6 mapping ok
[ 1.447238] tegra-asoc: sound: ADMAIF7 <-> ADMAIF7 mapping ok
[ 1.447299] tegra-asoc: sound: ADMAIF8 <-> ADMAIF8 mapping ok
[ 1.447361] tegra-asoc: sound: ADMAIF9 <-> ADMAIF9 mapping ok
[ 1.447427] tegra-asoc: sound: ADMAIF10 <-> ADMAIF10 mapping ok
[ 1.447491] tegra-asoc: sound: ADMAIF11 <-> ADMAIF11 mapping ok
[ 1.447554] tegra-asoc: sound: ADMAIF12 <-> ADMAIF12 mapping ok
[ 1.447622] tegra-asoc: sound: ADMAIF13 <-> ADMAIF13 mapping ok
[ 1.447685] tegra-asoc: sound: ADMAIF14 <-> ADMAIF14 mapping ok
[ 1.447748] tegra-asoc: sound: ADMAIF15 <-> ADMAIF15 mapping ok
[ 1.447814] tegra-asoc: sound: ADMAIF16 <-> ADMAIF16 mapping ok
[ 1.447877] tegra-asoc: sound: ADMAIF17 <-> ADMAIF17 mapping ok
[ 1.447964] tegra-asoc: sound: ADMAIF18 <-> ADMAIF18 mapping ok
[ 1.448032] tegra-asoc: sound: ADMAIF19 <-> ADMAIF19 mapping ok
[ 1.448093] tegra-asoc: sound: ADMAIF20 <-> ADMAIF20 mapping ok
[ 9.251444] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -14
[ 10.238442] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -14
[ 11.236868] tegra-asoc: sound: ASoC: PRE_PMU: I2S1 DAP Transmit-x Playback event failed: -14
[ 11.795433] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -14
[ 12.256778] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -14
[ 13.125222] tegra-asoc: sound: ASoC: PRE_PMU: I2S1 DAP Transmit-x Playback event failed: -14
[ 13.683388] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -14
[ 14.144820] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -14
[ 15.028751] tegra-asoc: sound: ASoC: PRE_PMU: I2S1 DAP Transmit-x Playback event failed: -14

tegra186-quill-common.dtsi
pinmux@2430000 {
common {
aud_mclk_pj4 {
//enable audio_mclk, give the clock to sgtl5000
nvidia,pins = “aud_mclk_pj4”;
nvidia,function = “aud”;
nvidia,full = <TEGRA_PIN_PULL_NONE>;
nvidia,tristate = <TEGRA_PIN_DISABLE>;
nvidia,enable-input = <TEGRA_PIN_DISABLE>;
nvidia,lpdr = <TEGRA_PIN_ENABLE>;
};
};
};

tegra_sound: sound {
compatible = “nvidia,tegra-audio-t186ref-mobile-rt565x”;
nvidia,model = “tegra-snd-t186ref-mobile-rt565x”;
nvidia,num-codec-link = <12>;
nvidia,num-clk = <8>;
nvidia,clk-rates = < 270950400 /* PLLA_x11025_RATE /
11289600 /
AUD_MCLK_x11025_RATE /
45158400 /
PLLA_OUT0_x11025_RATE /
45158400 /
AHUB_x11025_RATE /
245760000/
PLLA_x8000_RATE /
12288000 /
AUD_MCLK_x8000_RATE /
49152000 /
PLLA_OUT0_x8000_RATE /
49152000 >;/
AHUB_x8000_RATE */

            clocks = <&tegra_car TEGRA186_CLK_PLLP_OUT0>,
                    <&tegra_car TEGRA186_CLK_PLLA>,
                    <&tegra_car TEGRA186_CLK_PLL_A_OUT0>,
                    <&tegra_car TEGRA186_CLK_AHUB>,
                    <&tegra_car TEGRA186_CLK_CLK_M>,
                    <&tegra_car TEGRA186_CLK_AUD_MCLK>;
            clock-names = "pll_p_out1", "pll_a", "pll_a_out0", "ahub",
                            "clk_m", "extern1";
            resets = <&tegra_car TEGRA186_RESET_AUD_MCLK>;
            reset-names = "extern1_rst";

            status = "okay";
            nvidia,audio-routing =

/* “x Headphone”, “x OUT”,
“x IN”, “x Mic”,
*/

                    "x MIC_IN",                     "x Mic Jack",
                    "x Mic Jack",                   "x Mic Bias",
                    "x Headphone Jack",             "x HP_OUT",

                    "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";

	nvidia,xbar = <&tegra_axbar>;

            rt565x_dai_link: nvidia,dai-link-1 {
                    link-name = "sgtl5000-playback";
                    cpu-dai = <&tegra_i2s1>;
                    codec-dai = <&sgtl5000>;
                    cpu-dai-name = "I2S1";
                    codec-dai-name = "sgtl5000";
                    format = "i2s";
                    bitclock-slave;
                    frame-slave;
                    bitclock-noninversion;
                    frame-noninversion;
                    bit-format = "s16_le";
                    bclk_ratio = <1>;
                    srate = <48000>;
                    num-channel = <2>;

		ignore_suspend;
                    name-prefix = "x";
                    status = "okay";
            };

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)
{
//add

rtd = snd_soc_get_pcm_runtime(card, "sgtl5000-playback");
    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;

            if(!strcmp(rtd->codec_dai->name, "sgtl5000")){
                    err = snd_soc_dai_set_sysclk(rtd->codec_dai,
                            SGTL5000_SYSCLK, aud_mclk,
                            SND_SOC_CLOCK_IN);
                    printk(KERN_INFO"9001_SGTL5000_AUD_MCLK_IS_SET");
                    if(err < 0 ){
                            dev_err(card->dev,"codev_dai clock not set\n");
                            return err;
                    }
            }

}

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, "sgtl5000-playback"))
                    dai_links[i].init = tegra_machine_fepi_init;
    }

    return 0;

}

Have a reference at L4T doc to see if can help:

Hello!

The SGTL5000 codec is supported with the FE-PI Audio Z V2 module. Unfortunately this module is no longer available for purchase, but assume that the connections between Jetson and SGTL5000 are the same, then you should be able to simply use the device-tree overlay that is provided for this module …

$ sudo /opt/nvidia/jetson-io/config-by-hardware.py -n "FE-PI Audio Z V2"
$ sudo reboot

For more details on jetson-io see this page.

Regards,
Jon

Thank you very much.

I will try,Thank you very much.