I2S1_LRCLK doesn't seem to work

Hi all,

I’m trying to enable the I2S port exposed on J21 of Jetson TX1 (I2S1) for audio playback only (my kernel is 3.10.96). For that purpose I’m using the following configuration:

gpio-to-sfio = < 
	TEGRA_GPIO(B, 0)     /*   8 H1 I2S0_LRCLK/SFSYNC */
	TEGRA_GPIO(B, 1)     /*   9 G1 I2S0_SDIN         */
	TEGRA_GPIO(B, 2)     /*  10 H2 I2S0_SDOUT        */
	TEGRA_GPIO(B, 3)     /*  11 G2 I2S0_CLK/SRCLK    */
	TEGRA_GPIO(BB, 0)    /* 216 F1 AUDIO_MCLK     */
>;

When I play audio, if I place a scope on the signals I can see how the SDOUT and SRCLK signals are working properly, however the LRCLK signal is always high which causes the audio not to work properly.

Am I missing any pinmuxing configuration?

Also, if I move to I2S5 which is exposed in J26 by just changing the pinmuxing configuration to :

gpio-to-sfio = < 
	TEGRA_GPIO(K, 0)     /*  80 D13 I2S5B_LRCLK/SFSYNC */
	TEGRA_GPIO(K, 1)     /*  81 C14 I2S5B_SDIN         */
	TEGRA_GPIO(K, 2)     /*  82 D14 I2S5B_SDOUT        */
	TEGRA_GPIO(K, 3)     /*  83 C15 I2S5B_CLK/SRCLK    */
>;

and using cpu-dai as I2S5 instead of I2S1 in nvidia-dai-link, all the signals work just fine so the problem seems to be only in I2S1.

Any advice would be appreciated.

Regards,
Edison

Hi Edsion
Could you dump the pin status by below command to check.

cat /sys/kernel/debug/tegra_gpio
cat /sys/kernel/debug/pinctrl/700008d4.pinmux/pinmux-pins | grep -i pb
cat /sys/kernel/debug/pinctrl/700008d4.pinmux/pinmux-functions | grep -i i2s1

Hi,

Thanks, here is the output of the requested commands.

ubuntu@tegra-ubuntu:~$ sudo cat /sys/kernel/debug/tegra_gpio
Name:Bank:Port CNF OE OUT IN INT_STA INT_ENB INT_LVL
 A: 0:0 24 00 00 04 00 00 000000
 B: 0:1 00 00 00 00 00 00 000000
 C: 0:2 1f 00 00 18 00 00 000000
 D: 0:3 10 10 00 00 00 00 000000
 E: 1:0 70 00 00 00 00 00 000000
 F: 1:1 00 00 00 00 00 00 000000
 G: 1:2 00 00 00 00 00 00 000000
 H: 1:3 ff 1b 0b 40 00 24 002024
 I: 2:0 0f 0d 01 02 00 00 000000
 J: 2:1 00 00 00 00 00 00 000000
 K: 2:2 f0 20 00 d0 00 80 008080
 L: 2:3 02 00 00 02 00 02 000000
 M: 3:0 00 00 00 00 00 00 000000
 N: 3:1 00 00 00 00 00 00 000000
 O: 3:2 00 00 00 00 00 00 000000
 P: 3:3 00 00 00 00 00 00 000000
 Q: 4:0 00 00 00 00 00 00 000000
 R: 4:1 00 00 00 00 00 00 000000
 S: 4:2 f0 f0 00 00 00 00 000000
 T: 4:3 03 03 00 00 00 00 000000
 U: 5:0 0c 00 00 00 00 00 000000
 V: 5:1 6e 66 00 00 00 00 000000
 W: 5:2 00 00 00 00 00 00 000000
 X: 5:3 ff 00 00 fe 00 70 606000
 Y: 6:0 03 00 00 03 00 01 010100
 Z: 6:1 1f 08 08 05 00 07 030300
AA: 6:2 00 00 00 00 00 00 000000
BB: 6:3 0c 04 00 00 00 00 000000
CC: 7:0 32 30 20 22 00 02 020200
DD: 7:1 00 00 00 00 00 00 000000
EE: 7:2 00 00 00 00 00 00 000000
FF: 7:3 00 00 00 00 00 00 000000
ubuntu@tegra-ubuntu:~$
ubuntu@tegra-ubuntu:~$ sudo cat /sys/kernel/debug/pinctrl/700008d4.pinmux/pinmux-pins | grep -i pb
pin 8 (DAP1_FS_PB0): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 9 (DAP1_DIN_PB1): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 10 (DAP1_DOUT_PB2): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 11 (DAP1_SCLK_PB3): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 12 (SPI2_MOSI_PB4): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 13 (SPI2_MISO_PB5): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 14 (SPI2_SCK_PB6): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 15 (SPI2_CS0_PB7): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 216 (AUD_MCLK_PBB0): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 217 (DVFS_PWM_PBB1): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 218 (DVFS_CLK_PBB2): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 219 (GPIO_X1_AUD_PBB3): (MUX UNCLAIMED) (GPIO UNCLAIMED)
pin 220 (GPIO_X3_AUD_PBB4): (MUX UNCLAIMED) (GPIO UNCLAIMED)
ubuntu@tegra-ubuntu:~$
ubuntu@tegra-ubuntu:~$ sudo cat /sys/kernel/debug/pinctrl/700008d4.pinmux/pinmux-functions | grep -i i2s1
function: i2s1, groups = [ dap1_fs_pb0 dap1_din_pb1 dap1_dout_pb2 dap1_sclk_pb3 ]
ubuntu@tegra-ubuntu:~$
ubuntu@tegra-ubuntu:~$ sudo cat /sys/kernel/debug/pinctrl/pinctrl-handles | grep i2s1
    type: MUX_GROUP controller 700008d4.pinmux group: dap1_din_pb1 (41) function: i2s1 (13)
    type: MUX_GROUP controller 700008d4.pinmux group: dap1_dout_pb2 (42) function: i2s1 (13)
    type: MUX_GROUP controller 700008d4.pinmux group: dap1_fs_pb0 (40) function: i2s1 (13)
    type: MUX_GROUP controller 700008d4.pinmux group: dap1_sclk_pb3 (43) function: i2s1 (13)
ubuntu@tegra-ubuntu:~$

Hi Edsion
There’s no any problem for the pinmux and function setting.
COuld you share the how the test procedure more detail for our verifying. And any source need modify beside DT.

Hi Shane,

Just in case these are the nodes I added to the DT.

max98357a_codec: max98357a.1@1 {
		compatible = "maxim,max98357a";
	// sdmode-gpios = < >;
	status = "okay";
	};

	max98357_sound_card: sound {
		compatible = "maxim,tegra-audio-max98357a";
		nvidia,model = "tegra-snd-t210ref-max98357a";

		nvidia,num-codec-link = <1>;

		nvidia,audio-routing =
			"Speaker",		"Spk";

		nvidia,xbar = <&tegra_axbar>;

		status = "okay";

		nvidia,dai-link-1 {
			link-name = "max98357a-playback";
			cpu-dai = <&tegra_i2s1>;
			// cpu-dai = <&tegra_i2s5>;
			codec-dai = <&max98357a_codec>;
			cpu-dai-name = "I2S1";
			// cpu-dai-name = "I2S5";
			codec-dai-name = "max98357a-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";
		};
	};

	gpio@6000d000 {
		gpio_default: default {
#if 1 // I2S1

				gpio-to-sfio = <  /* GPIO# TX1-PIN TX1-FUNC/ERA-FUNC */
				TEGRA_GPIO(B, 0)     /*   8 H1 I2S0_LRCLK/SFSYNC */
				TEGRA_GPIO(B, 1)     /*   9 G1 I2S0_SDIN         */
				TEGRA_GPIO(B, 2)     /*  10 H2 I2S0_SDOUT        */
				TEGRA_GPIO(B, 3)     /*  11 G2 I2S0_CLK/SRCLK    */
				TEGRA_GPIO(BB, 0)    /* 216 F1 AUDIO_MCLK     */

				>;
	#else // I2S5

/*LRCLK doesn't seem to be working on I2S1 so lets use I2S5*/

	gpio-to-sfio = <  /* GPIO# TX1-PIN TX1-FUNC/ERA-FUNC */
	TEGRA_GPIO(K, 0)     /*  80 D13 I2S5B_LRCLK/SFSYNC */
	TEGRA_GPIO(K, 1)     /*  81 C14 I2S5B_SDIN         */
	TEGRA_GPIO(K, 2)     /*  82 D14 I2S5B_SDOUT        */
	TEGRA_GPIO(K, 3)     /*  83 C15 I2S5B_CLK/SRCLK    */
	>;

	#endif
		};
	};

For the codec driver I’m using the one available at: http://elixir.free-electrons.com/linux/latest/source/sound/soc/codecs/max98357a.c

Unfortunatelly I can’t give you the machine driver but I based the driver on tegra_t210ref_mobile_rt565x_alt.c

The process I use for testing is just:

  • Boot the board
  • Rout audio
  • For I2S1:

    amixer -c 1 sset 'I2S1 Mux' 'MVC1'
    amixer -c 1 sset 'MVC1 Mux' 'ADMAIF1'
    amixer -c 1 cset name="MVC1 Vol" 50
    

    For I2S5:

    amixer -c 1 sset 'I2S5 Mux' 'MVC1'
    amixer -c 1 sset 'MVC1 Mux' 'ADMAIF1'
    amixer -c 1 cset name="MVC1 Vol" 50
    
  • Then I reproduce an audio file with:
  • aplay -c 1 audio_file.wav
    

    If I have the device tree configured for I2S1 I get audio but as the LRCLK signal is not being generated the audio is noisy and clipped (as the amplifier doesn’t know where the sample starts).

    If I just change the DTB to use I2S5 (drivers untouched) I get perfect audio.

    Regards,
    Edison

    Hi Edison
    Could share the kernel boot log for checking.

    Hi Edison
    I just verify there’s no problem with the super module rt5659. The audio working normally.
    Could you dump below reg for check.

    ubuntu@tegra-ubuntu:~$ sudo devmem2 0x70003124 h
    /dev/mem opened.
    Memory mapped at address 0x7fa52d2000.
    Value at address 0x70003124 (0x7fa52d2124): 0x6044
    ubuntu@tegra-ubuntu:~$ sudo devmem2 0x6000d004 b
    /dev/mem opened.
    Memory mapped at address 0x7f7cbca000.
    Value at address 0x6000D004 (0x7f7cbca004): 0x0
    

    Hi Shane,

    Sorry I didn’t replied before, I didn’t have the HW to run your tests.

    Turns out I realized we had some defective boards, I tested with another I found with no modifications to the SW and it worked in I2S1 so thanks a lot for your time.

    Regards,
    Edison