TLV320AIC3100 Codec Porting for the IMX8MP Custom Board

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

TLV320AIC3100 Codec Porting for the IMX8MP Custom Board

Jump to solution
8,989 Views
Wobaffet
Senior Contributor I

Hello,

I am trying to port TLV320AIC3100 for a custom board with imx8mp MPU. I've problem when probing the device with the simple-card driver. Having an issue with the dai-link configuration. Can you detect the error on my configuration? It is based on this post. I have the below config for the DT.

 

/   {
...
     sound-tlv320aic31xx {
                compatible = "simple-audio-card";
                simple-audio-card,name = "tlv320aic31xx-Codec";
                simple-audio-card,format = "i2s";
                simple-audio-card,frame-master = <&codec_dai>;
                simple-audio-card,bitclock-master = <&codec_dai>;

                simple-audio-card,widgets =
                "Speaker", "MAK-SPEAKER";
                simple-audio-card,routing =
                "MAK-SPEAKER", "SPK";
                
                simple-audio-card,cpu {
                        sound-dai = <&sai3>;
                };
                codec_dai: simple-audio-card,codec {
                        sound-dai = <&tlv320aic31xx>;
                        system-clock-frequency = <IMX8MP_CLK_AUDIO_BLK_CTRL_SAI3_MCLK1>; /* this matches sai3 */
                };

        };
};
&i2c5 {
        clock-frequency = <100000>; /* Lower clock speed for external bus. */
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_i2c5>;
        status = "okay"; /* can1 pins conflict with i2c5 */
        tlv320aic31xx: tlv320aic31xx@18 {
                #sound-dai-cells=<0>;
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_dac_rst>;
                compatible = "ti,tlv320aic3100";
                reg = <0x18>;
               // clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI3_MCLK1>;
               // clock-names = "mclk";
                reset-gpios = <&gpio4 29 GPIO_ACTIVE_LOW>;
//                ai31xx-micbias-vg = <MICBIAS_OFF>;
                HPVDD-supply = <&buck4>;
                SPRVDD-supply = <&vdd_input>; 
                SPLVDD-supply = <&vdd_input>;
                AVDD-supply = <&buck4>;
                IOVDD-supply = <&buck5>;
                DVDD-supply = <&buck5>;
        };
};
&sai3 {
        #sound-dai-cells = <0>;
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_sai3>;
        assigned-clocks = <&clk IMX8MP_CLK_SAI3>;
        assigned-clock-parents = <&clk IMX8MP_AUDIO_PLL1_OUT>;
        assigned-clock-rates = <12288000>;
        clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI3_IPG>, <&clk IMX8MP_CLK_DUMMY>,
                 <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI3_MCLK1>, <&clk IMX8MP_CLK_DUMMY>,
                 <&clk IMX8MP_CLK_DUMMY>;
        clock-names = "bus", "mclk0", "mclk1", "mclk2", "mclk3";
       // fsl,sai-mclk-direction-output; Should Be commented TODO
        status = "okay";
};

 

My clocks and I2C dump can be seen as below:

root@imx8mp-lpddr4-evk:~# grep -E "clock|sai3" /sys/kernel/debug/clk/clk_summary 
   clock                          count    count    count        rate   accuracy phase  cycle    enable
sai3_mclk                            0        0        0           0          0     0  50000         Y
                sai3_mclk3_clk        0        0        0    49152000          0     0  50000         N
    sai3                              0        0        0    24000000          0     0  50000         N
       sai3_root                      0        0        0    24000000          0     0  50000         N
          sai3_mclk1_sel              0        0        0    24000000          0     0  50000         Y
             sai3_mclk1_clk           0        0        0    24000000          0     0  50000         N
          sai3_mclk2_sel              0        0        0    24000000          0     0  50000         Y
             sai3_mclk2_clk           0        0        0    24000000          0     0  50000         N
                         sai3_ipg_clk       0        0        0   400000000          0     0  50000         N

root@imx8mp-lpddr4-evk:~# i2cdump -y  -f 4 0x18
No size specified (using byte-data access)
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f    0123456789abcdef
00: 00 00 01 66 00 11 04 00 00 00 00 01 01 00 80 80    ..?f.??....??.??
10: 08 00 01 01 80 80 04 00 00 00 01 00 00 00 01 00    ?.?????...?...?.
20: 00 00 00 00 80 00 00 00 00 00 00 00 00 00 00 00    ....?...........
30: 00 00 00 02 32 12 03 02 02 11 10 00 01 04 00 14    ...?2??????.??.?
40: 0c 00 00 00 6f 38 00 00 00 00 00 ee 10 d8 7e e3    ?...o8.....???~?
50: 00 00 80 00 00 00 00 00 7f 00 00 00 00 00 00 00    ..?.....?.......
60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00    ................

Thank you in advance!

Best Regards.

0 Kudos
1 Solution
1,581 Views
Wobaffet
Senior Contributor I

Codec is probed when we moved back to 5.15 with the same configuration.

View solution in original post

0 Kudos
38 Replies
1,582 Views
Wobaffet
Senior Contributor I

Codec is probed when we moved back to 5.15 with the same configuration.

0 Kudos
1,148 Views
Adi99
Contributor I

Hi @Wobaffet 

its great to hear you codec is working

Can you share the full patch and debugg logs so we also verify our end.

0 Kudos
1,143 Views
Wobaffet
Senior Contributor I

Hello, the codec is not working yet, we don't see any movements on the MCLK. Here is our latest configuration on a new issue.

Thanks!

0 Kudos
1,713 Views
MJD
Contributor II

Hello @JorgeCas @Wobaffet @Adi99 @nxp 

I am getting bellow logs when i try to start pulseaudio --start
[ 1740.322659] fsl-sai 30c30000.sai: ASoC: error at snd_soc_dai_hw_params on 30c30000.sai: -22
[ 1740.331071] 30c30000.sai-tlv320aic3x-hifi: ASoC: error at __soc_pcm_hw_params on 30c30000.sai-tlv320aic3x-hifi: -22
[ 1740.344818] fsl-sai 30c30000.sai: failed to derive required Rx rate: 1411200
[ 1740.351902] fsl-sai 30c30000.sai: ASoC: error at snd_soc_dai_hw_params on 30c30000.sai: -22
[ 1740.360301] 30c30000.sai-tlv320aic3x-hifi: ASoC: error at __soc_pcm_hw_params on 30c30000.sai-tlv320aic3x-hifi: -22
[ 1740.371158] fsl-sai 30c30000.sai: failed to derive required Rx rate: 1411200
[ 1740.378237] fsl-sai 30c30000.sai: ASoC: error at snd_soc_dai_hw_params on 30c30000.sai: -22
[ 1740.386635] 30c30000.sai-tlv320aic3x-hifi: ASoC: error at __soc_pcm_hw_params on 30c30000.sai-tlv320aic3x-hifi: -22
[ 1740.397486] fsl-sai 30c30000.sai: failed to derive required Rx rate: 1411200
[ 1740.404569] fsl-sai 30c30000.sai: ASoC: error at snd_soc_dai_hw_params on 30c30000.sai: -22
[ 1740.412972] 30c30000.sai-tlv320aic3x-hifi: ASoC: error at __soc_pcm_hw_params on 30c30000.sai-tlv320aic3x-hifi: -22
[ 1740.423770] fsl-sai 30c30000.sai: failed to derive required Rx rate: 1411200
[ 1740.430851] fsl-sai 30c30000.sai: ASoC: error at snd_soc_dai_hw_params on 30c30000.sai: -22
[ 1740.439251] 30c30000.sai-tlv320aic3x-hifi: ASoC: error at __soc_pcm_hw_params on 30c30000.sai-tlv320aic3x-hifi: -22
[ 1740.450095] fsl-sai 30c30000.sai: failed to derive required Rx rate: 1411200
[ 1740.457177] fsl-sai 30c30000.sai: ASoC: error at snd_soc_dai_hw_params on 30c30000.sai: -22
[ 1740.465576] 30c30000.sai-tlv320aic3x-hifi: ASoC: error at __soc_pcm_hw_params on 30c30000.sai-tlv320aic3x-hifi: -22
[ 1740.479482] fsl-sai 30c30000.sai: failed to derive required Rx rate: 1411200
[ 1740.486571] fsl-sai 30c30000.sai: ASoC: error at snd_soc_dai_hw_params on 30c30000.sai: -22

Bellow are the dts inputs,
1 sound-tlv320aic310x {
152 compatible = "simple-audio-card";
153 simple-audio-card,name = "sound-tlv320aic310x";
154 simple-audio-card,format = "i2s";
155 simple-audio-card,bitclock-master = <&cpudai2>;
156 simple-audio-card,frame-master = <&cpudai2>;
157 simple-audio-card,mclk-fs = <256>;
158 simple-audio-card,widgets =
159 "Microphone", "Microphone Jack",
160 "Line", "Line In Jack",
161 "Line", "Line Out Jack",
162 "Headphone", "Headphone Jack",
163 "Speaker", "Speaker External";
164 simple-audio-card,routing =
165 "Headphone Jack", "HPLOUT",
166 "Headphone Jack", "HPROUT";
167 cpudai2:simple-audio-card,cpu {
168 sound-dai = <&sai3>;
169 };
170 simple-audio-card,codec {
171 sound-dai = <&codec>;
172 clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI3_MCLK1>;
173 };
174 };

660 &i2c3 {
661 clock-frequency = <400000>;
662 pinctrl-names = "default", "gpio";
663 pinctrl-0 = <&pinctrl_i2c3>;
664 status = "okay";
665
666 codec: codec@18 {
667 #sound-dai-cells=<0>;
668 pinctrl-names = "default";
669 pinctrl-0 = <&pinctrl_tlv320>;
670 compatible = "ti,tlv320aic3x";
671 reg = <0x18>;
672 reset-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>;
673 IOVDD-supply = <&buck5>;
674 DVDD-supply = <&buck5>;
675 AVDD-supply = <&buck4>;
676 DRVDD-supply = <&buck4>;
677 };
678
&sai3 {
903 #sound-dai-cells = <0>;
904 pinctrl-names = "default";
905 pinctrl-0 = <&pinctrl_sai3>;
906 assigned-clocks = <&clk IMX8MP_CLK_SAI3>;
907 assigned-clock-parents = <&clk IMX8MP_AUDIO_PLL1_OUT>;
908 assigned-clock-rates = <12288000>;
909 clocks = <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI3_IPG>, <&clk IMX8MP_CLK_DUMMY>,
910 <&audio_blk_ctrl IMX8MP_CLK_AUDIO_BLK_CTRL_SAI3_MCLK1>, <&clk IMX8MP_CLK_DUMMY>,
911 <&clk IMX8MP_CLK_DUMMY>, <&clk IMX8MP_AUDIO_PLL1_OUT>, <&clk IMX8MP_AUDIO_PLL2_OUT>;
912 clock-names = "bus", "mclk0", "mclk1", "mclk2", "mclk3", "pll8k", "pll11k";
913 fsl,sai-synchronous-rx;
914 status = "okay";
915 };

pinctrl_tlv320: tlv320grp {
1254 fsl,pins = <
1255 MX8MP_IOMUXC_GPIO1_IO10__GPIO1_IO10 0x00
1256 >;
1257 };
1258
1259 pinctrl_sai3: sai3grp {
1260 fsl,pins = <
1261 MX8MP_IOMUXC_SAI3_TXFS__AUDIOMIX_SAI3_TX_SYNC 0xd6
1262 MX8MP_IOMUXC_SAI3_TXC__AUDIOMIX_SAI3_TX_BCLK 0xd6
1263 MX8MP_IOMUXC_SAI3_RXD__AUDIOMIX_SAI3_RX_DATA00 0xd6
1264 MX8MP_IOMUXC_SAI3_TXD__AUDIOMIX_SAI3_TX_DATA00 0xd6
1265 MX8MP_IOMUXC_SAI3_MCLK__AUDIOMIX_SAI3_MCLK 0xd6
1266 MX8MP_IOMUXC_SAI3_RXFS__GPIO4_IO28 0xd6
1267 MX8MP_IOMUXC_SAI3_RXC__GPIO4_IO29 0xd6
1268 >;
1269 };
root@imx8mp-lpddr4-evk:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: btscoaudio [bt-sco-audio], device 0: 30c20000.sai-bt-sco-pcm-wb bt-sco-pcm-wb-0 [30c20000.sai-bt-sco-pcm-wb bt-sco-pcm-wb-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 1: soundtlv320aic3 [sound-tlv320aic310x], device 0: 30c30000.sai-tlv320aic3x-hifi tlv320aic3x-hifi-0 [30c30000.sai-tlv320aic3x-hifi tlv320aic3x-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 2: audiohdmi [audio-hdmi], device 0: i.MX HDMI i2s-hifi-0 [i.MX HDMI i2s-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0
root@imx8mp-lpddr4-evk:~#
 

root@imx8mp-lpddr4-evk:~# aplay -f S16_LE -c 1 -r 48000 --device plughw:1,0 Rear_Center.wav
Playing WAVE 'Rear_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
^CAborted by signal Interrupt...
aplay: pcm_write:2127: write error: Interrupted system call
root@imx8mp-lpddr4-evk:~# aplay -f S16_LE -c 2 -r 8000 --device plughw:1,0 Rear_Center.wav
Playing WAVE 'Rear_Center.wav' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono
^CAborted by signal Interrupt...
aplay: pcm_write:2127: write error: Interrupted system call
root@imx8mp-lpddr4-evk:~#
root@imx8mp-lpddr4-evk:~#
root@imx8mp-lpddr4-evk:~# grep -E "clock|sai3" /sys/kernel/debug/clk/clk_summary
clock count count count rate accuracy phase cycle enable
sai3_mclk 0 0 0 0 0 0 50000 Y
sai3_mclk3_clk 0 0 0 49152000 0 0 50000 N
sai3_mclk2_sel 0 0 0 24000000 0 0 50000 Y
sai3_mclk2_clk 0 0 0 24000000 0 0 50000 N
sai3_ipg_clk 0 0 0 400000000 0 0 50000 N
sai3 0 0 0 12288000 0 0 50000 N
sai3_root 0 0 0 12288000 0 0 50000 N
sai3_mclk1_sel 0 0 0 12288000 0 0 50000 Y
sai3_mclk1_clk 0 0 0 12288000 0 0 50000 N
root@imx8mp-lpddr4-evk:~#

We are not able listen music, but some buss sound we can listen.

Guide me if in any changes required are any necessary things to check.





0 Kudos
1,890 Views
Wobaffet
Senior Contributor I

Hello MJD, sorry for the late response. Can you please share the

cat /sys/kernel/debug/devices_deferred output.

Thanks!

0 Kudos
1,883 Views
MJD
Contributor II

root@imx8mp-lpddr4-evk:~# cat /sys/kernel/debug/devices_deferred
sound-tlv320aic3101 asoc-simple-card: parse error

root@imx8mp-lpddr4-evk:~# i2cdump -y -f 2 0x18
No size specified (using byte-data access)
0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00: 00 00 00 10 04 00 00 00 00 00 00 01 00 00 00 80 ...??......?...?
10: 80 ff ff 78 78 78 78 78 78 06 00 fe 00 00 fe 00 ?..xxxxxx?.?..?.
20: 20 0c 00 00 00 00 00 00 00 00 00 80 80 00 00 00 ?.........??...
30: 00 00 00 04 00 00 00 00 00 00 04 00 00 00 00 00 ...?......?.....
40: 00 04 00 00 00 00 00 00 04 00 00 00 00 00 00 00 .?......?.......
50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
60: 00 00 00 00 00 00 02 00 00 00 00 00 00 00 00 00 ......?.........
70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
80: 00 00 00 10 04 00 00 00 00 00 00 01 00 00 00 80 ...??......?...?
90: 80 ff ff 78 78 78 78 78 78 06 00 fe 00 00 fe 00 ?..xxxxxx?.?..?.
a0: 20 0c 00 00 00 00 00 00 00 00 00 80 80 00 00 00 ?.........??...
b0: 00 00 00 04 00 00 00 00 00 00 04 00 00 00 00 00 ...?......?.....
c0: 00 04 00 00 00 00 00 00 04 00 00 00 00 00 00 00 .?......?.......
d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
e0: 00 00 00 00 00 00 02 00 00 00 00 00 00 00 00 00 ......?.........
f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
root@imx8mp-lpddr4-evk:~# grep -E "clock|sai3"
^Z
[1]+ Stopped(SIGTSTP) grep -E "clock|sai3"
root@imx8mp-lpddr4-evk:~# grep -E "clock|sai3" /sys/kernel/debug/c
cec/ clear_warn_once clk/
root@imx8mp-lpddr4-evk:~# grep -E "clock|sai3" /sys/kernel/debug/clk/clk_summary
clock count count count rate accuracy phase cycle enable
sai3_mclk 0 0 0 0 0 0 50000 Y
sai3_mclk3_clk 0 0 0 49152000 0 0 50000 N
sai3_mclk2_sel 0 0 0 24000000 0 0 50000 Y
sai3_mclk2_clk 0 0 0 24000000 0 0 50000 N
sai3_ipg_clk 0 0 0 400000000 0 0 50000 N
sai3 0 0 0 12288000 0 0 50000 N
sai3_root 0 0 0 12288000 0 0 50000 N
sai3_mclk1_sel 0 0 0 12288000 0 0 50000 Y
sai3_mclk1_clk 0 0 0 12288000 0 0 50000 N
root@imx8mp-lpddr4-evk:~# i2cdetect -y 2
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- 18 -- -- -- -- -- -- --
20: UU -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
zcat /proc/config
CONFIG_SND_SOC_TLV320AIC31XX=m
CONFIG_SND_SOC_TLV320AIC32X4=m
CONFIG_SND_SOC_TLV320AIC32X4_I2C=m
# CONFIG_SND_SOC_TLV320AIC32X4_SPI is not set
CONFIG_SND_SOC_TLV320AIC3X=y
CONFIG_SND_SOC_TLV320AIC3X_I2C=y
# CONFIG_SND_SOC_TLV320AIC3X_SPI is not set
# CONFIG_SND_SOC_TLV320ADCX140 is not set
# CONFIG_SND_SOC_TS3A227E is not set

I am i attaching the dts file

0 Kudos
1,877 Views
Wobaffet
Senior Contributor I

Hello,

We have the same problem and unfortunately, we don't have any solution yet. However, we've also asked TI about this matter maybe their suggestions can help you.

Best Regards.

0 Kudos
1,871 Views
MJD
Contributor II

Hello @Wobaffet 
I had an doubt with my dts file attached in the previous message, pls clarify wither the @i2c3 bus. 
voltage supply parameters given to the codec are correct? 

0 Kudos
1,867 Views
Wobaffet
Senior Contributor I

They seem to be okay, also you can manually copy the ko for the codec driver assuming tlv320aic31xx.ko is not included in your image, and then you can dynamically debug the issues if there exists one. As I recall there should be debug statements within the tlv320aic31xx driver.

0 Kudos
7,034 Views
Wobaffet
Senior Contributor I

Hello, @MJD  unfortunately no luck. Are you using the same MPU?

 

0 Kudos
7,025 Views
MJD
Contributor II

hi @Wobaffet 
Actually i do not see tlv320aic3101 chip got probed, can you please guide me to fix, i have attached dt file. 

0 Kudos
7,033 Views
MJD
Contributor II

Yes. with tlv320aci3101 chip

Tags (1)
0 Kudos
7,042 Views
MJD
Contributor II

hi @Wobaffet 
Did you got the solution, if so please can share me the DT file.. 

0 Kudos
7,283 Views
Adi99
Contributor I

Hi @Wobaffet 

you got any solutions? i am also using same codec chip for my custom board.

 

 

0 Kudos
7,319 Views
Wobaffet
Senior Contributor I

Hello Thomas,

Unfortunately I couldn't find any solution. TI suggested this working configuration. But also did not worked for me. Maybe you can also check it could work out for you. If so can you let me know? 

https://e2e.ti.com/support/audio-group/audio/f/audio-forum/1269307/tlv320aic3100-tlv320aic3100-24mhz...

Best Regards.

0 Kudos
7,288 Views
Adi99
Contributor I

Hi @Wobaffet 

 

What is the problem you are facing?

chip is not probed ? OR 

issue you are facing related audio-card?

 

0 Kudos
7,286 Views
Wobaffet
Senior Contributor I

Well, tlv320aic31xx i2c driver is probed successfully but aic31xx_codec_probe function is not being called, also SAI peripheral and audio-card driver is deferred. I've tried both simple-audio card driver and fsl-asoc-card driver, the situation is the same for both audio-card drivers.

 

0 Kudos
7,280 Views
Adi99
Contributor I

Yes exactly same issue is i am facing.

i2c chip is probed but the issue in  simple-audio card driver and fsl-asoc-card driver . 

 

also in dts file its gives me below error:

/sound-tlv320aic31xx: Reference to non-existent node or label "codec_tlv"

codec_tlv node is already available in dts file.

0 Kudos
7,262 Views
Wobaffet
Senior Contributor I

For the non-existent problem, have you checked the generated dtb if the node is created or not?

And if you can find a solution regarding the audio card driver could you share the solution?

Thank you in advance! 

Best Regards.

0 Kudos
7,899 Views
JorgeCas
NXP TechSupport
NXP TechSupport

Hello, I hope you are doing well.

We do not have a specific device tree configuration for TLV320AIC3100 codec but, we have a device tree example from the EVK board and also some documentation that you could use as a reference for your design.

simple-card.yaml 

tlv320aic31xx.txt 

fsl-asoc-card.txt 

imx8mp-evk.dts 

What it the issue that you are presenting with dai-link configuration?

Best regards.

0 Kudos