Hi Igor,
Thank you for pointing me to this problem which is a bit different, the M4 hang when the linux boot because the linux is touching some registers used by the M4
In my case it is a lot more simpler, what I want to do is just use EXT_CLK3 as MCLK for SAI3 & SPDIF1 modules
I have try several things :
1. I have tested to modify the code into drivers/clk/imx/clk-imx8mm.c, adding thoses lines :
pr_info("i.MX8MM clock driver before setting CLK_EXT3");
clk_set_parent(clks[IMX8MM_CLK_SAI3], clks[IMX8MM_CLK_EXT3]);
clk_set_parent(clks[IMX8MM_CLK_SPDIF1], clks[IMX8MM_CLK_EXT3]);
pr_info("i.MX8MM clock driver after setting CLK_EXT3");
#just before :
imx_register_uart_clocks(uart_clks);
pr_info("i.MX8MM clock driver init done\n");
Unfortunately the iMX is hanging directly ... :
Starting kernel ...
[ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[ 0.000000] Linux version 4.19.35-rt20-rc1 (oe-user@oe-host) (gcc version 8.2.0 (GCC)) #1 SMP PREEMPT RT Wed Jan 29 15:01:49 UTC 2020
[ 0.000000] Machine model: FSL i.MX8MM Emperor board id 1
[ 0.000000] earlycon: ec_imx6q0 at MMIO 0x0000000030890000 (options '115200')
2. I have change dts SAI3 and SPDIF1 part to use
captina: captina {
compatible = "cp,captina";
#sound-dai-cells = <0>;/* simple-card needs */
clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;
clock-names = "mclk";
};
sound-captina {
compatible = "simple-audio-card";
simple-audio-card,name = "captina Card";
simple-audio-card,format = "i2s";
simple-audio-card,bitclock-master = <&dailink0_master>;
simple-audio-card,frame-master = <&dailink0_master>;
/* Switch between Right and Left channels */
simple-audio-card,frame-inversion;
simple-audio-card,widgets =
"Line", "Line Out Jack",
"Line", "Line In Jack";
simple-audio-card,routing =
"Line Out Jack", "LOUT",
"Line Out Jack", "ROUT",
"LIN", "Line In Jack",
"RIN", "Line In Jack";
dailink0_master: simple-audio-card,cpu {
sound-dai = <&sai3>;
dai-tdm-slot-num = <2>;
dai-tdm-slot-width = <32>;
};
simple-audio-card,codec {
sound-dai = <&captina>;
clocks = <&clk IMX8MM_CLK_SAI3_ROOT>;
clock-names = "mclk";
};
};
sound-spdif {
compatible = "fsl,imx-audio-spdif";
model = "imx-spdif";
spdif-controller = <&spdif1>;
spdif-out;
spdif-in;
};
pinctrl_sai3: sai3grp {
fsl,pins = <
MX8MM_IOMUXC_SAI3_TXFS_SAI3_TX_SYNC 0xd6
MX8MM_IOMUXC_SAI3_TXD_SAI3_TX_DATA0 0xd6
MX8MM_IOMUXC_SAI3_TXC_SAI3_TX_BCLK 0xd6
/* RXFS have to be tri state since TXFS also play on the same wire */
MX8MM_IOMUXC_SAI3_RXFS_GPIO4_IO28 0x19
MX8MM_IOMUXC_SAI3_RXD_SAI3_RX_DATA0 0xd6
MX8MM_IOMUXC_SAI3_RXC_SAI3_RX_BCLK 0xd6
/* MCLK input from oscillator */
MX8MM_IOMUXC_GPIO1_IO06_CCMSRCGPCMIX_EXT_CLK3 0x00000011
>;
};
&sai3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sai3>;
#sound-dai-cells = <0>;/* simple-card needs */
assigned-clocks = <&clk IMX8MM_CLK_SAI3>;
assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL2_OUT>;
assigned-clock-rates = <22579200>;
status = "okay";
};
&spdif1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_spdif1>;
assigned-clocks = <&clk IMX8MM_CLK_SPDIF1>;
assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL2_OUT>;
assigned-clock-rates = <22579200>;
clocks = <&clk IMX8MM_CLK_AUDIO_AHB>, <&clk IMX8MM_CLK_24M>,
<&clk IMX8MM_CLK_SPDIF1>, <&clk IMX8MM_CLK_DUMMY>,
<&clk IMX8MM_CLK_DUMMY>, <&clk IMX8MM_CLK_DUMMY>,
<&clk IMX8MM_CLK_AUDIO_AHB>, <&clk IMX8MM_CLK_DUMMY>,
<&clk IMX8MM_CLK_DUMMY>, <&clk IMX8MM_CLK_DUMMY>,
<&clk IMX8MM_AUDIO_PLL1_OUT>, <&clk IMX8MM_AUDIO_PLL2_OUT>;
clock-names = "core", "rxtx0", "rxtx1", "rxtx2", "rxtx3",
"rxtx4", "rxtx5", "rxtx6", "rxtx7", "spba", "pll8k", "pll11k";
status = "okay";
};
The iMX8 boot without any problem, and I can play sound without troubles
I then check the pin muxing which actually was correct
Pages RM 1330 : IOMUXC_SW_MUX_CTL_PAD_GPIO1_IO06
sudo memtool -32 0x30330040 1
return : 00000006
=>ALT6 => CCM_EXT_CLK3
Pages RM 1492 : IOMUXC_SW_PAD_CTL_PAD_GPIO1_IO06
sudo memtool -32 0x303302A8 1
return : 00000011
Then I check
CCM_TARGET_ROOTn : page RM 487
CCM_TARGET_ROOT_SAI3 : page RM 411
Trying to set-up dynamically the source from audio_pll2 into ext_mlck does the same and freeze the linux :
When first read : when audio is in idle mode :
sudo memtool -32 0x3038a680 1
return : 0200001F
When first read : when audio is in playing mode :
sudo memtool -32 0x3038a680 1
return : 1200001F
When I force to use ext_clk3 :
sudo memtool -32 0x3038a680=0x0600001F
linux freeze ...
So I wonder if you have already get any work done with ext_clkX pins ?
Thank you by advance if you have any other reference, any hints, any help
Regards
Aurelien BOUIN