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.

Suggestion for improving the Sitara Linux Audio DAC Example

Other Parts Discussed in Thread: PCM5102A

I was going through your Audio DAC example:

processors.wiki.ti.com/.../Sitara_Linux_Audio_DAC_Example

and I got everything working.  Then as I was studying the rest of ALSA/ASoC I found the ASoC simple card support layer (simple-card.c) which can be used to completely replace davinci-evm.c with just entries in the device tree.  For example, the tutorial could be reduced to just creating the codec driver and then adding the following to your device tree: 

  sound {
    compatible = "simple-audio-card";
    simple-audio-card,format = "i2s";
simple-audio-card,cpu { sound-dai = <&mcasp0>; bitclock-master; bitclock-inversion; frame-master; system-clock-frequency = <24000000>; system-clock-direction = "out"; }; simple-audio-card,codec { sound-dai = <&pcm5102a>; }; };

This describes to the simple card support layer how to create the DAI link between the codec and McASP.  I hope this helps others!

  • Thanks for this contribution Brian!
  • Hi Brian,

    First, thanks for this contribution!

    Let me ask you some basic questions:

    1) Is it necessary to add something to the "sound/soc/davinci/Kconfig" as in the original example? If so, could you post what is it?
    2) In the device tree, do I still have to set the pinmuxing, add the mcasp node and add a node to the pcm5102a? like bellow:

    pcm5102a: pcm5102a {
    compatible = "ti,pcm5102a";
    };
    3) Could you post the complete .dts?

    Thanks in advance!
  • Hi Brian,

    I am trying your improvement, but I get the following error:

    root@am335x-evm:~# dmesg | grep -i simple  

    [    1.246382] /sound/simple-audio-card,cpu: could not get #sound-dai-cells for /ocp/mcasp@48038000

    [    1.255240] asoc-simple-card sound: parse error -22

    [    1.260385] asoc-simple-card: probe of sound failed with error -22

    I am using PROCESSOR SDK 03.02.00.05 and Beaglebone white.

    My am335x-bone.dts file is:

    /*
     * 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 "am335x-bone-common.dtsi"
    
    / {
    	model = "TI AM335x BeagleBone";
    	compatible = "ti,am335x-bone", "ti,am33xx";
    };
    
    &ldo3_reg {
    	regulator-min-microvolt = <1800000>;
    	regulator-max-microvolt = <3300000>;
    	regulator-always-on;
    };
    
    &mmc1 {
    	vmmc-supply = <&ldo3_reg>;
    };
    
    &sgx {
    	status = "okay";
    };
    
    &am33xx_pinmux {
    	mcasp0_pins: mcasp0_pins {
    		pinctrl-single,pins = <
    			0x190 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)	/* mcasp0_aclkx */
    			0x194 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)	/* mcasp0_fsx*/
    			0x198 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)	/* mcasp0_axr0 */
    		>;
    	};
    };
     
    &mcasp0 {
    		pinctrl-names = "default";
    		pinctrl-0 = <&mcasp0_pins>;
    		status = "okay";
    		op-mode = <0>;          /* MCASP_IIS_MODE */
    		tdm-slots = <2>;
    		/* 16 serializer */
    		serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
    			1 0 0 0
    		>;
    		tx-num-evt = <32>;
    		rx-num-evt = <32>;
    };
     
    /{
    
    pcm5102a: pcm5102a{
    	compatible = "ti,pcm5102a";
    };
    
    sound {
    	  compatible = "simple-audio-card";
    	  simple-audio-card,format = "i2s";
    	  simple-audio-card,cpu {
    		    sound-dai = <&mcasp0>;
    		    bitclock-master;
    		    bitclock-inversion;
    		    frame-master;
    		    system-clock-frequency = <24000000>;
    		    system-clock-direction = "out";
    		  };
    
    	 
    	  simple-audio-card,codec {
    	    sound-dai = <&pcm5102a>;      
    	  };
      
    };
    };
    

    Thanks in advance!

  • Hi,

    from a Brian's post elsewhere in E2E, I realized that "#sound-dai-cells = <0>;" is necessary in MCASP and PCM5102A nodes.

    Here is the am335x-bone.dts that works:

    /*
     * 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 "am335x-bone-common.dtsi"
    
    / {
    	model = "TI AM335x BeagleBone";
    	compatible = "ti,am335x-bone", "ti,am33xx";
    };
    
    &ldo3_reg {
    	regulator-min-microvolt = <1800000>;
    	regulator-max-microvolt = <3300000>;
    	regulator-always-on;
    };
    
    &mmc1 {
    	vmmc-supply = <&ldo3_reg>;
    };
    
    &sgx {
    	status = "okay";
    };
    
    &am33xx_pinmux {
    	mcasp0_pins: mcasp0_pins {
    		pinctrl-single,pins = <
    			0x190 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)	/* mcasp0_aclkx */
    			0x194 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)	/* mcasp0_fsx*/
    			0x198 (PIN_OUTPUT_PULLDOWN | MUX_MODE0)	/* mcasp0_axr0 */
    		>;
    	};
    };
     
    &mcasp0 {
    		#sound-dai-cells = <0>;		
    		pinctrl-names = "default";
    		pinctrl-0 = <&mcasp0_pins>;
    		status = "okay";
    		op-mode = <0>;          /* MCASP_IIS_MODE */
    		tdm-slots = <2>;
    		/* 16 serializer */
    		serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
    			1 0 0 0
    		>;
    		tx-num-evt = <32>;
    		rx-num-evt = <32>;
    };
     
    /{
    
    pcm5102a: pcm5102a{
    	#sound-dai-cells = <0>;	
    	compatible = "ti,pcm5102a";
    };
    
    sound {
    	  compatible = "simple-audio-card";
    	  simple-audio-card,format = "i2s";
    	  simple-audio-card,cpu {
    		    sound-dai = <&mcasp0>;
    		    bitclock-master;
    		    bitclock-inversion;
    		    frame-master;
    		    system-clock-frequency = <24000000>;
    		    system-clock-direction = "out";
    		  };
    
    	 
    	  simple-audio-card,codec {
    		sound-dai = <&pcm5102a>;      
    	  };
      
    };
    };

    Best regards,