IMX6UL L SAI MCLK Output on startup to initialize Codec / DAC / sound device correctly

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

IMX6UL L SAI MCLK Output on startup to initialize Codec / DAC / sound device correctly

767 Views
IndustrialP_LB
Contributor I

We use an IMX6ULL board running yocto and are using it for audio application.

As a second sound device we are using a PCM1681 DAC (reading some questions here the WM8960 behaves similarly.

The device needs a running MCLK to be properly initialized which we couldn't get with the existing settings and properties.

 

Besides the

fsl,sai-mclk-direction-output;
 
property we introduced our own
 
fsl,sai-mclk-force-output;
 
property in the SAI device tree entry and added a patch to the sound/soc/fsl/fsl_sai.c driver.
 
When the argument is used, the MCLK of the corresponding SAI doesn't get stopped by the power management.
 
Here is our custom patch featuring debug messages as warnings. This could probably be cleaned up a bit.
Has anyone had a similar issue or solution? We hope this patch can be useful for others.
 
 

Subject: [PATCH] SAI MCLK force output

---
sound/soc/fsl/fsl_sai.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index 6a12cbd43084..87e3b12ed679 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -1173,6 +1173,15 @@ static int fsl_sai_probe(struct platform_device *pdev)
if (ret)
goto err_pm_get_sync;

+ if (of_find_property(np, "fsl,sai-mclk-force-output", NULL)) {
+ dev_warn(dev, "MCLK Output forced 1: %d\n", sai->mclk_streams);
+ sai->mclk_streams |= BIT(SNDRV_PCM_STREAM_PLAYBACK);
+ dev_warn(dev, "MCLK Output forced 2: %d\n", sai->mclk_streams);
+ fsl_sai_runtime_resume(dev);
+ sai->mclk_streams &= ~BIT(SNDRV_PCM_STREAM_PLAYBACK);
+ dev_warn(dev, "MCLK Output forced 3: %d\n", sai->mclk_streams);
+ }
+
return ret;

err_pm_get_sync:
--
2.25.1

Labels (3)
0 Kudos
Reply
0 Replies