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.

Linux/PROCESSOR-SDK-AM335X: McASP internal MCLK issue

Part Number: PROCESSOR-SDK-AM335X
Other Parts Discussed in Thread: TLV320AIC3104

Tool/software: Linux

Hi all,
I am using beagle bone black with kernel 4.4.41-rt50-g968d071ce9. (am335x-evm-linux-rt-sdk-src-03.03.00.04.tar.tar package)
I want to run audio subsystem with the tlv320aic3104 codec.

My goal is to use internal clock for MCLK ( instead of externall clock provided by oscillator) and the codec become master.

I edited the base dts and added the proper nodes for configuring audio subsystem.

But when i run speaker-test utility, it gets follows error:

Write error: -5,input/output error
xrun_recovery failed: -5 input/output error
Transfer failed: input/output error

also I have no signal on the ahclkx pin.

where is the source of the problem?

here is my dts file:

/*
 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
/dts-v1/;

#include "am33xx.dtsi"
#include "am33xx-es2.dtsi"
#include "am335x-bone-common.dtsi"

#include <dt-bindings/board/am335x-bbw-bbb-base.h>
#include <dt-bindings/pinctrl/am33xx.h>

/ {
	model = "TI AM335x BeagleBone Black";
	compatible = "ti,am335x-bone-black", "ti,am335x-bone", "ti,am33xx";

	
	sound {
		compatible = "simple-audio-card";
		simple-audio-card,name = "AudioCape Rev B";
		simple-audio-card,widgets =
			"Headphone", "Headphone Jack",
			"Line", "Line In";
		simple-audio-card,routing =
			"Headphone Jack",       "HPLOUT",
			"Headphone Jack",       "HPROUT",
			"LINE1L",               "Line In",
			"LINE1R",               "Line In";
		simple-audio-card,format = "dsp_b";
		simple-audio-card,bitclock-master = <&sound_master>;
		simple-audio-card,frame-master = <&sound_master>;
		simple-audio-card,bitclock-inversion;
	
		simple-audio-card,cpu {
			sound-dai = <&mcasp0>;
		};
	
	        sound_master: simple-audio-card,codec {
			#sound-dai-cells = <0>;
			sound-dai = <&tlv320aic3104>;
			system-clock-frequency = <24576000>;
		};
	};
};

&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";
};

&am33xx_pinmux {
	bone_audio_cape_audio_pins: pinmux_bone_audio_cape_audio_pins {
		pinctrl-single,pins = <
			0x190 (PIN_INPUT_PULLDOWN | MUX_MODE0)	/* mcasp0_aclkx.mcasp0_aclkx */
			0x194 (PIN_INPUT_PULLDOWN | MUX_MODE0)	/* mcasp0_fsx.mcasp0_fsx, INPUT */
			0x198 (PIN_INPUT_PULLDOWN | MUX_MODE0)	/* mcasp0_axr0.mcasp0_axr0 */
			0x19c (PIN_INPUT_PULLDOWN | MUX_MODE2)	/* mcasp0_ahclkr.mcasp0_axr2 */
			0x1ac (PIN_INPUT_PULLDOWN | MUX_MODE0)	/* MCASP0_AHCLKX -> MCASP0_AHCLKX (I2S_MCLK_OUT)- in */
		>;
	};
	i2c2_pins: pinmux_i2c2_pins {
		pinctrl-single,pins = <
			/* P9_20: uart1_ctsn.i2c2_sda */
			BONE_P9_20 (SLEWCTRL_SLOW | PIN_INPUT_PULLUP | MUX_MODE3)
			/* P9_19: uart1_rtsn.i2c2_scl */
			BONE_P9_19 (SLEWCTRL_SLOW | PIN_INPUT_PULLUP | MUX_MODE3)
		>;
	};
};

&i2c2  {
	#address-cells = <1>;
	#size-cells = <0>;
	clock-frequency = <100000>;
	status = "okay";
	pinctrl-names = "default";
	pinctrl-0 = <&i2c2_pins>;

	tlv320aic3104: tlv320aic3104@18 {
		#sound-dai-cells = <0>;
		compatible = "ti,tlv320aic3104";
		reg = <0x18>;
	};
};

&mcasp0  {
	#sound-dai-cells = <0>;
	pinctrl-names = "default";
	pinctrl-0 = <&bone_audio_cape_audio_pins>;
	status = "okay";
	op-mode = <0>;          /* MCASP_IIS_MODE */
	tdm-slots = <2>;
	num-serializer = <16>;
	serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
		2 0 1 0
		0 0 0 0
		0 0 0 0
		0 0 0 0
	>;
	tx-num-evt = <1>;
	rx-num-evt = <1>;
};

  • I added to  simple-audio-card,cpu subnode below properties. But there is no difference in results

    system-clock-direction = "out";

    system-clock-frequency = <24576000>;

     

    I also changed the pin muxing of ahclkx to output pin.

    this my new dts file:

    /*
     * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License version 2 as
     * published by the Free Software Foundation.
     */
    /dts-v1/;
    
    #include "am33xx.dtsi"
    #include "am33xx-es2.dtsi"
    #include "am335x-bone-common.dtsi"
    
    #include <dt-bindings/board/am335x-bbw-bbb-base.h>
    #include <dt-bindings/pinctrl/am33xx.h>
    
    / {
    	model = "TI AM335x BeagleBone Black";
    	compatible = "ti,am335x-bone-black", "ti,am335x-bone", "ti,am33xx";
    
    	
    	sound {
    		compatible = "simple-audio-card";
    		simple-audio-card,name = "AudioCape Rev B";
    		simple-audio-card,widgets =
    			"Headphone", "Headphone Jack",
    			"Line", "Line In";
    		simple-audio-card,routing =
    			"Headphone Jack",       "HPLOUT",
    			"Headphone Jack",       "HPROUT",
    			"LINE1L",               "Line In",
    			"LINE1R",               "Line In";
    		simple-audio-card,format = "dsp_b";
    		simple-audio-card,bitclock-master = <&sound_master>;
    		simple-audio-card,frame-master = <&sound_master>;
    		simple-audio-card,bitclock-inversion;
    	
    		simple-audio-card,cpu {
    			sound-dai = <&mcasp0>;
    			system-clock-direction = "out";
    			system-clock-frequency = <24576000>;
    		};
    	
    	        sound_master: simple-audio-card,codec {
    			#sound-dai-cells = <0>;
    			sound-dai = <&tlv320aic3104>;
    			system-clock-frequency = <24576000>;
    		};
    	};
    };
    
    &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";
    };
    
    &am33xx_pinmux {
    	bone_audio_cape_audio_pins: pinmux_bone_audio_cape_audio_pins {
    		pinctrl-single,pins = <
    			0x190 (PIN_INPUT_PULLDOWN | MUX_MODE0)	/* mcasp0_aclkx.mcasp0_aclkx */
    			0x194 (PIN_INPUT_PULLDOWN | MUX_MODE0)	/* mcasp0_fsx.mcasp0_fsx, INPUT */
    			0x198 (PIN_INPUT_PULLDOWN | MUX_MODE0)	/* mcasp0_axr0.mcasp0_axr0 */
    			0x19c (PIN_INPUT_PULLDOWN | MUX_MODE2)	/* mcasp0_ahclkr.mcasp0_axr2 */
    			0x1ac (PIN_OUTPUT_PULLDOWN | MUX_MODE0)	/* MCASP0_AHCLKX -> MCASP0_AHCLKX (I2S_MCLK_OUT)- in */
    		>;
    	};
    	i2c2_pins: pinmux_i2c2_pins {
    		pinctrl-single,pins = <
    			/* P9_20: uart1_ctsn.i2c2_sda */
    			BONE_P9_20 (SLEWCTRL_SLOW | PIN_INPUT_PULLUP | MUX_MODE3)
    			/* P9_19: uart1_rtsn.i2c2_scl */
    			BONE_P9_19 (SLEWCTRL_SLOW | PIN_INPUT_PULLUP | MUX_MODE3)
    		>;
    	};
    };
    
    &i2c2  {
    	#address-cells = <1>;
    	#size-cells = <0>;
    	clock-frequency = <100000>;
    	status = "okay";
    	pinctrl-names = "default";
    	pinctrl-0 = <&i2c2_pins>;
    
    	tlv320aic3104: tlv320aic3104@18 {
    		#sound-dai-cells = <0>;
    		compatible = "ti,tlv320aic3104";
    		reg = <0x18>;
    	};
    };
    
    &mcasp0  {
    	#sound-dai-cells = <0>;
    	pinctrl-names = "default";
    	pinctrl-0 = <&bone_audio_cape_audio_pins>;
    	status = "okay";
    	op-mode = <0>;          /* MCASP_IIS_MODE */
    	tdm-slots = <2>;
    	num-serializer = <16>;
    	serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
    		2 0 1 0
    		0 0 0 0
    		0 0 0 0
    		0 0 0 0
    	>;
    	tx-num-evt = <1>;
    	rx-num-evt = <1>;
    };
    

  • There is no way to generate an internal master clock with a frequency of 24.576MHz on the AM335x device.
  • Thanks Biser.

    I have to point out that I was able to run the sound subsystem. Of course, with the settings

    in which the CPU was Master. That is, I was able to use the internal CPU clock. Although the

    fsclk and blck that it produced was not accurate, and that's why I want to get a system in which

    the codec is in the master mode! (while using the internall clock).

    My question is

    is there a way to use internal clock instead of an external clock? Also, the codec works in

    Master mode. In other words,it's a codec that produces fs and bclk.

    It's also my DTS file with the settings I said:

    /*
     * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
     *
     * This program is free software; you can redistribute it and/or modify
     * it under the terms of the GNU General Public License version 2 as
     * published by the Free Software Foundation.
     */
    /dts-v1/;
    
    #include "am33xx.dtsi"
    #include "am33xx-es2.dtsi"
    #include "am335x-bone-common.dtsi"
    
    #include <dt-bindings/board/am335x-bbw-bbb-base.h>
    #include <dt-bindings/pinctrl/am33xx.h>
    
    / {
    	model = "TI AM335x BeagleBone Black";
    	compatible = "ti,am335x-bone-black", "ti,am335x-bone", "ti,am33xx";
    
    	
    	sound {
    		compatible = "simple-audio-card";
    		simple-audio-card,name = "AudioCape Rev B";
    		simple-audio-card,widgets =
    			"Headphone", "Headphone Jack",
    			"Line", "Line In";
    		simple-audio-card,routing =
    			"Headphone Jack",       "HPLOUT",
    			"Headphone Jack",       "HPROUT",
    			"LINE1L",               "Line In",
    			"LINE1R",               "Line In";
    		simple-audio-card,format = "dsp_b";
    		simple-audio-card,bitclock-master = <&sound_master>;
    		simple-audio-card,frame-master = <&sound_master>;
    		simple-audio-card,bitclock-inversion;
    	
    		sound_master: simple-audio-card,cpu {
    			sound-dai = <&mcasp0>;
    			system-clock-direction = "out";
    			system-clock-frequency = <24576000>;
    		};
    	
    	        simple-audio-card,codec {
    			#sound-dai-cells = <0>;
    			sound-dai = <&tlv320aic3104>;
    			system-clock-frequency = <24576000>;
    		};
    	};
    };
    
    &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";
    };
    
    &am33xx_pinmux {
    	bone_audio_cape_audio_pins: pinmux_bone_audio_cape_audio_pins {
    		pinctrl-single,pins = <
    			0x190 (PIN_INPUT_PULLDOWN | MUX_MODE0)	/* mcasp0_aclkx.mcasp0_aclkx */
    			0x194 (PIN_INPUT_PULLDOWN | MUX_MODE0)	/* mcasp0_fsx.mcasp0_fsx, INPUT */
    			0x198 (PIN_INPUT_PULLDOWN | MUX_MODE0)	/* mcasp0_axr0.mcasp0_axr0 */
    			0x19c (PIN_INPUT_PULLDOWN | MUX_MODE2)	/* mcasp0_ahclkr.mcasp0_axr2 */
    			0x1ac (PIN_OUTPUT_PULLDOWN | MUX_MODE0)	/* MCASP0_AHCLKX -> MCASP0_AHCLKX (I2S_MCLK_OUT)- in */
    		>;
    	};
    	i2c2_pins: pinmux_i2c2_pins {
    		pinctrl-single,pins = <
    			/* P9_20: uart1_ctsn.i2c2_sda */
    			BONE_P9_20 (SLEWCTRL_SLOW | PIN_INPUT_PULLUP | MUX_MODE3)
    			/* P9_19: uart1_rtsn.i2c2_scl */
    			BONE_P9_19 (SLEWCTRL_SLOW | PIN_INPUT_PULLUP | MUX_MODE3)
    		>;
    	};
    };
    
    &i2c2  {
    	#address-cells = <1>;
    	#size-cells = <0>;
    	clock-frequency = <100000>;
    	status = "okay";
    	pinctrl-names = "default";
    	pinctrl-0 = <&i2c2_pins>;
    
    	tlv320aic3104: tlv320aic3104@18 {
    		#sound-dai-cells = <0>;
    		compatible = "ti,tlv320aic3104";
    		reg = <0x18>;
    	};
    };
    
    &mcasp0  {
    	#sound-dai-cells = <0>;
    	pinctrl-names = "default";
    	pinctrl-0 = <&bone_audio_cape_audio_pins>;
    	status = "okay";
    	op-mode = <0>;          /* MCASP_IIS_MODE */
    	tdm-slots = <2>;
    	num-serializer = <16>;
    	serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
    		2 0 1 0
    		0 0 0 0
    		0 0 0 0
    		0 0 0 0
    	>;
    	tx-num-evt = <1>;
    	rx-num-evt = <1>;
    };
    

    Regards

  • You can use the CLKOUT1 output from the AM335x to feed the main oscillator clock to the Codec MCLK. The Codec itself has an internal PLL, which can be programmed to generate the bit clock frequency you require. I will ask the software team to comment whether this use case is supported by the Linux driver. They will respond directly here.