alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* imx8mm fsl_sai clock config failing
@ 2020-05-11 21:58 Tim Harvey
  2020-05-18  9:11 ` Aisheng Dong
  0 siblings, 1 reply; 4+ messages in thread
From: Tim Harvey @ 2020-05-11 21:58 UTC (permalink / raw)
  To: Timur Tabi, Nicolin Chen, Xiubo Li, Fabio Estevam, Stephen Boyd,
	Michael Turquette, Shawn Guo, Sascha Hauer, NXP Linux Team,
	Peng Fan, Anson Huang, Abel Vesa
  Cc: Linux-ALSA

Greetings,

I'm trying to get imx8mm sai working with a tlv320aic3x codec on a new
board and am finding that the sai3 bus clock is getting derived from
the wrong source leading hw_params() to fail with 'fsl-sai
30030000.sai: failed to derive required Tx rate: 3072000'

In comparison to the imx8mm-evk I find it's clock gets configured as
desired yet I have the same device-tree configuration for sai3.

Here is my board's dts:
/ {
...
        sound {
                compatible = "simple-audio-card";
                simple-audio-card,name = "tlv320-audio";
                simple-audio-card,format = "i2s";
                simple-audio-card,frame-master = <&cpudai>;
                simple-audio-card,bitclock-master = <&cpudai>;
                simple-audio-card,widgets =
                        "Line", "Left Line Out Jack",
                        "Line", "Right Line Out Jack";
                simple-audio-card,routing =
                        "Left Line Out Jack", "LLOUT",
                        "Right Line Out Jack", "RLOUT";

                cpudai: simple-audio-card,cpu {
                        sound-dai = <&sai3>;
                        dai-tdm-slot-num = <2>;
                        dai-tdm-slot-width = <32>;
                };

                simple-audio-card,codec {
                        sound-dai = <&tlv320aic3105>;
                        clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;
                };
        };
};

&i2c2 {
...
        tlv320aic3105: codec@18 {
                #sound-dai-cells = <0>;
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_tlv>;
                compatible = "ti,tlv320aic3x";
                reg = <0x18>;
                reset-gpios = <&gpio4 4 GPIO_ACTIVE_LOW>;
                ai3x-micbias-vg = <2>; /* MICBIAS_2_5V */
                /* Regulators */
                DRVDD-supply = <&reg_3p3v>;
                AVDD-supply = <&reg_3p3v>;
                IOVDD-supply = <&reg_3p3v>;
                DVDD-supply = <&reg_1p8v>;
        };
}

&sai3 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_sai3>;
        assigned-clocks = <&clk IMX8MM_CLK_SAI3>;
        assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
        assigned-clock-rates = <24576000>;
        status = "okay";
};

and /sys/kernel/debug/clk/clk_summary from my board:
 osc_24m                              7       10        0    24000000
        0     0  50000
...
    audio_pll1_ref_sel                0        0        0    24000000
        0     0  50000
       audio_pll1                     0        0        0   650000000
        0     0  50000
          audio_pll1_bypass           0        0        0   650000000
        0     0  50000
             audio_pll1_out           0        0        0   650000000
        0     0  50000
                sai3                  0        0        0    25000000
        0     0  50000
                   sai3_root_clk       0        0        0    25000000
         0     0  50000
^^^^ note 25000000 instead of requested 24576000

And Here is the imx8mm-evk dts:
/ {
...
        wm8524: audio-codec {
                #sound-dai-cells = <0>;
                compatible = "wlf,wm8524";
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_gpio_wlf>;
                wlf,mute-gpios = <&gpio5 21 GPIO_ACTIVE_LOW>;
        };

        sound-wm8524 {
                compatible = "simple-audio-card";
                simple-audio-card,name = "wm8524-audio";
                simple-audio-card,format = "i2s";
                simple-audio-card,frame-master = <&cpudai>;
                simple-audio-card,bitclock-master = <&cpudai>;
                simple-audio-card,widgets =
                        "Line", "Left Line Out Jack",
                        "Line", "Right Line Out Jack";
                simple-audio-card,routing =
                        "Left Line Out Jack", "LINEVOUTL",
                        "Right Line Out Jack", "LINEVOUTR";

                cpudai: simple-audio-card,cpu {
                        sound-dai = <&sai3>;
                        dai-tdm-slot-num = <2>;
                        dai-tdm-slot-width = <32>;
                };

                simple-audio-card,codec {
                        sound-dai = <&wm8524>;
                        clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;
                };
        };
};

&sai3 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_sai3>;
        assigned-clocks = <&clk IMX8MM_CLK_SAI3>;
        assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
        assigned-clock-rates = <24576000>;
        status = "okay";
};

and /sys/kernel/debug/clk/clk_summary from imx8mm_evk:
 osc_24m                              7       10        0    24000000
        0     0  50000
...
    audio_pll1_ref_sel                0        0        0    24000000
        0     0  50000
       audio_pll1                     0        0        0   393215995
        0     0  50000
          audio_pll1_bypass           0        0        0   393215995
        0     0  50000
             audio_pll1_out           0        0        0   393215995
        0     0  50000
                sai3                  0        0        0    24576000
        0     0  50000
                   sai3_root_clk       0        0        0    24576000
         0     0  50000
^^^^ note 24576000 as requested

Any ideas what I'm doing wrong here?

Note that even though the imx8mm-evk appears to configure its clock
correctly I still have not been able to play audio out the wm8524 and
the system appears to hang during playback as if BCLK/MCLK were not
clocking.

Perhaps there is something not supported yet upstream with regards to
IMX8MM SAI?

Best Regards,

Tim

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: imx8mm fsl_sai clock config failing
  2020-05-11 21:58 imx8mm fsl_sai clock config failing Tim Harvey
@ 2020-05-18  9:11 ` Aisheng Dong
  2020-05-18 14:48   ` Daniel Baluta
  0 siblings, 1 reply; 4+ messages in thread
From: Aisheng Dong @ 2020-05-18  9:11 UTC (permalink / raw)
  To: tharvey, Timur Tabi, Nicolin Chen, Xiubo Li, Fabio Estevam,
	Stephen Boyd, Michael Turquette, Shawn Guo, Sascha Hauer,
	dl-linux-imx, Peng Fan, Anson Huang, Abel Vesa, Daniel Baluta
  Cc: Linux-ALSA

> From: Tim Harvey <tharvey@gateworks.com>
> Sent: Tuesday, May 12, 2020 5:58 AM
> 
> Greetings,
> 
> I'm trying to get imx8mm sai working with a tlv320aic3x codec on a new board
> and am finding that the sai3 bus clock is getting derived from the wrong source
> leading hw_params() to fail with 'fsl-sai
> 30030000.sai: failed to derive required Tx rate: 3072000'
> 
> In comparison to the imx8mm-evk I find it's clock gets configured as desired yet
> I have the same device-tree configuration for sai3.
> 
> Here is my board's dts:
> / {
> ...
>         sound {
>                 compatible = "simple-audio-card";
>                 simple-audio-card,name = "tlv320-audio";
>                 simple-audio-card,format = "i2s";
>                 simple-audio-card,frame-master = <&cpudai>;
>                 simple-audio-card,bitclock-master = <&cpudai>;
>                 simple-audio-card,widgets =
>                         "Line", "Left Line Out Jack",
>                         "Line", "Right Line Out Jack";
>                 simple-audio-card,routing =
>                         "Left Line Out Jack", "LLOUT",
>                         "Right Line Out Jack", "RLOUT";
> 
>                 cpudai: simple-audio-card,cpu {
>                         sound-dai = <&sai3>;
>                         dai-tdm-slot-num = <2>;
>                         dai-tdm-slot-width = <32>;
>                 };
> 
>                 simple-audio-card,codec {
>                         sound-dai = <&tlv320aic3105>;
>                         clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;
>                 };
>         };
> };
> 
> &i2c2 {
> ...
>         tlv320aic3105: codec@18 {
>                 #sound-dai-cells = <0>;
>                 pinctrl-names = "default";
>                 pinctrl-0 = <&pinctrl_tlv>;
>                 compatible = "ti,tlv320aic3x";
>                 reg = <0x18>;
>                 reset-gpios = <&gpio4 4 GPIO_ACTIVE_LOW>;
>                 ai3x-micbias-vg = <2>; /* MICBIAS_2_5V */
>                 /* Regulators */
>                 DRVDD-supply = <&reg_3p3v>;
>                 AVDD-supply = <&reg_3p3v>;
>                 IOVDD-supply = <&reg_3p3v>;
>                 DVDD-supply = <&reg_1p8v>;
>         };
> }
> 
> &sai3 {
>         pinctrl-names = "default";
>         pinctrl-0 = <&pinctrl_sai3>;
>         assigned-clocks = <&clk IMX8MM_CLK_SAI3>;
>         assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
>         assigned-clock-rates = <24576000>;
>         status = "okay";
> };
> 
> and /sys/kernel/debug/clk/clk_summary from my board:
>  osc_24m                              7       10        0
> 24000000
>         0     0  50000
> ...
>     audio_pll1_ref_sel                0        0        0
> 24000000
>         0     0  50000
>        audio_pll1                     0        0        0
> 650000000
>         0     0  50000
>           audio_pll1_bypass           0        0        0
> 650000000
>         0     0  50000
>              audio_pll1_out           0        0        0
> 650000000
>         0     0  50000
>                 sai3                  0        0        0
> 25000000
>         0     0  50000
>                    sai3_root_clk       0        0        0
> 25000000
>          0     0  50000
> ^^^^ note 25000000 instead of requested 24576000
> 
> And Here is the imx8mm-evk dts:
> / {
> ...
>         wm8524: audio-codec {
>                 #sound-dai-cells = <0>;
>                 compatible = "wlf,wm8524";
>                 pinctrl-names = "default";
>                 pinctrl-0 = <&pinctrl_gpio_wlf>;
>                 wlf,mute-gpios = <&gpio5 21 GPIO_ACTIVE_LOW>;
>         };
> 
>         sound-wm8524 {
>                 compatible = "simple-audio-card";
>                 simple-audio-card,name = "wm8524-audio";
>                 simple-audio-card,format = "i2s";
>                 simple-audio-card,frame-master = <&cpudai>;
>                 simple-audio-card,bitclock-master = <&cpudai>;
>                 simple-audio-card,widgets =
>                         "Line", "Left Line Out Jack",
>                         "Line", "Right Line Out Jack";
>                 simple-audio-card,routing =
>                         "Left Line Out Jack", "LINEVOUTL",
>                         "Right Line Out Jack", "LINEVOUTR";
> 
>                 cpudai: simple-audio-card,cpu {
>                         sound-dai = <&sai3>;
>                         dai-tdm-slot-num = <2>;
>                         dai-tdm-slot-width = <32>;
>                 };
> 
>                 simple-audio-card,codec {
>                         sound-dai = <&wm8524>;
>                         clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;
>                 };
>         };
> };
> 
> &sai3 {
>         pinctrl-names = "default";
>         pinctrl-0 = <&pinctrl_sai3>;
>         assigned-clocks = <&clk IMX8MM_CLK_SAI3>;
>         assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
>         assigned-clock-rates = <24576000>;
>         status = "okay";
> };
> 
> and /sys/kernel/debug/clk/clk_summary from imx8mm_evk:
>  osc_24m                              7       10        0
> 24000000
>         0     0  50000
> ...
>     audio_pll1_ref_sel                0        0        0
> 24000000
>         0     0  50000
>        audio_pll1                     0        0        0
> 393215995
>         0     0  50000
>           audio_pll1_bypass           0        0        0
> 393215995
>         0     0  50000
>              audio_pll1_out           0        0        0
> 393215995
>         0     0  50000
>                 sai3                  0        0        0
> 24576000
>         0     0  50000
>                    sai3_root_clk       0        0        0
> 24576000
>          0     0  50000
> ^^^^ note 24576000 as requested
> 
> Any ideas what I'm doing wrong here?
> 
> Note that even though the imx8mm-evk appears to configure its clock correctly I
> still have not been able to play audio out the wm8524 and the system appears
> to hang during playback as if BCLK/MCLK were not clocking.
> 
> Perhaps there is something not supported yet upstream with regards to
> IMX8MM SAI?
> 

Copy Daniel in case he has some comments.

Regards
Aisheng

> Best Regards,
> 
> Tim

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: imx8mm fsl_sai clock config failing
  2020-05-18  9:11 ` Aisheng Dong
@ 2020-05-18 14:48   ` Daniel Baluta
  2020-05-19 20:24     ` Tim Harvey
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Baluta @ 2020-05-18 14:48 UTC (permalink / raw)
  To: Aisheng Dong, tharvey, Timur Tabi, Nicolin Chen, Xiubo Li,
	Fabio Estevam, Stephen Boyd, Michael Turquette, Shawn Guo,
	Sascha Hauer, dl-linux-imx, Peng Fan, Anson Huang, Abel Vesa
  Cc: Linux-ALSA

Hi Tim,

<snip>


>> I'm trying to get imx8mm sai working with a tlv320aic3x codec on a new board
>> and am finding that the sai3 bus clock is getting derived from the wrong source
>> leading hw_params() to fail with 'fsl-sai
>> 30030000.sai: failed to derive required Tx rate: 3072000'
>>
>> In comparison to the imx8mm-evk I find it's clock gets configured as desired yet
>> I have the same device-tree configuration for sai3.

It is strange that setting sai3 works with wolfson codec but not yours.

It should either work for both or for none.

Anyhow, can you please try to create a more specific clock hierarchy

similar with the on for 8mq (see imx8mq-evk.dts).


&sai2 {
»       pinctrl-names = "default";
»       pinctrl-0 = <&pinctrl_sai2>;
»       assigned-clocks = <&clk IMX8MQ_AUDIO_PLL1_BYPASS>, <&clk 
IMX8MQ_CLK_SAI2>;
»       assigned-clock-parents = <&clk IMX8MQ_AUDIO_PLL1>, <&clk 
IMX8MQ_AUDIO_PLL1_OUT>;
»       assigned-clock-rates = <0>, <24576000>;
»       status = "okay";
};
Note that even though the imx8mm-evk appears to configure its clock 
correctly I

>> still have not been able to play audio out the wm8524 and the system appears
>> to hang during playback as if BCLK/MCLK were not clocking.
>>
>> Perhaps there is something not supported yet upstream with regards to
>> IMX8MM SAI?
>>
>

I remember that wm8524 worked for me both with imx8mm/imx8mq. Can you sync

at commit


commit 13f3b9fdef6c7d9ad069ae617707e5a10a685074
Author: Daniel Baluta <daniel.baluta@nxp.com>
Date:   Tue Jun 4 20:32:57 2019 +0800

and give it a try.


Also, what SDMA firmware are you using? That might be a problem. I don't 
remember

if the default ROM firmware worked.


Sorry for the late reply. Somehow I missed your email. You can always 
find some of us

from NXP on linux-imx IRC channel on irc.freenode.net


thanks,

Daniel.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: imx8mm fsl_sai clock config failing
  2020-05-18 14:48   ` Daniel Baluta
@ 2020-05-19 20:24     ` Tim Harvey
  0 siblings, 0 replies; 4+ messages in thread
From: Tim Harvey @ 2020-05-19 20:24 UTC (permalink / raw)
  To: Daniel Baluta
  Cc: Aisheng Dong, Peng Fan, Anson Huang, Timur Tabi, Xiubo Li,
	Stephen Boyd, Shawn Guo, Michael Turquette, Linux-ALSA,
	Nicolin Chen, dl-linux-imx, Fabio Estevam, Sascha Hauer,
	Abel Vesa

On Mon, May 18, 2020 at 7:48 AM Daniel Baluta <daniel.baluta@nxp.com> wrote:
>
> Hi Tim,
>
> <snip>
>

Daniel,

Thanks for the reply!

>
> >> I'm trying to get imx8mm sai working with a tlv320aic3x codec on a new board
> >> and am finding that the sai3 bus clock is getting derived from the wrong source
> >> leading hw_params() to fail with 'fsl-sai
> >> 30030000.sai: failed to derive required Tx rate: 3072000'
> >>
> >> In comparison to the imx8mm-evk I find it's clock gets configured as desired yet
> >> I have the same device-tree configuration for sai3.
>
> It is strange that setting sai3 works with wolfson codec but not yours.
>
> It should either work for both or for none.

Well... it doesn't 'work' for the imx8mm-evk wm8524-audio as it hangs
during playback (see below) yet it does get past negotiating the sai
master clock.

>
> Anyhow, can you please try to create a more specific clock hierarchy
>
> similar with the on for 8mq (see imx8mq-evk.dts).
>
>
> &sai2 {
> »       pinctrl-names = "default";
> »       pinctrl-0 = <&pinctrl_sai2>;
> »       assigned-clocks = <&clk IMX8MQ_AUDIO_PLL1_BYPASS>, <&clk
> IMX8MQ_CLK_SAI2>;
> »       assigned-clock-parents = <&clk IMX8MQ_AUDIO_PLL1>, <&clk
> IMX8MQ_AUDIO_PLL1_OUT>;
> »       assigned-clock-rates = <0>, <24576000>;
> »       status = "okay";
> };
> Note that even though the imx8mm-evk appears to configure its clock
> correctly I
>
> >> still have not been able to play audio out the wm8524 and the system appears
> >> to hang during playback as if BCLK/MCLK were not clocking.
> >>
> >> Perhaps there is something not supported yet upstream with regards to
> >> IMX8MM SAI?
> >>
> >
>
> I remember that wm8524 worked for me both with imx8mm/imx8mq. Can you sync
>
> at commit
>
>
> commit 13f3b9fdef6c7d9ad069ae617707e5a10a685074
> Author: Daniel Baluta <daniel.baluta@nxp.com>
> Date:   Tue Jun 4 20:32:57 2019 +0800
>
> and give it a try.

looks like fsl-sai isn't supported yet in
13f3b9fdef6c7d9ad069ae617707e5a10a685074... used
a860fac420971c5a90d4f78959b44ead793aee4f instead which has the sai
driver but fails with:

[    2.579234] wm8524-codec audio-codec: simple-card: set_sysclk error
[    2.585512] asoc-simple-card sound-wm8524: ASoC: failed to init
30030000.sai-wm8524-hifi: -22
[    2.594050] asoc-simple-card sound-wm8524: ASoC: failed to
instantiate card -22
[    2.601467] asoc_simple_probe err:-22
[    2.605161] asoc-simple-card: probe of sound-wm8524 failed with error -22

Can you please sync up with mainline and take a look?

>
>
> Also, what SDMA firmware are you using? That might be a problem. I don't
> remember
>
> if the default ROM firmware worked.
>

I've tried the default as well as that from
https://www.nxp.com/lgfiles/NMG/MAD/YOCTO/firmware-imx-8.0.bin which
shows as firmware 4.4:

# dmesg | grep imx-sdma
[    2.037854] imx-sdma 302c0000.dma-controller: loaded firmware 4.4
[    2.042705] imx-sdma 302b0000.dma-controller: loaded firmware 4.4
[    2.049132] imx-sdma 30bd0000.dma-controller: loaded firmware 4.4

I ended up working around this on my board by making the tlv320aic3x
the master. I do recall reading someplace that using the codec as the
master is a better choice anyway as it provides better clk per
sample-rate matching... is this true? I'm not clear which option to
pick in general.

So in summary I have my imx8mm board working using codec as master but
imx8mm-evk in mainline does not work currently, at least 5.7-rc4 which
is what I tested.

Thanks,

Tim

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-19 20:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-11 21:58 imx8mm fsl_sai clock config failing Tim Harvey
2020-05-18  9:11 ` Aisheng Dong
2020-05-18 14:48   ` Daniel Baluta
2020-05-19 20:24     ` Tim Harvey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).