iMX8MP SAI and MCLK

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

iMX8MP SAI and MCLK

Jump to solution
343 Views
ulrich_sorensen
Contributor II

Hi,

I am using the iMX8MP and I have a codec connected to SAI1 which requires the MCLK to be present before codec is setup. Codec is connected to iMX8MP so that codec uses SAI1_MCLK pin. iMX8MP is the master in the system providing MCLK, BCLK and WCLK.

I have tried various things to make MCLK start before codec is setup via I2C or to make it continuous, but MCLK is not started until capture is started (eg. with arecord). See screenshot below.

I have tried to move clk_prepare_enable(mclk); to probe of codec driver without luck. I think the MCLK might be gated by SAI1 somehow.

Some register dumps when system is idle. Looks like SAI1 is enabled

devmem 0x30c10100 0xC0000000

devmem 0x30e20000 0x04000002

Is there a way to start MCLK before I2C commands? Alternatively, have it run continuously.

 

BR,

Ulrich

Screenshot from 2024-05-22 09-22-20.png

0 Kudos
Reply
1 Solution
311 Views
Alejandro_Salas
NXP TechSupport
NXP TechSupport

Hello @ulrich_sorensen 

One can try modifying the fsl_sai.c in fsl_sai_probe function:

clk_prepare_enable(sai->bus_clk);
clk_prepare_enable(sai->mclk_clk[1]);
regmap_update_bits(sai->regmap, FSL_SAI_MCTL,
    FSL_SAI_MCTL_MCLK_EN, FSL_SAI_MCTL_MCLK_EN);
regmap_update_bits(sai->regmap, FSL_SAI_TCSR(8),
    FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE);

 

After of modifiying the sai MCLK should be active when the system bootup.

 

But after sai driver callback ends (e.g aplay ends), MCLK will be de-active again. The reason is that in sai trigger stop, the transmitter is disabled. To keep the MCLK always on, need to keep transmitter always on. 

In a few words, do not clear FSL_SAI_CSR_TERE in trigger stop.

 

I hope this information can helps to you.

 

Best regards,

Salas.

View solution in original post

0 Kudos
Reply
1 Reply
312 Views
Alejandro_Salas
NXP TechSupport
NXP TechSupport

Hello @ulrich_sorensen 

One can try modifying the fsl_sai.c in fsl_sai_probe function:

clk_prepare_enable(sai->bus_clk);
clk_prepare_enable(sai->mclk_clk[1]);
regmap_update_bits(sai->regmap, FSL_SAI_MCTL,
    FSL_SAI_MCTL_MCLK_EN, FSL_SAI_MCTL_MCLK_EN);
regmap_update_bits(sai->regmap, FSL_SAI_TCSR(8),
    FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE);

 

After of modifiying the sai MCLK should be active when the system bootup.

 

But after sai driver callback ends (e.g aplay ends), MCLK will be de-active again. The reason is that in sai trigger stop, the transmitter is disabled. To keep the MCLK always on, need to keep transmitter always on. 

In a few words, do not clear FSL_SAI_CSR_TERE in trigger stop.

 

I hope this information can helps to you.

 

Best regards,

Salas.

0 Kudos
Reply