audio codec error

I am using I2S0 for rt5659 codec in i2c-0 with customer carrier board,

And I got this error message in loop, what’s wrong with it???

[ 13.085819] tegra-snd-t186ref-mobile-rt565x sound: dspk-playback-r codec_dai clock not set
[ 13.094144] tegra-snd-t186ref-mobile-rt565x sound: Failed dai init
[ 13.100513] tegra-snd-t186ref-mobile-rt565x sound: ASoC: machine hw_params failed: -524

tegra186-quill-common.dtsi
(1)rt565x_dai_link: nvidia,dai-link-1 {
link-name = “rt565x-playback”;
cpu-dai = <&tegra_i2s1>;
codec-dai = <&str_rt5659>;
cpu-dai-name = “I2S1”;
codec-dai-name = “rt5659-aif1”;
format = “i2s”;
bitclock-slave;
frame-slave;
bitclock-noninversion;
frame-noninversion;
bit-format = “s16_le”;
bclk_ratio = <0>;
srate = <48000>;
num-channel = <2>;
ignore_suspend;
name-prefix = “x”;
status = “okay”;
};
(2)ahub {
i2s@2901000 {
nvidia,is-pinctrl = <1>;
pinctrl-names = “dap_active”, “dap_inactive”;
pinctrl-0 = <&i2s1_dap_active_state>;
pinctrl-1 = <>;
};
};
(3)pinmux@2430000 {
i2s1_dap_active_state: i2s1_dap_active {
i2s1_dap1_fs_pj3 {
// I2S0_LRCLK
nvidia,pins = “dap1_fs_pj3”;
nvidia,function = “i2s1”;
};
i2s1_dap1_din_pj2 {
// I2S0_SDIN
nvidia,pins = “dap1_din_pj2”;
nvidia,function = “i2s1”;
};
i2s1_dap1_dout_pj1 {
// I2S0_SDOUT
nvidia,pins = “dap1_dout_pj1”;
nvidia,function = “i2s1”;
};
i2s1_dap1_sclk_pj0 {
// I2S0_CLK
nvidia,pins = “dap1_sclk_pj0”;
nvidia,function = “i2s1”;
};
};
};
(4)i2c@c240000 {
status = “okay”;
str_rt5659: rt5659.1-001b@1b {
compatible = “realtek,rt5659”;
reg = <0x1b>;
status = “okay”;

		/* gpio for jack detection */
		gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(J , 5) GPIO_ACTIVE_HIGH>;

		/* refer include/sound/rt5659.h for the values to be used */
		realtek,jd-src = <1>; /* RT5659_JD3 */
	
	};

};

Hello!

Let me see if I can help you with this.

At NVIDIA we also test with an rt565x based codec and when it detects the presence of this codec the machine driver assumes that the rt565x daughtercard we test with is present and is trying to initialise the other links for DSPK as well. Since you only have the rt565x codec it is failing on initialising the DSPK.

Here is the piece of code that is checking if the codec is present in the function tegra_t186ref_driver_probe() (see sound/soc/tegra-alt/tegra_t186ref_mobile_rt565x.c) …

1287         idx = tegra_machine_get_codec_dai_link_idx_t18x("rt565x-playback");
1288         /* check if idx has valid number */
1289         if (idx == -EINVAL)
1290                 dev_warn(&pdev->dev, "codec link not defined - codec not part of sound card");
1291         else {
1292                 codec = card->rtd[idx].codec;
1293                 codec_dai_name = card->rtd[idx].dai_link->codec_dai_name;
1294 
1295                 dev_info(&pdev->dev,
1296                         "codec-dai \"%s\" registered\n", codec_dai_name);
1297                 if (!strcmp("dit-hifi", codec_dai_name)) {
1298                         dev_info(&pdev->dev, "This is a dummy codec\n");
1299                         machine->is_codec_dummy = 1;
1300                 }
1301 
1302                 if (!machine->is_codec_dummy) {
1303                         /* setup for jack detection only in non-dummy case */
1304                         rt5659_set_jack_detect(codec, &tegra_t186ref_hp_jack);
1305                 }
1306         }

This sets machine->is_codec_dummy variable and so in the tegra_t186ref_dai_init(), the following code is called and this is where the error occurs …

330         idx = tegra_machine_get_codec_dai_link_idx_t18x("dspk-playback-r");
 331         if (idx != -EINVAL) {
 332                 dai_params =
 333                 (struct snd_soc_pcm_stream *)card->rtd[idx].dai_link->params;
 334 
 335                 if (!machine->is_codec_dummy) {
 336 #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)
 337                         err = snd_soc_dai_set_sysclk(card->rtd[idx].codec_dai,
 338                                 0, clk_out_rate, SND_SOC_CLOCK_IN);
 339 #else
 340                         err = snd_soc_dai_set_sysclk(card->rtd[idx].codec_dai,
 341                                 TAS2552_PDM_CLK_IVCLKIN, clk_out_rate,
 342                                 SND_SOC_CLOCK_IN);
 343 #endif
 344                         if (err < 0) {
 345                                 dev_err(card->dev, "codec_dai clock not set\n");
 346                                 return err;
 347                         }
 348                 }
 349         }

So probably the best way to workaround this is to remove the dai-links that you are not using in the tegra186-quill-common.dtsi file …

diff --git a/kernel-dts/t18x-common-platforms/tegra186-quill-common.dtsi b/kernel-dts/t18x-common-platforms/tegra186-quill-common.dtsi
index 46de427f71f8..59f4ce9a1576 100644
--- a/kernel-dts/t18x-common-platforms/tegra186-quill-common.dtsi
+++ b/kernel-dts/t18x-common-platforms/tegra186-quill-common.dtsi
@@ -790,7 +790,7 @@
        tegra_sound: sound {
                compatible = "nvidia,tegra-audio-t186ref-mobile-rt565x";
                nvidia,model = "tegra-snd-t186ref-mobile-rt565x";
-               nvidia,num-codec-link = <13>;
+               nvidia,num-codec-link = <11>;
                nvidia,num-clk = <8>;
                nvidia,clk-rates = < 270950400  /* PLLA_x11025_RATE */
                                     11289600   /* AUD_MCLK_x11025_RATE */
@@ -1022,34 +1022,6 @@
                        name-prefix = "e";
                        status = "okay";
                };
-               dspk_1_dai_link: nvidia,dai-link-12 {
-                       link-name = "dspk-playback-r";
-                       cpu-dai = <&tegra_dspk1>;
-                       codec-dai = <&spdif_dit12>;
-                       cpu-dai-name = "DSPK1";
-                       codec-dai-name = "dit-hifi";
-                       format = "i2s";
-                       bit-format = "s16_le";
-                       srate = <48000>;
-                       num-channel = <2>;
-                       ignore_suspend;
-                       name-prefix = "d1";
-                       status = "okay";
-               };
-               dspk_2_dai_link: nvidia,dai-link-13 {
-                       link-name = "dspk-playback-l";
-                       cpu-dai = <&tegra_dspk2>;
-                       codec-dai = <&spdif_dit13>;
-                       cpu-dai-name = "DSPK2";
-                       codec-dai-name = "dit-hifi";
-                       format = "i2s";
-                       bit-format = "s16_le";
-                       srate = <48000>;
-                       num-channel = <2>;
-                       ignore_suspend;
-                       name-prefix = "d2";
-                       status = "okay";
-                };
        };

Let me know if that helps.

Regards,
Jon

Hi jonathanh
Yes, to skip dspk is OK