Colibri iMX6ULL and WM8523 no sound

Building Attached to the Colibri via I2C1 and SAI3 is a WM8523 for audio playback. For the device tree I followed mostly the thread here.

With the following device tree I still have no soundcard or WM8523 loaded.

/ {
        sound-wm8523 {
                compatible = "simple-audio-card";
                simple-audio-card,name = "Wolfson WM8523";
                simple-audio-card,format = "i2s";
                simple-audio-card,widgets =
                        //"AMIC","Microphone",
                        //"Headphone", "Headphone",
                        "Speaker", "Speaker";
                simple-audio-card,routing =
                        //"LMICN","AMIC",
                        //"RMICN","AMIC",
                        //"Headphone","LSPK",
                        //"Headphone","RSPK",
                        "Speaker","LSPK",
                        "Speaker","RSPK";

                simple-audio-card,cpu {
                        sound-dai = <&sai3 0>;
                        system-clock-frequency = <2624000>; // freq 41000 * channels 32 * wordlen 2 = 2'634'000
                        bitclock-master;
                        frame-master;
                };
                simple-audio-card,codec {
                        sound-dai = <&wm8523 0>;
                        clocks = <24000000>;
                };
        };
};

&i2c1 {
        status = "okay";
        clock-frequency = <400000>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_i2c1>;

        wm8523: wm8523@1a {
                compatible = "wlf,wm8523";
                reg = <0x1a>;

        };
};

&sai3 {
        status = "okay";
};

&iomuxc {
        imx6ull-colibri {
                pinctrl_audmux: audmuxgrp {
                        fsl,pins = <
                                MX6UL_PAD_SD1_CLK__SAI2_MCLK            0x130b1
                                MX6UL_PAD_JTAG_TDI__SAI2_TX_BCLK        0x130b0
                                MX6UL_PAD_JTAG_TRST_B__SAI2_TX_DATA     0x130b0
                                MX6UL_PAD_SD1_DATA2__SAI2_RX_DATA       0x130b1
                        >;
                };
        };
};

I2C seems OK, I can read the registers:

i2cdetect 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- 1a -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                        

i2cget 0 0x1a 0x00 w                                                                                                                                           
0x2385

But there is no sound card.

cat /proc/asound/cards  
--- no soundcards ---

Also in dmesg i don’t see any WM8523 message.


2020-12-18 Progress update

Updated menuconfig and it looks as follows

--> Device Drivers
	--> Sound card support
		--> Advanced Linux Sound Architecture
			--> [*] Enable OSS Emulation 
			--> [*] Generic sound devices
				--> [*] Dummy (dev/null) soundcard
			--> [*] SPI sound devices
			--> [*] ALSA for SoC audio support
				--> SoC Audio for Freescale CPUs
					--> [*] Synchronous Audio Interface (SAI) module support
					--> [*] Synchronous Serial Interface module (SSI) support
					--> [*] Enhanced Serial Audio Interface (ESAI) module support
					--> [*] SoC Audio for Freescale i.MX CPUs
					--> [*] Generic ASoC Sound Card with ASRC support
				--> CODEC drivers
					--> [*] Wolfson Microelectronics WM8523 DAC
				--> [*] ASoC Simple sound card support

No I see the i2c is used

 i2cdetect 0
      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
 00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
 10: -- -- -- -- -- -- -- -- -- -- UU -- -- -- -- -- 
 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
 60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- -- 
 70: -- -- -- -- -- -- -- --                        

But no soundcard seen in alsamixer (except the dummy one).
I the Generic sound devices is deactivated, no soundcards are found.

Greetings @codeshredder726b!

Which version of software (BSP, kernel) are you using? Also, please provide the version of your module.

Hi @gustavo.tx

bitbake -e virtual/kernel | grep "^PV"

PV=“4.14-2.3.x+gitAUTOINC+baa6c24240”

bitbake -e virtual/kernel | grep "^PN"

PN=“linux-toradex

from the Dockerfile:

~/bin/repo init -u http://git.toradex.com/toradex-bsp-platform.git -b LinuxImage3.0 -m default.xml

LinuxImage3.0

Col iMX6ULL 512MB IT V1.1 A

@codeshredder726b,

Thank you. Can you please post a full dmesg log? It seems that the I2C part is working, so I guess we might have to tweak the device tree a bit.

Hi @gustavo.tx
I got a bit more, so I post an update of the device tree and the corresponding dmesg output.
Audio is still not working, but the WM8523 simple-audio-card is working (i2c). So I think the problem is within the simple-audio-card or sai2 (or clocks…).

Device Tree:

/ {
        sound-wm8523 {
                compatible = "simple-audio-card";
                simple-audio-card,name = "Wolfson WM8523";

                simple-audio-card,format = "i2s";
                simple-audio-card,widgets = "Speaker", "Speaker";
                simple-audio-card,routing = "Speaker","LSPK", "Speaker","RSPK";
                simple-audio-card,cpu {
                        sound-dai = <&sai2 0>;
                        system-clock-frequency = <3072000>; /*<2634000>;*/ // freq 41000 * channels 32 * wordlen 2 = 2'634'000
                        bitclock-master;
                        frame-master;
                };
                simple-audio-card,codec {
                        sound-dai = <&wm8523>;
                        clocks = <24000000>;
                        #sound-dai-cells = <0>;
                };
        };
};

&i2c1 {
        status = "okay";
        clock-frequency = <400000>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_i2c1>;

        wm8523: wm8523@1a {
                compatible = "wlf,wm8523";
                reg = <0x1a>;
                clock-names = "mclk";
                #sound-dai-cells = <0>;
        };
};

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

&iomuxc {
        pinctrl-0 = <&pinctrl_gpio1 &pinctrl_gpio3 &pinctrl_gpio5 &pinctrl_additionalgpio>;

        imx6ull-colibri {
                pinctrl_gpiotouch: touchgpios {
                        fsl,pins = <
                                MX6UL_PAD_NAND_DQS__GPIO4_IO16          0x74
                                MX6UL_PAD_ENET1_TX_EN__GPIO2_IO05       0x14
                        >;
                };

                pinctrl_audmux: audmuxgrp {
                        fsl,pins = <
                                MX6UL_PAD_SD1_CLK__SAI2_MCLK            0x130b1
                                MX6UL_PAD_JTAG_TDI__SAI2_TX_BCLK        0x130b0
                                MX6UL_PAD_JTAG_TRST_B__SAI2_TX_DATA     0x130b0
                                MX6UL_PAD_SD1_DATA0__SAI2_TX_SYNC       0x130b1
                        >;
                };
};

dmesg:

    [    1.711919] wm8523 0-001a: 0-001a supply AVDD not found, using dummy regulator
    [    1.719667] wm8523 0-001a: 0-001a supply LINEVDD not found, using dummy regulator
    [    1.728475] wm8523 0-001a: revision C 
    
    [    1.896916] OF: /sound-wm8523/simple-audio-card,codec: could not find phandle
    [    1.906037] asoc-simple-card sound-wm8523: wm8523-hifi <-> 202c000.sai mapping ok
    [    1.913568] asoc-simple-card sound-wm8523: ASoC: no source widget found for LSPK
    [    1.921033] asoc-simple-card sound-wm8523: ASoC: Failed to add route LSPK -> direct -> Speaker
    [    1.929717] asoc-simple-card sound-wm8523: ASoC: no source widget found for RSPK
    [    1.937173] asoc-simple-card sound-wm8523: ASoC: Failed to add route RSPK -> direct -> Speaker
    [    1.945826] usb 1-1: new high-speed USB device number 2 using ci_hdrc

Try to play some file:

    aplay -L
    null
        Discard all samples (playback) or generate zero samples (capture)
    sysdefault:CARD=Dummy
        Dummy, Dummy PCM
        Default Audio Device
    sysdefault:CARD=WM8523
        Wolfson WM8523, 
        Default Audio Device

    aplay --device sysdefault:CARD=WM8523 ../test.mp3 
    
    [  288.916342] wm8523 0-001a: No MCLK configured, call set_sysclk() on init
    [  288.923100] wm8523 0-001a: ASoC: can't open codec wm8523-hifi: -22
    aplay: main:828: audio open error: Invalid argument

@codeshredder726b,

Another customer apparently had some success getting another Wolfson codec to work after we did some investigation. This is the related thread.

I suggest you to try comparing your device-tree nodes to the nodes of the built-in audio codec to make sure all the clocks and sub-nodes are correctly set up.

Hi @gustavo.tx
OK thanks, I diff the device-tree etc. Also I have to check, that the i2s are not already in defined before my definition. Update coming soon.

Hi @gustavo.tx

Some progress has been made, I have clocks on BCLK (bit clock on pin 31) and LRCLK (frame clock on pin 192) but no MCLK (pin 47).

Goal:

  • MCLK: 12’288’000
  • fs: 256
  • LRCLK: 48’000
  • BCLK: 3’072’000 (MCLK/4)

But instead of the expected 48kHz on the LRCLK it was 173kHz and instead of 3.072MHz it was 5.536MHz on the BCLK. And no MCLK!

The device tree for soundcard, codec, sai2 and clocks:

/ {
	sound {
		compatible = "simple-audio-card";
		simple-audio-card,name = "Wolfson WM8523";
		simple-audio-card,format = "i2s";
		simple-audio-card,widgets = "Line", "Line0";
		simple-audio-card,routing = "Line0","LINEVOUTL", "Line0","LINEVOUTR";
		simple-audio-card,bitclock-master = <&dailink_master>;
		simple-audio-card,frame-master = <&dailink_master>;
		dailink_master: simple-audio-card,cpu {
			sound-dai = <&sai2>;
		};
		wm8523_dai: simple-audio-card,codec {
			#sound-dai-cells = <0>;
			sound-dai = <&wm8523>;
		};
	};
};

&i2c1 {
	status = "okay";
	clock-frequency = <400000>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_i2c1>;

	wm8523: wm8523@1a {
		compatible = "wlf,wm8523";
		reg = <0x1a>;
		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_audmux>;
		#sound-dai-cells = <0>;

		clock-names = "mclk";
		clocks = <&clks IMX6UL_CLK_SAI2>;

		assigned-clocks = <&clks IMX6UL_CLK_SAI2_SEL>, <&clks IMX6UL_CLK_SAI2>;
		assigned-clock-parents = <&clks IMX6UL_CLK_PLL4_AUDIO_DIV>;
		assigned-clock-rates = <36864000>, <12288000>;
	};
};

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

Hi @codeshredder726b

Is this issue solved?

Best regards,
Jaski

if anyone runs into this issue, please have a look at this
codec.patch (4.1 KB). It ouputs bit clock 1536000 on SODIMM31 for SAI2. The audio format is 2 channels, 16bit, 48K sample rate.
.