iMX8MP SAI and MCLK

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
344件の閲覧回数
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 件の賞賛
返信
1 解決策
312件の閲覧回数
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 件の賞賛
返信
1 返信
313件の閲覧回数
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 件の賞賛
返信