How to configure IMX7D_AUDIO_MCLK_ROOT_SRC for an external clock?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

How to configure IMX7D_AUDIO_MCLK_ROOT_SRC for an external clock?

1,545 次查看
florianharmuth
Contributor II

Hello,

I'm trying to configure the SAI1 interface to work with an externally generated MCLK on a IMX7D based board under linux (4.1.15).

To enable the interface I have added the following lines to my device tree:
/ {
    sound-XY {

        /* asoc sound card driver */
        compatible = "fsl,xy-card-master";
        model = "xy-card";
        audio-cpu = <&sai1>;
        audio-codec = <&xy_codec>;
    };
    
    xy_codec: xy-hifi {

        /* just a dummy codec based on spif_transmitter.c */
        compatible = "linux,xy-codec";
        #sound-dai-cells = <0>;
        clocks = <&codec_osc>;
        clock-names = "mclk";
        status = "okay";    
    };
    
    clocks {
        codec_osc: extclock0 {
            compatible = "fixed-clock";
            clock-frequency = <24576000>;
            #clock-cells = <0>;    
        };
    };
};

&sai1 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_sai1>;
    
    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>, <36864000>;
    status = "okay";
};

The audio device gets initialized on startup and the codec reports the correct configured frequency (24,576 MHz). The playing of an audio file fails with "Unable to install hw params". After digging around for a while and adding some printk messages to the fsl_sai driver I have seen that fsl_sai_set_bclk() wasn't able to find a valid master clock frequency - the only one which has been found was the 24 MHz osc. Instead of using my codecs frequency setting it still tries to use the normal osc which is 24 MHz.

So my question is - how should I properly configure the SAI interface to use my externally generated 24,576 MHz clock?

Best Regards,

flo

标签 (3)
标记 (3)
0 项奖励
回复
2 回复数

1,132 次查看
Carlos_Musich
NXP Employee
NXP Employee

Hi Florian,

In Table 5-11. Clock Root Table you can see all the available clock sources for SAI. Have you set the Mux field in Target Register (CCM_TARGET_ROOTn) to select the external root clock?


Regards,
Carlos

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复

1,132 次查看
florianharmuth
Contributor II

Hello Carlos,

I have already tried to set the clock root for sai1 to ext_clk2 with imx_clk_set_parent() in clk-imx7d.c but I wasn't able to do so due to the fact that for the ext_clks there is no existing clock entry. Setting up the mux value should be possible with the clk api shouldn't it? If I'm setting the mux value in CCM_TARGET_ROOTn directly how will linux be aware of this setting?

Best Regards,

flo

0 项奖励
回复