AnsweredAssumed Answered

How to configure IMX7D_AUDIO_MCLK_ROOT_SRC for an external clock?

Question asked by Florian Harmuth on Sep 7, 2017
Latest reply on Sep 8, 2017 by Florian Harmuth

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

Outcomes