Question about R32.3.1 version using RT5639

Hi,
I use RT5639 on the R32.3.1 version of Jetson Tx2, I add data in dts,

tegra_sound: sound {
compatible = “nvidia,tegra-audio-t186ref-mobile-rt5639/40”;
nvidia,model = “tegra-snd-t186ref-mobile-rt5639_40”;
realtek,in1-differential = <1>;
sel_jd_source = <3>;
nvidia,num-codec-link = <5>;
nvidia,num-clk = <8>;
nvidia,hp-det-gpios = <&tegra_main_gpio TEGRA_MAIN_GPIO(J, 5) GPIO_ACTIVE_HIGH>;
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 Jack", 	"x HP L Playback",
		"x Headphone Jack", 	"x HP R Playback",
		"x Int Spk", 	"x SPORP",
		"x Int Spk", 	"x SPORN",
		"x Int Spk", 	"x SPOLP",
		"x Int Spk", 	"x SPOLN",
		"x IN2P",		"x Mic Jack",
		"x IN2P",		"x Mic Jack",
		"x DMIC L1",	"x Int Mic",
		"x DMIC L2",	"x Int Mic",
		"x DMIC R1",	"x Int Mic",
		"x DMIC R2",	"x Int Mic",
		"y Headphone", 	"y OUT",
		"y IN",		"y Mic",
		"z Headphone", 	"z OUT",
		"z IN",		"z Mic";

	nvidia,xbar = <&tegra_axbar>;

	rt5640_dai_link: nvidia,dai-link-1 {
		link-name = "rt5640-playback";
		cpu-dai = <&tegra_i2s1>;
		codec-dai = <&pcptx2_rt5639>;
		/* codec-dai = <&spdif_dit0>; */
		cpu-dai-name = "I2S1";
		codec-dai-name = "rt5640-aif1";
		/* codec-dai-name = "dit-hifi"; */
		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";
	};

	nvidia,dai-link-2 {
		link-name = "spdif-dit-1";
		cpu-dai = <&tegra_i2s2>;
		codec-dai = <&spdif_dit1>;
		cpu-dai-name = "I2S2";
		codec-dai-name = "dit-hifi";
		format = "dsp_a";
		bitclock-slave;
		frame-slave;
		bitclock-inversion;
		frame-inversion;
		bit-format = "s16_le";
		bclk_ratio = <4>;
		srate = <8000>;
		num-channel = <1>;
		ignore_suspend;
		name-prefix = "y";
		status = "okay";
	};
	
	nvidia,dai-link-3 {
		link-name = "spdif-dit-2";
		cpu-dai = <&tegra_i2s3>;
		codec-dai = <&spdif_dit2>;
		cpu-dai-name = "I2S3";
		codec-dai-name = "dit-hifi";
		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 = "z";
		status = "okay";
	};
	
	dspk_dai_link_1: nvidia,dai-link-4 {
		link-name = "dspk-playback-r";
		cpu-dai = <&tegra_dspk1>;
		codec-dai = <&spdif_dit3>;
		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_dai_link_2: nvidia,dai-link-5 {
		link-name = "dspk-playback-l";
		cpu-dai = <&tegra_dspk2>;
		codec-dai = <&spdif_dit4>;
		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";
            };
};

////

tegra_udrm: tegra_udrm {
	compatible = "nvidia,tegra-udrm";
};

};

and modify the program in kwenwl / nvidia / sound / soc / tegra-alt / machine_drivers / tegra_machine_driver_mobile.c
static const struct of_device_id tegra_machine_of_match = {
{.compatible = “nvidia, tegra-audio-t186ref-mobile-rt5639 / 40”,
.data = & soc_data_tegra186}

The sound card hardware has appeared, but the sound is accompanied by a strange noise like metal or broken sound. What adjustments should be made?

Hello!

First guess would be a clocking issue. From the above it appears that Tegra is the bitclock and frame clock master which is fine. However, please can you explain what clock is used to drive the codecs MCLK input (assuming that you have a clock source connected to the MCLK).

Also, please provide details on how you are testing the audio playback. For example, if using aplay, what commands are you using?

Regards,
Jon