I2S - master for ADC

I’m trying to enable I2S0 to be a master for an ADC and I am trying to use rt5639.

I changed the assignments of rt5659 to rt5639 in the tegra210-jetson-cv-base-p2597-2180-a00.dts.
According to some other posts, I had to do a gpio-to-sfio for the I2S0 pins and the AUDIO_MCLK
Here is a snippet of my dts:

sound_card: sound {

compatible = "nvidia,tegra-audio-t210ref-mobile-rt5639";
		nvidia,model = "tegra-snd-t210ref-mobile-rt5639";
		nvidia,ldo-gpios = <&gpio TEGRA_GPIO(BB, 3) GPIO_ACTIVE_HIGH>;
		nvidia,hp-det-gpios = <&gpio TEGRA_GPIO(E, 6) GPIO_ACTIVE_HIGH>;
		
		nvidia,num-codec-link = <5>;

		nvidia,audio-routing =
			"x Headphone Jack",	"x HPO L Playback",
			"x Headphone Jack",	"x HPO R Playback",
			"x MICBIAS1",		"x Mic Jack",
			"x IN1P",		"x Mic Jack",
			"x Mic Det Power",	"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 OUT",
			"x IN",			"x Mic",
			"y Headphone",		"y OUT",
			"y IN",			"y Mic",
			"l IN",			"l OUT",
			"s Headphone", 		"s OUT",
			"s IN",			"s Mic";

nvidia,xbar = <&tegra_axbar>;

		nvidia,dai-link-1 {
			link-name = "rt5639-playback";
			cpu-dai = <&tegra_i2s1>;
			codec-dai = <&rt5639>;
			cpu-dai-name = "I2S1";
			codec-dai-name = "rt5639-aif1";
			format = "i2s";
			bitclock-master;
			frame-master;
			bitclock-noninversion;
			frame-noninversion;
			bit-format = "s16_le";
			bclk_ratio = <0>;
			srate = <48000>;
			num-channel = <2>;
			ignore_suspend;
			name-prefix = "x";
		};

		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";
		};
	
		nvidia,dai-link-3 {
			link-name = "spdif-dit-2";
			cpu-dai = <&tegra_dmic3>;
			codec-dai = <&spdif_dit2>;
			cpu-dai-name = "DMIC3";
			codec-dai-name = "dit-hifi";
			format = "i2s";
			bit-format = "s16_le";
			srate = <48000>;
			num-channel = <2>;
			ignore_suspend;
			name-prefix = "z";
		};

		nvidia,dai-link-4 {
			link-name = "spdif-dit-3";
			cpu-dai = <&tegra_i2s3>;
			codec-dai = <&spdif_dit3>;
			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 = <0>;
			srate = <48000>;
			num-channel = <2>;
			ignore_suspend;
			name-prefix = "l";
		};

		nvidia,dai-link-5 {
			link-name = "spdif-dit-0";
			cpu-dai = <&tegra_i2s4>;
			codec-dai = <&spdif_dit0>;
			cpu-dai-name = "I2S4";
			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 = "s";
		};
	};
	gpio@6000d000 {
		gpio_default: default {

			gpio-to-sfio = < 
                                TEGRA_GPIO(B, 0)     /* I2S0_LRCLK */
                                TEGRA_GPIO(B, 1)     /* I2S0_SDIN */
                                TEGRA_GPIO(B, 2)     /* I2S0_SDOUT */
                                TEGRA_GPIO(B, 3)     /* I2S0_CLK/SRCLK */
                                TEGRA_GPIO(BB, 0)    /* AUDIO_MCLK */
                                >;
		};
	};

I am not getting an output from any of the I2S0 clocks or the AUDIO_MCLK, I looked at the clock_tree but for one I’m not sure where the AUDIO_MCLK is in the clock_tree.

I’m also not getting an attempted routing it says

[7.125973] Error: Driver 'tegra-snd-t210ref-mobile-rt5639' is already registered, aborting...

Is there something wrong with my device tree that is causing this?

I am also new to this, if I am making a wrong assumption please let me know if I am going about this the wrong way.
Thanks!

bump

Hi Dev29
These attached already verify rt5639 working well. Please apply it to try.
8bf5d231.diff.zip (1.01 KB)
fec3c033.diff.zip (982 Bytes)

Hi @ShaneCCC ,

Looking at the file, if those gpio’s are disabled and I set them in my dts shown above, how will that work? I’m a little bit confused on why rt5658 is called for audio? is it because it is the super module?

(I posted the code for easy reference)

gpio@60000d000 {
e2614_audio: <b>e2614-rt5658-audio</b> {
gpio-hog;
function;
gpios = <
TEGRA_GPIO(B,0) 0
TEGRA_GPIO(B,1) 0
TEGRA_GPIO(B,2) 0
TEGRA_GPIO(B,3) 0
TEGRA_GPIO(BB,0) 0
TEGRA_GPIO(BB,3) 0
>;
label = "I2S0_LCLK", "I2S0_SDIN", "I2S0_SDOUT", I2S0_CLK", "AUDIO_MCLK", "AUD_RST";
status = "disabled";
};
};

Sorry if I’m not understanding this correctly, I’m trying to learn by working on it and reading as I go.

I’m also getting a couple of things now in the debug when using the command: dmesg | grep ASoC

[6.801345] tegra210-ape-admaif tegra210-admaif: ASoC: Failed to create codec debugfs directory
[6.811577] tegra210-adsp adsp_audio.3: ASoC: Failed to create platform debugfs directory
[9.837784] rt5639 0-001c: ASoC: failed to probe CODEC -1
[9.847727] tegra-snd-t210ref-mobile-rt5639 sound.27: ASoC: failed to instantiate card -1

Is this an address issue in my device tree in regards to rt5639?
I used tegra210-jetson-e-base-p2595-0000-a00.dts as a reference for the rt5639 register and instantiation, so I figured it would work.

[6.958316] tegra-i2c 7000c000.i2c: no acknowledge from address 0x1c
[6.958383] rt5639 0-001c: Codec not ready yet: write failed: Retry 24

Appreciate the help.

EDIT:

I found that rt5639 is in another place in the dts and looked like this:

rt5639_codec: rt5639.1@1 {
compatible = "nvidia,rt5639";
status = "okay";
};

This could cause problems if I’m registering rt5639 to register = <0x1c> right? I’m going to change the address of the code above to be rt5639.1c@1c and see if that works.

Any insight or help would be appreciated.

bump

Hi
You need to make sure what the I2C address and on which I2C bus from you HW designer or schematic.
And there’s fec3c033.diff.zip patch remove by the system. I am attached it again.