Device Tree for new Audio codec under imx8qm Custom

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

Device Tree for new Audio codec under imx8qm Custom

3,805 Views
vinothkumars
Senior Contributor IV

Hi All,

 

I am working on IMX8QM Custom Platform. I unable to achieve new codec (nau8810) interface in my platform. Please find my below code and give your feedback.

 

Using I2C0 interface with SAI1

 

/* Do not have fsl codec interface driver, So I used the simple codec driver for interface */

+ sound{
+ compatible = "simple-audio-card";
+ lable = "nau8810-audio";
+ simple-audio-card,frame-master = <&nacpu>;
+ simple-audio-card,bitclock-master = <&nacpu>;
+ simple-audio-card,widgets = "Speaker", "Speaker";
+ simple-audio-card,routing = "Speaker", "Speaker";
+ simple-audio-card,dai-link {
+ format = "i2s";
+ cpu {
+ sound-dai = <&sai1 1>;
+ };
+ nacpu: codec {
+ sound-dai = <&nau8810>;
+ };
+ };
+ };

/* Under I2C0 */
+ nau8810: nau8810@1a {
+ #sound-dai-cells = <0>;
+ compatible = "nuvoton,nau8810";
+ reg = <0x1a>;
+ };


 

Regards,
Vinothkumar Sekar
0 Kudos
11 Replies

2,208 Views
KBL
Contributor I

@vinothkumars did you find a soulution? We have the same problem and get the error:

nau8810 0-001a: ASoC: error at snd_soc_component_update_bits on nau8810.0-001a: -6

 

Regards,

Blume

0 Kudos

3,638 Views
DhavalS
Contributor II

Hi Team,

I am working on the same task. We have shared the part of the schematic to provide the idea how the SOC SAI1 and  codec pins are interfaced.

Just to provide more info on machine driver and also some more details

file : sound/soc/fsl/fsl-asoc-card.c

With this interfacing, we can see clock as follows on SAI1_TXC_CODEC and so on MCLK pin of the codec

  • Configure codec as slave and format is I2S (SND_SOC_DAIFMT_I2S)
    • Format S16_LE and two channel
    • Clock for Sampling rate 8k = 256000HZ
    • Clock for Sampling rate 48k = 1536000HZ
    • Audio output = Only noise and no audio

 

  • Configure codec as slave and format is PCM (SND_SOC_DAIFMT_DSP_A)
    • Format S16_LE and two channel
    • Clock for Sampling rate 8k = 512000HZ
    • Clock for Sampling rate 48k = 3072000HZ
    • Audio output = Only noise and no audio

Can you please let us know that MCLK_OUT0 of the SOC need to connect with the Codec MCLK pin instead of the SAI1_TXC_CODEC pin?

Any pointers are really appreciated.

0 Kudos

3,623 Views
igorpadykov
NXP Employee
NXP Employee

>Can you please let us know that MCLK_OUT0 of the SOC need to connect with

>the Codec MCLK pin instead of the SAI1_TXC_CODEC pin?

 

for MCLK_OUT0 connection one can look at p.12, p.31 U43 NC7WV16, p.24

U29 WM8960 SPF-29420  MCIMX8QM-CPU MEK – Schematics

 

Best regards
igor

0 Kudos

3,615 Views
DhavalS
Contributor II

Hi Igor,

 

Thanks a lot for your quick reponse.

I have seen this MCLK_OUT0 is connected with Codec MCLK pin in MEK board.

But, same thing is not connected in our case so to get proper clock and make codec work is MCLK_OUT0 required to connect with MCLK pin of codec or that is not mandetory ?

 

We are using sai1 for connection with codec and codec is nau8810.

0 Kudos

3,601 Views
igorpadykov
NXP Employee
NXP Employee

> our case so to get proper clock and make codec work is MCLK_OUT0

>required to connect with MCLK pin of codec or that is not mandetory ?

 

suggest to ask tech support vendor of this codec, if nau8810 codec MCLK is mandatory:

https://www.nuvoton.com/support/technical-support/nuforum/

 

Best regards
igor

 

 

0 Kudos

3,583 Views
DhavalS
Contributor II

Thanks Igor for the reply.

Just give me one information that If we use SAI1_TXC pin for clock instead of MCLK_OUT0 pin then

Is there any software configuration required in machine driver or dts node?

 

Thanks & Regards,

Dhaval

0 Kudos

3,579 Views
igorpadykov
NXP Employee
NXP Employee

>use SAI1_TXC pin for clock instead of MCLK_OUT0 pin then

>Is there any software configuration required in machine driver or dts node?

 

sorry nxp did not use such configuration in its bsps.

 

Best regards
igor

0 Kudos

3,799 Views
igorpadykov
NXP Employee
NXP Employee

Hi Vinothkumar

 

for porting new codec one can look at Chapter 16 Porting Audio Codecs  i.MX Porting Guide​  

and Chapter 7 Audio   i.MX Linux Reference Manual​

 

Best regards
igor

0 Kudos

3,779 Views
vinothkumars
Senior Contributor IV

Thank you @igorpadykov ,

 

I did the configuration and codec also detecting now, But, I got error while capture and playback. and also there is no audio from speaker

 

root@root:~# cat /proc/asound/cards
0 [D59050000sainau]: 59050000_sai-na - 59050000.sai-nau8810-hifi
59050000.sai-nau8810-hifi

root@root:~# arecord -d 0 -f u8 viz.wav
Recording WAVE 'viz.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
[ 1066.472264] nau8810 3-001a: ASoC: error at snd_soc_component_update_bits on nau8810.3-001a: -110
[ 1067.488257] nau8810 3-001a: ASoC: error at snd_soc_component_update_bits on nau8810.3-001a: -110
[ 1068.504247] nau8810 3-001a: ASoC: error at snd_soc_component_update_bits on nau8810.3-001a: -110



root@root:~# aplay viz.wav
Playing WAVE 'viz.wav' : Unsigned 8 bit, Rate 8000 Hz, Mono
[ 1670.316265] nau8810 3-001a: ASoC: error at snd_soc_component_update_bits on nau8810.3-001a: -110
[ 1671.332247] nau8810 3-001a: ASoC: error at snd_soc_component_update_bits on nau8810.3-001a: -110
[ 1672.348247] nau8810 3-001a: ASoC: error at snd_soc_component_update_bits on nau8810.3-001a: -110

 

Regards,
Vinothkumar Sekar
0 Kudos

3,751 Views
vinothkumars
Senior Contributor IV

Thank you @igorpadykov for the reply,

Audio Codec DTS: 

/* Connected with I2C0 */
        nau8810: nau8810@1a {

                #sound-dai-cells = <0>;

                compatible = "nuvoton,nau8810";

                reg = <0x1a>;

                clocks = <&mclkout0_lpcg 0>;

                clock-names = "mclk";

                assigned-clocks = <&clk IMX_SC_R_AUDIO_PLL_0 IMX_SC_PM_CLK_PLL>,

                                <&clk IMX_SC_R_AUDIO_PLL_0 IMX_SC_PM_CLK_SLV_BUS>,

                                <&clk IMX_SC_R_AUDIO_PLL_0 IMX_SC_PM_CLK_MST_BUS>,

                                <&mclkout0_lpcg 0>;

                assigned-clock-rates = <786432000>, <49152000>, <12288000>, <12288000>;




        };

 

/* Connected with SAI1 */
        sound-nau8810{

                compatible = "simple-audio-card";

                lable = "nau8810-audio";

                simple-audio-card,frame-master = <&nacpu>;

                simple-audio-card,bitclock-master = <&nacpu>;

                simple-audio-card,widgets =

                        "Speaker", "Ext Spk",

                        "Microphone", "Mic Jack";

                simple-audio-card,routing =

                        "Ext Spk", "MONOOUT",

                        "Ext Spk", "SPKOUTP",

                        "Ext Spk", "SPKOUTN",

                        "MICN", "Mic Jack",

                        "MICP", "Mic Jack",

                        "Mic Jack", "Mic Bias";




                simple-audio-card,dai-link {

                        format = "i2s";

                        cpu {

                                sound-dai = <&sai1>;

                        };

                        nacpu: codec {

                                sound-dai = <&nau8810>;

                        };

                };

        };





But, problem I here I don't MCLK line. MCLK and BCLK are shorted. 

 

vinothkumars_1-1632829284504.png

 

So, There is no separate MCLK and BCLK

 

Regards,
Vinothkumar Sekar
0 Kudos

3,735 Views
vinothkumars
Senior Contributor IV

Hi @igorpadykov ,

 

Audio codec is working, But, I got noise instead of proper sound, Will you please check the device tree and schematic.

Regards,
Vinothkumar Sekar
0 Kudos