AnsweredAssumed Answered

IMX7s SAI mclk clock source

Question asked by jensalsig on Oct 24, 2017
Latest reply on Oct 25, 2017 by igorpadykov

Hi

 

I'm trying to get the the a SAI working under Linux 4.9.47. The SAI must be master (generate mclk, bclk and frame sync). The mclk must be 24.576 MHz, the blck must be  3.072MHz and the frame sync must be 48kHz.

 

 

My problem is that  I can't set configure the clock source to the SAI to any other value than 24MHz. 

I do my testing wtih "speaker-test --format S32_LE". I can measure the the mclk on the mclk pad but it is 24MHz. It seems that everything is working but with the wrong clock source. 

 

Questions:

1) Which clock source is used for the SAI1? IMX7D_SAI1_ROOT_CLK? IMX7D_AUDIO_MCLK_ROOT_CLK? Or...?

2) How do I configure it?

 

The datasheet isn't very clear regarding this.

 

Best regards

Jens Alsig

 

Device tree sniplets:

codec1: codec1 {
compatible = "linux,snd-soc-dummy";
#sound-dai-cells = <0>;
clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>;
assigned-clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_SRC>,
<&clks IMX7D_AUDIO_MCLK_ROOT_CLK>;
assigned-clock-parents = <&clks IMX7D_PLL_AUDIO_POST_DIV>;
assigned-clock-rates = <0>, <24576000>;
status = "okay";
};

sound {
compatible = "simple-audio-card";
simple-audio-card,name = "sai_1";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&dailink1_master>;
simple-audio-card,frame-master = <&dailink1_master>;
simple-audio-card,mclk-fs = <512>;
dailink1_master: simple-audio-card,cpu {
sound-dai = <&sai1>;
clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>;
};
simple-audio-card,codec {
sound-dai = <&codec1>;

};
};

&sai1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sai1>;
assigned-clocks = <&clks IMX7D_SAI1_ROOT_SRC>,
<&clks IMX7D_SAI1_ROOT_CLK>;
assigned-clock-parents = <&clks IMX7D_PLL_AUDIO_POST_DIV>;
assigned-clock-rates = <0>,<24576000>;
fsl,sai-mclk-direction-output;
fsl,sai-synchronous-rx;
status = "okay";
};

 

From the kernel the following clocks are configured:

root@morris:~# cat /sys/kernel/debug/clk/clk_summary | grep sai
sai3_src 0 0 24000000 0 0
sai3_cg 0 0 24000000 0 0
sai3_pre_div 0 0 24000000 0 0
sai3_post_div 0 0 24000000 0 0
sai3_root_clk 0 0 24000000 0 0
sai2_src 0 0 884736000 0 0
sai2_cg 0 0 884736000 0 0
sai2_pre_div 0 0 884736000 0 0
sai2_post_div 0 0 24576000 0 0
sai2_root_clk 0 0 24576000 0 0
sai1_src 0 0 884736000 0 0
sai1_cg 0 0 884736000 0 0
sai1_pre_div 0 0 884736000 0 0
sai1_post_div 0 0 24576000 0 0
sai1_root_clk 0 0 24576000 0 0
sai3_ipg_clk 0 0 0 0 0
sai2_ipg_clk 0 1 0 0 0
sai1_ipg_clk 0 1 0 0 0
root@morris:~# cat /sys/kernel/debug/clk/clk_summary | grep audio_mclk
audio_mclk_src 0 0 884736000 0 0
audio_mclk_cg 0 0 884736000 0 0
audio_mclk_pre_div 0 0 884736000 0 0
audio_mclk_post_div 0 0 24576000 0 0
audio_mclk_root_clk 0 0 24576000 0 0

Outcomes