SAI7 not outputting mclk on i.MX 8M Plus EVK

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SAI7 not outputting mclk on i.MX 8M Plus EVK

Jump to solution
4,070 Views
chrispeterson
Contributor IV

Hello all,

I am attempting to get an I2S device working using SAI7 on the 8MPLUSEVK.  I have confirmed that I have everything hooked up propery by using the /sys/class/gpio/ sysfs method and I could see the correct lines toggle.   I can see the I2C working, however it always fails due not not having MCLK running at the time.

Here is my device tree:

 

/dts-v1/;

#include "imx8mp-evk.dts"

/ {

	sound-wm8960 {
		status = "disabled";
	};

	sound-micfil {
		status = "disabled";
	};
	
	sound-xcvr {
		status = "disabled";	
	};
	
	sound-ssm2518 {
		compatible = "simple-audio-card";
		simple-audio-card,name = "ssm2518-audio";
		simple-audio-card,format = "i2s";
		simple-audio-card,frame-master = <&cpudai>;
		simple-audio-card,bitclock-master = <&cpudai>;		
		simple-audio-card,mclk-fs = <256>;
		simple-audio-card,widgets =
			"Speaker", "Speakers";
		simple-audio-card,routing =
			"Speakers", "OUTL",
			"Speakers", "OUTR";
		status = "okay";
				
		cpudai: simple-audio-card,cpu {
			sound-dai = <&sai7>;
		};
	
		simple-audio-card,codec {
			sound-dai = <&ssm2518_i2c>;
			clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI7_MCLK1>;
		};
	};
};

&i2c3 {
	clock-frequency = <100000>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_i2c3>;
	status = "okay";
		
	codec: wm8960@1a {
		status = "disabled";
	};
	
	ssm2518_i2c: ssm2518@34 {
		#sound-dai-cells = <0>;
		status = "okay";
		compatible = "adi,ssm2518";
		reg = <0x34>;		
		clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI7_MCLK1>;
		clock-names = "mclk";
		assigned-clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI7_MCLK1>;
		assigned-clock-rates = <12288000>;
	};	
};

&uart3 {
	status = "disabled";
};

&ecspi2 {
	status = "disabled";
};


&sai2 {
	status = "disabled";
};


&sai3 {
	status = "disabled";
};

&xcvr {
	status = "disabled";
};


&sai7 {
	#sound-dai-cells = <0>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_sai7>;
	assigned-clocks = <&clk IMX8MP_CLK_SAI7>;
	assigned-clock-parents = <&clk IMX8MP_AUDIO_PLL1_OUT>;
	assigned-clock-rates = <12288000>;	
	clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI7_IPG>, <&clk IMX8MP_CLK_DUMMY>,
		 <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI7_MCLK1>, <&clk IMX8MP_CLK_DUMMY>,
		 <&clk IMX8MP_CLK_DUMMY>, <&clk IMX8MP_AUDIO_PLL1_OUT>, <&clk IMX8MP_AUDIO_PLL2_OUT>;
	clock-names = "bus", "mclk0", "mclk1", "mclk2", "mclk3", "pll8k", "pll11k";
	fsl,sai-mclk-direction-output;
	fsl,sai-asynchronous;
	status = "okay";
};


&iomuxc {
	pinctrl_sai7: sai7grp {
		fsl,pins = <
			MX8MP_IOMUXC_ECSPI1_SS0__AUDIOMIX_SAI7_TX_SYNC		0xd6
			MX8MP_IOMUXC_ECSPI2_SCLK__AUDIOMIX_SAI7_TX_BCLK		0xd6
			MX8MP_IOMUXC_ECSPI2_MOSI__AUDIOMIX_SAI7_TX_DATA00	0xd6
			MX8MP_IOMUXC_ECSPI2_MISO__AUDIOMIX_SAI7_MCLK		0xd6
		>;
	};
};

 

 

At this point I am out of ideas.   I have tried all sorts of combinations of different clock settings in the sound device, I2C, and SAI configurations and nothing seems to give any effect. 

I found the following threads and tried all the suggestions there:

I can see that the clock rates are set properly though the clk_summary:

 

root@imx8mpevk:~# cat /sys/kernel/debug/clk/clk_summary | grep -i sai7
 sai7_mclk                            0        0        0           0          0     0  50000
                sai7_mclk3_clk        0        0        0    49152000          0     0  50000
          sai7_mclk2_sel              0        0        0    24000000          0     0  50000
             sai7_mclk2_clk           0        0        0    24000000          0     0  50000
                         sai7_ipg_clk       0        0        0   400000000          0     0  50000
                sai7                  0        0        0    12288000          0     0  50000
                   sai7_root          0        0        0    12288000          0     0  50000
                      sai7_mclk1_sel       0        0        0    12288000          0     0  50000
                         sai7_mclk1_clk       0        0        0    12288000          0     0  50000
    audio_pll1_ref_sel                0        0        0    24000000          0     0  50000
       audio_pll1                     0        0        0   393216000          0     0  50000
          audio_pll1_bypass           0        0        0   393216000          0     0  50000
             audio_pll1_out           0        0        0   393216000          0     0  50000

root@imx8mpevk:~# 

 


Any ideas or hints?

Thank you,

Chris

0 Kudos
1 Solution
3,898 Views
chrispeterson
Contributor IV

@igorpadykov 

 

I got it all working.  Turns out you do not need MCLK for the I2C to work.  The EVAL-SSM2518Z board that I was using had the pins on the External I2C header mislabeled (they are also wrong in the schematic) so all I had to do was swap them and everything works.

Thank you for your support

Chris

View solution in original post

0 Kudos
14 Replies
4,050 Views
igorpadykov
NXP Employee
NXP Employee

Hi Chris

 

one can look at below sa3&wm8960 example and make similar settings for sai7

https://source.codeaurora.org/external/imx/linux-imx/tree/arch/arm64/boot/dts/freescale/imx8mp-evk.d...

 

Best regards
igor

0 Kudos
4,040 Views
chrispeterson
Contributor IV

Hi @igorpadykov,

I have tried copying the same settings for SAI3.  Infact I went so far as setting up the WM8960 to run on SAI7 to see if it would output the MCLK.  No dice.

Any other suggestions?

-Chris

0 Kudos
4,033 Views
igorpadykov
NXP Employee
NXP Employee

colud you please provide dts file with changes, also what bsp used in the case.

 

Best regards
igor

0 Kudos
4,028 Views
chrispeterson
Contributor IV

@igorpadykov 

Attached is my most recent .dts file.  As for BSP I am using I ran the following command:
repo init -u https://source.codeaurora.org/external/imx/imx-manifest -b imx-linux-hardknott -m imx-5.10.52-2.1.0.xml

 

Thank you,

Chris

0 Kudos
4,016 Views
igorpadykov
NXP Employee
NXP Employee

from team:

----------------

Can you get the value in 30e20000 and 30e20314?

----------------

Best regards
igor

0 Kudos
3,993 Views
chrispeterson
Contributor IV

@igorpadykov 

I attempted to read these values using /dev/mem and /unit_tests/memtool and both of them gave me a bus error.

root@imx8mpevk:/unit_tests# ./memtool 30e20000 *
E
Reading 0xA count starting at [ 232.989679] audit: type=1701 audit(1616581743.564:4): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=1178 comm="memtool" exe="/unit_tests/memtool" sig=7 res=1
address 0x30E20000

Bus error

and

root@imx8mpevk:/unit_tests# hexdump -C -s 0x30e20000 /dev/mem
hexdump: /dev/mem: Bad address
30e20000

How do I read them?  I currently do not have a debugger hooked up.

I did get this if it helps:

root@imx8mpevk:~# hexdump -C /sys/firmware/devicetree/base/soc\@0/bus\@30c00000/audio-blk-ctrl\@30e20000/reg
00000000 30 e2 00 00 00 00 05 0c |0.......|
00000008

Thank you,

Chris

0 Kudos
3,982 Views
igorpadykov
NXP Employee
NXP Employee

>I attempted to read these values using /dev/mem and /unit_tests/memtool and both

>of them gave me a bus error.  root@imx8mpevk:/unit_tests# ./memtool 30e20000 *

 

please read 0x30e20000 and 0x30e20314

 

Best regards
igor

 

 

0 Kudos
3,968 Views
igorpadykov
NXP Employee
NXP Employee

from team:

----------------

1.jpg

 -----------------

Best regards
igor

0 Kudos
3,960 Views
chrispeterson
Contributor IV

@igorpadykov 

I get the same error when running the suggested command:

 

root@imx8mpevk:~# /unit_tests/memtool 30e20000 1
E
Reading 0x1 count starting at [ 125.680513] audit: type=1701 audit(1616581635.560:5): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=976 comm="memtool" exe="/unit_tests/memtool" sig=7 res=1
address 0x30E20000

Bus error
root@imx8mpevk:~#

I even switched to the imx8mp-evk.dtb and had the same result.

Is there something that I need to enable (kernel parameter, build options, etc)?

Thank you,

Chris

0 Kudos
3,951 Views
igorpadykov
NXP Employee
NXP Employee

from team:

----------------

You need to play/record something first to make SAI working.

For example, with default 8mp evk, when I use the wm8960 for playback, SAI3 will be used, then I can read the register like

oot@imx8mpevk:~# /unit_tests/memtool 30e20000 1
E
Reading 0x1 count starting at address 0x30E20000

0x30E20000:  04000300

Check with the register definition, you can see SDMA2, SAI3_MCLK and SAI3 are being used.

 

xiaocong_fu_0-1641782748317.png

 

Same with the 30e20314.

The customer can use this way to check if the desired SAI is really enabled.


-----------------

Best regards
igor

0 Kudos
3,943 Views
chrispeterson
Contributor IV

@igorpadykov 

I downloaded and flashed the default EVK build (LF_v5.10.72-2.2.0_images_IMX8MPEVK.zip) and flashed both the multimedia and full versions to an SD card and I get the same result from memtool:

root@imx8mpevk:~# cd /unit_tests/
root@imx8mpevk:/unit_tests# ./memtool 30e20000 1
E
Reading 0x1 count starting at [ 55.261971] audit: type=1701 audit(1616581569.284:4): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=937 comm="memtool" exe="/unit_tests/memtool" sig=7 res=1
address 0x30E20000

Bus error
root@imx8mpevk:/unit_tests#

Could this be due to me running on a Power EVK instead of a standard EVK?

 

Also, when I run aplay -L the SSM2518 device is not listed as an option when I test my custom build.

Thank you,

Chris

0 Kudos
3,937 Views
igorpadykov
NXP Employee
NXP Employee

>I downloaded and flashed the default EVK build..

 

default build  has not sai7 enabled.

default build has sai3 enabled.

So one can try to replace sai3 with sai7 and rebuild image.

 

Best regards
igor

 

0 Kudos
3,907 Views
chrispeterson
Contributor IV

@igorpadykov 

I was finally able to get MCLK out of SAI7 by modifying the WM8960 to be on SAI7 and running a speaker-test using the attached imx8mp-evk.dts.   Now, I need to get it to work on the SSM2518.

-Chris

0 Kudos
3,899 Views
chrispeterson
Contributor IV

@igorpadykov 

 

I got it all working.  Turns out you do not need MCLK for the I2C to work.  The EVAL-SSM2518Z board that I was using had the pins on the External I2C header mislabeled (they are also wrong in the schematic) so all I had to do was swap them and everything works.

Thank you for your support

Chris

0 Kudos