Hello,
We are trying to get SAI working on the IMX7d under Linux 4.14.98. The SAI must be the master.
It will use an internal clock as mclk, and from that generate the frame sync and bclk.
I have been able to register the soundcard, but have not had any success transmitting audio data.
I've attached relevant DTB input pieces below, along with some kernel data and command line tests.
Any advice on what might be configured incorrectly OR any area to look at, is appreciated.
///////////////////////////////////////////////
// DTS nodes for sound card, dai and codec
///////////////////////////////////////////////
codec_dummy: codec_dummy {
compatible = "linux,snd-soc-dummy";
#sound-dai-cells = <0>;
clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>;
assigned-clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_SRC>,
<&clks IMX7D_AUDIO_MCLK_ROOT_CLK>;
assigned-clock-parents = <&clks IMX7D_PLL_AUDIO_POST_DIV>;
assigned-clock-rates = <0>, <24576000>;
status = "okay";
};
sound {
compatible = "simple-audio-card";
simple-audio-card,name = "test_dummy";
simple-audio-card,format="i2s";
simple-audio-card,bitclock-master = <&dailink_master>;
simple-audio-card,frame-master = <&dailink_master>;
//simple-audio-card,mclk-fs = <512>;
dailink_master: simple-audio-card,codec {
sound-dai = <&codec_dummy>;
clocks = <&clks IMX7D_AUDIO_MCLK_ROOT_CLK>;
};
simple-audio-card,cpu {
sound-dai = <&sai1>;
};
};
/////////////////////
// DTS notes for SAI
/////////////////////
&sai1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_sai1>;
assigned-clocks = <&clks IMX7D_SAI1_ROOT_SRC>,
<&clks IMX7D_SAI1_ROOT_CLK>;
assigned-clock-parents = <&clks IMX7D_PLL_AUDIO_POST_DIV>;
assigned-clock-rates = <0>, <24576000>;
fsl,sai-mclk-direction-output;
fsl,sai-synchronous-rx;
status = "okay";
};
sai1: sai@308a0000 {
#sound-dai-cells = <0>;
compatible = "fsl,imx7d-sai", "fsl,imx6sx-sai";
reg = <0x308a0000 0x10000>;
interrupts = <GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>;
clocks = <&clks IMX7D_SAI1_IPG_CLK>,
<&clks IMX7D_CLK_DUMMY>,
<&clks IMX7D_SAI1_ROOT_CLK>,
<&clks IMX7D_CLK_DUMMY>,
<&clks IMX7D_CLK_DUMMY>;
clock-names = "bus", "mclk0", "mclk1", "mclk2", "mclk3";
dma-names = "rx", "tx";
dmas = <&sdma 8 24 0>, <&sdma 9 24 0>;
status = "disabled";
};
pinctrl_sai1: sai1grp {
fsl,pins = <
MX7D_PAD_ENET1_RX_CLK__SAI1_TX_BCLK 0x1f
MX7D_PAD_ENET1_CRS__SAI1_TX_SYNC 0x1f
MX7D_PAD_ENET1_COL__SAI1_TX_DATA0 0x30
MX7D_PAD_ENET1_TX_CLK__SAI1_RX_DATA0 0x1f
>;
};
//////////////////////
// Kernel data
//////////////////////
root@pico-imx7:/# aplay -L
...
sysdefault:CARD=test_dummy
test_dummy,
Default Audio Device
root@pico-imx7:/# aplay -l
card0: test_dummy [test_dummy], device 0: 308a0000.sai-snd-soc-dummy-dai snd-soc-dummy-dai-0
root@pico-imx7:/# cat /proc/asound/cards
0 [test_dummy ]: test_dummy - test_dummy
test_dummy
root@pico-imx7:/# dmesg | grep dummy
asoc-simple-card sound: snd-soc-dummy-dai <-> 308a0000.sai mapping ok
root@pico-imx7:/# cat /sys/kernel/debug/asoc/dais
308b0000.sai
308a0000.sai
snd-soc-dummy-dai
snd-soc-dummy-dai
///////////////////////////////////////
// Test Results (cmdline)
//////////////////////////////////////
root@pico-imx7:/# aplay -D sysdefault:test_dummy -d 5 -r 44100 audiotest.wav
Playing WAVE 'audiotest.wav' ..
aplay: pcm_write:2051: write error: Input/output error
root@pico-imx7:/# speaker-test -Dsysdefault:test_dummy -c2 -twav
...
0 - Front Left
Write error: -5, Input/output error
Xrun_recovery failed: -5 Input/output error
Transfer failed: Input/Output error