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.

BEAGL-BONE-BLACK: DT changes for am335x-boneblack-common.dtsi for TLV320AIC3256

Part Number: BEAGL-BONE-BLACK
Other Parts Discussed in Thread: TLV320AIC3256, TLV320AIC3256EVM-U, AM3358, TLV320AIC3106

Hi,

We are trying to configure TLV320AIC3256 Audio Codec with Beagle Bone Black Rev C.

Following are the DT node changes we made:

&i2c2 {

	status = "okay";
	//tda19988: tda19988@70 {
	//	compatible = "nxp,tda998x";
	//	reg = <0x70>;
	//	nxp,calib-gpios = <&gpio1 25 0>;
	//	interrupts-extended = <&gpio1 25 IRQ_TYPE_LEVEL_LOW>;
	//
	//	pinctrl-names = "default", "off";
	//	pinctrl-0 = <&nxp_hdmi_bonelt_pins>;
	//	pinctrl-1 = <&nxp_hdmi_bonelt_off_pins>;

		/* Convert 24bit BGR to RGB, e.g. cross red and blue wiring */
		/* video-ports = <0x234501>; */

	//	#sound-dai-cells = <0>;
	//	audio-ports = <	TDA998x_I2S	0x03>;

	//	ports {
	//		port@0 {
	//			hdmi_0: endpoint@0 {
	//				remote-endpoint = <&lcdc_0>;
	//			};
	//		};
	//	};
	//};

	tlv320aic32x6: tlv320aic32x6@18 {
		status = "okay";
		compatible = "ti,tlv320aic32x6";
		reg = <0x18>;
		ldoin-supply = <&reg_audio_3v3>;
		iov-supply = <&reg_audio_3v3>;
	};

};

sound {
    ...
		simple-audio-card,codec {
			sound-dai = <&tlv320aic32x6>;
		};
	...
};

reg_audio_3v3: regulator-audio-3v3 {
		compatible = "regulator-fixed";
		regulator-name = "VCC3V3_AUDIO";
		regulator-min-microvolt = <3300000>;
		regulator-max-microvolt = <3300000>;
		regulator-always-on;
};

&am33xx_pinmux {
    ...
    mcasp0_pins: mcasp0_pins {
		pinctrl-single,pins = <
			AM33XX_PADCONF(AM335X_PIN_MCASP0_AHCLKX, PIN_INPUT_PULLUP, MUX_MODE0) /* mcasp0_ahcklx.mcasp0_ahclkx */
			AM33XX_PADCONF(AM335X_PIN_MCASP0_AHCLKR, PIN_OUTPUT_PULLDOWN, MUX_MODE2) /* mcasp0_ahclkr.mcasp0_axr2*/
			AM33XX_PADCONF(AM335X_PIN_MCASP0_FSX, PIN_OUTPUT_PULLUP, MUX_MODE0)
			AM33XX_PADCONF(AM335X_PIN_MCASP0_ACLKX, PIN_OUTPUT_PULLDOWN, MUX_MODE0)
			AM33XX_PADCONF(AM335X_PIN_MCASP0_AXR0, PIN_OUTPUT_PULLDOWN, MUX_MODE0)
			AM33XX_PADCONF(AM335X_PIN_GPMC_A11, PIN_OUTPUT_PULLDOWN, MUX_MODE7) /* gpmc_a11.GPIO1_27 */
		>;
    };
    ...
};

We have made the following connections between the Audio Codeck EVK and BBB:

We are receiving this error during the kernel boot up: 'tlv320aic32x4 2-0018: Failed to parse DT node'

We are also not able to figure out if we need to add I2C2 pins config in the DT because in am335x-boneblack.dts we see in Port 0 pins i2c2 mentioned,

&gpio0 {
        gpio-line-names =
                ...
                "P9_20 [i2c2_sda]",
                "P9_19 [i2c2_scl]",
                ...;
};

  • Hello,

    Have you tried to add print statements to the tlv320aic32x4 driver to figure out what failed to parse the DT node?

    Regards,
    Krunal

  • Hi Krunal,

    We were able to find out that not defining the clock in the tlv320aic32x6 node is what triggered that error. I am still confused as to how to define this clock property. Below is the updated i2c2 node that I am working with:

    &i2c2 {
    
            pinctrl-names = "default";
            pinctrl-0 = <&i2c2_pins>;
            status = "okay";
            tlv320aic32x6: tlv320aic32x6@18 {
                    compatible = "ti,tlv320aic32x6";
                    reg = <0x18>;
                    #clock-cells = <0>;
                    clock-names = "mclk";
                    //clocks = <117>;
                    clocks = <&gpio3 21 0>;
                    ldoin-supply = <&reg_audio_3v3>;
                    iov-supply = <&reg_audio_3v3>;
                    status = "okay";
            };
    };
    
    &am33xx_pinmux {
            ...
            i2c2_pins: i2c2_pins {
                    pinctrl-single,pins = <
                            AM33XX_PADCONF(AM335X_PIN_UART1_RTSN, PIN_INPUT, MUX_MODE3) /* UART1_RTSN.I2C2_SCL*/
                            AM33XX_PADCONF(AM335X_PIN_UART1_CTSN, PIN_INPUT, MUX_MODE3) /* UART1_RTSN.I2C2_SDA*/
                    >;
            };
            ...
    };

    For the clock, we used the same pin that we are using as MCLK for I2S

    But now we can see in the kernel logs that for some reason tlv320aic32x6 is being probed with i2c0 instead of i2c2

    Error: 

    [ 13.121743] OF: /ocp/interconnect@48000000/segment@100000/target-module@9c000/i2c@0/tlv320aic32x6@18: could not get #clock-cells for /ocp/interconnect@48000000/segmnt@100000/target-module@ae000/gpio@0
    [ 13.142736] OF: /ocp/interconnect@48000000/segment@100000/target-module@9c000/i2c@0/tlv320aic32x6@18: could not get #clock-cells for /ocp/interconnect@48000000/segment@100000/target-module@ae000/gpio@0

    Also, I could not find the slave address from the TLV320AIC3256 datasheet. I have used 0x18 because the same was used across various examples. Please let me know if that needs correction.

    I would appreciate any help to move forward.

    Thanks,

    Twinkle.

  • Hi Twinkle,

    If you were to do i2cdetect -r -y 2, do you see the address being detected?

    Regards,
    Krunal

  • Hi Krunal,

    I think there was some issue when I replied 2 days ago. Anyways, deleting that and reposting the same below.

    Yes, the device is being detected. The slave address for the codec is 0x18. Here is the response of i2cdetect:

    Thanks,

    Twinkle

  • Hello,

    The device is getting probed and I am not sure what problems you are still running into.

    Regards,
    Krunal

  • Hi Krunal,

    Even though the device is getting detected on i2c, aplay -L or record -L shows no device. Adding the latest am335x-boneblack-common.dtsi file below,

    // SPDX-License-Identifier: GPL-2.0-only
    /*
     * Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com/
     */
    
    #include <dt-bindings/display/tda998x.h>
    #include <dt-bindings/interrupt-controller/irq.h>
    
    &ldo3_reg {
    	regulator-min-microvolt = <1800000>;
    	regulator-max-microvolt = <1800000>;
    	regulator-always-on;
    };
    
    &mmc1 {
    	vmmc-supply = <&vmmcsd_fixed>;
    };
    
    &mmc2 {
    	vmmc-supply = <&vmmcsd_fixed>;
    	pinctrl-names = "default";
    	pinctrl-0 = <&emmc_pins>;
    	bus-width = <8>;
    	status = "okay";
    	non-removable;
    };
    
    &am33xx_pinmux {
    	nxp_hdmi_bonelt_pins: nxp_hdmi_bonelt_pins {
    		pinctrl-single,pins = <
    			AM33XX_PADCONF(AM335X_PIN_XDMA_EVENT_INTR0, PIN_OUTPUT_PULLDOWN, MUX_MODE3)
    			AM33XX_PADCONF(AM335X_PIN_LCD_DATA0, PIN_OUTPUT, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_DATA1, PIN_OUTPUT, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_DATA2, PIN_OUTPUT, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_DATA3, PIN_OUTPUT, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_DATA4, PIN_OUTPUT, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_DATA5, PIN_OUTPUT, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_DATA6, PIN_OUTPUT, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_DATA7, PIN_OUTPUT, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_DATA8, PIN_OUTPUT, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_DATA9, PIN_OUTPUT, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_DATA10, PIN_OUTPUT, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_DATA11, PIN_OUTPUT, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_DATA12, PIN_OUTPUT, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_DATA13, PIN_OUTPUT, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_DATA14, PIN_OUTPUT, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_DATA15, PIN_OUTPUT, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_VSYNC, PIN_OUTPUT_PULLDOWN, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_HSYNC, PIN_OUTPUT_PULLDOWN, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_PCLK, PIN_OUTPUT_PULLDOWN, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_LCD_AC_BIAS_EN, PIN_OUTPUT_PULLDOWN, MUX_MODE0)
    		>;
    	};
    
    	nxp_hdmi_bonelt_off_pins: nxp_hdmi_bonelt_off_pins {
    		pinctrl-single,pins = <
    			AM33XX_PADCONF(AM335X_PIN_XDMA_EVENT_INTR0, PIN_OUTPUT_PULLDOWN, MUX_MODE3)
    		>;
    	};
    
    	mcasp0_pins: mcasp0_pins {
    		pinctrl-single,pins = <
    			AM33XX_PADCONF(AM335X_PIN_MCASP0_AHCLKX, PIN_INPUT_PULLUP, MUX_MODE0)  /*mcasp0_ahcklx.mcasp0_ahclkx */
    			AM33XX_PADCONF(AM335X_PIN_MCASP0_AHCLKR, PIN_OUTPUT_PULLDOWN, MUX_MODE2) /* mcasp0_ahclkr.mcasp0_axr2*/
    			AM33XX_PADCONF(AM335X_PIN_MCASP0_FSX, PIN_OUTPUT_PULLUP, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_MCASP0_ACLKX, PIN_OUTPUT_PULLDOWN, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_MCASP0_AXR0, PIN_OUTPUT_PULLDOWN, MUX_MODE0)
    			/*AM33XX_PADCONF(AM335X_PIN_GPMC_A11, PIN_OUTPUT_PULLDOWN, MUX_MODE7)  gpmc_a11.GPIO1_27 */
    		>;
    	};
    	i2c2_pins: i2c2_pins {
    		pinctrl-single,pins = <
    			AM33XX_PADCONF(AM335X_PIN_UART1_RTSN, PIN_INPUT, MUX_MODE3) /* uart1_rtsn.i2c2_scl*/
    			AM33XX_PADCONF(AM335X_PIN_UART1_CTSN, PIN_INPUT, MUX_MODE3) /* uart1_ctsn.i2c2_sda*/
    		>;
    	};
    };
    
    &lcdc {
    	status = "okay";
    
    	/* If you want to get 24 bit RGB and 16 BGR mode instead of
    	 * current 16 bit RGB and 24 BGR modes, set the propety
    	 * below to "crossed" and uncomment the video-ports -property
    	 * in tda19988 node.
    	 */
    	blue-and-red-wiring = "straight";
    
    	port {
    		lcdc_0: endpoint@0 {
    			remote-endpoint = <&hdmi_0>;
    		};
    	};
    };
    
    &i2c0 {
    
    	tda19988: tda19988@70 {
    		compatible = "nxp,tda998x";
    		reg = <0x70>;
    		nxp,calib-gpios = <&gpio1 25 0>;
    		interrupts-extended = <&gpio1 25 IRQ_TYPE_LEVEL_LOW>;
    		pinctrl-names = "default", "off";
    		pinctrl-0 = <&nxp_hdmi_bonelt_pins>;
    		pinctrl-1 = <&nxp_hdmi_bonelt_off_pins>;
    
    		/* Convert 24bit BGR to RGB, e.g. cross red and blue wiring */
    		/* video-ports = <0x234501>; */
    
    		#sound-dai-cells = <0>;
    		audio-ports = <	TDA998x_I2S	0x03>;
    
    		ports {
    			port@0 {
    				hdmi_0: endpoint@0 {
    					remote-endpoint = <&lcdc_0>;
    				};
    			};
    		};
    	};
    };
    
    &i2c2 {
    	pinctrl-names = "default";
    	pinctrl-0 = <&i2c2_pins>;
    	clock-frequency = <400000>;
    	status = "okay";
    
    	tlv320aic32x6: tlv320aic32x6@18 {
    		#sound-dai-cells = <0>;
    		compatible = "ti,tlv320aic32x6";
    		reg = <0x18>;
    		clock-names = "mclk";
    		clocks = <&clk_mcasp0>;
    		iov-supply = <&reg_audio_3v3>;
    		dv-supply = <&reg_audio_1v8>;
    		av-supply = <&reg_audio_1v8>;
    		reset-gpios = <&gpio1 16 GPIO_ACTIVE_LOW>;
    		status = "okay";
    	};
    
    };
    
    &rtc {
    	system-power-controller;
    };
    
    &mcasp0	{
    	#sound-dai-cells = <0>;
    	pinctrl-names = "default";
    	pinctrl-0 = <&mcasp0_pins>;
    	status = "okay";
    	op-mode = <0>;	/* MCASP_IIS_MODE */
    	tdm-slots = <2>;
    	serial-dir = <	/* 0: INACTIVE, 1: TX, 2: RX */
    			1 0 2 0
    		>;
    	tx-num-evt = <32>;
    	rx-num-evt = <32>;
    };
    
    / {
    	memory@80000000 {
    		device_type = "memory";
    		reg = <0x80000000 0x20000000>; /* 512 MB */
    	};
    
    	clk_mcasp0_fixed: clk_mcasp0_fixed {
    		#clock-cells = <0>;
    		compatible = "fixed-clock";
    		clock-frequency = <24576000>;
    	};
    
    	clk_mcasp0: clk_mcasp0 {
    		#clock-cells = <0>;
    		compatible = "gpio-gate-clock";
    		clocks = <&clk_mcasp0_fixed>;
    		enable-gpios = <&gpio1 27 0>; /* BeagleBone Black Clk enable on GPIO1_27 */
    	};
    
    	sound {
    		compatible = "simple-audio-card";
    		status = "okay";
    		simple-audio-card,name = "TI BeagleBone Black";
    		simple-audio-card,widgets =
    			"Headphone", "Headphone Jack",
    			"Line", "Line Out",
    			"Mic", "Mic Bias";
    		simple-audio-card,routing =
    			"Headphone Jack", "HPL",
            		"Headphone Jack", "HPR",
    		        "Line Out", "LOL",
    		        "Line Out", "LOR",
    		        "Mic Jack", "IN1_L",
    		        "Mic Jack", "IN1_R",
    		        "Mic Jack", "IN2_L",
    		        "Mic Jack", "IN2_R",
    		        "Mic Jack", "IN3_L",
    		        "Mic Jack", "IN3_R",
    		        "Mic Jack", "Mic Bias",
    		        "CM_L", "Mic Bias",
    		        "CM_R", "Mic Bias";
    		simple-audio-card,format = "i2s";
    		simple-audio-card,bitclock-master = <&dailink0_master>;
    		simple-audio-card,frame-master = <&dailink0_master>;
    
    		dailink0_master: simple-audio-card,cpu {
    			sound-dai = <&mcasp0>;
    			clocks = <&clk_mcasp0>;
    		};
    
    		simple-audio-card,codec {
    			sound-dai = <&tlv320aic32x6>;
    			//sound-dai = <&tda19988>;
    		};
    	};
    
    	reg_audio_3v3: regulator-audio-3v3 {
    		compatible = "regulator-fixed";
    		regulator-name = "VCC3V3_AUDIO";
    		regulator-min-microvolt = <3300000>;
    		regulator-max-microvolt = <3300000>;
    		regulator-always-on;
    	};
    
    	reg_audio_1v8: regulator-audio-1v8 {
    		compatible = "regulator-fixed";
    		regulator-name = "VCC1V8_AUDIO";
    		regulator-min-microvolt = <1800000>;
    		regulator-max-microvolt = <1800000>;
    		regulator-always-on;
    	};
    };

    We tried to observe the different clocks: MCLK: 11.3MHz, WCLK: 44KHz, BCLK: 2.8MHz.

    We still don't understand why alsa utilities cannot detect the codec. We have also enabled the driver through menuconfig,

    We would appreciate the help to get this working.

    Thanks,

    Twinkle

  • Hi Twinkle,

    Is McASP the master in your system? Any McASP or codec errors observed in the bootlogs? 

    Regards,
    Krunal

  • Hi Krunal,

    As per the current am335x-boneblack-common.dtsi, MCASP0 is the master.

    We don't see any errors with reference to tlv, mcasp, audio or sound. Logs below:

    root@beaglebone:~# dmesg | grep -i tlv
    [    7.122265] of_get_named_gpiod_flags: parsed 'reset-gpios' property of node '/ocp/interconnect@48000000/segment@100000/target-module@9c000/i2c@0/tlv320aic32x6@18[0]-
     status (0)
    root@beaglebone:~# dmesg | grep -i audio
    [    3.203092] reg-fixed-voltage regulator-audio-3v3: GPIO lookup for consumer (null)
    [    3.203112] reg-fixed-voltage regulator-audio-3v3: using device tree for GPIO lookup
    [    3.203161] of_get_named_gpiod_flags: can't parse 'gpios' property of node '/regulator-audio-3v3[0]'
    [    3.203201] of_get_named_gpiod_flags: can't parse 'gpio' property of node '/regulator-audio-3v3[0]'
    [    3.203226] reg-fixed-voltage regulator-audio-3v3: using lookup tables for GPIO lookup
    [    3.203245] reg-fixed-voltage regulator-audio-3v3: No GPIO consumer (null) found
    [    3.204142] reg-fixed-voltage regulator-audio-1v8: GPIO lookup for consumer (null)
    [    3.204160] reg-fixed-voltage regulator-audio-1v8: using device tree for GPIO lookup
    [    3.204204] of_get_named_gpiod_flags: can't parse 'gpios' property of node '/regulator-audio-1v8[0]'
    [    3.204244] of_get_named_gpiod_flags: can't parse 'gpio' property of node '/regulator-audio-1v8[0]'
    [    3.204269] reg-fixed-voltage regulator-audio-1v8: using lookup tables for GPIO lookup
    [    3.204287] reg-fixed-voltage regulator-audio-1v8: No GPIO consumer (null) found
    [   10.162356] hdmi-audio-codec hdmi-audio-codec.1.auto: no of_node; not parsing pinctrl DT
    root@beaglebone:~# dmesg | grep -i sound
    [    3.214371] Advanced Linux Sound Architecture Driver Initialized.
    [    7.310250]   No soundcards found.
    root@beaglebone:~# dmesg | grep -i mcasp
    root@beaglebone:~# 

    Adding the latest am335x-boneblack-common.dtsi file below,

    &i2c2 {
    	pinctrl-names = "default";
    	pinctrl-0 = <&i2c2_pins>;
    	clock-frequency = <400000>;
    	status = "okay";
    
    	tlv320aic32x6: tlv320aic32x6@18 {
    		#sound-dai-cells = <0>;
    		compatible = "ti,tlv320aic32x6";
    		reg = <0x18>;
    		clock-names = "mclk";
    		clocks = <&tlv320aic3256_mclk>;
    		iov-supply = <&reg_audio_3v3>;
    		dv-supply = <&reg_audio_1v8>;
    		av-supply = <&reg_audio_1v8>;
    		reset-gpios = <&gpio1 16 GPIO_ACTIVE_LOW>;
    		status = "okay";
    	};
    };
    
    &mcasp0	{
    	#sound-dai-cells = <0>;
    	pinctrl-names = "default";
    	pinctrl-0 = <&mcasp0_pins>;
    	status = "okay";
    	op-mode = <0>;	/* MCASP_IIS_MODE */
    	tdm-slots = <2>;
    	serial-dir = <	/* 0: INACTIVE, 1: TX, 2: RX */
    			1 0 2 0
    		>;
    	tx-num-evt = <32>;
    	rx-num-evt = <32>;
    };
    
    / {
    	...
    
    	tlv320aic3256_mclk: tlv320aic3256_mclk {
                    compatible = "fixed-clock";
                    #clock-cells = <0>;
                    clock-frequency = <25000000>;
            };
    
    	sound {
    		compatible = "simple-audio-card";
    		status = "okay";
    		simple-audio-card,name = "Twinkle Audio Card";
    		simple-audio-card,widgets =
    			"Headphone", "Headphone Jack",
    			"Line Out", "Line Out",
    			"Line In", "Mic Jack";
    		simple-audio-card,routing =
    			"Headphone Jack", "HPL",
            		"Headphone Jack", "HPR",
    		        "Line Out", "LOL",
    		        "Line Out", "LOR",
    		        "Mic Jack", "IN1_L",
    		        "Mic Jack", "IN1_R",
    		        "Mic Jack", "IN2_L",
    		        "Mic Jack", "IN2_R",
    		        "Mic Jack", "IN3_L",
    		        "Mic Jack", "IN3_R",
    		        "Mic Jack", "Mic Bias",
    		        "CM_L", "Mic Bias",
    		        "CM_R", "Mic Bias";
    
    		simple-audio-card,format = "i2s";
    		simple-audio-card,bitclock-master = <&dailink0_master>;
    		simple-audio-card,frame-master = <&dailink0_master>;
    
    		dailink0_master: simple-audio-card,cpu {
    			sound-dai = <&mcasp0>;
    		};
    
    		simple-audio-card,codec {
    			sound-dai = <&tlv320aic32x6>;
    		};
    	};
    
    	reg_audio_3v3: regulator-audio-3v3 {
    		compatible = "regulator-fixed";
    		regulator-name = "VCC3V3_AUDIO";
    		regulator-min-microvolt = <3300000>;
    		regulator-max-microvolt = <3300000>;
    		regulator-always-on;
    		regulator-boot-on;
    	};
    
    	reg_audio_1v8: regulator-audio-1v8 {
    		compatible = "regulator-fixed";
    		regulator-name = "VCC1V8_AUDIO";
    		regulator-min-microvolt = <1800000>;
    		regulator-max-microvolt = <1800000>;
    		regulator-always-on;
    		regulator-boot-on;
    	};
    };

    Appreciate the help.

    Thanks,

    Twinkle

  • Hi Krunal,

    We discovered that the previously mentioned clocks were being provided by the TLV320AIC3256EVM-U instead of the AM3358. We were able to disable the clocks coming through the USB controller from the TLV EVK. We are able to enable MCK from MCASP on BBB but now, we observe that the AM3358 is not providing WCLK or BCLK to the TLV IC. Can you please go through our dtsi configuration and let us know what we are doing wrong with the clocks?

    Regards,

    Twinkle

  • I would also add the following in the dailink0_master node:

    system-clock-frequency = <24000000>;
    system-clock-direction-out;

    Also, McASP will not provide clocks if it's idle and you need to play sounds using the aplay or gstreamer.

    Regards,
    Krunal

  • Hi Krunal,

    We tried adding the clock factor but with 12 MHz because that is the frequency we want. We still don't see the MCLK. We are also not able to run aplay because no sound card is being detected. Logs below,

    root@beaglebone:~# aplay /usr/share/sounds/alsa/Noise.wav
    ALSA lib ../../alsa-lib-1.2.1.2/src/confmisc.c:767:(parse_card) cannot find card '0'
    ALSA lib ../../alsa-lib-1.2.1.2/src/conf.c:4660:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib ../../alsa-lib-1.2.1.2/src/confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib ../../alsa-lib-1.2.1.2/src/conf.c:4660:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib ../../alsa-lib-1.2.1.2/src/confmisc.c:1246:(snd_func_refer) error evaluating name
    ALSA lib ../../alsa-lib-1.2.1.2/src/conf.c:4660:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib ../../alsa-lib-1.2.1.2/src/conf.c:5148:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib ../../../alsa-lib-1.2.1.2/src/pcm/pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
    aplay: main:828: audio open error: No such file or directory
    root@beaglebone:~# arecord test.wav
    ALSA lib ../../alsa-lib-1.2.1.2/src/confmisc.c:767:(parse_card) cannot find card '0'
    ALSA lib ../../alsa-lib-1.2.1.2/src/conf.c:4660:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
    ALSA lib ../../alsa-lib-1.2.1.2/src/confmisc.c:392:(snd_func_concat) error evaluating strings
    ALSA lib ../../alsa-lib-1.2.1.2/src/conf.c:4660:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
    ALSA lib ../../alsa-lib-1.2.1.2/src/confmisc.c:1246:(snd_func_refer) error evaluating name
    ALSA lib ../../alsa-lib-1.2.1.2/src/conf.c:4660:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
    ALSA lib ../../alsa-lib-1.2.1.2/src/conf.c:5148:(snd_config_expand) Evaluate error: No such file or directory
    ALSA lib ../../../alsa-lib-1.2.1.2/src/pcm/pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
    arecord: main:828: audio open error: No such file or directory
    root@beaglebone:~# aplay -l
    aplay: device_list:272: no soundcards found...
    root@beaglebone:~# arecord -l
    arecord: device_list:272: no soundcards found...

    Below is the i2cdump. Take note we have not made any changes in the tlv320aic32x4 driver. Let us know if any changes are required.

    Adding the latest am335x-boneblack-common.dtsi file below,

     

    &am33xx_pinmux {
    	mcasp0_pins: mcasp0_pins {
    		pinctrl-single,pins = <
    			AM33XX_PADCONF(AM335X_PIN_MCASP0_AHCLKX, PIN_OUTPUT_PULLUP, MUX_MODE0) 
    			AM33XX_PADCONF(AM335X_PIN_MCASP0_AHCLKR, PIN_INPUT_PULLDOWN, MUX_MODE2) /* mcasp0_ahclkr.mcasp0_axr2*/
    			AM33XX_PADCONF(AM335X_PIN_MCASP0_AXR0, PIN_OUTPUT_PULLDOWN, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_MCASP0_FSX, PIN_OUTPUT_PULLUP, MUX_MODE0)
    			AM33XX_PADCONF(AM335X_PIN_MCASP0_ACLKX, PIN_OUTPUT_PULLDOWN, MUX_MODE0)
    			/*AM33XX_PADCONF(AM335X_PIN_GPMC_A11, PIN_OUTPUT_PULLDOWN, MUX_MODE7)  gpmc_a11.GPIO1_27 */
    		>;
    	};
    	i2c2_pins: i2c2_pins {
    		pinctrl-single,pins = <
    			AM33XX_PADCONF(AM335X_PIN_UART1_RTSN, PIN_INPUT, MUX_MODE3) /* uart1_rtsn.i2c2_scl*/
    			AM33XX_PADCONF(AM335X_PIN_UART1_CTSN, PIN_INPUT, MUX_MODE3) /* uart1_ctsn.i2c2_sda*/
    		>;
    	};
    };
    
    &i2c2 {
    	pinctrl-names = "default";
    	pinctrl-0 = <&i2c2_pins>;
    	clock-frequency = <100000>;
    	status = "okay";
    
    	tlv320aic32x6: tlv320aic32x6@18 {
    		#sound-dai-cells = <0>;
    		compatible = "ti,tlv320aic32x6";
    		reg = <0x18>;
    		clock-names = "mclk";
    		clocks = <&codec_mclk>;
    		iov-supply = <&reg_audio_3v3>;
    		dv-supply = <&reg_audio_1v8>;
    		av-supply = <&reg_audio_1v8>;
    		reset-gpios = <&gpio1 6 GPIO_ACTIVE_LOW>;
    		status = "okay";
    	};
    };
    
    &mcasp0	{
    	#sound-dai-cells = <0>;
    	pinctrl-names = "default";
    	pinctrl-0 = <&mcasp0_pins>;
    	status = "okay";
    	op-mode = <0>;	/* MCASP_IIS_MODE */
    	tdm-slots = <2>;
    	serial-dir = <	/* 0: INACTIVE, 1: TX, 2: RX */
    			1 0 2 0
    		>;
    	tx-num-evt = <32>;
    	rx-num-evt = <32>;
    };
    
    / {
    	...
    
    	codec_mclk: codec_mclk {
                    compatible = "fixed-clock";
                    #clock-cells = <0>;
    		clock-frequency = <12000000>;
            };
    
    	sound {
    		compatible = "simple-audio-card";
    		status = "okay";
    		simple-audio-card,name = "Twinkle Audio Card";
    		simple-audio-card,widgets =
    			"Headphone", "Headphone Jack",
    			"Line Out", "Line Out",
    			"Line In", "Mic Jack";
    		simple-audio-card,routing =
    			"Headphone Jack", "HPL",
            		"Headphone Jack", "HPR",
    		        "Line Out", "LOL",
    		        "Line Out", "LOR",
    		        "Mic Jack", "IN1_L",
    		        "Mic Jack", "IN1_R",
    		        "Mic Jack", "IN2_L",
    		        "Mic Jack", "IN2_R",
    		        "Mic Jack", "IN3_L",
    		        "Mic Jack", "IN3_R",
    		        "Mic Jack", "Mic Bias",
    		        "CM_L", "Mic Bias",
    		        "CM_R", "Mic Bias";
    		simple-audio-card,format = "i2s";
    		simple-audio-card,bitclock-master = <&dailink0_master>;
    		simple-audio-card,frame-master = <&dailink0_master>;
    
    		dailink0_master: simple-audio-card,cpu {
    			sound-dai = <&mcasp0>;
    			system-clock-frequency = <12000000>;
    			system-clock-direction-out;
    		};
    
    		simple-audio-card,codec {
    			sound-dai = <&tlv320aic32x6>;
    		};
    	};
    
    	reg_audio_3v3: regulator-audio-3v3 {
    		compatible = "regulator-fixed";
    		regulator-name = "VCC3V3_AUDIO";
    		regulator-min-microvolt = <3300000>;
    		regulator-max-microvolt = <3300000>;
    		regulator-always-on;
    		regulator-boot-on;
    	};
    
    	reg_audio_1v8: regulator-audio-1v8 {
    		compatible = "regulator-fixed";
    		regulator-name = "VCC1V8_AUDIO";
    		regulator-min-microvolt = <1800000>;
    		regulator-max-microvolt = <1800000>;
    		regulator-always-on;
    		regulator-boot-on;
    	};

    Thanks,

    Twinkle

  • Hi Twinkle,

    1) Sorry, please remove system-clock-direction-out; because that will force McASP to use internal clock as opposed to the AHCLKX. 

    2) Also, the McASP driver isn't written to operate in ASYC mode. My recommendation would be to remove the AHCLKR and drive the MCLK to AHCLKX.

    3) Is there a way to make McASP the slave and drive all the clocks from AIC to McASP? 

    4) It's strange that your Audio card is not getting detected. Even if the clock settings are incorrect, it should atleast notice the sound node. 

    Regards,
    Krunal 

  • Hi Krunal,

    Appreciate the quick response.

    1. Tried to remove system-clock-direction-out and run the system but no improvement.

    2. If you will have another look at the dts we use AHCLKR pin but in mode 2 to enable it as AXR2. We are already using AHCLKX to drive MCLK as you suggested.
    AM33XX_PADCONF(AM335X_PIN_MCASP0_AHCLKR, PIN_INPUT_PULLDOWN, MUX_MODE2) /* mcasp0_ahclkr.mcasp0_axr2*/

    3. We do not have an external crystal to drive the MCLK and other clocks from AIC so that is not feasible for us.

    What further steps can we take to get this issue in line?

    Thanks,

    Twinkle

  • Hi Twinkle,

    We don't have a EVM with tlv320aic32x4 driver and my recommendation would be to review our sound node for tlv320aic3106[1]. I know it's different than what you have but it's a reference that is known to work. Also, check with the beagle community for more references on the sound node. 

    [1] https://git.ti.com/cgit/ti-linux-kernel/ti-linux-kernel/tree/arch/arm/boot/dts/am437x-gp-evm.dts?h=ti-linux-5.10.y#n115 

    Regards,
    Krunal

  • Hi Krunal,

    I tried to use the reference you mentioned but with same results. However, I found out that simple-audio-card probe is failing when I placed some extra debug prints in sound/soc/generic/simple-card.c

    I was able to climb down the function calls to some extent and the source of error came down to asoc_simple_parse_cpu, asoc_simple_parse_codec, etc function calls. in the same driver file.

    From what we can see from several references, our cpu and codec node in the sound node seem simple and correct.

    Can you suggest further action here?

    Thanks and Regards,

    Twinkle

  • Hi Krunal,

    Along with the above mentioned issue, we are not able to see the AM3358 generate the MCLK. Is there some Processor specific patch or PLL configuration required for the same?

    Awaiting your response.

    Regards,

    Twinkle

  • Hello,

    I thought the MCLK is being generated by the AIC codec. The above DTS shows AHCLKX as input so I thought McASP is getting that from the AIC codec. 

    Regards,
    Krunal

  • Hi Krunal,

    We have never mentioned AHCLKX as input and we have also previously mentioned that,

    We do not have an external crystal to drive the MCLK and other clocks from AIC so that is not feasible for us.

    So I am not able to understand your response.

    Regards,
    Twinkle

  • Hi Twinkle,

    1) Could you share your DTS file (please don't copy/paste it in the chat)?

    2) Could you share a system block diagram and what clocks you expect McASP to provide to AIC?

    3) Also, share any errors you are observing in the simple-card or Linux boot. I will ask our internal dev team for any additional feedback. 

    Regards,
    Krunal

  • Hi Krunal,

    Adding the edited DTSs and DTSIs below. It also has the patch files to understand the debug prints we put in simple-card.c and tlv320aic32x4.c along with errors in error.log file.

    Below is the block diagram,

    We have also tried by making TLV320AIC3256 as master by changing the direction of BCLK and WCLK pins along with labelling the 'codec' as 'dailink0_master' instead of 'cpu' in the 'sound node' but with same result.

    Let me know if any other data is required from our side.

    Thanks and Regards,

    Twinkle

    5516.Files.zip

  • Thanks! I will internally review with our developer and get back to you by the end of the week.

    Regards,
    Krunal

  • Hi Twinkle,

    Based on my internal discussion, here is what we saw:

    [    6.382431] twinkle: sound/soc/soc-core.c:2998 Flag ret:-517

    [    6.388518] twinkle: sound/soc/soc-core.c:2998 Flag ret:-517 

    The error "ret:-517" in the logs of the sound node means it is waiting for one of its dependent components probe to complete. https://github.com/torvalds/linux/blob/master/include/linux/errno.h#L19. We see that McASP is being probed but could we add more prints in the codec node to see if it is fully initialized and probe is successful. 

    Regards,
    Krunal

  • Hi Krunal,

    Thanks for the input. I'll try to add more debug logs in the mcasp and tlv320aic32x4 drivers and send you the complete dmesg.

    Meanwhile, I tried to use the kernel (Linux 5.10.100+) from the readily available TI AM335x SDK, and using that I was able to detect the TLV sound card. I was not able to play or record any audio, but getting the sound card is progress. I tried to use the same .config file with my Yocto Setup which has Linux 5.9.16.  Using that I was able to observe in boot-up logs that the sound card was detected but the console was not coming up. I tried to verify which sound-related config was missing from my Yocto config that is present in the SDK config but could not figure it out. I am attaching both the config files for your reference if you can find any clue as to what is missing.

    Thanks and Regards,

    Twinkle

    defconfig-sdk.txtdefconfig-yocto.txt

  • Hey,

    Attaching the latest dtsi with the patches and dmesg output. I was not able to gather much information from them but do have a look. Do let me know if you want me to add extensive debug prints.

    Thanks,

    Twinkle

    7142.File.zip

  • Hi Twinkle,

    That's strange that default SDK Linux has the sound card detecting but your custom kernel does not. For debugging purposes, let's use the PSDK Linux as a baseline and if you try aplay command, do you see any clocks coming out of McASP? I know you still don't hear sound but let's see if McASP is generating any clocks. 

    Regards,
    Krunal

  • Hi Krunal,

    aplay command still won't give out any clocks on either of the clock lines.

    Regards,

    Twinkle

  • Hi Krunal,

    I have taken reference from https://www.ti.com/lit/ug/spruh73q/spruh73q.pdf?ts=1664872266051
    This says that AUXCLK is the source for AHCLKX. Can you help me by letting me know how AUXCLK is generated? Or what is it's original value?

    Thanks,

    Twinkle

  • Hi Twinkle,

    By default, the internal AUXCLK is 24MHz. If McASP is configured as a master, you either use the internal AUXCLK to generate FSYNC/BCLK or you use external crystal to provide clock to the AHCLKX to generate FSYNC or BLCK. Based on my understanding, the default driver doesn't automatically output 24MHz to AHCLKX. We haven't tested the above usecase and we can't provide any references/documentation.  

    Regards,
    Krunal

  • Hi Krunal,

    We were able to use the mcasp0_fck clock signal defined in am33xx-clocks.dtsi to get the 24 MHz clock you mentioned as output.

    But as per TLV320AIC3256's example PLL configurations, 24 MHz is not supported as MCLK. So we need to implement a frequency divider and bring it up to 12MHz. We tried to make the required changes in the DTS as below but the output is still 24MHz.

    Please advise us as to how we can divide this clock to bring it down to 12 MHz.

    Thanks and Regards,

    Twinkle

  • Hello Twinkle,

    Unfortunately, you cannot change the internal AUXCLK frequency. Also, feel free to review the clock tree tool to see if there are other PLL you could use for 12MHz signal: https://www.ti.com/tool/CLOCKTREETOOL

    Regards,
    Krunal

  • Hi Krunal,

    It seems like the Clock Tree won't be able to help us. Since either all the PLLs output 24MHz as per the oscillator connected or they output frequency in KHz like 32KHz, etc.

    We are trying to use the clock divider mentioned in AHCLKXCTL and ACLKXCTL. But we are not able to figure out how to edit them using the driver or device tree.
    Can you please look into it and let us know if you can help?

    Thanks and Regards,
    Twinkle

  • Hello,

    By default, I don't think the driver supports the above usecase. As an experiment, have you tried to manually modify the bit 15 and bits11-0 using devmem?

    Regards,
    Krunal

  • Hey Krunal,

    Yes, I did try to modify these registers using devmem2. I tried to set the value of AHCLKXCTL to 0x00008001. But the register is inaccessible when no audio is playing or being recorded. And when I try to modify it during audio play or record, the command returns success but reading the value immediately afterward gives the reg value as 0x00000000.

    I see from the following link that it should be possible to divide the 24MHz OSC freq to 12MHz by editing AHCLKXCTL but I am not able to figure out how and where to make the changes. Really would appreciate the help.

    Thanks and Regards,

    Twinkle

  • Hi Krunal,

    I was able to get 12MHz frequency from AHCLKX by manually configuring AHCLKXCTL to 0x00008001 via devmem2 while arecord was running in the background.

    But I need to understand how to do this via the DTS or before the arecord command. Please help as this is very critical.

    Regards,

    Twinkle

  • Hi Twinkle,

    In the following thread: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1161741/beagl-bone-black-i2s-mic-configuration-incorrect-bclk-aclkx-lrclk-fsx, you are able to output BCLK and FSYNC. I know in one case it's record vs playback in current thread but McASP configuration remains the same. I am wondering if there are any delta's between the two configuration?

    Regards,
    Krunal

  • Hi Krunal,

    As per the thread you mentioned, I am able to receive BCLK and FSYNC but they are all incorrect. I have to manually set them via AHCLKXCTL, ACLKXCTL, and XFMT registers using devmem2. I am using almost the same configuration in both cases. The difference is in the case of TLV, I want codec to be the master while in the case of Mic, AM3358 is the master.

    However, in both cases, the AHCLKX being received on output is 24MHz. I want to know how to get 12 MHz on AHCLKX without manually changing the register.

    Thanks and Regards,

    Twinkle 

  • Hello Twinkle,

    By default, our driver does not support the above usecase. If you select McASP as the master and use the internal AUX clock, it will generate the 24MHz signal. Now, it's possible to modify the driver by changing davinci-evm.c file. The driver will check if you want to use the AUXCLK or an external signal. Please refer to the "davinci_mcasp_set_sysclk" function and the direction is set in the "simple-card-utils.c" file (function name asoc_simple_parse_clk). If McASP is the master and you have the property "system-clock-direction-out" defined, davinci_mcasp_set_sysclk will execute the "else" statment. In that "else" statement, feel free to add logic to perform the division. In summary, you would need to experiment with the davinci-evm.c file for your clock output requirements.

    Regards,
    Krunal