This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TLV320DAC3100EVM-U: ASoC: error at snd_soc_component_update_bits on tlv320aic31xx-codec.

Part Number: TLV320DAC3100EVM-U
Other Parts Discussed in Thread: TLV320DAC3100,

Tool/software:

I integrated tlv320dac3100 into my linux IMX93QS93 board. It is working, I can test-speaker and aplay some wav files. Butthe thing that the first time I power the board and codec on I got error while testing it and I hear just noise when I test the speaker. I power them off and on again and magically the codec works fine without any error and I hear the correct sound coming out of speaker. 

The error I got :

 ~# aplay -D plughw:0,0 /usr/share/sounds/alsa/Rear_Right.wav
Playing WAVE '/usr/share/sounds/alsa/Rear_Right.w[   38.619370] tlv320aic31xx-codec 1-0018: ASoC: error at snd_soc_component_update_bits on tlv320aic31xx-codec.1-0018 for register: [0x00000040] -5
av' : Signed 16 bit Little Endian, Rate 48000 Hz, Mono

and when I test speaker I got an error but I can hear just noise coming out:

~# speaker-test -D plughw:0,0 -c 2 -r 48000 -F S16_LE -t sine -f 500

speaker-test 1.2.8

Playback device is plughw:0,0
Stream parameters are 48000[  156.926645] tlv320aic31xx-codec 1-0018: ASoC: error at snd_soc_component_update_bits on tlv320aic31xx-codec.1-0018 for register: [0x00000040] -5
Hz, S16_LE, 2 channels
Sine wave rate is 500.0000Hz
Rate set to 48000Hz (requested 48000Hz)
Buffer size range from 32 to 131072
Period size range from 16 to 8184
Using max buffer size 131072
Periods = 4
was set period_size = 4096
was set buffer_size = 131072
 0 - Front Left
 1 - Front Right
Time per period = 3.264035
 

Here it is my DT configuration: 

`

audio_clk: audio-clk {
		compatible = "fixed-clock";
		#clock-cells = <0>;
		clock-frequency = <12000000>; 
	};
	
	codec_audio: sound {
		compatible = "simple-audio-card";
		simple-audio-card,name = "tlv320dac3100-codec";
		simple-audio-card,format = "i2s";
		simple-audio-card,bitclock-master = <&cpu_dai>;
		simple-audio-card,frame-master = <&cpu_dai>;
		simple-audio-card,widgets =
			"Line", "Line Out",
			"Headphone", "Headphone Jack",
			"Speaker", "Speaker Out";
		simple-audio-card,routing =
			"Line Out", "HPL",
			"Line Out", "HPR",
			"Headphone Jack", "HPL",
			"Headphone Jack", "HPR";
		status = "okay";
		cpu_dai: simple-audio-card,cpu {
			sound-dai = <&sai1>;
		};
		codec_dai: simple-audio-card,codec {
			sound-dai = <&audio_codec>;
			clocks = <&audio_clk>;
		};
	};
};

&sai1 {
	#sound-dai-cells = <0>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_sai1>;
	assigned-clocks = <&clk IMX93_CLK_SAI1>;
	assigned-clock-parents = <&clk IMX93_CLK_AUDIO_PLL>;
	assigned-clock-rates = <12288000>;
	fsl,sai-mclk-direction-output;
	status = "okay";	
};

&lpi2c2 {
	clock-frequency = <400000>;
	pinctrl-names = "default", "gpio";
	pinctrl-0 = <&pinctrl_lpi2c2>;
	status = "okay";

	// Add TLV320AIC3100 audio codec node
	audio_codec: codec@18 {
		compatible = "ti,tlv320dac3100";
		pinctrl-names = "default";
		reg = <0x18>;
		#sound-dai-cells = <0>;
		reset-gpios = <&gpio4 9 GPIO_ACTIVE_LOW>;
		HPVDD-supply = <&reg_audio_pwr_3v3>; // 1.8V in the schematic BUT 3.3V in the TLV320AIC3100 datasheet !
		AVDD-supply = <&reg_audio_pwr_3v3>;
		DVDD-supply = <&reg_audio_pwr_1v8>;
		IOVDD-supply = <&reg_audio_pwr_3v3>;
		SPRVDD-supply = <&reg_audio_pwr_3v3>;
		SPLVDD-supply = <&reg_audio_pwr_3v3>;
		SPKVDD-supply = <&reg_audio_pwr_5v>;
	};
};


	pinctrl_lpi2c2: lpi2c2grp {
		fsl,pins = <
			MX93_PAD_I2C2_SCL__LPI2C2_SCL				0x40001a1e
			MX93_PAD_I2C2_SDA__LPI2C2_SDA				0x40001a1e
		>;
	};

What ids the problem here, is there something that I missed ? probably there is something missed related to device initialization !!

  • Hi,

    Yes, it seems like the codec is not being initialized properly in the driver or your settings. I will test this next week on an EVM, and I can ask our driver expert about the reset. You may need to send a reset pulse to the codec before sending audio out to re-initialize it, maybe your board does not send that reset pulse until it is restarted. Can you trigger the reset pulse while the board is on and the amplifier out is not working, and see if that makes it work again?

    Also, can you attach a schematic of your system?

    Best,
    Mir

  • Hi, Thank you for your reply. I've tried manually to trigger the reset pulse but seems nothing is happening. 

  • Hi,

    Thanks for the schematic and info. My thought is that maybe the power supplies are not sequenced correctly. In the datasheet, there is a "power supply recommendations" section that specifies that you should enable the speaker supplies (SPKVDD), digital supplies, and then analog supplies, waiting for each to become stable before the next. So, I would suggest seeing if you can monitor the sequencing of your power supplies on a scope, and see if there is a difference between the sequencing when you first power it on and have the output issue and after your power cycle that you are doing. You may also want to connect IOVDD to DVDD and not AVDD, as it is a digital supply as well, and may have an effect with the timing if the digital supplies are not stable before the analog supply. Let me know what you find with this, and if you need more help, you can post the sequencing here.

    One more recommendation is that the decoupling capacitors on the power supplies should be placed close to the pin physically. I don't think this is your issue but it is good to check just in case.

    Best,
    Mir

  • Hello, Thank you for the information. How about the evaluation module, I am using TLV320DAC3100EVM-U to test. and I power it once by connecting it to my pc via usb cable. I think in this case the power supply sequencing is done automatically!

    Currently, I don't get sound out anymore even if I power off/on the devices, it is always noise coming out(same configuration). 

    Note: The module works fine when I tested with my computer using Codec Control Software. 

  • One thing I forgot to mention, when I reset the codec manually, the next time I want to play some sound or try to change volume I got this errors :

    ~# speaker-test -D plughw:0,0 -c 2 -r 480000 -F S16_LE -t sine -f 500[  284.644945] tlv320aic31xx-codec 1-0018: aic31xx_wait_bits: Failed! 0x25 was 0x88 expected 0x0 (0, 0x80, 500000 us)
    [  284.655305] tlv320aic31xx-codec 1-0018: ASoC: POST_PMD: DAC Left event failed: -1
    [  285.685677] tlv320aic31xx-codec 1-0018: aic31xx_wait_bits: Failed! 0x25 was 0x88 expected 0x0 (0, 0x8, 500000 us)
    [  285.695958] tlv320aic31xx-codec 1-0018: ASoC: POST_PMD: DAC Right event failed: -1
    

  • Hi,

    So sorry about the late response. It is interesting that you no longer are able to hear sound even after a power cycle, but you were before. Can you do a register dump of the codec? Also, which version of the Linux kernel are you on, or which version of the device driver are you using? If the register dump does not help me figure it out, I can reach out to our Linux driver expert. It sounds like your system is configured incorrectly for the device. Can you explain why you chose the 12000000 clock and not 12288000 in the device tree? Also, what is the 400000 clock about? I am not an expert in device tree files, so my apologies if this does not help. 

    Let me know about the register dump and please check the clocks on your device tree file to make sure it is setting what you expect. I look forward to your response! 

    Best,
    Mir

  • I am using Linux-kernel 6.1, the device driver is the official driver from the kernel maintainers so it is same version of Linux kernel.

    12000000 is the codec mclk and it is suitable with the driver for 48kHz rate.
    - 12288000 = 12.288 MHz is the clock rates, as it is multiple of 48kHz, it should be okay. 
    - 400000  is or I2C communication does not interfere with or affect the audio clock I guess. 

    For some reason I can't access to registers(even when the codec was working fine I get the same with dump) as you can see here: 

    # i2cdump -y 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: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
    10: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
    20: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
    30: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
    40: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
    50: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
    60: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
    70: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
    80: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
    90: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
    a0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
    b0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
    c0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
    d0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
    e0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
    f0: XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX    XXXXXXXXXXXXXXXX
    

    Known, that I am able to change volume and mute/unmute through `alsamixer`

  • Hi again, I downloaded the driver source code from master, it should be the latest version, and added as kernel module to my build. 
    The driver now is complaining about a coefficient file `tlv320dac3100-coeffs.bin` from where I can get this file! do TI provide an example?

  • Hi,

    I think the coeffs.bin file is not an issue, in the driver code it is a "warning" that the device doesn't load any filter coefficients. If you are not trying to add a filter to your system I think this is not something you need to worry about. 

    As for the clocks, thanks for clarifying. I wasn't sure about the I2C clock, that is not the issue I think. But, having two different MCLKs in your clock tree is not great. In the driver, there is a default PLL configuration for an MCLK of 12000000, so can you change the 12.288MHz clock to 12MHz? It may help.

    The all XX in your I2C dump seems like it cannot read the registers since it may be busy with another process. Does this still happen if you don't have any other programs open? I am going to send our Linux expert this thread to see if we can figure out what your issue is, getting a register dump will be a huge help in the debugging process. Please let me know if changing that one clock helps at all!

    Best,
    Mir

  • Hi, good news, the codec is working again with the latest version of its kernel module source code, I downloaded the tlv320aic31xx source code and build it as LKM, I ignored the complaining about the coefficients by commenting the responsible lines. I had to adjust a bit the code to fit with my build and finally it is working without the noise.

    Regarding the `assigned-clock-rates` value it doesn't work with 12MHz, As I understood from my investigation that value should be multiple of 48KHz if you are working with 48kHz sample rates, so that's why I set it to 12.288MHz. 

    The MCLK of 12000000 it is supported for 48KHz in the kernel module as you can see here from the source code : 

        /* mclk/p    rate  pll: r  j     d     dosr ndac mdac  aors nadc madc */
    	/* 48k rate */
    	{ 1536000,  48000,	2, 32,   0,	128,   8,  2,	128,   8,  2},
    	{ 3072000,  48000,	1, 32,   0,	128,   8,  2,	128,   8,  2},
    	{12000000,  48000,	1, 8, 1920,	128,   8,  2,	128,   8,  2},
    	{12000000,  48000,	1, 7, 6800,	 96,   5,  4,	 96,   5,  4},
    	{12500000,  48000,	1, 7, 8643,	128,   8,  2,	128,   8,  2},


  • Hi,

    Great, glad it works with the most recent driver! We can close this thread now, unless you need more help? Let me know.

    Best,
    Mir