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.

AM3358: McASP interface

Part Number: AM3358
Other Parts Discussed in Thread: TLV320AIC3104, TLV320AIC3007, TLV320AIC3106, AM3352

Hi,

I am trying to figure out if I can interface TDM on AM3358 to PCM interface on a Voice chip. The PCM interface has PCLK, FSYNC, DTX, and DRX and the signals look like this.

 On AM3358, I have CLK, FS and AXR[n]. 

On the voice chip it can be configured to support from 8-128 (8 bit) time slots in each 125us frame, with a PCLK range of 256KHz - 8.192 MHz. Will I be able to make it work with this voice chip? 

Thank you

  • Hi,

    You will find detailed description of the AM335x McASP interface in:

    Section 7.11 of the AM335x Datasheet Rev. K.
    Section 22 of the AM335x Technical Reference Manual Rev. P.

  • Hi Biser,

    I have read both datasheet and TRM. I am having hard time understanding section 22.3.3.1 which explains TDM. Can I use AXR[0] to connect to TX and AXR[1] to connect to RX on the voice chip?  If yes, is there any example of how to set it up in DTS?

    Thank you

  • Hi Biser,

    I am trying to write driver for the Voice chip. Can someone explain the serial-dir in following code:

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

    Thank you

  • Samer,

    Samer Abbas said:
    Can I use AXR[0] to connect to TX and AXR[1] to connect to RX on the voice chip?

    Yes you can.

    Samer Abbas said:
    If yes, is there any example of how to set it up in DTS?

    You can check AM335x TI PSDK Linux DTS files:

    {PSDK}/board-support/linux-4.19.38/arch/arm/boot/dts/am335x-evm.dts

    &mcasp1 {
        #sound-dai-cells = <0>;
        pinctrl-names = "default", "sleep";
        pinctrl-0 = <&mcasp1_pins>;
        pinctrl-1 = <&mcasp1_pins_sleep>;

        status = "okay";

        op-mode = <0>;          /* MCASP_IIS_MODE */
        tdm-slots = <2>;
        /* 4 serializers */
        serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
            0 0 1 2
        >;
        tx-num-evt = <32>;
        rx-num-evt = <32>;
    };

     

    In this DTS file, AXR[2] is configured for TX, AXR[3] is configure for RX

    You can also check am57xx-beagle-x15-common.dtsi file, where AXR[0] is configured for TX, AXR[1] is configured for RX

    /* 4 serializers */
        serial-dir = <    /* 0: INACTIVE, 1: TX, 2: RX */
            1 2 0 0

    Regards,
    Pavel

  • Samer Abbas said:
    I am trying to write driver for the Voice chip. Can someone explain the serial-dir in following code:

    In this code you are configuring McASP0 AXR[0] pin for TX (transmit), while rest of the McASP0 AXR[n] pins are inactive.

    See also below files:

    linux-4.19.38/sound/soc/ti/davinci-mcasp.c

    linux-4.19.38/bindings/sound/davinci-mcasp-audio.txt

    Regards,
    Pavel

  • Hi Pavel,

    Thanks for the response.

    My board design is based on beaglebone, so my MCASP1 pins are not available because of RGMII1 connection to LAN8710. On my MCASP0, I have TLV320AIC3104 connected.

    Is there anyway I can connect the voice chip to either MCASP0 or MCASP1?

    The voice chip requires both SPI and TDM/PCM. I do have pin-outs available for SPI but I am not sure about MCASP.

    Thank you,

    Samer

  • Samer,

    Yes, you can connect AIC3x codec to McASP0 on your custom board. In BeagleBone Black board, by default we have TDA19988 HDMI transmitter connected to McASP0 module, and you can update this McASP0 node from TDA19988 to TLV320AIC3104:

    linux-4.19.38/arch/arm/boot/dts/am335x-boneblack-common.dtsi

    You can refer to the below DTS file for example of McASP0 to tlv320aic3007 codec connection:

    linux-4.19.38/arch/arm/boot/dts/am335x-wega.dtsi

    You can refer to the below DTS file for example of McASP3 to tlv320aic3104 codec connection:

    linux-4.19.38/arch/arm/boot/dts/am57xx-beagle-x15-common.dtsi


    Regards,
    Pavel

  • Pavel,

    It seems like there has been a miscommunication. Let me explain my application. On my custom board, I already have AIC3x codec connected to MCASP0, and my MCASP1 pins are not available due to RGMII being used from those pins.

    I want to connect one more audio interface for telephony (FXO/FXS) to my custom board and it requires TDM pins. How can I connect this new telephony chip to AM335x while still keeping AIC3x on my MCASP0?

    Thank you,

    Samer

  • Samer,

    For connection two external audio chips to McASP0, you can refer to below user guides:

    Check section 4.2.1.1, we have examples for HDMI Transmitter + DAC, and we also have ADC+ DAC


    5.1 Digital Audio Interface Links - we have McASP6 connected with 3 codecs

    Regards,
    Pavel

  • Pavel Botev said:

    5.1 Digital Audio Interface Links - we have McASP6 connected with 3 codecs

    Pavel,

    Where can I get more details on this type of situation where one MCASP is connected to multiple codecs?

    For my application I will have AIC3x as a audio output device in one scenario, and I will have telephony chip for audio input and output in one scenario, and they both will be connected to MCASP0.

    Thank you,

    Samer

  • Samer,

    Check below e2e threads:

    Regards,
    Pavel

  • Pavel,

    Pavel Botev said:

    Linux/AM3352: Multi-codec operation with TDM

    TI E2E support forums
    Part Number: AM3352 Tool/software: Linux Hi, We have a design using an AM335x processor and 3 x TLV320AIC3106 codecs interfaced using a McASP in TDM mode. The topology appears to be similar to the multi-codec case described in SPRAC09A ( http:/...

    In this thread you recommend just modifying DTS to add multiple codec support on one MCASP. There is no example of that. Can you please explain what would I have to change in the following DTS to add support for another codec on MCASP1.

    sound {
    		compatible = "simple-audio-card";
    		simple-audio-card,name = "AM335x-EVM";
    		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 = <&mcasp1>;
    		};
    
    		sound_master: simple-audio-card,codec {
    			sound-dai = <&tlv320aic3106>;
    			system-clock-frequency = <12000000>;
    		};
    	};
    
    &mcasp1 {
    	#sound-dai-cells = <0>;
    	pinctrl-names = "default", "sleep";
    	pinctrl-0 = <&mcasp1_pins>;
    	pinctrl-1 = <&mcasp1_pins_sleep>;
    
    	status = "okay";
    
    	op-mode = <0>;          /* MCASP_IIS_MODE */
    	tdm-slots = <2>;
    	/* 4 serializers */
    	serial-dir = <  /* 0: INACTIVE, 1: TX, 2: RX */
    		0 0 1 2
    	>;
    	tx-num-evt = <32>;
    	rx-num-evt = <32>;
    };

    Thank you,

    Samer

  • Samer,

    You can refer to EVMK2G DTS file and user guide:

    linux-4.19.38/arch/arm/boot/dts/keystone-k2g-evm.dts

    We have McASP2 attached to two codecs: TLV320AIC3106 and Sii9022 HDMI transmitter

    For general DTS guidelines, refer to below txt file:

    linux-4.19.38/Documentation/devicetree/bindings/sound/simple-card.txt

    Below e2e thread might be also in help:

    Regards,
    Pavel

  • Pavel Botev said:

    You can refer to EVMK2G DTS file and user guide:

    linux-4.19.38/arch/arm/boot/dts/keystone-k2g-evm.dts

    Pavel,

    Thank you for the information. I will try the method used in EVMK2G DTS file.

    One more thing, in EVMK2G both codecs are connected through I2S, but in my configuration one will be connected through "dsp_b" and the other will be connected through "TDM". Will this cause any issues?

    Thank you,

    Samer

  • Samer Abbas said:
    One more thing, in EVMK2G both codecs are connected through I2S, but in my configuration one will be connected through "dsp_b" and the other will be connected through "TDM". Will this cause any issues?

    The available format options are listed in below file:

    linux-kernel/sound/soc/soc-core.c - i2s, right_j, left_j, dsp_a, dsp_b, ac97, pdm, msb, lsb

    You can use dsp_b for codec one , and another option for codec 2. This is shown in below DTS files:

    linux-4.19.38/arch/arm/boot/dts/stihxxx-b2120.dtsi

    simple-audio-card,dai-link0 {
                /* HDMI */
                format = "i2s";

    simple-audio-card,dai-link1 {
                /* DAC */
                format = "i2s";

    simple-audio-card,dai-link2 {
                /* SPDIF */
                format = "left_j";

    See also below TXT file:

    linux-4.19.38/Documentation/devicetree/bindings/sound/st,sti-asoc-card.txt

    From AM335x McASP side, these formats impact DAVINCI_MCASP_TXFMCTL_REG and DAVINCI_MCASP_RXFMCTL_REG registers. Make sure you have the correct McASP FMCTL settings for each codec.

    linux-4.19.38/sound/soc/ti/davinci-mcasp.c -> davinci_mcasp_set_dai_fmt()


    Regards,
    Pavel

  • Pavel,

    Right now for my 1st codec TLV320AIC3104, I use dsp_b and I am using following pins for it: MCASP0_ACLKx, MCASP0_FSx, MCASP0_AXR0, MCASP0_AXR2. For my 2nd codec Si3217x which only uses PCM, I will use I2C to receive TDM on the same pins MCASP0_ACLKx, MCASP0_FSx, MCASP0_AXR0, MCASP0_AXR2. This should be good right? Or is my approach wrong?

    After reading all the articles and device trees you suggested, I have a device tree now. Please have a look at my partial dts below and let me know if this will work:

    sound0: sound@0 {
    		compatible = "simple-audio-card";
    		simple-audio-card,name = "AM335x-EVM";
    		simple-audio-card,widgets =
    			"Headphone", "Headphone Jack",
    			"Line", "Line Out",
    			"Line", "Line In";
    		simple-audio-card,routing =
    			"Headphone Jack",	"HPLOUT",
    			"Headphone Jack",	"HPROUT",
    			"LINE1L",		"Line In",
    			"LINE1R",		"Line In"
    			"Line Out",     "LLOUT",
    			"Line Out",     "RLOUT";
    		simple-audio-card,dai-link@0 {
    			format = "dsp_b";
    			bitclock-master = <&sound0_0_master>;
    			frame-master = <&sound0_0_master>;
    			sound0_0_master: cpu {
    				sound-dai = <&mcasp0>;
    			};
    
    			codec {
    				sound-dai = <&tlv320aic3104>;
    				clocks = <&clk_mcasp0>;
    				clock-names = "mclk";
    			};
    		};
    
    		simple-audio-card,dai-link@1 {
    			format = "i2s";
    			bitclock-master = <&sound0_1_master>;
    			frame-master = <&sound0_1_master>;
    			sound0_1_master: cpu {
    				sound-dai = <&mcasp0>;
    			};
    
    			codec {
    				sound-dai = <&si3217x>;
    				clocks = <&clk_mcasp0>;
    				clock-names = "mclk";
    			};
    		};
    	};
    
    &mcasp0 {
    	#sound-dai-cells = <0>;
    
    	pinctrl-names = "default";
    	pinctrl-0 = <&mcasp0_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 = <32>;
    	rx-num-evt = <32>;
    };
    

    Here I am not sure about "tx-num-evt", "rx-num-evt", and "tdm-slots". Can I use I2S to receive PCM data? Is the device tree ok? Or do I need to make changes?

    Thank you,

    Samer

  • Samer Abbas said:
    Right now for my 1st codec TLV320AIC3104, I use dsp_b and I am using following pins for it: MCASP0_ACLKx, MCASP0_FSx, MCASP0_AXR0, MCASP0_AXR2. For my 2nd codec Si3217x which only uses PCM, I will use I2C to receive TDM on the same pins MCASP0_ACLKx, MCASP0_FSx, MCASP0_AXR0, MCASP0_AXR2. This should be good right? Or is my approach wrong?

    As you share the same McASP0 pins between two different codecs, you will need MUX/Buffer to switch between these codecs. For example you can refer to EVMK2G user's guide, sections 3.28 McASP Configuration and 3.18 Audio Codec


    Your device tree looks correct, but I can not test it on my side, as I do not have a board with your specific configuration. Thus you will need to test this DTS on your custom board, as just looking at it, we can not be sure it will work or not.

    For more info regarding "tx-num-evt", "rx-num-evt", and "tdm-slots",  you can refer to below TXT file and also check how MCASP driver is handling these:

    linux-4.19.38/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt

    linux-4.19.38/sound/soc/ti/davinci-mcasp.c

     

    Regards,
    Pavel