[alsa-devel] iMX6UL EVK with kernel 4.6
Hi,
I'm trying to run the latest mainline kernel 4.6 on the iMX6UL EVK. The board mostly works and the only problem is audio. Even though the sound card is detected and the ALSA mixer can be controlled there is no MCLK coming out of the SAI2 interface. All the related peripherals in the DTS (pinmux, SAI2, sound card, codec) seem to be set-up correctly, I also tried out various things like disabling the ASRC, but without success and I'm slowly running out of ideas.
Could somebody give me a hint please, what is different to the Freescale kernel branch where the MCLK works? By the way, why aren't the Freescale patches merged to the mainline kernel?
Thanks Petr
Hi Petr,
On Sat, Apr 30, 2016 at 8:18 AM, Petr Kulhavy brain@jikos.cz wrote:
Hi,
I'm trying to run the latest mainline kernel 4.6 on the iMX6UL EVK. The board mostly works and the only problem is audio. Even though the sound card is detected and the ALSA mixer can be controlled there is no MCLK coming out of the SAI2 interface. All the related peripherals in the DTS (pinmux, SAI2, sound card, codec) seem to be set-up correctly, I also tried out various things like disabling the ASRC, but without success and I'm slowly running out of ideas.
Is the MCLK IOMUX setup correctly?
Can you share all your changes to get audio working with 4.6-rc on imx6ul-evk?
I am also interested in getting this functional.
On Sat, Apr 30, 2016 at 8:18 AM, Petr Kulhavy brain@jikos.cz wrote:
Hi,
I'm trying to run the latest mainline kernel 4.6 on the iMX6UL EVK. The board mostly works and the only problem is audio. Even though the sound card is detected and the ALSA mixer can be controlled there is no MCLK coming out of the SAI2 interface.
Also, have you tried setting bit 20 (SAI2_MCLK_DIR) of register IOMUXC_GPR_GPR1?
You can set this bit in the bootloader for a quick test.
On Sun, May 1, 2016 at 11:49 AM, Fabio Estevam festevam@gmail.com wrote:
On Sat, Apr 30, 2016 at 8:18 AM, Petr Kulhavy brain@jikos.cz wrote:
Hi,
I'm trying to run the latest mainline kernel 4.6 on the iMX6UL EVK. The board mostly works and the only problem is audio. Even though the sound card is detected and the ALSA mixer can be controlled there is no MCLK coming out of the SAI2 interface.
Also, have you tried setting bit 20 (SAI2_MCLK_DIR) of register IOMUXC_GPR_GPR1?
You can set this bit in the bootloader for a quick test.
So I tried it myself and here are the changes I did:
diff --git a/arch/arm/boot/dts/imx6ul-14x14-evk.dts b/arch/arm/boot/dts/imx6ul-14x14-evk.dts index 7207280..8c20783 100644 --- a/arch/arm/boot/dts/imx6ul-14x14-evk.dts +++ b/arch/arm/boot/dts/imx6ul-14x14-evk.dts @@ -36,6 +36,23 @@ enable-active-high; }; }; + + sound { + compatible = "simple-audio-card"; + simple-audio-card,name = "mx6ul-evk-sound-card"; + simple-audio-card,format = "i2s"; + simple-audio-card,bitclock-master = <&dailink_master>; + simple-audio-card,frame-master = <&dailink_master>; + + simple-audio-card,cpu { + sound-dai = <&sai2>; + }; + + dailink_master: simple-audio-card,codec { + sound-dai = <&codec>; + clocks = <&clks IMX6UL_CLK_SAI2>; + }; + }; };
&cpu0 { @@ -43,6 +60,20 @@ soc-supply = <®_soc>; };
+&i2c2 { + clock_frequency = <100000>; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_i2c2>; + status = "okay"; + + codec: wm8960@1a { + #sound-dai-cells = <0>; + compatible = "wlf,wm8960"; + reg = <0x1a>; + wlf,shared-lrclk; + }; +}; + &fec1 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_enet1>; @@ -86,6 +117,18 @@ }; };
+&sai2 { + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_sai2>; + + assigned-clocks = <&clks IMX6UL_CLK_SAI2_SEL>, + <&clks IMX6UL_CLK_SAI2>; + assigned-clock-parents = <&clks IMX6UL_CLK_PLL4_AUDIO_DIV>; + assigned-clock-rates = <0>, <12288000>; + + status = "okay"; +}; + &snvs_poweroff { status = "okay"; }; @@ -272,6 +315,17 @@ >; };
+ pinctrl_sai2: sai2grp { + fsl,pins = < + MX6UL_PAD_JTAG_TDI__SAI2_TX_BCLK 0x17088 + MX6UL_PAD_JTAG_TDO__SAI2_TX_SYNC 0x17088 + MX6UL_PAD_JTAG_TRST_B__SAI2_TX_DATA 0x11088 + MX6UL_PAD_JTAG_TCK__SAI2_RX_DATA 0x11088 + MX6UL_PAD_JTAG_TMS__SAI2_MCLK 0x17088 + MX6UL_PAD_SNVS_TAMPER4__GPIO5_IO04 0x17059 + >; + }; + pinctrl_pwm1: pwm1grp { fsl,pins = < MX6UL_PAD_GPIO1_IO08__PWM1_OUT 0x110b0
On 01/05/16 20:27, Fabio Estevam wrote:
On Sun, May 1, 2016 at 11:49 AM, Fabio Estevam festevam@gmail.com wrote:
On Sat, Apr 30, 2016 at 8:18 AM, Petr Kulhavy brain@jikos.cz wrote:
Hi,
I'm trying to run the latest mainline kernel 4.6 on the iMX6UL EVK. The board mostly works and the only problem is audio. Even though the sound card is detected and the ALSA mixer can be controlled there is no MCLK coming out of the SAI2 interface.
Also, have you tried setting bit 20 (SAI2_MCLK_DIR) of register IOMUXC_GPR_GPR1?
You can set this bit in the bootloader for a quick test.
So I tried it myself and here are the changes I did:
Hi Fabio,
and did that work for you? In my DTS file I made a few more changes, see below.
Petr
diff --git a/arch/arm/boot/dts/imx6ul-14x14-evk.dts b/arch/arm/boot/dts/imx6ul-14x14-evk.dts index 7207280..8c20783 100644 --- a/arch/arm/boot/dts/imx6ul-14x14-evk.dts +++ b/arch/arm/boot/dts/imx6ul-14x14-evk.dts @@ -36,6 +36,23 @@ enable-active-high; }; };
- sound {
compatible = "simple-audio-card";
simple-audio-card,name = "mx6ul-evk-sound-card";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&dailink_master>;
simple-audio-card,frame-master = <&dailink_master>;
simple-audio-card,widgets = "Microphone", "Mic Jack", "Line", "Line In", "Line", "Line Out", "Speaker", "Speaker", "Headphone", "Headphone Jack"; simple-audio-card,routing = "Headphone Jack", "HP_L", "Headphone Jack", "HP_R", "Speaker", "SPK_LP", "Speaker", "SPK_LN", "Speaker", "SPK_RP", "Speaker", "SPK_RN",
"LINPUT1", "Mic Jack", "LINPUT3", "Mic Jack", "RINPUT1", "Mic Jack", "RINPUT2", "Mic Jack";
simple-audio-card,cpu {
sound-dai = <&sai2>;
};
dailink_master: simple-audio-card,codec {
sound-dai = <&codec>;
clocks = <&clks IMX6UL_CLK_SAI2>;
};
}; };
&cpu0 {
@@ -43,6 +60,20 @@ soc-supply = <®_soc>; };
+&i2c2 {
- clock_frequency = <100000>;
- pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_i2c2>;
- status = "okay";
- codec: wm8960@1a {
#sound-dai-cells = <0>;
compatible = "wlf,wm8960";
reg = <0x1a>;
clocks = <&clks IMX6UL_CLK_SAI2>; clock-names = "mclk";
wlf,shared-lrclk;
- };
+};
- &fec1 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_enet1>;
@@ -86,6 +117,18 @@ }; };
+&sai2 {
- pinctrl-names = "default";
- pinctrl-0 = <&pinctrl_sai2>;
- assigned-clocks = <&clks IMX6UL_CLK_SAI2_SEL>,
<&clks IMX6UL_CLK_SAI2>;
- assigned-clock-parents = <&clks IMX6UL_CLK_PLL4_AUDIO_DIV>;
- assigned-clock-rates = <0>, <12288000>;
- status = "okay";
+};
- &snvs_poweroff { status = "okay"; };
@@ -272,6 +315,17 @@ >; };
- pinctrl_sai2: sai2grp {
fsl,pins = <
MX6UL_PAD_JTAG_TDI__SAI2_TX_BCLK 0x17088
MX6UL_PAD_JTAG_TDO__SAI2_TX_SYNC 0x17088
MX6UL_PAD_JTAG_TRST_B__SAI2_TX_DATA 0x11088
MX6UL_PAD_JTAG_TCK__SAI2_RX_DATA 0x11088
MX6UL_PAD_JTAG_TMS__SAI2_MCLK 0x17088
MX6UL_PAD_SNVS_TAMPER4__GPIO5_IO04 0x17059
>;
- };
pinctrl_pwm1: pwm1grp { fsl,pins = < MX6UL_PAD_GPIO1_IO08__PWM1_OUT 0x110b0
On Sun, May 1, 2016 at 3:43 PM, Petr Kulhavy brain@jikos.cz wrote:
Hi Fabio,
and did that work for you? In my DTS file I made a few more changes, see below.
No, as explained in my earlier e-mail the system hangs after running aplay.
However, the same hang happens with NXP kernel.
Have you tried setting bit20 of GPR1 register?
Which NXP kernel did you use that provides audio functionality on mx6ul-evk?
On 01/05/16 20:47, Fabio Estevam wrote:
On Sun, May 1, 2016 at 3:43 PM, Petr Kulhavy brain@jikos.cz wrote:
Hi Fabio,
and did that work for you? In my DTS file I made a few more changes, see below.
No, as explained in my earlier e-mail the system hangs after running aplay.
However, the same hang happens with NXP kernel.
Have you tried setting bit20 of GPR1 register?
Which NXP kernel did you use that provides audio functionality on mx6ul-evk?
I have not tried setting the bit 20 of the GPR1 register. How would that be set?
Both the 3.x and 4.1 work for me. However you need to set the headphone volume to non-zero and especially the pcm output mixer (unmute), otherwise the audio path is not routed through and the codec is switched off due to power saving (and generates no bclk and lrclk). This confused me as well, but after setting the mixer playback stasrts working with the Freescale kernel.
Petr
On Sun, May 1, 2016 at 3:59 PM, Petr Kulhavy brain@jikos.cz wrote:
I have not tried setting the bit 20 of the GPR1 register. How would that be set?
If you have memtool installed in your rootfs:
./memtool -32 20E4004=0F560005
You can do this via bootloader prompt or via devmem2 in the Linux prompt.
Without this MCLK will not be out.
Both the 3.x and 4.1 work for me. However you need to set the headphone volume to non-zero and especially the pcm output mixer (unmute), otherwise the audio path is not routed through and the codec is switched off due to power saving (and generates no bclk and lrclk). This confused me as well, but after setting the mixer playback stasrts working with the Freescale kernel.
I was putting the volume to a suitable value, but didn't touch PCM output mixer.
I see in alsamixer: "PCM Playback -6dB [Off]", but it does not allow me to change this setting though.
On 01/05/16 21:22, Fabio Estevam wrote:
On Sun, May 1, 2016 at 3:59 PM, Petr Kulhavy brain@jikos.cz wrote:
I have not tried setting the bit 20 of the GPR1 register. How would that be set?
If you have memtool installed in your rootfs:
./memtool -32 20E4004=0F560005
You can do this via bootloader prompt or via devmem2 in the Linux prompt.
Without this MCLK will not be out.
Thanks, I'll check that out.
Both the 3.x and 4.1 work for me. However you need to set the headphone volume to non-zero and especially the pcm output mixer (unmute), otherwise the audio path is not routed through and the codec is switched off due to power saving (and generates no bclk and lrclk). This confused me as well, but after setting the mixer playback stasrts working with the Freescale kernel.
I was putting the volume to a suitable value, but didn't touch PCM output mixer.
I see in alsamixer: "PCM Playback -6dB [Off]", but it does not allow me to change this setting though.
The controls to unmute are:
Left Output Mixer PCM [Off] Right Output Mixer PCM [Off]
Petr
On Sun, May 1, 2016 at 4:24 PM, Petr Kulhavy brain@jikos.cz wrote:
The controls to unmute are:
Left Output Mixer PCM [Off] Right Output Mixer PCM [Off]
I don't know why, but alsamixer does not allow me to unmute thes options.
Hi Petr,
On Sun, May 1, 2016 at 5:19 PM, Fabio Estevam festevam@gmail.com wrote:
On Sun, May 1, 2016 at 4:24 PM, Petr Kulhavy brain@jikos.cz wrote:
The controls to unmute are:
Left Output Mixer PCM [Off] Right Output Mixer PCM [Off]
I don't know why, but alsamixer does not allow me to unmute thes options.
Should sound/soc/codecs/wm8960.c be changed so that thes options are turned on by default?
On Sun, May 1, 2016 at 5:19 PM, Fabio Estevam festevam@gmail.com wrote:
On Sun, May 1, 2016 at 4:24 PM, Petr Kulhavy brain@jikos.cz wrote:
The controls to unmute are:
Left Output Mixer PCM [Off] Right Output Mixer PCM [Off]
I don't know why, but alsamixer does not allow me to unmute thes options.
Ok, managed to unmute these options in alsamixer and now I get audio with NXP 3.14 kernel.
Will try with mainline now.
Thanks for your hint!
Hi Petr,
On Mon, May 2, 2016 at 9:43 AM, Fabio Estevam festevam@gmail.com wrote:
Ok, managed to unmute these options in alsamixer and now I get audio with NXP 3.14 kernel.
Will try with mainline now.
I can get audio with mainline now, but it plays with an incorrect pitch.
Here is a quick hack to allow MCLK to be driven:
--- a/arch/arm/mach-imx/mach-imx6ul.c +++ b/arch/arm/mach-imx/mach-imx6ul.c @@ -22,9 +22,12 @@ static void __init imx6ul_enet_clk_init(void) struct regmap *gpr;
gpr = syscon_regmap_lookup_by_compatible("fsl,imx6ul-iomuxc-gpr"); - if (!IS_ERR(gpr)) + if (!IS_ERR(gpr)) { regmap_update_bits(gpr, IOMUXC_GPR1, IMX6UL_GPR1_ENET_CLK_DIR, IMX6UL_GPR1_ENET_CLK_OUTPUT); + regmap_update_bits(gpr, IOMUXC_GPR1, (1 << 20), (1 << 20)); + + } else pr_err("failed to find fsl,imx6ul-iomux-gpr regmap\n");
As next steps we need:
1. Fix the sound pitch
2. Find a proper way to enable MCLK.
Let me know if you get any progress so that we can upstream audio on this board.
Hi Fabio,
On 02/05/16 15:17, Fabio Estevam wrote:
Hi Petr,
I can get audio with mainline now, but it plays with an incorrect pitch.
Here is a quick hack to allow MCLK to be driven:
--- a/arch/arm/mach-imx/mach-imx6ul.c +++ b/arch/arm/mach-imx/mach-imx6ul.c @@ -22,9 +22,12 @@ static void __init imx6ul_enet_clk_init(void) struct regmap *gpr;
gpr = syscon_regmap_lookup_by_compatible("fsl,imx6ul-iomuxc-gpr");
if (!IS_ERR(gpr))
if (!IS_ERR(gpr)) { regmap_update_bits(gpr, IOMUXC_GPR1, IMX6UL_GPR1_ENET_CLK_DIR, IMX6UL_GPR1_ENET_CLK_OUTPUT);
regmap_update_bits(gpr, IOMUXC_GPR1, (1 << 20), (1 << 20));
} else pr_err("failed to find fsl,imx6ul-iomux-gpr regmap\n");
Cool, now my board plays too! Thanks!
As next steps we need:
- Fix the sound pitch
Mine plays at the correct speed. For the correct speed the clock assignment from the Freescale DTS needs to be copied, so that the SAI2 clock generates 12.288MHz. Below are the relevant nodes from my DTS:
&clks { assigned-clocks = <&clks IMX6UL_CLK_PLL4_AUDIO_DIV>; assigned-clock-rates = <786432000>; };
&sai2 { pinctrl-names = "default"; pinctrl-0 = <&pinctrl_sai2>;
assigned-clocks = <&clks IMX6UL_CLK_SAI2_SEL>, <&clks IMX6UL_CLK_SAI2>; assigned-clock-parents = <&clks IMX6UL_CLK_PLL4_AUDIO_DIV>; assigned-clock-rates = <0>, <12288000>;
status = "okay"; };
- Find a proper way to enable MCLK.
I would tend to put the control of the SAIx_MCLK_DIR into the SAI driver and if needed add an extra boolean property like "enable-mclk-output". Leaving it independent makes not much sense, for binding to the clock/pinmux it's too generic and the Freescale solution with a gpr phandle isn't very lucky either as it forces the use of the fsl soundcard and doesn't allow e.g. the simple-audio-card.
But let's see what else the Freescale or ALSA developers suggest.
Cheers Petr
On Mon, May 2, 2016 at 4:30 PM, Petr Kulhavy brain@jikos.cz wrote:
Mine plays at the correct speed. For the correct speed the clock assignment from the Freescale DTS needs to be copied, so that the SAI2 clock generates 12.288MHz. Below are the relevant nodes from my DTS:
&clks { assigned-clocks = <&clks IMX6UL_CLK_PLL4_AUDIO_DIV>; assigned-clock-rates = <786432000>; };
That was the part I was missing, thanks!
It plays correctly now, but I get this error message from the wm8960 driver:
$ aplay /home/clarinet.wav [ 55.007221] wm8960 1-001a: failed to configure clock [ 55.012583] wm8960 1-001a: ASoC: Failed to prepare bias: -22
Do you see this too?
- Find a proper way to enable MCLK.
I would tend to put the control of the SAIx_MCLK_DIR into the SAI driver and if needed add an extra boolean property like "enable-mclk-output".
Yes, I think this makes sense.
I will propose some patches today or tomorrow and will keep you on Cc.
Thanks for the cooperation :-)
participants (2)
-
Fabio Estevam
-
Petr Kulhavy