How to setup sai1 tdm mode for imx8mq-evk?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to setup sai1 tdm mode for imx8mq-evk?

4,812 Views
johnadamson
Contributor III

The end goal is to configure sai1, txd0 for 8 frame, 32-bit, TDM mode (if it's not already) under Yocto Linux. 

In "fsl-imx8mq-evk.dts", I see "fsl,sai-multi-lane" and "fsl,dataline,dsd = ...", but there's no mention (that I can find) in the devicetree documentation fsl-sai.txt file to describe either of these two options.   

I don't know if I'm even looking in the right place given my goal.  Where should the sai be configured under Linux?  

For what it's worth, I think I see how the ak4458 gets configured in alsa.state and alsa.conf, but I'm guessing that this will tell the ak4458 driver how to configure the ak4458, and what I really need is the other end, the sai configuration.  

John

0 Kudos
Reply
8 Replies

3,830 Views
johnadamson
Contributor III

Update, and a follow-up question involving the same setup.  I've had some luck hacking at the fsl_sai.c driver to support 8-frame tdm on sai1 and successfully drove an AKM4458 eval board with the imx8mq eval board as frame sync and bit clock master.  The next step is to configure the imx8mq eval board as frame sync and bit clock slave instead of master.  

I thought this would be as simple as:

  • NOT setting the BCD bit in TCR2
  • NOT setting the FSD bit in TCR4

But having done this, and confirming the register settings (and supplying the external frame sync and bit clock), I no longer see data on the transmit line, and the 'play' operation eventually errors out with an I/O error.  To add to the mystery, MCLK is no longer being generated by the imx8mq EVK.  I thought that would have been independent of the two bits in the TCR2 and TCR4 registers.

Is there something else that must be done in software or the kernel configuration to change a working SAI1 clock master to a clock slave ?

John

0 Kudos
Reply

3,830 Views
johnadamson
Contributor III
0 Kudos
Reply

3,830 Views
sreedhar_appala
Contributor IV

Hi John,

Good day!!

I understand from your post https://community.nxp.com/thread/499282 , you made tdm operation succesful in sai1 as master.

Could you please let us know the changes you have made to the fsl_sai.c diver for supporting tdm operation.

Could you please post the patch of it.

Thank you, Sreedhar

0 Kudos
Reply

3,830 Views
johnadamson
Contributor III

Sorry it's taken a while to respond, but that was quite a while ago and I'm still trying to remember what I did.   It doesn't readily take the form of a "patch" and in the end, there's very little, if anything, different in fsl_sai.c, and a whole lot of changes in other places.   The sai driver is, I think, set up to handle tdm mode, the trick is to create a codec driver that configures the sai driver with the proper parameters.  In the end, I created a new imx- "codec" file based on an existing codec, added my own parameters for my codec in the devicetree so that I could set the format and the tdm width from the devicetree, and then added the codec to the kernel config so it could be selected and built in the kernel configuration and build.   

You might be able to shorten some of those steps by creating your own imx-codec file, but simply hardcode the slots, width and fmt into the imx_(yourcodecname)_hw_params() function.  Take a look at imx-ak4485.c and the calls to snd_soc_dai_set_fmt() and snd_soc_dai_set_tdm_slot().  

Hope this helps.  If you still want to see my version of the "not a codec" codec driver, I can provide it, but it may take me a while to clean up the code to be presentable.  

John

0 Kudos
Reply

3,830 Views
sreedhar_appala
Contributor IV

Thank you John,

your suggestions will help me a lot and I will try to implement the tdm mode in SAI driver.

thank you once again,

Sreedhar

0 Kudos
Reply

3,830 Views
igorpadykov
NXP Employee
NXP Employee

Hi John

tdm is supported in sai driver linux/sound/soc/fsl/fsl_sai.c

fsl_sai.c\fsl\soc\sound - linux-imx - i.MX Linux kernel 

fsl-sai.txt\sound\bindings\devicetree\Documentation - linux-imx - i.MX Linux kernel 

unfortunately there are no tdm configurations which could be set in dts file.

fsl-sai.txt\sound\bindings\devicetree\Documentation - linux-imx - i.MX Linux kernel 

one can check driver for tdm settings, in fsl_sai_set_dai_tdm_slot(), sai->slot_width = slot_width;

and set them to necessary values.

Best regards
igor
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

3,830 Views
johnadamson
Contributor III

Hi, Igor,

Thank you for replying, but I'm not sure you completely understood.  I know about the documentation you linked to in your reply, I specifically mentioned them in my original.  But there are two options included in the devicetree for the evk (and apparently supported in the sai driver, from what I can tell) that are not included in the documentation.   I'd like to know what "sai-multi-lane" and "dataline,dsd = ..." do.  

As for your suggestion to set the slot widths, please forgive my ignorance, but how would that best be accomplished?  In a user-space app ?  Wouldn't it be better to modify the fsl_sai.c driver to support TDM options in the devicetree?  Or is that more complicated than it seems?  

John

0 Kudos
Reply

3,830 Views
igorpadykov
NXP Employee
NXP Employee

Hi John

unfortunately currently there are no tdm configurations which could be set through dts file,

so one will have to change sai driver according to tdm configuration for used codec (that

should be described in codec datasheet).

> I'd like to know what "sai-multi-lane" and "dataline,dsd = ..." do.  

one can check driver sources: driver linux/sound/soc/fsl/fsl_sai.c

fsl_sai.c\fsl\soc\sound - linux-imx - i.MX Linux kernel

Note NXP has special service for helping porting drivers for customer needs

NXP Professional Services | NXP 

Best regards
igor

0 Kudos
Reply