Sound issue in mt7628evb with wm8960 codec

hii

i have mt7628evb board with wm8960 codec openwrt version is 21.02. mt762x-wm8960 driver version is 5.4 the device is registered but when i play any wav file there is no sound. can anyone suggest me what is wrong with the configuration.

[ 14.834064] kmodloader: loading kernel modules from /etc/modules.d/*
[ 14.981660] i2c /dev entries driver
[ 15.000940] ralink_gdma: module is from the staging directory, the quality is unknown, you have been warned.
[ 15.039663] gdma-rt2880 10002800.gdma: revision: 3, channels: 16
[ 15.116108] i2c-mt7621 10000900.i2c: clock 100 kHz
[ 15.140496] ralink-i2s 10000a00.i2s: mclk 480MHz
[ 15.205956] mt762x-wm8960 sound: wm8960-hifi <-> 10000a00.i2s mapping ok
[ 15.261825] urngd: v1.0.2 started.
[ 15.340943] Loading modules backported from Linux version v5.10.157-0-gf4245f05389c


aplay -l output 

root@OpenWrt:/# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Card [MT762X WM8960 ASoC Card], device 0: wm8960-hifi wm8960-hifi-0 [wm8960-hifi wm8960-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0

root@OpenWrt:/# aplay -L
null
Discard all samples (playback) or generate zero samples (capture)
default:CARD=Card
MT762X WM8960 ASoC Card, wm8960-hifi wm8960-hifi-0
Default Audio Device
sysdefault:CARD=Card
MT762X WM8960 ASoC Card, wm8960-hifi wm8960-hifi-0
Default Audio Device

commands given to amixer 

amixer sset "Headphone" 90
mixer sset "Speaker" 90Simple mixer control 'Headphone',0
Capabilities: pvolume
Playback channels: Front Left - Front Right
Limits: Playback 0 - 127
Mono:
Front Left: Playback 90 [71%] [-31.00dB]
Front Right: Playback 90 [71%] [-31.00dB]
root@OpenWrt:/# amixer sset "Speaker" 90
Simple mixer control 'Speaker',0
Capabilities: pvolume
Playback channels: Front Left - Front Right
Limits: Playback 0 - 127
Mono:
Front Left: Playback 90 [71%] [-31.00dB]
Front Right: Playback 90 [71%] [-31.00dB]
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/#
root@OpenWrt:/# amixer sset "Left Output Mixer PCM" on
ixer sset "Right Output Mixer PCM" onSimple mixer control 'Left Output Mixer PCM',0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]
root@OpenWrt:/# amixer sset "Right Output Mixer PCM" on
Simple mixer control 'Right Output Mixer PCM',0
Capabilities: pswitch pswitch-joined
Playback channels: Mono
Mono: Playback [on]

aplay sampl music play

aplay -vv preamble10.wav
Playing WAVE 'preamble10.wav' : Signed 16 bit Little Endian, Rate 22050 Hz, Mono
Plug PCM: Route conversion PCM (sformat=S16_LE)
Transformation table:
0 <- 0
1 <- 0
Its setup is:
stream : PLAYBACK
access : RW_INTERLEAVED
format : S16_LE
subformat : STD
channels : 1
rate : 22050
exact rate : 22050 (22050/1)
msbits : 16
buffer_size : 10240
period_size : 2048
period_time : 92879
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 2048
period_event : 0
start_threshold : 10240
stop_threshold : 10240
silence_threshold: 0
silence_size : 0
boundary : 1342177280
Slave: Hardware PCM card 0 'MT762X WM8960 ASoC Card' device 0 subdevice 0
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S16_LE
subformat : STD
channels : 2
rate : 22050
exact rate : 22050 (22050/1)
msbits : 16
buffer_size : 10240
period_size : 2048
period_time : 92879
tstamp_mode : NONE
tstamp_type : MONOTONIC
period_step : 1
avail_min : 2048
period_event : 0
start_threshold : 10240
stop_threshold : 10240
silence_threshold: 0
silence_size : 0
boundary : 1342177280
appl_ptr : 0
hw_ptr : 0

Could you check pinctrl module config?

Working dts file (checked on SKW92A board):

/{
...
    sound {
        compatible = "mediatek,mt762x-wm8960-machine";
        mediatek,platform = <&i2s>;
        mediatek,audio-codec = <&codec>;
        audio-routing =
            "Ext Spk", "SPK_LN",
            "Ext Spk", "SPK_LP";
    };
};

&pinctrl {
        state_default: pinctrl0 {
                gpio {
                        ralink,group = "wdt", "wled_an", "refclk", "pwm0", "pwm1", "spis", "uart2", "sdmode";
                        ralink,function = "gpio";
                };
                refclk {
                        ralink,group = "gpio";
                        ralink,function = "refclk";
                };
                i2s {
                    ralink,group = "i2s";
                    ralink,function = "i2s";
                };
        };
};

&i2c {
        status = "okay";
        codec: wm8960@1a {
//              #sound-dai-cells = <0>;
                compatible = "wlf,wm8960";
                reg = <0x1a>;
                wlf,shared-lrclk;
        };
};

&i2s {
//      #sound-dai-cells = <0>;
        status = "okay";
//      pinctrl-names = "default";
//      pinctrl-0 = <&i2s_pins>;
};

Volume configuration for my driver (https://github.com/redchenjs/mt762x-wm8960)

amixer sset "Speaker" 110 # volume: 0 - 127
amixer sset "Left Output Mixer PCM" on
amixer sset "Right Output Mixer PCM" on

Relevant messages from kernel startup:

[   14.559820] i2c /dev entries driver
[   14.569675] gdma-rt2880 10002800.gdma: revision: 3, channels: 16
[   14.617942] snd-soc-dummy snd-soc-dummy: no of_node; not parsing pinctrl DT
[   14.659953] pinctrl core: add 1 pinctrl maps
[   14.660006] rt2880-pinmux pinctrl: found group selector 4 for i2c
[   14.660026] rt2880-pinmux pinctrl: request pin 4 (io4) for 10000900.i2c
[   14.660038] rt2880-pinmux pinctrl: request pin 5 (io5) for 10000900.i2c
[   14.678693] i2c-mt7621 10000900.i2c: clock 100KHz, re-start not support
[   14.720326] ralink-i2s 10000a00.i2s: mclk 480MHz
[   14.788746] mt762x-wm8960 sound: wm8960-hifi <-> 10000a00.i2s mapping ok

@yetihehe thanks for replying here is my dts file changes so far , my board has external 12Mhz clock source so i excluded refclk configuration from dts file.

	
	sound {
		compatible = "mediatek,mt762x-wm8960-machine";
		mediatek,platform = <&i2s>;
		mediatek,audio-codec = <&codec>;
		audio-routing =
			"Headphone", "HP_L",
			"Headphone", "HP_R",
			"Ext Spk", "SPK_LN",
			"Ext Spk", "SPK_LP",
			"Ext Spk", "SPK_RN",
			"Ext Spk", "SPK_RP",
			"Mic", "MICB",
			"LINPUT1", "Mic",
			"LINPUT2", "Line In",
			"RINPUT2", "Line In";
	};

&state_default {
	gpio {
		groups = "gpio";
		function = "gpio";
	};	

	i2s {
		groups = "i2s";
		function = "i2s";
	};


};

&i2c {
	status = "okay";

	codec: wm8960@1a {
		compatible = "wlf,wm8960";
		reg = <0x1a>;
		wlf,shared-lrclk;
	};
};


&i2s {
	status = "okay";
};

&gdma {
	status = "okay";
};
	

some logs


6,108,12787699,-;i2c /dev entries driver
4,109,12804505,-;ralink_gdma: module is from the staging directory, the quality is unknown, you have been warned.
6,110,12847360,-;gdma-rt2880 10002800.gdma: revision: 3, channels: 16
 SUBSYSTEM=platform
 DEVICE=+platform:10002800.gdma
7,111,12887919,-;i2c-dev: adapter [10000900.i2c] registered as minor 0
7,112,12888005,-;i2c i2c-0: adapter [10000900.i2c] registered
 SUBSYSTEM=i2c
 DEVICE=+i2c:i2c-0
7,113,12888015,-;i2c i2c-0: of_i2c: walking child nodes
 SUBSYSTEM=i2c
 DEVICE=+i2c:i2c-0
7,114,12888032,-;i2c i2c-0: of_i2c: register /palmbus@10000000/i2c@900/wm8960@1a
 SUBSYSTEM=i2c
 DEVICE=+i2c:i2c-0
7,115,12888197,-;i2c i2c-0: client [wm8960] registered with bus id 0-001a
 SUBSYSTEM=i2c
 DEVICE=+i2c:i2c-0
6,116,12888214,-;i2c-mt7621 10000900.i2c: clock 100 kHz
 SUBSYSTEM=platform
 DEVICE=+platform:10000900.i2c
6,117,12912098,-;ralink-i2s 10000a00.i2s: mclk 480MHz
 SUBSYSTEM=platform
 DEVICE=+platform:10000a00.i2s
7,118,12936492,-;wm8960 0-001a: probe
 SUBSYSTEM=i2c
 DEVICE=+i2c:0-001a
7,119,12947197,-;i2c-core: driver [wm8960] registered
6,120,12965878,-;mt762x-wm8960 sound: wm8960-hifi <-> 10000a00.i2s mapping ok
 SUBSYSTEM=platform
 DEVICE=+platform:sound
6,121,13143586,-;xt_time: kernel timezone is -0000

If you don't have headphone detection pin, I suggest removing headphones from config and leave just "SPK_*" (I have only LN and LP because I have mono audio speaker). Also as far as I know, no one yet managed to make sound inputs work. You might also need to check any audio or volume enable pins for your codec. If you have external clock, you might check if processor doesn't try to generate it's own clock also I don't see that pinctrl config, I think it might be required for working. If you have proper signal on i2c, i2s and clock pins checked with some logic analyser, then it might be something other. I had to modify control registers via direct memory write to change pin mapping. Maybe you need this to change clock source.