Probe of sound failed with error stgl5000

Hi,

We are trying to make audio up using stgl5000 in Nvidia Xavier jetson.

I am able to see m_clk in oscilloscope.

Below is the dmesg log:

stgl5000 7-000a: sgtl5000 revision 0x11

tegra-asoc : sound: Inside tegra_machine_driver_probe
ERROR: could not get clock /sound:externl(5)
tegra-asoc: sound: Can't retrieve clk cdev1
tegra-asoc:: probe of sound failed with error -2

I am also able to see 0x0A address as “UU” enumerated in i2cdetect

Below is my audio device tree in tegra194-audio-p2822-0000.dtsi:

/ {

        aconnect@2a41000 {
                status = "okay";

                agic-controller@2a41000 {
                        status = "okay";
                };

                adsp@2993000 {
                        status = "okay";
                };
        };

        i2c@c250000 {
                sgtl5000: sgtl5000.7-000a@0a {
                        compatible = "fsl,sgtl5000";
                        reg = <0x0a>;
                        clocks = <&bpmp_clks TEGRA194_CLK_AUD_MCLK>;
                        clock-names = "extern1";
                        /*
                        realtek,jd-src = <RT5659_JD_NULL>;
                        realtek,dmic1-data-pin = <RT5659_DMIC1_NULL>;
                        realtek,dmic2-data-pin = <RT5659_DMIC2_DATA_IN2P>;

                        gpios = <&tegra_main_gpio TEGRA194_MAIN_GPIO(S, 5) 0>;
            */
                        status = "okay";
};
        };

        /* Default for all I2S is long fsync width(31) */
        aconnect@2a41000 {
                ahub {
                        /* I2S4 in Short frame sync for BT SCO */
                        i2s@2901300 {
                                fsync-width = <0>;
                        };
                };
        };

        hda@3510000 {
                status = "okay";
                resets = <&bpmp_resets TEGRA194_RESET_HDA>,
                        <&bpmp_resets TEGRA194_RESET_HDA2CODEC_2X>,
                        <&bpmp_resets TEGRA194_RESET_HDA2HDMICODEC>;
                reset-names = "hda_rst", "hda2codec_2x_rst",
                       "hda2hdmi_rst";
                nvidia,do-reset;

        };

        tegra_sound: sound {
                status = "okay";
                compatible = "nvidia,tegra-audio-t186ref-mobile-rt565x";
                nvidia,model = "tegra-snd-t19x-mobile-rt565x";
                clocks = <&bpmp_clks TEGRA194_CLK_PLLP_OUT0>,
                        <&bpmp_clks TEGRA194_CLK_PLLA>,
                        <&bpmp_clks TEGRA194_CLK_PLLA_OUT0>,
                        <&bpmp_clks TEGRA194_CLK_AHUB>,
                        <&bpmp_clks TEGRA194_CLK_CLK_M>;

                clock-names = "pll_p_out1", "pll_a", "pll_a_out0", "ahub",
                        "clk_m" , "extern1";

                nvidia,audio-routing =
                        "x Headphone Jack",     "x HPO L Playback",
                        "x Headphone Jack",     "x HPO R Playback",
                        "x IN1P",               "x Mic Jack",
                        "x Int Spk",            "x SPO Playback",
                        "x DMIC L1",            "x Int Mic",
                        "x DMIC L2",            "x Int Mic",
                        "x DMIC R1",            "x Int Mic",
                        "x DMIC R2",            "x Int Mic",
                        "x  Headphone",         "x HP_OUT",
                        "x MIC_IN",             "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";

                        /* Default config for all I2S dai links are
                        format = "i2s", bitclock-slave, frame-slave,
                        bitclock-noninversion, frame-noninversion,
                        bclk_ratio = 1 , Any change from default needs
                        override on platform specific files. */

                        /* Override with Codec entries */
                        nvidia,dai-link-1 {
                link-name = "sgtl5000-playback";
                codec-dai = <&sgtl5000>;
                codec-dai-name = "sgtl5000";
                        };

                        /* Override with BT SCO entries */
                        nvidia,dai-link-4 {
                                format = "dsp_a";
                                tx-mask = <0xFF>;
                                rx-mask = <0xFF>;
                                bitclock-inversion;
                                bclk_ratio = <4>;
                                srate = <8000>;
                                num-channel = <1>;
                        };
        };
};

Please let me know is there any changes required in dts or in driver source.

Thanks
Vinayak

Hello Vinayak,

Yes there are changes that are required to the Tegra machine driver. Is the AUD_MCLK from Tegra used to drive the MCLK on the SGTL5000? If so, then please refer to the following forum post which provides some examples of the changes needed …

Regards,
Jon

Hi Jon,

I have updated updated the Tegra ASoC machine driver as mentioned. But prior to that I am getting below error for sgtl5000@7-000a:

[ 4.732533] sgtl5000 7-000a: Error reading chip id -121
[ 4.733034] sgtl5000: probe of 7-000a failed with error -121

Below is my dts for “sgtl5000@7-000a” node:

sgtl5000: sgtl5000@7-000a {
compatible = “fsl,sgtl5000”;
reg = <0x0a>;
clocks = <&bpmp_clks TEGRA194_CLK_AUD_MCLK>;
clock-names = “extern1”;
status = “okay”;

};

Best Regards
Vinayak

Hello Vinayak,

Looking at the driver it appears that the I2C read for the chip ID is failing. How is the SGTL5000 codec connected to the Xavier Jetson? Is this via the 40-pin header? The clock exposed by the 40-pin header is not the AUD_MCLK but the MCLK05. Can you confirm which pin on the Jetson board the SGTL5000 MCLK is connected to?

Thanks
Jon

Hello Jon,

we are bringing up new carrier card, referring xavier development board where only codec chip is replaced. And we are using AUD_MCLK as in development board.

Best Regards
Vinayak

Hello Vinayak,

OK, that’s for confirming. You said you can see the MCLK toggling. What frequency is it operating at?

You could try adding a larger delay in the SGTL5000 codec driver between where the clock is enabled and the ID is read to see if this helps.

Otherwise, I would check the codec is powered OK and no resets asserted (assuming the codec has a reset pin). If power and clocks look good, then I would check the I2C signals between Tegra and the codec to make sure they are toggling as expected and the codec is ACK’ing the I2C commands.

Regards,
Jon

Hello Jon,

MCLK is toggling at freq 48 to 50 MHz. Power and clocks looks good at SGTL5000 audio codec. I ran i2cdetect, codec is ACK’ing under 0x0a

I2C is now able to read chip id.

Today I made some progress and found below error coming out from “kernel-4.9/sound/soc/codecs/sgtl5000.c”

[    4.775278] sgtl5000 7-000a: sgtl5000 revision 0x11
[    4.775836] sgtl5000 7-000a: Using internal LDO instead of VDDD: check ER1
[    4.776021] sgtl5000 7-000a: inside else DT parse default
[    4.782073] sgtl5000 7-000a: Registering codec
[   20.018398] sgtl5000 7-000a: sgtl5000_pcm_hw_params: set sysclk first!
[   20.018607] sgtl5000 7-000a: ASoC: can't set sgtl5000 hw params: -14
[   21.776439] sgtl5000 7-000a: sgtl5000_pcm_hw_params: set sysclk first!
[   21.776601] sgtl5000 7-000a: ASoC: can't set sgtl5000 hw params: -14
[   22.982547] sgtl5000 7-000a: sgtl5000_pcm_hw_params: set sysclk first!
....
....

where does setting of sysclk is missing??

Below is my dts file looks like for sgtl5000 node:

i2c@c250000 {
                sgtl5000: sgtl5000.7-000a@0a {
                        compatible = "fsl,sgtl5000";
                        reg = <0x0a>;
                        clocks = <&bpmp_clks TEGRA194_CLK_AUD_MCLK>;
                        //clock-names = "extern1";
                        clock-names = "pll_a", "pll_a_out0","clk_m";
                        nvidia,audio-routing =
                                 "Headphone Jack", "HP_OUT",
                                 "LINE_IN", "Line In Jack",
                                 "MIC_IN", "Mic Jack";
                        /*
                        realtek,jd-src = <RT5659_JD_NULL>;
                        realtek,dmic1-data-pin = <RT5659_DMIC1_NULL>;
                        realtek,dmic2-data-pin = <RT5659_DMIC2_DATA_IN2P>;

                        gpios = <&tegra_main_gpio TEGRA194_MAIN_GPIO(S, 5) 0>;
                      */
                        status = "okay";
                };
        };

And I can also see that audio routing is failing:

<s></s>[    1.015831] iommu: Adding device sound to group 22
[    4.785875] input: tegra-hda-galen-t194 HDMI/DP,pcm=3 as /devices/3510000.hda/sound/card0/input0
[    4.786063] input: tegra-hda-galen-t194 HDMI/DP,pcm=7 as /devices/3510000.hda/sound/card0/input1
[    4.786313] input: tegra-hda-galen-t194 HDMI/DP,pcm=8 as /devices/3510000.hda/sound/card0/input2
[    4.786595] input: tegra-hda-galen-t194 HDMI/DP,pcm=9 as /devices/3510000.hda/sound/card0/input3
[    4.872718] tegra-asoc: sound: Inside tegra_machine_driver_probe
[    4.933984] tegra-asoc: sound: ADMAIF1 <-> ADMAIF1 mapping ok
[    4.934079] tegra-asoc: sound: ADMAIF2 <-> ADMAIF2 mapping ok
[    4.934184] tegra-asoc: sound: ADMAIF3 <-> ADMAIF3 mapping ok
[    4.934262] tegra-asoc: sound: ADMAIF4 <-> ADMAIF4 mapping ok
[    4.934330] tegra-asoc: sound: ADMAIF5 <-> ADMAIF5 mapping ok
[    4.934401] tegra-asoc: sound: ADMAIF6 <-> ADMAIF6 mapping ok
[    4.934478] tegra-asoc: sound: ADMAIF7 <-> ADMAIF7 mapping ok
[    4.934596] tegra-asoc: sound: ADMAIF8 <-> ADMAIF8 mapping ok
[    4.934667] tegra-asoc: sound: ADMAIF9 <-> ADMAIF9 mapping ok
[    4.934737] tegra-asoc: sound: ADMAIF10 <-> ADMAIF10 mapping ok
[    4.934807] tegra-asoc: sound: ADMAIF11 <-> ADMAIF11 mapping ok
[    4.934880] tegra-asoc: sound: ADMAIF12 <-> ADMAIF12 mapping ok
[    4.934950] tegra-asoc: sound: ADMAIF13 <-> ADMAIF13 mapping ok
[    4.935025] tegra-asoc: sound: ADMAIF14 <-> ADMAIF14 mapping ok
[    4.935105] tegra-asoc: sound: ADMAIF15 <-> ADMAIF15 mapping ok
[    4.935177] tegra-asoc: sound: ADMAIF16 <-> ADMAIF16 mapping ok
[    4.935255] tegra-asoc: sound: ADMAIF17 <-> ADMAIF17 mapping ok
[    4.935330] tegra-asoc: sound: ADMAIF18 <-> ADMAIF18 mapping ok
[    4.935403] tegra-asoc: sound: ADMAIF19 <-> ADMAIF19 mapping ok
[    4.935475] tegra-asoc: sound: ADMAIF20 <-> ADMAIF20 mapping ok
[    4.957559] tegra-asoc: sound: ASoC: no source widget found for x HPO L Playback
[    4.957568] tegra-asoc: sound: ASoC: Failed to add route x HPO L Playback -> direct -> x Headphone Jack
[    4.957590] tegra-asoc: sound: ASoC: no source widget found for x HPO R Playback
[    4.957592] tegra-asoc: sound: ASoC: Failed to add route x HPO R Playback -> direct -> x Headphone Jack
[    4.957675] tegra-asoc: sound: ASoC: no sink widget found for x IN1P
[    4.957676] tegra-asoc: sound: ASoC: Failed to add route x Mic Jack -> direct -> x IN1P
[    4.957705] tegra-asoc: sound: ASoC: no source widget found for x SPO Playback
[    4.957706] tegra-asoc: sound: ASoC: Failed to add route x SPO Playback -> direct -> x Int Spk
[    4.957770] tegra-asoc: sound: ASoC: no sink widget found for x DMIC L1
[    4.957771] tegra-asoc: sound: ASoC: Failed to add route x Int Mic -> direct -> x DMIC L1
[    4.957830] tegra-asoc: sound: ASoC: no sink widget found for x DMIC L2
[    4.957831] tegra-asoc: sound: ASoC: Failed to add route x Int Mic -> direct -> x DMIC L2
[    4.957899] tegra-asoc: sound: ASoC: no sink widget found for x DMIC R1
[    4.957900] tegra-asoc: sound: ASoC: Failed to add route x Int Mic -> direct -> x DMIC R1
[    4.957975] tegra-asoc: sound: ASoC: no sink widget found for x DMIC R2
[    4.957977] tegra-asoc: sound: ASoC: Failed to add route x Int Mic -> direct -> x DMIC R2
[   20.018753] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -14
[   21.776753] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -14
[   22.982918] tegra-asoc: sound: ASoC: PRE_PMU: I2S1 DAP Transmit-x Playback event failed: -14
[   23.630932] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -14
[   24.062712] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -14
[   24.924228] tegra-asoc: sound: ASoC: PRE_PMU: I2S1 DAP Transmit-x Playback event failed: -14
[   25.524847] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -14
[   25.947943] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -14
[   26.836976] tegra-asoc: sound: ASoC: PRE_PMU: I2S1 DAP Transmit-x Playback event failed: -14
[   27.642749] tegra-asoc: sound: ASoC: PRE_PMU: x Capture-I2S1 DAP Receive event failed: -14

Best Regards
Vinayak