Verdin imx8mm with sound codec TLV320DAC3100

Hello,

I want to use an external sound codec TLV320DAC3100 on a Verdin Development Board V1.1C with a Verdin iMX8MM and BSP 5.7.1.

I made the following device tree overlay ‘verdin-imx8mm_tlv.dts’:

/dts-v1/;
/plugin/;

/ {
	compatible = "toradex,verdin-imx8mm";
};

&i2c4 {	
	#address-cells = <1>;
	#size-cells = <0>;

	// audio codec TLV320DAC3100
	tlv320aic31xx: tlv320aic31xx@18 {
		compatible = "ti,tlv320aic3100";
		reg = <0x18>;
		//gpio-reset = <&gpio3 06 GPIO_ACTIVE_LOW>;	// SODIMM 56
		#sound-dai-cells = <0>;

		HPVDD-supply = <&reg_3p3v>;
		SPRVDD-supply = <&reg_3p3v>;
		SPLVDD-supply = <&reg_3p3v>;
		AVDD-supply = <&reg_3p3v>;
		IOVDD-supply = <&reg_3p3v>;
		DVDD-supply = <&reg_3p3v>;

		status = "okay";
	};
};

// modify existing sound card for audio codec TLV320DAC3100
&sound_card {
	simple-audio-card,name = "tlv320aic3100";
	simple-audio-card,routing =
		"Speaker", "SPK";
	simple-audio-card,widgets =
		"Speaker", "Speaker";
};

&dailink_master {
	sound-dai = <&tlv320aic31xx>;
	system-clock-frequency = <12500000>; // this matches sai2
};

&sai2 {
	assigned-clock-rates = <12500000>;
};

// deactivate audio codec NAU8822
&nau8822_1a {
	status = "disabled";
};

But there are errors during boot (see attached dmesg.log, timestamp 5.075526)
It seems I have a problem with the MCLK of the codec. In the kernel source tlv320aic31xx.c, only 12 and 12,5 MHz are supported (see struct aic31xx_divs). But with the default device tree for the Verdin iMX8MM these values are not achievable. I only got 12684288 Hz or 11915637 Hz.

Do you have an advice how I solve this problem?

Best regards,
Markus

dmesg.log (28.2 KB)

Since the clock IMX8MM_AUDIO_PLL1_OUT is the parent clock of the sai2 (Line 696 of file imx8mm-verdin.dtsi) I tried to change this PLL-clock to a multiple of 12 MHz. But this didn’t work either.

Is it even possible to use the TLV320DAC3100 on a Verdin IMX8MM or do I have to use another codec?

Best regards,
Markus

I managed to get the codec get registered successfully by the kernel with the following device tree overlay:

/dts-v1/;
/plugin/;

#include <dt-bindings/clock/imx8mm-clock.h>
#include <dt-bindings/gpio/gpio.h>
#include "imx8mm-pinfunc.h"

/ {
	compatible = "toradex,verdin-imx8mm";
};

&iomuxc {
	// reset of codec (pulled-up as active-low)
	pinctrl_i2s_1_codec_reset: i2s1codecresetgrp {
		fsl,pins = <
			MX8MM_IOMUXC_NAND_DATA00_GPIO3_IO6		0x146	/* SODIMM 56 */
		>;
	};
};

&i2c4 {	
	#address-cells = <1>;
	#size-cells = <0>;

	// audio codec TLV320DAC3100
	tlv320aic31xx: tlv320aic31xx@18 {
		compatible = "ti,tlv320aic3100";
		reg = <0x18>;
		#sound-dai-cells = <0>;

		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_i2s_1_codec_reset>;
		gpio-reset = <&gpio3 06 GPIO_ACTIVE_LOW>;	// SODIMM 56

		HPVDD-supply = <&reg_3p3v>;
		SPRVDD-supply = <&reg_3p3v>;
		SPLVDD-supply = <&reg_3p3v>;
		AVDD-supply = <&reg_3p3v>;
		IOVDD-supply = <&reg_3p3v>;
		DVDD-supply = <&reg_3p3v>;

		status = "okay";
	};
};

// modify existing sound card for audio codec TLV320DAC3100
&sound_card {
	simple-audio-card,name = "tlv320aic3100";
	simple-audio-card,routing =
		"Speaker", "SPK";
	simple-audio-card,widgets =
		"Speaker", "Speaker";
};

&dailink_master {
	sound-dai = <&tlv320aic31xx>;
};

&sai2 {
	assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_REF_SEL>;
	assigned-clock-rates = <12000000>;
};

// deactivate audio codec NAU8822
&nau8822_1a {
	status = "disabled";
};

See the attached dmesg.log. The solution was, to assign a clock-parent to &sai2 with 24 MHz.

Now when I try to test the codec I get the error -19, that there is no device:

$ speaker-test

speaker-test 1.2.1

Playback device is default
Stream parameters are 48000Hz, S16_LE, 1 channels
Using 16 octaves of pink noise
ALSA lib ../../../alsa-lib-1.2.1.2/src/pcm/pcm_direct.c:1824:(_snd_pcm_direct_get_slave_ipc_offset) Invalid value for card
Playback open error: -19,No such device

There is no data transfer on the I2C or I2S lines.
Any ideas?

Best regards,
Markus

dmesg.log (27.2 KB)

Hi @Mowlwurf !

Could you please check alsamixer to see which sound card is being used by default? Also, using the alsamixer are you able to enable the speaker? Please share the dmesg log after performing configuration using alsamixer.

Please, also check the commands from this Audio (Linux) | Toradex Developer Center article. You can see that there is an example for speaker-test as well: please try to point to your specific sound card as well.

I understand that you are trying to use IMX8MM_AUDIO_PLL1_REF_SEL instead of the default IMX8MM_AUDIO_PLL1_OUT for &sai2. But could you please test with the default clock (IMX8MM_AUDIO_PLL1_OUT) again?

Also could you please share how are you connecting your codec to the module?

Best regards,
Henrique

Hi Henrique,

thank you for your reply.

When I try this then I get the errors during boot, that the MCLK has an unsupported frequency (12684288 Hz) and I have no soundcard at all. Please see the dmesg.log in my first post.

When I call alsamixer, I got the error cannot open mixer: No such device.
Alsamixer only opens, when I use alsamixer -Dsysdefault. There I can unmute the speaker and set the volume. The dmesg log is attached.
Pressing F6 to select the sound card, I see two entries: - (default) and 0 tlv320aic3100. When I try to select the default one I get the error Cannot open mixer device 'default'. No such device.

With speaker-test -Dsysdefault the test starts and I see traffic on all I2S-lines (BCLK, SYNC, DOUT, MCLK). But still no sound. We connected the module as follows:

The GPIO_Audio signal is not connected at the moment. The #Reset-Signal is tied to SODIMM_56.

Best regards,
Markus

dmesg.log (27.2 KB)

Hi @Mowlwurf !

Thanks for the information!

The fact that tlv320aic3100 is showing up in alsamixer is good, at least :slight_smile:
What happens when you try to select tlv320aic3100 and unmute it?

That is intriguing… does unmuting and increasing tlv320aic3100’s volume in alsamixer helps?

Could you please also share the output of:

cat /proc/asound/cards

and

cat /etc/asound.conf

If you want to use your tlv320aic3100 as the default sound card, please refer to Setting the default device - AlsaProject to learn how to set the default sound card to it.

Maybe your default sound card is by default pointing to nowhere?

Best regards,
Henrique

Hi @henrique.tx,

thank you for your help!

I finally got it to output a sound.
All this time I didn’t realize that I had to unmute not only the speaker, but also the output of the DAC.
Additionally there was a bug in my wire setup.

Another source of error was the /etc/asound.conf. I use the reference multimedia image with the built in asound.conf. In this the default sound card is set to the NAU8822. So I made the following entries:

pcm.default_card{
type hw
card "tlv320aic3100"
}

ctl.!default{
type hw
card "tlv320aic3100"
}

ctl.mixer0{
type hw
card "tlv320aic3100"
}

The sound quality is not necessarily good and also quite quiet. But that should be fixable.

Best regards,
Markus

Hi @Mowlwurf !

That is great that you could make it work!

Also, thanks for the feedback!

Have a great day!

Best regards,