I wrote a codec driver and modified the "fsl-asoc-card.c" driver to work with my system, which went surprisingly well.
My system consists of the following:
iMX8M SAI2 connected to a TLV320ADC3100 with SAI/I2S interface plus I2C3 for register read/write.
The expectation is that the iMX8M provides MCLK out of its pin named:
And based on this, the TLV320ADC3100 will generate BCLK and WCLK (or BCLK and FS, as you wish).
I plan to have 44100Hz sampling rate, so that's what I set up in the I2C driver, which would result in a BCLK frequency of 705.6kHz (fs * bitdepth = 44100 Hz * 16bit)
After playing around with the device tree, I was finally able to get the output on the MCLK pin, but it looks "odd".
Here are the relevant entries:
With such a setting, the driver gets loaded, maps up to the SAI interface, everything looks sunny.
According to dmesg:
And I'm able to start a recording as a sound card gets registered:
Recording WAVE 'stdin' : Signed 16 bit Little Endian, Rate 44100 Hz, Mono
Now it hangs here and my oscilloscope shows the following on pins MCLK and BCLK:
GREEN -> MCLK (from iMX8)
YELLOW -> BCLK (from TLV320ADC3100 codec)
(This is a zoomed oscilloscope view, the unzoomed "preview" is on top, the zoomed part is on the bottom)
As you can see MCLK is around the expected 11.26 MHz (close enough for now...)
BCLK, generated by the CODEC TLV320ADC3100 also seems correct with its 702kHz (again, not perfect, but good for now)
The "odd" behavior is in-between, when it looks like the MCLK goes away, then returns (upper view is unzoomed, in the red rectangle MCLK disappears, then comes back again)
Any idea why this happens and how to fix it would be greatly appreciated!