diff mbox

Setting some clocks back to DUMMY fixes spdif output on imx6q wandboard rev B1

Message ID 20160830111414.GA1968@begut (mailing list archive)
State New, archived
Headers show

Commit Message

Xavier Drudis Ferran Aug. 30, 2016, 11:14 a.m. UTC
El Mon, Aug 29, 2016 at 09:54:28PM +0200, Xavi Drudis Ferran deia:
> El Mon, Aug 29, 2016 at 12:28:21PM -0700, Nicolin Chen deia:
> > Would you
> > please do a little debug using "#define DEBUG 1" and check printk
> > from fsl_spdif_probe_txclk() to see the difference between before
> > and after Shengjiu's commit?
> 
> Yes, but I'm compiling the kernel in the wandboard, so it'll take me some time. 
> 

Now. Sorry for the delay. 

I did a mistake and had to do it twice. I added a couple of sanity check messages:
"enter fsl_spdif_probe"
"enter fsl_spdif_probe_txclk"


linux-libre-4.7 without my patch, i.e. clocks defined like this :
arch/arm/boot/dts/imx6qdl.dtsi:
aips-bus@02000000 { /* AIPS1 */
[...]
   spba-bus@02000000 {
[...]
       spdif: spdif@02004000 {
          clocks = <&clks IMX6QDL_CLK_SPDIF_GCLK>, <&clks IMX6QDL_CLK_OSC>,
                   <&clks IMX6QDL_CLK_SPDIF>, <&clks IMX6QDL_CLK_ASRC>,
                   <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_ESAI_EXTAL>,
                   <&clks IMX6QDL_CLK_IPG>, <&clks IMX6QDL_CLK_MLB>,
                   <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_SPBA>;
          clock-names = "core",  "rxtx0",
                        "rxtx1", "rxtx2",
                        "rxtx3", "rxtx4",
                        "rxtx5", "rxtx6",
                        "rxtx7", "spba";
[...]

The messages at boot: 

[    8.803603] 20ec000.sdma: Missing Free firmware (non-Free firmware loading is disabled)
[    8.813737] imx-sdma 20ec000.sdma: failed to get firmware from device tree
[    8.870764] imx-sdma 20ec000.sdma: Direct firmware load for /*(DEBLOBBED)*/ failed with error -2
[...]
[    9.083301] fsl-asrc 2034000.asrc: driver registered
[    9.087050] sgtl5000 1-000a: sgtl5000 revision 0x11
[    9.107141] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe
[    9.144839] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    9.225228] fsl-spdif-dai 2004000.spdif: use rxtx5 as tx clock source for 32000Hz sample rate
[    9.234058] fsl-spdif-dai 2004000.spdif: use txclk df 16 for 32000Hz sample rate
[    9.235565] imx-spdif sound-spdif: ASoC: CPU DAI (null) not registered
[    9.236007] imx-spdif sound-spdif: snd_soc_register_card failed: -517
[...]
[    9.262713] fsl-spdif-dai 2004000.spdif: use sysclk df 2 for 32000Hz sample rate
[    9.269349] fsl-spdif-dai 2004000.spdif: the best rate for 32000Hz sample rate is 32226Hz
[    9.276431] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
[    9.276438] fsl-asoc-card sound: snd_soc_register_card failed (-517)
[    9.289559] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    9.306991] imx-sgtl5000 sound: ASoC: CPU DAI (null) not registered
[    9.346253] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[    9.376398] fsl-spdif-dai 2004000.spdif: use rxtx6 as tx clock source for 44100Hz sample rate
[    9.376404] fsl-spdif-dai 2004000.spdif: use txclk df 94 for 44100Hz sample rate
[    9.376409] fsl-spdif-dai 2004000.spdif: the best rate for 44100Hz sample rate is 43882Hz
[    9.376415] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    9.403159] fsl-spdif-dai 2004000.spdif: use rxtx6 as tx clock source for 48000Hz sample rate
[    9.403165] fsl-spdif-dai 2004000.spdif: use txclk df 86 for 48000Hz sample rate
[    9.403170] fsl-spdif-dai 2004000.spdif: the best rate for 48000Hz sample rate is 47965Hz
[    9.403174] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    9.424007] fsl-spdif-dai 2004000.spdif: use rxtx6 as tx clock source for 96000Hz sample rate
[    9.424013] fsl-spdif-dai 2004000.spdif: use txclk df 43 for 96000Hz sample rate
[    9.424021] fsl-spdif-dai 2004000.spdif: the best rate for 96000Hz sample rate is 95930Hz
[    9.424025] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    9.450424] fsl-spdif-dai 2004000.spdif: use rxtx6 as tx clock source for 192000Hz sample rate
[    9.481561] fsl-spdif-dai 2004000.spdif: use txclk df 21 for 192000Hz sample rate
[    9.488400] fsl-spdif-dai 2004000.spdif: the best rate for 192000Hz sample rate is 196428Hz
[    9.536785] fsl-ssi-dai 2028000.ssi: No cache defaults, reading back from HW
[    9.582106] imx-spdif sound-spdif: snd-soc-dummy-dai <-> 2004000.spdif mapping ok
[    9.612159] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
[    9.621942] fsl-asoc-card sound: snd_soc_register_card failed (-517)
[    9.638227] imx-sgtl5000 sound: ASoC: CPU DAI (null) not registered
[    9.647247] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[    9.682092] sgtl5000 1-000a: Using internal LDO instead of VDDD
[    9.776989] fsl-asoc-card sound: sgtl5000 <-> 2028000.ssi mapping ok
[...]
[   70.407805] fsl-spdif-dai 2004000.spdif: expected clock rate = 265305600
[   70.407829] fsl-spdif-dai 2004000.spdif: actual clock rate = 264000000
[   70.407857] fsl-spdif-dai 2004000.spdif: set sample rate to 43882Hz for 44100Hz playback
[   70.407867] fsl-spdif-dai 2004000.spdif: STCSCH: 0x304000
[   70.407875] fsl-spdif-dai 2004000.spdif: STCSCL: 0x000000
[   70.469948] fsl-spdif-dai 2004000.spdif: expected clock rate = 265305600
[   70.469965] fsl-spdif-dai 2004000.spdif: actual clock rate = 264000000
[   70.469977] fsl-spdif-dai 2004000.spdif: set sample rate to 43882Hz for 44100Hz playback
[   70.469999] fsl-spdif-dai 2004000.spdif: STCSCH: 0x304000
[   70.470014] fsl-spdif-dai 2004000.spdif: STCSCL: 0x000000
[...]

Then when I try to play sound through spdif:

[  140.176536] fsl-spdif-dai 2004000.spdif: expected clock rate = 265305600
[  140.176555] fsl-spdif-dai 2004000.spdif: actual clock rate = 264000000
[  140.176566] fsl-spdif-dai 2004000.spdif: set sample rate to 43882Hz for 44100Hz playback
[  140.176579] fsl-spdif-dai 2004000.spdif: STCSCH: 0x304000
[  140.176587] fsl-spdif-dai 2004000.spdif: STCSCL: 0x000000




linux-libre-4.7 with my patch, i.e. clocks defined like this :
arch/arm/boot/dts/imx6qdl.dtsi:
aips-bus@02000000 { /* AIPS1 */
[...]
   spba-bus@02000000 {
[...]
      spdif: spdif@02004000 {
          clocks = <&clks IMX6QDL_CLK_SPDIF_GCLK>, <&clks IMX6QDL_CLK_OSC>,
                   <&clks IMX6QDL_CLK_SPDIF>, <&clks IMX6QDL_CLK_DUMMY>,
                   <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_DUMMY>,
                   <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_DUMMY>,
                   <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_SPBA>;
          clock-names = "core",  "rxtx0",
                        "rxtx1", "rxtx2",
                        "rxtx3", "rxtx4",
                        "rxtx5", "rxtx6",
                        "rxtx7", "spba";
[...]


The messages at boot: 

[...]
[    6.655532] imx-spdif sound-spdif: ASoC: CPU DAI (null) not registered
[    6.655545] imx-spdif sound-spdif: snd_soc_register_card failed: -517
[    6.656895] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe
[    6.657567] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    6.660895] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 32000Hz sample rate
[    6.660902] fsl-spdif-dai 2004000.spdif: use txclk df 4 for 32000Hz sample rate
[    6.660907] fsl-spdif-dai 2004000.spdif: the best rate for 32000Hz sample rate is 31719Hz
[    6.660911] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    6.662922] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 44100Hz sample rate
[    6.662927] fsl-spdif-dai 2004000.spdif: use txclk df 9 for 44100Hz sample rate
[    6.662932] fsl-spdif-dai 2004000.spdif: the best rate for 44100Hz sample rate is 43859Hz
[    6.662936] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    6.663205] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
[    6.663213] fsl-asoc-card sound: snd_soc_register_card failed (-517)
[    6.676779] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 48000Hz sample rate
[    6.676785] fsl-spdif-dai 2004000.spdif: use txclk df 5 for 48000Hz sample rate
[    6.676790] fsl-spdif-dai 2004000.spdif: the best rate for 48000Hz sample rate is 47368Hz
[    6.676795] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    6.687008] imx-sgtl5000 sound: ASoC: CPU DAI (null) not registered
[    6.687016] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[    6.704876] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 96000Hz sample rate
[    6.704882] fsl-spdif-dai 2004000.spdif: use txclk df 3 for 96000Hz sample rate
[    6.704888] fsl-spdif-dai 2004000.spdif: the best rate for 96000Hz sample rate is 94736Hz
[    6.704892] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    6.723554] fsl-spdif-dai 2004000.spdif: use rxtx0 as tx clock source for 192000Hz sample rate
[    6.723561] fsl-spdif-dai 2004000.spdif: use txclk df 2 for 192000Hz sample rate
[    6.723567] fsl-spdif-dai 2004000.spdif: the best rate for 192000Hz sample rate is 187500Hz
[    6.723679] fsl-spdif-dai 2004000.spdif: imx_pcm_dma_init failed: -517
[    7.626351] fsl-asrc 2034000.asrc: driver registered
[    7.642378] imx-spdif sound-spdif: ASoC: CPU DAI (null) not registered
[    7.650279] imx-spdif sound-spdif: snd_soc_register_card failed: -517
[    7.667765] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
[    7.676924] fsl-asoc-card sound: snd_soc_register_card failed (-517)
[    7.696535] imx-sgtl5000 sound: ASoC: CPU DAI (null) not registered
[    7.704977] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[    7.718722] sgtl5000 1-000a: sgtl5000 revision 0x11
[...]
[    7.725855] fsl-ssi-dai 2028000.ssi: No cache defaults, reading back from HW
[    7.728561] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe
[    7.738178] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.740172] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 32000Hz sample rate
[    7.740177] fsl-spdif-dai 2004000.spdif: use txclk df 4 for 32000Hz sample rate
[    7.740183] fsl-spdif-dai 2004000.spdif: the best rate for 32000Hz sample rate is 31719Hz
[    7.740187] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.760659] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 44100Hz sample rate
[    7.760665] fsl-spdif-dai 2004000.spdif: use txclk df 9 for 44100Hz sample rate
[    7.760672] fsl-spdif-dai 2004000.spdif: the best rate for 44100Hz sample rate is 43859Hz
[    7.760676] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.765495] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 48000Hz sample rate
[    7.765501] fsl-spdif-dai 2004000.spdif: use txclk df 5 for 48000Hz sample rate
[    7.765506] fsl-spdif-dai 2004000.spdif: the best rate for 48000Hz sample rate is 47368Hz
[    7.765510] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.774373] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 96000Hz sample rate
[    7.774378] fsl-spdif-dai 2004000.spdif: use txclk df 3 for 96000Hz sample rate
[    7.774384] fsl-spdif-dai 2004000.spdif: the best rate for 96000Hz sample rate is 94736Hz
[    7.774388] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.778530] fsl-spdif-dai 2004000.spdif: use rxtx0 as tx clock source for 192000Hz sample rate
[    7.778536] fsl-spdif-dai 2004000.spdif: use txclk df 2 for 192000Hz sample rate
[    7.778541] fsl-spdif-dai 2004000.spdif: the best rate for 192000Hz sample rate is 187500Hz
[    7.783897] fsl-spdif-dai 2004000.spdif: imx_pcm_dma_init failed: -517
[    7.828163] imx-spdif sound-spdif: ASoC: CPU DAI (null) not registered
[    7.828174] imx-spdif sound-spdif: snd_soc_register_card failed: -517
[    7.828703] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
[    7.828712] fsl-asoc-card sound: snd_soc_register_card failed (-517)
[    7.828825] imx-sgtl5000 sound: ASoC: CPU DAI (null) not registered
[    7.828832] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[    7.829908] fsl-ssi-dai 2028000.ssi: No cache defaults, reading back from HW
[    7.834312] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe
[    7.837686] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.842472] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 32000Hz sample rate
[    7.842478] fsl-spdif-dai 2004000.spdif: use txclk df 4 for 32000Hz sample rate
[    7.842485] fsl-spdif-dai 2004000.spdif: the best rate for 32000Hz sample rate is 31719Hz
[    7.842490] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.844695] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 44100Hz sample rate
[    7.844700] fsl-spdif-dai 2004000.spdif: use txclk df 9 for 44100Hz sample rate
[    7.844705] fsl-spdif-dai 2004000.spdif: the best rate for 44100Hz sample rate is 43859Hz
[    7.844708] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.848458] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 48000Hz sample rate
[    7.848464] fsl-spdif-dai 2004000.spdif: use txclk df 5 for 48000Hz sample rate
[    7.848470] fsl-spdif-dai 2004000.spdif: the best rate for 48000Hz sample rate is 47368Hz
[    7.848474] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.858907] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 96000Hz sample rate
[    7.858912] fsl-spdif-dai 2004000.spdif: use txclk df 3 for 96000Hz sample rate
[    7.858917] fsl-spdif-dai 2004000.spdif: the best rate for 96000Hz sample rate is 94736Hz
[    7.858921] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.868189] fsl-spdif-dai 2004000.spdif: use rxtx0 as tx clock source for 192000Hz sample rate
[    7.868195] fsl-spdif-dai 2004000.spdif: use txclk df 2 for 192000Hz sample rate
[    7.868200] fsl-spdif-dai 2004000.spdif: the best rate for 192000Hz sample rate is 187500Hz
[    7.868555] fsl-spdif-dai 2004000.spdif: imx_pcm_dma_init failed: -517
[    8.094960] imx-spdif sound-spdif: ASoC: CPU DAI (null) not registered
[    8.094994] imx-spdif sound-spdif: snd_soc_register_card failed: -517
[    8.095669] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
[    8.095808] fsl-asoc-card sound: snd_soc_register_card failed (-517)
[    8.098338] imx-sgtl5000 sound: ASoC: CPU DAI (null) not registered
[    8.098347] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[    8.099067] fsl-ssi-dai 2028000.ssi: No cache defaults, reading back from HW
[    8.109691] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe
[    8.113038] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    8.117534] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 32000Hz sample rate
[    8.117539] fsl-spdif-dai 2004000.spdif: use txclk df 4 for 32000Hz sample rate
[    8.117544] fsl-spdif-dai 2004000.spdif: the best rate for 32000Hz sample rate is 31719Hz
[    8.117548] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    8.120341] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 44100Hz sample rate
[    8.120347] fsl-spdif-dai 2004000.spdif: use txclk df 9 for 44100Hz sample rate
[    8.120352] fsl-spdif-dai 2004000.spdif: the best rate for 44100Hz sample rate is 43859Hz
[    8.120356] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    8.134938] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 48000Hz sample rate
[    8.134944] fsl-spdif-dai 2004000.spdif: use txclk df 5 for 48000Hz sample rate
[    8.134949] fsl-spdif-dai 2004000.spdif: the best rate for 48000Hz sample rate is 47368Hz
[    8.134953] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    8.139127] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 96000Hz sample rate
[    8.139133] fsl-spdif-dai 2004000.spdif: use txclk df 3 for 96000Hz sample rate
[    8.139139] fsl-spdif-dai 2004000.spdif: the best rate for 96000Hz sample rate is 94736Hz
[    8.139143] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    8.147727] fsl-spdif-dai 2004000.spdif: use rxtx0 as tx clock source for 192000Hz sample rate
[    8.147734] fsl-spdif-dai 2004000.spdif: use txclk df 2 for 192000Hz sample rate
[    8.147740] fsl-spdif-dai 2004000.spdif: the best rate for 192000Hz sample rate is 187500Hz
[    8.147822] fsl-spdif-dai 2004000.spdif: imx_pcm_dma_init failed: -517
[...]
[    8.831797] 20ec000.sdma: Missing Free firmware (non-Free firmware loading is disabled)
[    8.880684] imx-sdma 20ec000.sdma: failed to get firmware from device tree
[    8.910258] imx-sdma 20ec000.sdma: Direct firmware load for /*(DEBLOBBED)*/ failed with error -2
[    9.073968] imx-spdif sound-spdif: ASoC: CPU DAI (null) not registered
[    9.081645] imx-spdif sound-spdif: snd_soc_register_card failed: -517
[    9.095074] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
[    9.110834] fsl-asoc-card sound: snd_soc_register_card failed (-517)
[    9.121216] imx-sgtl5000 sound: ASoC: CPU DAI (null) not registered
[    9.130267] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[    9.153016] fsl-ssi-dai 2028000.ssi: No cache defaults, reading back from HW
[    9.165177] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe
[    9.195832] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    9.211198] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 32000Hz sample rate
[    9.217917] fsl-spdif-dai 2004000.spdif: use txclk df 4 for 32000Hz sample rate
[    9.224900] fsl-spdif-dai 2004000.spdif: the best rate for 32000Hz sample rate is 31719Hz
[    9.231164] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    9.241790] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 44100Hz sample rate
[    9.248073] fsl-spdif-dai 2004000.spdif: use txclk df 9 for 44100Hz sample rate
[    9.254457] fsl-spdif-dai 2004000.spdif: the best rate for 44100Hz sample rate is 43859Hz
[    9.260822] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    9.279536] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 48000Hz sample rate
[    9.285950] fsl-spdif-dai 2004000.spdif: use txclk df 5 for 48000Hz sample rate
[    9.292236] fsl-spdif-dai 2004000.spdif: the best rate for 48000Hz sample rate is 47368Hz
[    9.298648] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    9.313550] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 96000Hz sample rate
[...]
[    9.328117] fsl-spdif-dai 2004000.spdif: use txclk df 3 for 96000Hz sample rate
[    9.334526] fsl-spdif-dai 2004000.spdif: the best rate for 96000Hz sample rate is 94736Hz
[    9.340888] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    9.351639] fsl-spdif-dai 2004000.spdif: use rxtx0 as tx clock source for 192000Hz sample rate
[    9.358052] fsl-spdif-dai 2004000.spdif: use txclk df 2 for 192000Hz sample rate
[    9.364471] fsl-spdif-dai 2004000.spdif: the best rate for 192000Hz sample rate is 187500Hz
[    9.417677] imx-spdif sound-spdif: snd-soc-dummy-dai <-> 2004000.spdif mapping ok
[    9.461316] sgtl5000 1-000a: Using internal LDO instead of VDDD
[    9.592189] fsl-asoc-card sound: sgtl5000 <-> 2028000.ssi mapping ok
[...]
[   69.198853] fsl-spdif-dai 2004000.spdif: expected clock rate = 25401600
[   69.198874] fsl-spdif-dai 2004000.spdif: actual clock rate = 25263158
[   69.198892] fsl-spdif-dai 2004000.spdif: set sample rate to 43859Hz for 44100Hz playback
[   69.198902] fsl-spdif-dai 2004000.spdif: STCSCH: 0x304000
[   69.198910] fsl-spdif-dai 2004000.spdif: STCSCL: 0x000000
[   69.349763] fsl-spdif-dai 2004000.spdif: expected clock rate = 25401600
[   69.349776] fsl-spdif-dai 2004000.spdif: actual clock rate = 25263158
[   69.349793] fsl-spdif-dai 2004000.spdif: set sample rate to 43859Hz for 44100Hz playback
[   69.349812] fsl-spdif-dai 2004000.spdif: STCSCH: 0x304000
[   69.349820] fsl-spdif-dai 2004000.spdif: STCSCL: 0x000000
[...]

Then when I try (successfully) to play sound through spdif:

[  113.186850] fsl-spdif-dai 2004000.spdif: expected clock rate = 25401600
[  113.186863] fsl-spdif-dai 2004000.spdif: actual clock rate = 25263158
[  113.186872] fsl-spdif-dai 2004000.spdif: set sample rate to 43859Hz for 44100Hz playback
[  113.186882] fsl-spdif-dai 2004000.spdif: STCSCH: 0x304000
[  113.186889] fsl-spdif-dai 2004000.spdif: STCSCL: 0x000000


Does it mean that a 43859Hz clock is close enough to theoretical 44100Hz
but  43882Hz is not ? 

The clock that doesn't work seems closer to the desired value.
I don't understand. 

Maybe there's something wrong with rxtx6 (IMX6QDL_CLK_MLB). This clock
does not seem to be used elsewhere (I mean in files, it's used in any
board that includes imx6qdl.dtsi)


include/dt-bindings/clock/imx6qdl-clock.h: 
#define IMX6QDL_CLK_MLB						139



Might it have to do with the fact I'm using (still trying in fact) to use etnaviv ?

drivers/clk/imx/clk-imx6q.c:

   if (clk_on_imx6dl())
      /*
       * The multiplexer and divider of the imx6q clock gpu2d get
       * redefined/reused as mlb_sys_sel and mlb_sys_clk_podf on imx6dl.
       */
       clk[IMX6QDL_CLK_MLB] = imx_clk_gate2("mlb",            "gpu2d_core_podf",   base + 0x74, 18);
   else
       clk[IMX6QDL_CLK_MLB] = imx_clk_gate2("mlb",            "axi",               base + 0x74, 18);


But I'm on a imx6q not imx6dl .

It seems I've found a similar case, just more ancient. I've tried the
patch in the last message there instead of the one I sent, and it
works for me (gives me sound on the spdif output) but I still don't
understand.

https://community.nxp.com/thread/387131

The patch is 


And the dmesg is: 

[...]
[    6.757672] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
[    6.757680] fsl-asoc-card sound: snd_soc_register_card failed (-517)
[    6.767863] imx-sgtl5000 sound: ASoC: CPU DAI (null) not registered
[    6.767874] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[    6.771927] fsl-ssi-dai 2028000.ssi: No cache defaults, reading back from HW
[    6.782230] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe
[    6.795682] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    6.851089] fsl-spdif-dai 2004000.spdif: use rxtx5 as tx clock source for 32000Hz sample rate
[    6.857631] fsl-spdif-dai 2004000.spdif: use txclk df 16 for 32000Hz sample rate
[    6.864477] fsl-spdif-dai 2004000.spdif: use sysclk df 2 for 32000Hz sample rate
[    6.864484] fsl-spdif-dai 2004000.spdif: the best rate for 32000Hz sample rate is 32226Hz
[    6.864489] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    6.909089] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 44100Hz sample rate
[    6.909096] fsl-spdif-dai 2004000.spdif: use txclk df 9 for 44100Hz sample rate
[    6.909101] fsl-spdif-dai 2004000.spdif: the best rate for 44100Hz sample rate is 43859Hz
[    6.909105] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    6.981874] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 48000Hz sample rate
[    6.992935] fsl-spdif-dai 2004000.spdif: use txclk df 5 for 48000Hz sample rate
[    6.992943] fsl-spdif-dai 2004000.spdif: the best rate for 48000Hz sample rate is 47368Hz
[    6.992948] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    6.993678] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
[    6.993688] fsl-asoc-card sound: snd_soc_register_card failed (-517)
[    6.993809] imx-sgtl5000 sound: ASoC: CPU DAI (null) not registered
[    6.993816] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[    6.994121] fsl-ssi-dai 2028000.ssi: No cache defaults, reading back from HW
[    7.024546] 20ec000.sdma: Missing Free firmware (non-Free firmware loading is disabled)
[    7.024577] imx-sdma 20ec000.sdma: failed to get firmware from device tree
[    7.025416] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 96000Hz sample rate
[    7.025422] fsl-spdif-dai 2004000.spdif: use txclk df 3 for 96000Hz sample rate
[    7.025426] fsl-spdif-dai 2004000.spdif: the best rate for 96000Hz sample rate is 94736Hz
[    7.025430] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.040198] imx-sdma 20ec000.sdma: Direct firmware load for /*(DEBLOBBED)*/ failed with error -2
[    7.052490] fsl-spdif-dai 2004000.spdif: use rxtx0 as tx clock source for 192000Hz sample rate
[    7.052497] fsl-spdif-dai 2004000.spdif: use txclk df 2 for 192000Hz sample rate
[    7.052503] fsl-spdif-dai 2004000.spdif: the best rate for 192000Hz sample rate is 187500Hz
[    7.052601] fsl-spdif-dai 2004000.spdif: imx_pcm_dma_init failed: -517
[    7.053550] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
[    7.053560] fsl-asoc-card sound: snd_soc_register_card failed (-517)
[    7.054022] imx-sgtl5000 sound: ASoC: CPU DAI (null) not registered
[    7.054295] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[    7.056803] fsl-ssi-dai 2028000.ssi: No cache defaults, reading back from HW
[    7.060206] fsl-asrc 2034000.asrc: driver registered
[    7.063842] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe
[    7.064485] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.096570] fsl-spdif-dai 2004000.spdif: use rxtx5 as tx clock source for 32000Hz sample rate
[    7.096579] fsl-spdif-dai 2004000.spdif: use txclk df 16 for 32000Hz sample rate
[    7.096584] fsl-spdif-dai 2004000.spdif: use sysclk df 2 for 32000Hz sample rate
[    7.096589] fsl-spdif-dai 2004000.spdif: the best rate for 32000Hz sample rate is 32226Hz
[    7.096593] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.123283] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 44100Hz sample rate
[    7.123289] fsl-spdif-dai 2004000.spdif: use txclk df 9 for 44100Hz sample rate
[    7.123295] fsl-spdif-dai 2004000.spdif: the best rate for 44100Hz sample rate is 43859Hz
[    7.123299] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.144167] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 48000Hz sample rate
[    7.144173] fsl-spdif-dai 2004000.spdif: use txclk df 5 for 48000Hz sample rate
[    7.144180] fsl-spdif-dai 2004000.spdif: the best rate for 48000Hz sample rate is 47368Hz
[    7.144185] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.169620] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 96000Hz sample rate
[    7.169626] fsl-spdif-dai 2004000.spdif: use txclk df 3 for 96000Hz sample rate
[    7.169634] fsl-spdif-dai 2004000.spdif: the best rate for 96000Hz sample rate is 94736Hz
[    7.169637] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.190745] fsl-spdif-dai 2004000.spdif: use rxtx0 as tx clock source for 192000Hz sample rate
[    7.190753] fsl-spdif-dai 2004000.spdif: use txclk df 2 for 192000Hz sample rate
[    7.190758] fsl-spdif-dai 2004000.spdif: the best rate for 192000Hz sample rate is 187500Hz
[    7.190883] fsl-spdif-dai 2004000.spdif: imx_pcm_dma_init failed: -517
[    7.191660] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
[    7.191671] fsl-asoc-card sound: snd_soc_register_card failed (-517)
[    7.191777] imx-sgtl5000 sound: ASoC: CPU DAI (null) not registered
[    7.191784] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[    7.192106] fsl-ssi-dai 2028000.ssi: No cache defaults, reading back from HW
[    7.220888] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe
[    7.221677] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.246497] fsl-spdif-dai 2004000.spdif: use rxtx5 as tx clock source for 32000Hz sample rate
[    7.246504] fsl-spdif-dai 2004000.spdif: use txclk df 16 for 32000Hz sample rate
[    7.246510] fsl-spdif-dai 2004000.spdif: use sysclk df 2 for 32000Hz sample rate
[    7.246515] fsl-spdif-dai 2004000.spdif: the best rate for 32000Hz sample rate is 32226Hz
[    7.246520] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.266974] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 44100Hz sample rate
[    7.266980] fsl-spdif-dai 2004000.spdif: use txclk df 9 for 44100Hz sample rate
[    7.266985] fsl-spdif-dai 2004000.spdif: the best rate for 44100Hz sample rate is 43859Hz
[    7.266989] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.288040] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 48000Hz sample rate
[    7.288046] fsl-spdif-dai 2004000.spdif: use txclk df 5 for 48000Hz sample rate
[    7.288051] fsl-spdif-dai 2004000.spdif: the best rate for 48000Hz sample rate is 47368Hz
[    7.288055] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.320893] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 96000Hz sample rate
[    7.320901] fsl-spdif-dai 2004000.spdif: use txclk df 3 for 96000Hz sample rate
[    7.320909] fsl-spdif-dai 2004000.spdif: the best rate for 96000Hz sample rate is 94736Hz
[    7.320915] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.342352] fsl-spdif-dai 2004000.spdif: use rxtx0 as tx clock source for 192000Hz sample rate
[    7.342363] fsl-spdif-dai 2004000.spdif: use txclk df 2 for 192000Hz sample rate
[    7.342370] fsl-spdif-dai 2004000.spdif: the best rate for 192000Hz sample rate is 187500Hz
[    7.369879] fsl-asoc-card sound: ASoC: CPU DAI (null) not registered
[    7.369889] fsl-asoc-card sound: snd_soc_register_card failed (-517)
[    7.370024] imx-sgtl5000 sound: ASoC: CPU DAI (null) not registered
[    7.370033] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[    7.391119] fsl-ssi-dai 2028000.ssi: No cache defaults, reading back from HW
[    7.422777] fsl-asoc-card sound: ASoC: CODEC DAI sgtl5000 not registered
[    7.422789] fsl-asoc-card sound: snd_soc_register_card failed (-517)
[    7.423120] imx-sgtl5000 sound: ASoC: CODEC DAI sgtl5000 not registered
[    7.423133] imx-sgtl5000 sound: snd_soc_register_card failed (-517)
[    7.454462] sgtl5000 1-000a: sgtl5000 revision 0x11
[...]
[    7.658346] sgtl5000 1-000a: Using internal LDO instead of VDDD
[    7.766216] fsl-asoc-card sound: sgtl5000 <-> 2028000.ssi mapping ok
[...]
[    8.496784] imx-spdif sound-spdif: snd-soc-dummy-dai <-> 2004000.spdif mapping ok
[...]
[  110.494306] fsl-spdif-dai 2004000.spdif: expected clock rate = 25401600
[  110.494321] fsl-spdif-dai 2004000.spdif: actual clock rate = 25263158
[  110.494343] fsl-spdif-dai 2004000.spdif: set sample rate to 43859Hz for 44100Hz playback
[  110.494352] fsl-spdif-dai 2004000.spdif: STCSCH: 0x304000
[  110.494359] fsl-spdif-dai 2004000.spdif: STCSCL: 0x000000
[  110.549945] fsl-spdif-dai 2004000.spdif: expected clock rate = 25401600
[  110.549959] fsl-spdif-dai 2004000.spdif: actual clock rate = 25263158
[  110.549973] fsl-spdif-dai 2004000.spdif: set sample rate to 43859Hz for 44100Hz playback
[  110.549988] fsl-spdif-dai 2004000.spdif: STCSCH: 0x304000
[  110.549996] fsl-spdif-dai 2004000.spdif: STCSCL: 0x000000

Then, when I play music: 

[  178.269300] fsl-spdif-dai 2004000.spdif: expected clock rate = 25401600
[  178.269311] fsl-spdif-dai 2004000.spdif: actual clock rate = 25263158
[  178.269321] fsl-spdif-dai 2004000.spdif: set sample rate to 43859Hz for 44100Hz playback
[  178.269332] fsl-spdif-dai 2004000.spdif: STCSCH: 0x304000
[  178.269339] fsl-spdif-dai 2004000.spdif: STCSCL: 0x000000


AFAICS it just uses rxtx5 (IMX6QDL_CLK_IPG) for 32KHz and gets a little closer to that. 
But I haven't tried to play at 32KHz

Is there anything else I can try ? 

Thanks.

Comments

Nicolin Chen Aug. 31, 2016, 4:21 a.m. UTC | #1
On Tue, Aug 30, 2016 at 01:14:14PM +0200, Xavi Drudis Ferran wrote:

> linux-libre-4.7 without my patch, i.e. clocks defined like this :
> arch/arm/boot/dts/imx6qdl.dtsi:
> aips-bus@02000000 { /* AIPS1 */
> [...]
>    spba-bus@02000000 {
> [...]
>        spdif: spdif@02004000 {
>           clocks = <&clks IMX6QDL_CLK_SPDIF_GCLK>, <&clks IMX6QDL_CLK_OSC>,
>                    <&clks IMX6QDL_CLK_SPDIF>, <&clks IMX6QDL_CLK_ASRC>,
>                    <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_ESAI_EXTAL>,
>                    <&clks IMX6QDL_CLK_IPG>, <&clks IMX6QDL_CLK_MLB>,
>                    <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_SPBA>;
>           clock-names = "core",  "rxtx0",
>                         "rxtx1", "rxtx2",
>                         "rxtx3", "rxtx4",
>                         "rxtx5", "rxtx6",
>                         "rxtx7", "spba";
> [...]

> [    9.376398] fsl-spdif-dai 2004000.spdif: use rxtx6 as tx clock source for 44100Hz sample rate
> [    9.376404] fsl-spdif-dai 2004000.spdif: use txclk df 94 for 44100Hz sample rate
> [    9.376409] fsl-spdif-dai 2004000.spdif: the best rate for 44100Hz sample rate is 43882Hz

Without your patch, it chose rxtx6 (MLB) as the source for 44.1KHz.

> linux-libre-4.7 with my patch, i.e. clocks defined like this :
> arch/arm/boot/dts/imx6qdl.dtsi:
> aips-bus@02000000 { /* AIPS1 */
> [...]
>    spba-bus@02000000 {
> [...]
>       spdif: spdif@02004000 {
>           clocks = <&clks IMX6QDL_CLK_SPDIF_GCLK>, <&clks IMX6QDL_CLK_OSC>,
>                    <&clks IMX6QDL_CLK_SPDIF>, <&clks IMX6QDL_CLK_DUMMY>,
>                    <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_DUMMY>,
>                    <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_DUMMY>,
>                    <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_SPBA>;
>           clock-names = "core",  "rxtx0",
>                         "rxtx1", "rxtx2",
>                         "rxtx3", "rxtx4",
>                         "rxtx5", "rxtx6",
>                         "rxtx7", "spba";
> [...]

> [    6.662922] fsl-spdif-dai 2004000.spdif: use rxtx1 as tx clock source for 44100Hz sample rate
> [    6.662927] fsl-spdif-dai 2004000.spdif: use txclk df 9 for 44100Hz sample rate
> [    6.662932] fsl-spdif-dai 2004000.spdif: the best rate for 44100Hz sample rate is 43859Hz

With your patch, it selects rxtx1 (the dedicated SPDIF baud clock).

> Does it mean that a 43859Hz clock is close enough to theoretical 44100Hz
> but  43882Hz is not ? 

No, the problem is not at the rate but the source -- Although the
MLB clock exists in the clock tree as a better rate provider, it
might not be correctly enabled or running at the rate it claims.

> Maybe there's something wrong with rxtx6 (IMX6QDL_CLK_MLB). This clock

Yes.

> does not seem to be used elsewhere (I mean in files, it's used in any
> board that includes imx6qdl.dtsi)
> 
> 
> include/dt-bindings/clock/imx6qdl-clock.h: 
> #define IMX6QDL_CLK_MLB						139
 
> Might it have to do with the fact I'm using (still trying in fact) to use etnaviv ?
> 
> drivers/clk/imx/clk-imx6q.c:
> 
>    if (clk_on_imx6dl())
>       /*
>        * The multiplexer and divider of the imx6q clock gpu2d get
>        * redefined/reused as mlb_sys_sel and mlb_sys_clk_podf on imx6dl.
>        */
>        clk[IMX6QDL_CLK_MLB] = imx_clk_gate2("mlb",            "gpu2d_core_podf",   base + 0x74, 18);
>    else
>        clk[IMX6QDL_CLK_MLB] = imx_clk_gate2("mlb",            "axi",               base + 0x74, 18);
> 
> 
> But I'm on a imx6q not imx6dl .

There are five MLB clocks sharing the same clock gate according
to CCM chapter in the Reference Manual of imx6q. But five clocks
come from three different parent clocks, and I am wondering if
the MLB clock that's connected to the S/PDIF module is really
derived from this AXI.

Hope Fabio might be able to help on the clock tree issue here:)

> --- linux-4.7-no-spdif-out/arch/arm/boot/dts/imx6qdl.dtsi	2016-07-25 00:19:43.000000000 +0200
> +++ linux-4.7/arch/arm/boot/dts/imx6qdl.dtsi	2016-08-30 12:51:37.369431791 +0200
> @@ -242,7 +242,7 @@
>  					clocks = <&clks IMX6QDL_CLK_SPDIF_GCLK>, <&clks IMX6QDL_CLK_OSC>,
>  						 <&clks IMX6QDL_CLK_SPDIF>, <&clks IMX6QDL_CLK_ASRC>,
>  						 <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_ESAI_EXTAL>,
> -						 <&clks IMX6QDL_CLK_IPG>, <&clks IMX6QDL_CLK_MLB>,
> +						 <&clks IMX6QDL_CLK_IPG>, <&clks IMX6QDL_CLK_DUMMY>,

As MLB might be gated or not available at all, disabling it is a
quick work around.
 
> AFAICS it just uses rxtx5 (IMX6QDL_CLK_IPG) for 32KHz and gets a little closer to that. 
> But I haven't tried to play at 32KHz
> 
> Is there anything else I can try ? 

Another solution for you could be to change the rates of two of
those existing clocks to the perfect rates for 44.1KHz and 48KHz
respectively, 22579200Hz and 24576000Hz for example. (If you
only need one sample rate support, changing rxtx1 SPDIF clock
only then.)
Xavier Drudis Ferran Aug. 31, 2016, 9:10 a.m. UTC | #2
El Tue, Aug 30, 2016 at 09:21:01PM -0700, Nicolin Chen deia:
> 
> No, the problem is not at the rate but the source -- Although the
> MLB clock exists in the clock tree as a better rate provider, it
> might not be correctly enabled or running at the rate it claims.
> 

> 
> There are five MLB clocks sharing the same clock gate according
> to CCM chapter in the Reference Manual of imx6q. But five clocks
> come from three different parent clocks, and I am wondering if
> the MLB clock that's connected to the S/PDIF module is really
> derived from this AXI.
> 
> Hope Fabio might be able to help on the clock tree issue here:)
>

I hope too, it's a little over my head, to be euphemistic. 

> 
> Another solution for you could be to change the rates of two of
> those existing clocks to the perfect rates for 44.1KHz and 48KHz
> respectively, 22579200Hz and 24576000Hz for example. (If you
> only need one sample rate support, changing rxtx1 SPDIF clock
> only then.)

Thank you very much.  I'm not sure what practical problem that would
solve for me, audio sounds quite right to my ears with the workaround
(disabling MLB). I've looked page 121 of
http://cache.freescale.com/files/32bit/doc/data_sheet/IMX6DQIEC.pdf
And it seems like the the margin for the SPDIF clock would be 16 ns
and I'm like 10 times out of spec. But I can't hear the problem.  I
may try it one day to hear how it sounds.

I'll try to remember it if I ever come across some problem with my audio.
For now what I'd like is to stay as close to linux-libre mainline 
as possible, so the quick workaround is enough for me. 

Now for the general case, I'm not sure what the solution should be.
Page 4 of the pdf above says MLB is not present in industrial "parts",
only automotive, or consumer "parts". There are several versions of
IMX6Q in the market.  What version must I have ? I guess consumer
(with MLB) but I'm not sure... According to the wandboard-quad-rev-b1
manual its consumer, MCIMX6Q5EYM10AC, so I should have MLB, I guess.

$ cat /proc/cpuinfo 
processor	   : 0
model name	   : ARMv7 Processor rev 10 (v7l)
BogoMIPS	   : 7.54
Features	   : half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpd32 
CPU implementer	   : 0x41
CPU architecture: 7
CPU variant	  : 0x2
CPU part	  : 0xc09
CPU revision	  : 10
[...]

I can't tell what CPU part : 0xc09 means.

In the reference manual pg 796 I see the same gate seems to affect Media
Local Bus (MLB) clock and Digital Transmission Content Protection
(DTCP). I don't use DTCP but I haven't done anything to disable it.

http://www.nxp.com/files/32bit/doc/ref_manual/IMX6DQRM.pdf?fasp=1&WT_TYPE=Reference%20Manuals&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT_ASSET=Documentation&fileExt=.pdf


Thanks again, you've been very helpful.
Fabio Estevam Aug. 31, 2016, 1:30 p.m. UTC | #3
Xavi,

On Wed, Aug 31, 2016 at 10:11 AM, Fabio Estevam <festevam@gmail.com> wrote:

> Xavi,
>
> Care to send a formal patch with your change?

If you prefer, I can send this change to the ARM kernel mailing list.

Please let me know what you prefer.

Thanks
Xavier Drudis Ferran Aug. 31, 2016, 1:47 p.m. UTC | #4
El Wed, Aug 31, 2016 at 10:30:25AM -0300, Fabio Estevam deia:
> Xavi,
> 
> On Wed, Aug 31, 2016 at 10:11 AM, Fabio Estevam <festevam@gmail.com> wrote:
> 
> > Xavi,
> >
> > Care to send a formal patch with your change?
> 
> If you prefer, I can send this change to the ARM kernel mailing list.
>

Whatever is easier for you. I'll have to look up the formalities for
sending the patch myself (format, copyright, where to send, etc.)
since I've never sent a patch for linux. I don't believe such a simple
change can be copyrightable, but the original isn't mine, it's from
that URL I gave, https://community.nxp.com/thread/387131 so originally
from ambika@iwavesystems.com

> Please let me know what you prefer.
>

If it's easy for you to send it yourself, I would prefer so and I'm
grateful. If not, it'll be an exercise for me, no problem.
Xavier Drudis Ferran Aug. 31, 2016, 1:49 p.m. UTC | #5
El Wed, Aug 31, 2016 at 10:11:13AM -0300, Fabio Estevam deia:
> 2. SPDIF clock rate not accurate. Probably using PLL4 as SPDIF source
> would help to get more accurate SPDIF clock rates.
> 
> Could you please try the untested change?
> 
> --- a/drivers/clk/imx/clk-imx6q.c
> +++ b/drivers/clk/imx/clk-imx6q.c
> @@ -623,7 +623,7 @@ static void __init imx6q_clocks_init(struct
> device_node *ccm_node)
>                 pr_warn("failed to set up CLKO: %d\n", ret);
> 
>         /* Audio-related clocks configuration */
> -       clk_set_parent(clk[IMX6QDL_CLK_SPDIF_SEL],
> clk[IMX6QDL_CLK_PLL3_PFD3_454M]);
> +       clk_set_parent(clk[IMX6QDL_CLK_SPDIF_SEL],
> clk[IMX6QDL_CLK_PLL4_AUDIO_DIV]);
> 
>         /* All existing boards with PCIe use LVDS1 */
>         if (IS_ENABLED(CONFIG_PCI_IMX6))
>

I'm going to try. I'll take a while. I'll report the result later.

Thank you very much.
Fabio Estevam Aug. 31, 2016, 2:02 p.m. UTC | #6
Hi Xavi,

On Wed, Aug 31, 2016 at 10:47 AM, Xavi Drudis Ferran <xdrudis@tinet.cat> wrote:

> If it's easy for you to send it yourself, I would prefer so and I'm
> grateful. If not, it'll be an exercise for me, no problem.

I have just submitted the patch with you on Cc.

If you could reply to it with your Tested-by tag, that would be great.

Thanks
Xavier Drudis Ferran Aug. 31, 2016, 5:49 p.m. UTC | #7
El Wed, Aug 31, 2016 at 03:49:25PM +0200, Xavi Drudis Ferran deia:
> El Wed, Aug 31, 2016 at 10:11:13AM -0300, Fabio Estevam deia:
> > 2. SPDIF clock rate not accurate. Probably using PLL4 as SPDIF source
> > would help to get more accurate SPDIF clock rates.
> > 
> > Could you please try the untested change?
> > 
> > --- a/drivers/clk/imx/clk-imx6q.c
> > +++ b/drivers/clk/imx/clk-imx6q.c
> > @@ -623,7 +623,7 @@ static void __init imx6q_clocks_init(struct
> > device_node *ccm_node)
> >                 pr_warn("failed to set up CLKO: %d\n", ret);
> > 
> >         /* Audio-related clocks configuration */
> > -       clk_set_parent(clk[IMX6QDL_CLK_SPDIF_SEL],
> > clk[IMX6QDL_CLK_PLL3_PFD3_454M]);
> > +       clk_set_parent(clk[IMX6QDL_CLK_SPDIF_SEL],
> > clk[IMX6QDL_CLK_PLL4_AUDIO_DIV]);
> > 
> >         /* All existing boards with PCIe use LVDS1 */
> >         if (IS_ENABLED(CONFIG_PCI_IMX6))
> >
> 
> I'm going to try. I'll take a while. I'll report the result later.
> 
> Thank you very much.

I just tried. Spdif output still works. I can't hear any difference. 

I've summarised the tests in a table:

Nominal    
Hz               32000      44100      48000      96000     192000
ns               31250      22676      20833      10417       5208

Linux-libre-4.7 (unchanged)   (no spdif output)                                                               
Hz               32226      43882      47965      95930     196428
ns               31031      22788      20849      10424       5091
deviation(ns)      219       -113        -15         -8        117

only core (SPDIF_GCLK), rxtx0 (CLK_OSC), rxtx1(SPDIF) & spba (spdif output)
Hz               31719      43859      47368      94736     187500
ns               31527      22800      21111      10556       5333
deviation(ns)     -277       -125       -278       -139       -125
 
without MLB (the rest  unchanged)   (spdif output)                         
Hz               32226      43859      47368      94736     187500
ns               31031      22800      21111      10556       5333
deviation(ns)      219       -125       -278       -139       -125

without MLB, and PLL4 instead of PLL3 for SPDIF (spdif output)               
Hz               32226      44836      49107      93750     187500
ns               31031      22304      20364      10667       5333
deviation(ns)      219        372        470       -250       -125

I saw page 121 of
http://cache.freescale.com/files/32bit/doc/data_sheet/IMX6DQIEC.pdf
And it seems like the the margin for the SPDIF clock would be 16 ns
so I've just inverted the frequencies to compare, but I'm not convinced
it's relevant. 

Here's the extract from dmesg with your patch (and .dtsi like mainline
except MLB replaced with DUMMY).

[...]
[    7.517394] etnaviv-gpu 130000.gpu: model: GC2000, revision: 5108
[    7.578089] imx_thermal 2000000.aips-bus:tempmon: Extended Commercial CPU temperature grade - max:105C critical:100C passive:95C
[    7.594443] etnaviv-gpu 2204000.gpu: model: GC355, revision: 1215
[    7.594454] etnaviv-gpu 2204000.gpu: Ignoring GPU with VG and FE2.0
[    7.594459] etnaviv-gpu 2204000.gpu: hw init failed: -6
[    7.653041] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe
[    7.656319] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.704159] fsl-spdif-dai 2004000.spdif: use rxtx5 as tx clock source for 32000Hz sample rate
[    7.711719] fsl-spdif-dai 2004000.spdif: use txclk df 16 for 32000Hz sample rate
[    7.718328] fsl-spdif-dai 2004000.spdif: use sysclk df 2 for 32000Hz sample rate
[    7.724762] fsl-spdif-dai 2004000.spdif: the best rate for 32000Hz sample rate is 32226Hz
[    7.732679] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.760087] fsl-spdif-dai 2004000.spdif: use rxtx5 as tx clock source for 44100Hz sample rate
[    7.766536] fsl-spdif-dai 2004000.spdif: use txclk df 1 for 44100Hz sample rate
[    7.772986] fsl-spdif-dai 2004000.spdif: use sysclk df 23 for 44100Hz sample rate
[    7.780120] fsl-spdif-dai 2004000.spdif: the best rate for 44100Hz sample rate is 44836Hz
[    7.788952] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.825238] fsl-spdif-dai 2004000.spdif: use rxtx5 as tx clock source for 48000Hz sample rate
[    7.831515] fsl-spdif-dai 2004000.spdif: use txclk df 7 for 48000Hz sample rate
[    7.837583] fsl-spdif-dai 2004000.spdif: use sysclk df 3 for 48000Hz sample rate
[    7.843718] fsl-spdif-dai 2004000.spdif: the best rate for 48000Hz sample rate is 49107Hz
[    7.849672] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.878632] fsl-spdif-dai 2004000.spdif: use rxtx0 as tx clock source for 96000Hz sample rate
[    7.884550] fsl-spdif-dai 2004000.spdif: use txclk df 4 for 96000Hz sample rate
[    7.890390] fsl-spdif-dai 2004000.spdif: the best rate for 96000Hz sample rate is 93750Hz
[    7.896253] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.921228] fsl-spdif-dai 2004000.spdif: use rxtx0 as tx clock source for 192000Hz sample rate
[    7.927034] fsl-spdif-dai 2004000.spdif: use txclk df 2 for 192000Hz sample rate
[    7.932809] fsl-spdif-dai 2004000.spdif: the best rate for 192000Hz sample rate is 187500Hz
[    7.938616] fsl-spdif-dai 2004000.spdif: imx_pcm_dma_init failed: -517
[    7.944791] fsl-ssi-dai 2028000.ssi: No cache defaults, reading back from HW
[    7.954697] fsl-asrc 2034000.asrc: driver registered
[    7.961411] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe
[    7.967622] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    7.992427] fsl-spdif-dai 2004000.spdif: use rxtx5 as tx clock source for 32000Hz sample rate
[    7.998228] fsl-spdif-dai 2004000.spdif: use txclk df 16 for 32000Hz sample rate
[    8.004122] fsl-spdif-dai 2004000.spdif: use sysclk df 2 for 32000Hz sample rate
[    8.009806] fsl-spdif-dai 2004000.spdif: the best rate for 32000Hz sample rate is 32226Hz
[    8.015572] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    8.044534] fsl-spdif-dai 2004000.spdif: use rxtx5 as tx clock source for 44100Hz sample rate
[    8.050294] fsl-spdif-dai 2004000.spdif: use txclk df 1 for 44100Hz sample rate
[    8.056069] fsl-spdif-dai 2004000.spdif: use sysclk df 23 for 44100Hz sample rate
[    8.061869] fsl-spdif-dai 2004000.spdif: the best rate for 44100Hz sample rate is 44836Hz
[    8.067662] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    8.092093] fsl-spdif-dai 2004000.spdif: use rxtx5 as tx clock source for 48000Hz sample rate
[    8.097916] fsl-spdif-dai 2004000.spdif: use txclk df 7 for 48000Hz sample rate
[    8.103769] fsl-spdif-dai 2004000.spdif: use sysclk df 3 for 48000Hz sample rate
[    8.109660] fsl-spdif-dai 2004000.spdif: the best rate for 48000Hz sample rate is 49107Hz
[    8.115488] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    8.141250] fsl-spdif-dai 2004000.spdif: use rxtx0 as tx clock source for 96000Hz sample rate
[    8.147179] fsl-spdif-dai 2004000.spdif: use txclk df 4 for 96000Hz sample rate
[    8.153066] fsl-spdif-dai 2004000.spdif: the best rate for 96000Hz sample rate is 93750Hz
[    8.158900] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    8.185506] fsl-spdif-dai 2004000.spdif: use rxtx0 as tx clock source for 192000Hz sample rate
[    8.191441] fsl-spdif-dai 2004000.spdif: use txclk df 2 for 192000Hz sample rate
[    8.197297] fsl-spdif-dai 2004000.spdif: the best rate for 192000Hz sample rate is 187500Hz
[    8.203477] fsl-spdif-dai 2004000.spdif: imx_pcm_dma_init failed: -517
[    8.210220] fsl-ssi-dai 2028000.ssi: No cache defaults, reading back from HW
[    8.653296] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe
[    8.678782] imx-spdif sound-spdif: ASoC: CPU DAI (null) not registered
[    8.682393] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    8.705822] imx-spdif sound-spdif: snd_soc_register_card failed: -517
[    8.735316] fsl-spdif-dai 2004000.spdif: use rxtx5 as tx clock source for 32000Hz sample rate
[    8.741460] fsl-spdif-dai 2004000.spdif: use txclk df 16 for 32000Hz sample rate
[    8.747889] fsl-spdif-dai 2004000.spdif: use sysclk df 2 for 32000Hz sample rate
[    8.754006] fsl-spdif-dai 2004000.spdif: the best rate for 32000Hz sample rate is 32226Hz
[    8.755063] sgtl5000 1-000a: sgtl5000 revision 0x11
[...]
[    8.776463] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    8.804281] fsl-spdif-dai 2004000.spdif: use rxtx5 as tx clock source for 44100Hz sample rate
[    8.810549] fsl-spdif-dai 2004000.spdif: use txclk df 1 for 44100Hz sample rate
[    8.816670] fsl-spdif-dai 2004000.spdif: use sysclk df 23 for 44100Hz sample rate
[    8.822881] fsl-spdif-dai 2004000.spdif: the best rate for 44100Hz sample rate is 44836Hz
[    8.829149] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    8.857633] fsl-spdif-dai 2004000.spdif: use rxtx5 as tx clock source for 48000Hz sample rate
[    8.864664] fsl-spdif-dai 2004000.spdif: use txclk df 7 for 48000Hz sample rate
[    8.871299] fsl-spdif-dai 2004000.spdif: use sysclk df 3 for 48000Hz sample rate
[    8.878169] fsl-spdif-dai 2004000.spdif: the best rate for 48000Hz sample rate is 49107Hz
[    8.885341] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    8.887272] 20ec000.sdma: Missing Free firmware (non-Free firmware loading is disabled)
[    8.887325] imx-sdma 20ec000.sdma: failed to get firmware from device tree
[    8.928411] fsl-spdif-dai 2004000.spdif: use rxtx0 as tx clock source for 96000Hz sample rate
[    8.932841] imx-sdma 20ec000.sdma: Direct firmware load for /*(DEBLOBBED)*/ failed with error -2
[    8.941518] fsl-spdif-dai 2004000.spdif: use txclk df 4 for 96000Hz sample rate
[    8.948104] fsl-spdif-dai 2004000.spdif: the best rate for 96000Hz sample rate is 93750Hz
[    8.954948] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    8.985543] fsl-spdif-dai 2004000.spdif: use rxtx0 as tx clock source for 192000Hz sample rate
[    8.992121] fsl-spdif-dai 2004000.spdif: use txclk df 2 for 192000Hz sample rate
[    8.998731] fsl-spdif-dai 2004000.spdif: the best rate for 192000Hz sample rate is 187500Hz
[...]
[    9.013319] fsl-spdif-dai 2004000.spdif: imx_pcm_dma_init failed: -517
[    9.029511] fsl-ssi-dai 2028000.ssi: No cache defaults, reading back from HW
[    9.052247] imx-spdif sound-spdif: ASoC: CPU DAI (null) not registered
[    9.061522] imx-spdif sound-spdif: snd_soc_register_card failed: -517
[    9.072088] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe
[    9.087019] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    9.120952] fsl-spdif-dai 2004000.spdif: use rxtx5 as tx clock source for 32000Hz sample rate
[    9.128069] fsl-spdif-dai 2004000.spdif: use txclk df 16 for 32000Hz sample rate
[    9.135255] fsl-spdif-dai 2004000.spdif: use sysclk df 2 for 32000Hz sample rate
[    9.142316] fsl-spdif-dai 2004000.spdif: the best rate for 32000Hz sample rate is 32226Hz
[    9.149247] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    9.181927] fsl-spdif-dai 2004000.spdif: use rxtx5 as tx clock source for 44100Hz sample rate
[    9.188687] sgtl5000 1-000a: Using internal LDO instead of VDDD
[    9.196207] fsl-spdif-dai 2004000.spdif: use txclk df 1 for 44100Hz sample rate
[    9.203005] fsl-spdif-dai 2004000.spdif: use sysclk df 23 for 44100Hz sample rate
[    9.209998] fsl-spdif-dai 2004000.spdif: the best rate for 44100Hz sample rate is 44836Hz
[    9.216928] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    9.250153] fsl-spdif-dai 2004000.spdif: use rxtx5 as tx clock source for 48000Hz sample rate
[    9.256987] fsl-spdif-dai 2004000.spdif: use txclk df 7 for 48000Hz sample rate
[    9.263890] fsl-spdif-dai 2004000.spdif: use sysclk df 3 for 48000Hz sample rate
[    9.270641] fsl-spdif-dai 2004000.spdif: the best rate for 48000Hz sample rate is 49107Hz
[    9.277343] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    9.305524] fsl-spdif-dai 2004000.spdif: use rxtx0 as tx clock source for 96000Hz sample rate
[    9.312400] fsl-spdif-dai 2004000.spdif: use txclk df 4 for 96000Hz sample rate
[    9.319041] fsl-spdif-dai 2004000.spdif: the best rate for 96000Hz sample rate is 93750Hz
[    9.325799] fsl-spdif-dai 2004000.spdif: enter fsl_spdif_probe_txclk
[    9.354693] fsl-asoc-card sound: sgtl5000 <-> 2028000.ssi mapping ok
[    9.357288] fsl-spdif-dai 2004000.spdif: use rxtx0 as tx clock source for 192000Hz sample rate
[    9.357293] fsl-spdif-dai 2004000.spdif: use txclk df 2 for 192000Hz sample rate
[    9.357298] fsl-spdif-dai 2004000.spdif: the best rate for 192000Hz sample rate is 187500Hz
[    9.470268] imx-spdif sound-spdif: snd-soc-dummy-dai <-> 2004000.spdif mapping ok
[...]
[   71.548012] fsl-spdif-dai 2004000.spdif: expected clock rate = 64915200
[   71.548027] fsl-spdif-dai 2004000.spdif: actual clock rate = 66000000
[   71.548043] fsl-spdif-dai 2004000.spdif: set sample rate to 44836Hz for 44100Hz playback
[   71.548054] fsl-spdif-dai 2004000.spdif: STCSCH: 0x304000
[   71.548065] fsl-spdif-dai 2004000.spdif: STCSCL: 0x000000
[   71.743796] fsl-spdif-dai 2004000.spdif: expected clock rate = 64915200
[   71.743812] fsl-spdif-dai 2004000.spdif: actual clock rate = 66000000
[   71.743823] fsl-spdif-dai 2004000.spdif: set sample rate to 44836Hz for 44100Hz playback
[   71.743844] fsl-spdif-dai 2004000.spdif: STCSCH: 0x304000
[   71.743867] fsl-spdif-dai 2004000.spdif: STCSCL: 0x000000

And when playing sound (spdif output works ok)

[  128.778530] fsl-spdif-dai 2004000.spdif: expected clock rate = 64915200
[  128.778549] fsl-spdif-dai 2004000.spdif: actual clock rate = 66000000
[  128.778560] fsl-spdif-dai 2004000.spdif: set sample rate to 44836Hz for 44100Hz playback
[  128.778575] fsl-spdif-dai 2004000.spdif: STCSCH: 0x304000
[  128.778583] fsl-spdif-dai 2004000.spdif: STCSCL: 0x000000


Thank you amd feel free to suggest more tests, but it is good enough
as it is for me.
Fabio Estevam Aug. 31, 2016, 6:02 p.m. UTC | #8
On Wed, Aug 31, 2016 at 2:49 PM, Xavi Drudis Ferran <xdrudis@tinet.cat> wrote:

> Thank you amd feel free to suggest more tests, but it is good enough
> as it is for me.

Ok, thanks for trying. So let's keep the SPDIF parent clock as is.
diff mbox

Patch

--- linux-4.7-no-spdif-out/arch/arm/boot/dts/imx6qdl.dtsi	2016-07-25 00:19:43.000000000 +0200
+++ linux-4.7/arch/arm/boot/dts/imx6qdl.dtsi	2016-08-30 12:51:37.369431791 +0200
@@ -242,7 +242,7 @@ 
 					clocks = <&clks IMX6QDL_CLK_SPDIF_GCLK>, <&clks IMX6QDL_CLK_OSC>,
 						 <&clks IMX6QDL_CLK_SPDIF>, <&clks IMX6QDL_CLK_ASRC>,
 						 <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_ESAI_EXTAL>,
-						 <&clks IMX6QDL_CLK_IPG>, <&clks IMX6QDL_CLK_MLB>,
+						 <&clks IMX6QDL_CLK_IPG>, <&clks IMX6QDL_CLK_DUMMY>,
 						 <&clks IMX6QDL_CLK_DUMMY>, <&clks IMX6QDL_CLK_SPBA>;
 					clock-names = "core",  "rxtx0",
 						      "rxtx1", "rxtx2",