AnsweredAssumed Answered

I2S microphone (SPH0645LM4H)  Driver Implementation with i.mx6ul

Question asked by Hitesh Kasera on Apr 17, 2019
Latest reply on May 25, 2019 by Hitesh Kasera

Hi,

 

I am working with 1 I2S microphone (SPH0645LM4H) which is connected to i.MX6UL I2s Interface. I want to record audio from this mems. My device tree set up for the same is:

/ {
   sound {
      compatible = "fsl,imx-audio-sph0645",
                           "fsl,imx-mic-sph0645";
      model = "sph0645-audio";
      cpu-dai = <&sai1>;
   };
};

 

&sai1 {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_sai1>;

 

    /*
     * Reference block.
     *
     * Codec dependent section.
     */
    assigned-clocks = <&clks IMX6UL_CLK_SAI1_SEL>,
            <&clks IMX6UL_CLK_SAI1>;
    assigned-clock-rates = <0>, <12288000>;
    assigned-clock-parents = <&clks IMX6UL_CLK_PLL4_AUDIO_DIV>;

 

    status = "okay";
};

 

 

The driver file main code set up like :

 

u32 channels = 2; //ALWAYS 2 CHANNELS  params_channels(params);
u32 rate = params_rate(params); //sampling rate

dev_err(cpu_dai->dev, "sampling rate parms_rate output rate : %d \n" , rate);
u32 bclk = rate * channels * 32; //fixed to sampling rate * 64
dev_err(cpu_dai->dev, "bclk : %d \n" , bclk);    

int ret = 0;

 

    /* set cpu DAI configuration */
    ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBS_CFS);
    if (ret) {
        dev_err(cpu_dai->dev, "failed to set dai fmt\n");
        return ret;
    }

 

    ret = snd_soc_dai_set_tdm_slot(cpu_dai, 0, 3, 2, 32);
    if (ret) {
        dev_err(cpu_dai->dev, "failed to set dai tdm slot\n");
        return ret;
    }

 

    ret = snd_soc_dai_set_sysclk(cpu_dai, 0, bclk, SND_SOC_CLOCK_OUT);
    if (ret)
        dev_err(cpu_dai->dev, "failed to set cpu sysclk\n");

 

 

Issue is i am not able to get desire bit clock and frame sync clock. for example i run below mentioned command to see signals on oscilloscope.

 

arecord -c 2 -d 5 -f S32 -r 48000 -v /home/root/test.wav

 

on oscilloscope i was getting bit clock frequency around 11.086Mhz and Frame sync clock was about 173 Khz. As i am passing 48000 hz sampling rate bclk should be 3.072Mhz but here its not the case. In this case i have not attached the microphone sensor because it could get damaged due to higher frequency. i have also tried to see prints in fsl_sai.c file there i see the mclk_clk[0]= 0Hz and mclk_clk[1]=12.288Mhz.

 

I tried different sampling rate also such as

 

arecord -c 2 -d 5 -f S32 -r 16000 -v /home/root/test.wav

 

In this case i was getting bclk of 3.69Mhz and frame sync of 57.663 Khz which is also not according to what i have requested.

 

I am not able to get this issue. How its taking 11Mhz?

 

 

Thanks & Regards,

Hitesh

Outcomes