SAI5 I2S not working | clock problems!?

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

SAI5 I2S not working | clock problems!?

Jump to solution
1,020 Views
ivan8mm
Contributor II

Hello.

I have searched around the forums and saw many posts with my problem but not a single one of the solutions works for me.

I am trying to connect a digital microphone to the SAI5 expansion pins on my i.mx 8m mini evk . Here is the device tree I have:

 

 

codec_dummy: codec_dummy {
                compatible = "asoc,snd-soc-dummy";

                #sound-dai-cells = <0>;
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_gpio_wlf>;
                frame-master;
                bitclock-master;
                status = "okay";

                };

sound-sai5 {
                compatible = "simple-audio-card";

                simple-audio-card,name="sound | sai5";
                simple-audio-card,format="i2s";

                simple-audio-card,frame-master=<&sai5>;
                simple-audio-card,bitclock-master=<&sai5>;
                status="okay";

                cpu_dai:simple-audio-card,cpu{
                        sound-dai=<&sai5>;
                        system-clock-frequency=<&clk IMX8MM_CLK_SAI5_ROOT>;
                };

                codec_dai: simple-audio-card,codec{
                        sound-dai=<&codec_dummy>;
                        system-clock-frequency=<&clk IMX8MM_CLK_SAI5_ROOT>;
                };



};
&sai5 {
        compatible="fsl,imx8mm-sai";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_sai5>;
        assigned-clocks=<&clk IMX8MM_CLK_SAI5>;
        assigned-clocks-parents=<&clk IMX8MM_AUDIO_PLL1_OUT>;
        assigned-clock-rates = <4096000>;
        fsl,sai-mclk-direction-output;
        fsl,txmasterflag = <0>;
        fsl,mode="i2s-master";
        status="okay";
};

 

 

 I can see the interface when I run the arecord -l command, when I run pactrl list the following error gets printed out in an infinite loop:

 

 

fsl-sai 30050000.sai: ASoC: error at snd_soc_dai_hw_params on 30050000.sai: -22
[ 1875.936608]  30050000.sai-snd-soc-dummy-dai: ASoC: soc_pcm_hw_params() failed (-22)
[ 1875.944756] fsl-sai 30050000.sai: failed to derive required Rx rate: 1411200

 

 

Any help is greatly appreciated as have been struggling with this error for the past month!

Labels (1)
0 Kudos
1 Solution
772 Views
ivan8mm
Contributor II

After 2 months of searching the internet, I managed to get it working using the simple audio driver. In order to get it in working condition, I made the following changes to the original device tree(build/workspace/sources/linux-imx/arch/arm64/boot/dts/freescaleimx8mm-evk.dtsi):

  • in the micfil node, change the status form "okay" to disabled". The reason is this node uses the SAI5 interface which I need for my microphone(check the &iomuxc -> pinctrl_pdm node)
  • inserted my custom node "sound-sai5" which can be found in the device tree file I attached
  • inserted my custom dummy node "codec_dummy" which can be found in the device tree file I attached
  • configured the pins I will use in the &iomuxc -> pinctrl_sai5 node. The exact names have to be specified as that is a part of the configuration. I got the names from the documentation(the 5k+ page one), chapter 8, Chip IO and Pinmux
  • changed the "ext_osc" value of the pcie node from 1 to 0
  • applied the following patch:
    ---
    sound/soc/soc-utils.c | 11 +++++++++++
    1 file changed, 11 insertions(+)
    
    diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c
    index 54dcece52b0c..892d02992b02 100644
    --- a/sound/soc/soc-utils.c
    +++ b/sound/soc/soc-utils.c
    @@ -7,6 +7,8 @@
    // Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
    // Liam Girdwood <lrg@slimlogic.co.uk>
    
    +#include <linux/module.h>
    +#include <linux/of.h>
    #include <linux/platform_device.h>
    #include <linux/export.h>
    #include <sound/core.h>
    @@ -149,9 +151,18 @@ static int snd_soc_dummy_probe(struct platform_device *pdev)
    return ret;
    }
    
    +#ifdef CONFIG_OF
    +static const struct of_device_id soc_dummy_device_id[] = {
    + { .compatible = "asoc,snd-soc-dummy" },
    + {}
    +};
    +MODULE_DEVICE_TABLE(of, soc_dummy_device_id);
    +#endif
    +
    static struct platform_driver soc_dummy_driver = {
    .driver = {
    .name = "snd-soc-dummy",
    + .of_match_table = of_match_ptr(soc_dummy_device_id),
    },
    .probe = snd_soc_dummy_probe,
    };
    --

View solution in original post

0 Kudos
7 Replies
773 Views
ivan8mm
Contributor II

After 2 months of searching the internet, I managed to get it working using the simple audio driver. In order to get it in working condition, I made the following changes to the original device tree(build/workspace/sources/linux-imx/arch/arm64/boot/dts/freescaleimx8mm-evk.dtsi):

  • in the micfil node, change the status form "okay" to disabled". The reason is this node uses the SAI5 interface which I need for my microphone(check the &iomuxc -> pinctrl_pdm node)
  • inserted my custom node "sound-sai5" which can be found in the device tree file I attached
  • inserted my custom dummy node "codec_dummy" which can be found in the device tree file I attached
  • configured the pins I will use in the &iomuxc -> pinctrl_sai5 node. The exact names have to be specified as that is a part of the configuration. I got the names from the documentation(the 5k+ page one), chapter 8, Chip IO and Pinmux
  • changed the "ext_osc" value of the pcie node from 1 to 0
  • applied the following patch:
    ---
    sound/soc/soc-utils.c | 11 +++++++++++
    1 file changed, 11 insertions(+)
    
    diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c
    index 54dcece52b0c..892d02992b02 100644
    --- a/sound/soc/soc-utils.c
    +++ b/sound/soc/soc-utils.c
    @@ -7,6 +7,8 @@
    // Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
    // Liam Girdwood <lrg@slimlogic.co.uk>
    
    +#include <linux/module.h>
    +#include <linux/of.h>
    #include <linux/platform_device.h>
    #include <linux/export.h>
    #include <sound/core.h>
    @@ -149,9 +151,18 @@ static int snd_soc_dummy_probe(struct platform_device *pdev)
    return ret;
    }
    
    +#ifdef CONFIG_OF
    +static const struct of_device_id soc_dummy_device_id[] = {
    + { .compatible = "asoc,snd-soc-dummy" },
    + {}
    +};
    +MODULE_DEVICE_TABLE(of, soc_dummy_device_id);
    +#endif
    +
    static struct platform_driver soc_dummy_driver = {
    .driver = {
    .name = "snd-soc-dummy",
    + .of_match_table = of_match_ptr(soc_dummy_device_id),
    },
    .probe = snd_soc_dummy_probe,
    };
    --
0 Kudos
955 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

Got it, thank you for the information!

Here is a community post were show the device tree and configuration to reach a successful microphone record with the same microphone and MPU (i.MX8MM).

I hope this information helps you.

Best regards.

0 Kudos
921 Views
ivan8mm
Contributor II

Hello Jorge,

after implementing the solution form the community post you linked it does not work. The driver does not work properly as it is based on the wmxxxx drivers(wm8524) which is outdated. Currently I am trying to debug it.

Error: Failed to register card: -517

Sincerely, Ivan

0 Kudos
897 Views
ivan8mm
Contributor II
After checking the soc-core.c file with the same file 2 years ago, nothing has changed which would cause the driver not working. It is now my assumption that ether the device tree configuration is not correct or the driver itself is not correct.
0 Kudos
876 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello!

The errors:

fsl-sai 30050000.sai: ASoC: error at snd_soc_dai_hw_params on 30050000.sai: -22
[ 1875.936608] 30050000.sai-snd-soc-dummy-dai: ASoC: soc_pcm_hw_params() failed (-22)
[ 1875.944756] fsl-sai 30050000.sai: failed to derive required Rx rate: 1411200

Are related to PLL, because cannot reach that specific frequency. Our BSP works with 12288000 and 24576000.

So, I suggest try with these clock rates and verify it on Linux's clk summary:

cat /sys/kernel/debug/clk/clk_summary

And check if your clock summary is configured to desired clock rate for your configurations.

Best regards.

0 Kudos
975 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello,

Could you please provide me which digital microphone are you trying to use?

I suggest you use the reference device tree for i.MX8MM or use BSP option to handle digital microphones with PDM, for example 8MIC-RPI-MX8 with precompiled device tree.

Best regards.

0 Kudos
973 Views
ivan8mm
Contributor II

Hi Jorge,

I am using the SPH0645 I2S digital microphone. And I have used that device tree for reference but to no avail!

 

Best regards.

0 Kudos