Alc5616 cannot work on xavier nx platform

Hi, sir:

I am porting alc5616 codec on nx platform, when i use aplay to play wav file. The alc5616 driver report the error:
[ 933.036215] Unable to handle kernel NULL pointer dereference at virtual address 00000628
[ 933.036392] Mem abort info:
[ 933.036446] ESR = 0x96000005
[ 933.036502] Exception class = DABT (current EL), IL = 32 bits
[ 933.036602] SET = 0, FnV = 0
[ 933.036663] EA = 0, S1PTW = 0
[ 933.036720] Data abort info:
[ 933.036771] ISV = 0, ISS = 0x00000005
[ 933.036839] CM = 0, WnR = 0
[ 933.036902] user pgtable: 4k pages, 39-bit VAs, pgd = ffffffc1c344d000
[ 933.037030] [0000000000000628] *pgd=0000000000000000, *pud=0000000000000000
[ 933.037168] Internal error: Oops: 96000005 [#1] PREEMPT SMP
[ 933.037265] Modules linked in: fuse xt_conntrack ipt_MASQUERADE nf_nat_masquerade_ipv4 nf_conntrack_netlink nfnetlink bnep xt_addrtype iptable_filter iptable_nat nf_conntrack_ipv4 nf_defrag_ipv4 nf_nat_ipv4 nf_nat nf_conntrack br_netfilter zram rtl8821cu cfg80211 overlay rtk_btusb btusb btrtl btbcm btintel userspace_alert nvgpu GobiNet option usb_wwan ip_tables x_tables
[ 933.039155] CPU: 0 PID: 7835 Comm: aplay Not tainted 4.9.253-tegra #5
[ 933.041953] Hardware name: NVIDIA Jetson Xavier NX Developer Kit (DT)
[ 933.048251] task: ffffffc1eaca8e00 task.stack: ffffffc1f6bbc000
[ 933.054313] PC is at rt5616_hw_params+0x34/0x1d0
[ 933.058848] LR is at soc_dai_hw_params+0x48/0x98
[ 933.063389] pc : [] lr : [] pstate: 80400045
[ 933.070740] sp : ffffffc1f6bbf700
[ 933.073977] x29: ffffffc1f6bbf700 x28: 00000000ffffffff
[ 933.079402] x27: 00000000ffffffff x26: 0000000000000001
[ 933.085174] x25: ffffff800a1d8ae8 x24: ffffffc1f1378300
[ 933.090163] x23: 0000000000000001 x22: ffffffc1f2572300
[ 933.095159] x21: ffffffc1e8009800 x20: ffffffc1f6bbf7c8
[ 933.100409] x19: ffffffc1e8009800 x18: 0000000000000e57
[ 933.106348] x17: 0000007fa6038530 x16: 00000000016e575f
[ 933.112123] x15: 000000000148bcee x14: 00000000000a0a5b
[ 933.117809] x13: 000000000000035c x12: 071c71c71c71c71c
[ 933.123410] x11: 000000000000000b x10: 0000000000000a10
[ 933.129098] x9 : 0000000000000000 x8 : 0000000000000300
[ 933.134620] x7 : 0000000000000000 x6 : 0000000000000000
[ 933.140385] x5 : 0000000000000000 x4 : 0000000000000000
[ 933.145724] x3 : 0000000000000000 x2 : 000000000000ac44
[ 933.150808] x1 : ffffffc1e8009800 x0 : 0000000000000000

[ 933.157544] Process aplay (pid: 7835, stack limit = 0xffffffc1f6bbc000)
[ 933.163929] Call trace:
[ 933.166562] [] rt5616_hw_params+0x34/0x1d0
[ 933.171898] [] soc_dai_hw_params+0x48/0x98
[ 933.176977] [] snd_soc_dai_link_event+0x34c/0x3d0
[ 933.183097] [] dapm_seq_check_event.isra.27+0x118/0x2d0
[ 933.189228] [] dapm_seq_run_coalesced+0xa0/0x1e0
[ 933.195171] [] dapm_seq_run+0xb0/0x3d0
[ 933.200164] [] dapm_power_widgets+0x59c/0x9e0
[ 933.205864] [] snd_soc_dapm_stream_event+0x9c/0xb8
[ 933.211971] [] soc_pcm_prepare+0x118/0x258
[ 933.217045] [] snd_pcm_do_prepare+0x28/0x48
[ 933.222469] [] snd_pcm_action_single+0x4c/0xa0
[ 933.228591] [] snd_pcm_action_nonatomic+0x84/0xa8
[ 933.234636] [] snd_pcm_common_ioctl1+0xa0c/0xe98
[ 933.240839] [] snd_pcm_playback_ioctl1+0x298/0x8a8
[ 933.247145] [] snd_pcm_playback_ioctl+0x48/0x68
[ 933.253446] [] do_vfs_ioctl+0xb0/0x8d8
[ 933.258955] [] SyS_ioctl+0x8c/0xa8
[ 933.264118] [] el0_svc_naked+0x34/0x38
[ 933.269461] —[ end trace af8e9eb5c32b11c7 ]—

my dtsi is :
tegra194-audio-p3668.dtsi:

i2c@3160000 {
    status = "okay";
	rt5616_codec: rt5616@1b {
		compatible = "realtek,rt5616";
		reg = <0x1b>;
		status = "okay";
	};
};
hda@3510000 {
	hda,card-name = "tegra-hda-xnx";
	status = "okay";
};

tegra_sound: sound {
	status = "okay";
	compatible = "nvidia,tegra-audio-t186ref-mobile-rt565x";
	nvidia,model = "jetson-xaviernx-ape";
	clocks = <&bpmp_clks TEGRA194_CLK_PLLA>,
		 <&bpmp_clks TEGRA194_CLK_PLLA_OUT0>,
		 <&bpmp_clks TEGRA194_CLK_AUD_MCLK>;
	clock-names = "pll_a", "pll_a_out0", "extern1";
	assigned-clocks = <&bpmp_clks TEGRA194_CLK_PLLA_OUT0>,
			  <&bpmp_clks TEGRA194_CLK_AUD_MCLK>;
	assigned-clock-parents = <&bpmp_clks TEGRA194_CLK_PLLA>,
				 <&bpmp_clks TEGRA194_CLK_PLLA_OUT0>;

	nvidia,audio-routing =
		"x Headphone",          "x HPOR", 
		"x Headphone",          "x HPOL", 
		"x IN2P",               "x Mic",
		"x IN2N",               "x Mic",
		"y Headphone",	"y OUT",
		"y IN",		"y Mic",
		"a IN",		"a Mic",
		"b IN",		"b Mic";

	mclk-fs = <256>;

	nvidia,dai-link-1 {
		name-prefix = "n";
	};

	hdr40_snd_link_i2s: nvidia,dai-link-5 {
		link-name = "rt565x-playback";
		codec-dai = <&rt5616_codec>;
		codec-dai-name = "rt5616-aif1";
		name-prefix = "x";
		status = "okay";   
	};

};

tegra194-p3668-common.dtsi:

i2s@2901400 {
	status = "okay";
};
pinmux@2430000 {
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&hdr40_pinmux>;

	hdr40_pinmux: header-40pin-pinmux {
		pin7 {
			nvidia,pins = HDR40_PIN7;
			nvidia,function = HDR40_CLK;
			nvidia,pull = <TEGRA_PIN_PULL_NONE>;
			nvidia,tristate = <TEGRA_PIN_DISABLE>;
			nvidia,enable-input = <TEGRA_PIN_ENABLE>;
		};

		pin12 {
			nvidia,pins = HDR40_PIN12;
			nvidia,function = HDR40_I2S;
			nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
			nvidia,tristate = <TEGRA_PIN_DISABLE>;
			nvidia,enable-input = <TEGRA_PIN_ENABLE>;
		};

		pin35 {
			nvidia,pins = HDR40_PIN35;
			nvidia,function = HDR40_I2S;
			nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
			nvidia,tristate = <TEGRA_PIN_DISABLE>;
			nvidia,enable-input = <TEGRA_PIN_ENABLE>;
		};

		pin38 {
			nvidia,pins = HDR40_PIN38;
			nvidia,function = HDR40_I2S;
			nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
			nvidia,tristate = <TEGRA_PIN_ENABLE>;
			nvidia,enable-input = <TEGRA_PIN_ENABLE>;
		};

		pin40 {
			nvidia,pins = HDR40_PIN40;
			nvidia,function = HDR40_I2S;
			nvidia,pull = <TEGRA_PIN_PULL_DOWN>;
			nvidia,tristate = <TEGRA_PIN_DISABLE>;
			nvidia,enable-input = <TEGRA_PIN_DISABLE>;
		};
	};        
    
};

codec and machine driver are tegra_machine_driver_mobile.c (22.6 KB)
as the attachment.rt5616.c (40.1 KB)

The amixer and aplay cmds are as following:

amixer -c1 cset name=“I2S5 Mux” “ADMAIF1”
amixer -c1 cset name=‘x DAC MIXL INF1 Switch’ 1
amixer -c1 cset name=‘x DAC MIXR INF1 Switch’ 1
amixer -c1 cset name=‘x Stereo DAC MIXR DAC R1 Switch’ 1
amixer -c1 cset name=‘x Stereo DAC MIXL DAC L1 Switch’ 1

amixer -c1 cset name=‘x HP Playback Switch’ 1
amixer -c1 cset name=‘x HPO MIX DAC1 Switch’ 1
amixer -c1 cset name=‘x HPO MIX HPVOL Switch’ 1

amixer -c1 cset name=‘x OUT Playback Switch’ 1
amixer -c1 cset name=‘x LOUT MIX DAC R1 Switch’ 1
amixer -c1 cset name=‘x LOUT MIX DAC L1 Switch’ 1

aplay -D hw:jetsonxaviernxa,0 test.wav

The i2s config is as following:
root@tegra-ubuntu:/home/ubuntu# sudo grep dap5 /sys/kernel/debug/tegra_pinctrl_reg
Bank: 0 Reg: 0x02431068 Val: 0x00000444 → dap5_fs_pu0
Bank: 0 Reg: 0x02431070 Val: 0x00000454 → dap5_din_pt7
Bank: 0 Reg: 0x02431078 Val: 0x00000404 → dap5_dout_pt6
Bank: 0 Reg: 0x02431080 Val: 0x00000444 → dap5_sclk_pt5

The result of amixer -c 1 controls is as the attachment.control.txt (54.4 KB)

The dmesg is as the attachment.dmesg.log (71.8 KB)

Dear sir:

This project used i2s5 and i2c@3160000, the rt5616 is probed successfully.

Hi,

The crash is in codec driver API - rt5616_hw_params.

Can you check if below patch is present in your tree? If not, please patch the codec driver, build and test again.

https://patchwork.kernel.org/project/alsa-devel/patch/1479067576-3589-1-git-send-email-lars@metafoo.de/

Thanks,
Sharad

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.