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.

AM5718: Audio issue

Part Number: AM5718

HI,

We have developed a custom board with AM5718 processor using ti-processor-sdk-linux-am57xx-evm-05.02.00.10. In the process of playing audio we are facing the problem and we are listing the patches and the parameters that we have changed in order to get the audio but we are unable to make the audio get played. For our processor in order to get the audio to play the MCLK should be 20MHz and we are able to get the MCLK but we are not able to get the sound while playing the audio files. So kindly help on this.

We have added the highlighted part in davinci-mcasp.c

static int davinci_mcasp_set_sysclk(struct snd_soc_dai *dai, int clk_id,
                    unsigned int freq, int dir)
{
static void __iomem *mcasp3_base;
uint32_t value/*,ui_temp*/;

    struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai);

printk(KERN_INFO "Enter davinci_mcasp_set_sysclk()\n");
    pm_runtime_get_sync(mcasp->dev);

  printk(KERN_INFO "dir == SND_SOC_CLOCK_OUT\n");



    mcasp_clr_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE);
    mcasp_set_bits(mcasp, DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE);
    mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AHCLKX);



#if 0
    if (dir == SND_SOC_CLOCK_IN) {
        switch (clk_id) {
        case MCASP_CLK_HCLK_AHCLK:
            mcasp_clr_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG,
                       AHCLKXE);
            mcasp_clr_bits(mcasp, DAVINCI_MCASP_AHCLKRCTL_REG,
                       AHCLKRE);
            mcasp_clr_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AHCLKX);
            break;
        case MCASP_CLK_HCLK_AUXCLK:
            mcasp_set_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG,
                       AHCLKXE);
            mcasp_set_bits(mcasp, DAVINCI_MCASP_AHCLKRCTL_REG,
                       AHCLKRE);
            break;
        default:
            dev_err(mcasp->dev, "Invalid clk id: %d\n", clk_id);
            goto out;
        }
    } else {
        /* Select AUXCLK as HCLK */
        mcasp_set_bits(mcasp, DAVINCI_MCASP_AHCLKXCTL_REG, AHCLKXE);
        mcasp_set_bits(mcasp, DAVINCI_MCASP_AHCLKRCTL_REG, AHCLKRE);
        mcasp_set_bits(mcasp, DAVINCI_MCASP_PDIR_REG, AHCLKX);
    }
#endif

mcasp3_base = ioremap(0x4A00369C,4);
value =  __raw_readl(mcasp3_base);   
printk(KERN_INFO "XREF_CLKOUT2 == %x \n",value);
(void)__raw_writel(0x10003,mcasp3_base );

mcasp3_base = ioremap(0x4A003774,4);
value =  __raw_readl(mcasp3_base);   
(void)__raw_writel(0x4000A,mcasp3_base );

mcasp3_base = ioremap(0x48440216,4);
value =  __raw_readl(mcasp3_base);   
(void)__raw_writel(value|0x2,mcasp3_base );

    /*
     * When AHCLK X/R is selected to be output it means that the HCLK is
     * the same clock - coming via AUXCLK.
     */
    mcasp->sysclk_freq = freq;
//out:
    pm_runtime_put(mcasp->dev);
    return 0;
}

static void mcasp_start_tx(struct davinci_mcasp *mcasp)
{

........

/* enable transmit IRQs */
    mcasp_set_bits(mcasp, DAVINCI_MCASP_EVTCTLX_REG,
               mcasp->irq_request[SNDRV_PCM_STREAM_PLAYBACK]);

mcasp3_base = ioremap(0x4A009868 ,4);
value =  __raw_readl(mcasp3_base);     
printk(KERN_INFO "CM_L4PER2_MCASP3_CLKCTRL  %x\n",value);



mcasp3_base = ioremap(0x4A0051EC ,4);
(void)__raw_writel(0x00800000,mcasp3_base );

mcasp3_base = ioremap(0x4A0051E0 ,4);
(void)__raw_writel(0x00000005,mcasp3_base );

mcasp3_base = ioremap(0x4A0051E4 ,4);
(void)__raw_writel(0x00000002,mcasp3_base );


}

static void mcasp_start_rx(struct davinci_mcasp *mcasp)
{
.............


    /* enable receive IRQs */
    mcasp_set_bits(mcasp, DAVINCI_MCASP_EVTCTLR_REG,
               mcasp->irq_request[SNDRV_PCM_STREAM_CAPTURE]);


mcasp3_base = ioremap(0x4A009868 ,4);
value =  __raw_readl(mcasp3_base);     
printk(KERN_INFO "CM_L4PER2_MCASP3_CLKCTRL  %x\n",value);

mcasp3_base = ioremap(0x4A0051EC ,4);
(void)__raw_writel(0x00800000,mcasp3_base );

mcasp3_base = ioremap(0x4A0051E0 ,4);
(void)__raw_writel(0x00000005,mcasp3_base );

mcasp3_base = ioremap(0x4A0051E4 ,4);
(void)__raw_writel(0x00000002,mcasp3_base );

}

am571x-idk.dts file :

    sound0: sound@0 {
                compatible = "simple-audio-card";
                simple-audio-card,name = "AM571x";
                simple-audio-card,widgets =
                        "Line", "Line Out",
                        "Line", "Line In";
                simple-audio-card,routing =
                        "Line Out",        "LLOUT",
                        "Line Out",        "RLOUT",
                        "MIC2L",        "Line In",
                        "MIC2R",        "Line In";
                simple-audio-card,format = "dsp_b";
                simple-audio-card,bitclock-master = <&sound0_master>;
                simple-audio-card,frame-master = <&sound0_master>;
                simple-audio-card,bitclock-inversion;

                simple-audio-card,cpu {
                        sound-dai = <&mcasp3>;
                        system-clock-frequency = <5644800>;
                };


                sound0_master: simple-audio-card,codec {
                        sound-dai = <&tlv320aic3104>;
            clocks = <&clkout2_clk>;                        
            //clocks = <&atl_clkin2_ck>;
                };
        };

    mcasp3_pins_default: mcasp3_pins_default {
        pinctrl-single,pins = <
            0x29c   ((0x40000)|PIN_OUTPUT_PULLUP | MUX_MODE3) /* clk2. */
            0x328 ( (0xC0000)| MUX_MODE0) /* mcasp3_fsx.mcasp1_fsx */
            0x324 ( (0x40000)| MUX_MODE0) /* mcasp3_aclkx.mcasp1_aclkx */        
            0x32c ((0xC0000) | MUX_MODE0) /* mcasp3_axr0.mcasp1_axr0 */
            0x330 ((0xC0160) | MUX_MODE0) /* mcasp3_axr1.mcasp1_axr1 */
        >;
    };

&i2c1 {
    status = "okay";
    clock-frequency = <400000>;

    tlv320aic3104: tlv320aic3104@18 {
        #sound-dai-cells = <0>;
        compatible = "ti,tlv320aic3104";
        reg = <0x18>;
        assigned-clocks = <&clkoutmux2_clk_mux>;
        assigned-clock-parents = <&sys_clk2_dclk_div>;

        adc-settle-ms = <40>;
        AVDD-supply = <&vdd_3v3>;
        IOVDD-supply = <&vdd_3v3>;
        DRVDD-supply = <&vdd_3v3>;
        DVDD-supply = <&aic_dvdd>;

        status = "okay";
    };
};


&mcasp3 {
    #sound-dai-cells = <0>;
    status = "okay";
    pinctrl-0 = <&mcasp3_pins_default>;
    assigned-clocks = <&mcasp3_ahclkx_mux>;
        assigned-clock-parents = <&sys_clkin2>;
        assigned-clock-rates = <22579200>;
    op-mode = <0>;    /* MCASP_IIS_MODE */
    tdm-slots = <2>;
    /* 4 serializers */
    serial-dir = <    /* 0: INACTIVE, 1: TX, 2: RX */
        1 2 0 0
    >;
    tx-num-evt = <8>;
    rx-num-evt = <8>;
};

Thanks & Regards

Prasad.

  • Prasad,

    From what I can see, your AIC3x codec is the master and should provide the bit clock and frame sync during audio playback. You first need to check with scope if you are having the expected and correct signals (bit clock frequency and frame sync) on mcasp3 pins. Check also if you have the correct pimux value on mcasp3 pins.

    Refer also to below guide for debug hints:

    Regards,
    Pavel

  • Hi Sir,

    We got the bit clock frequency and frame sync ( AFSX=39.06kHz, ACLKX=1.250MHz) and MCLK=20MHz.


    root@am57xx-evm:~# i2cdetect -r 0  
    WARNING! This program can confuse your I2C bus, cause data loss and worse!
    I will probe file /dev/i2c-0 using read byte commands.
    I will probe address range 0x03-0x77.
    Continue? [Y/n] Y
         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- -- UU -- -- -- -- -- --
    50: -- -- -- -- -- -- -- -- UU UU UU 5b -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- --                         
    root@am57xx-evm:~#

    where we have to focus to get the audio working. Please help us to resolve this.

    Thanks & Regards
    Prasad.

  • Prasad,

    Potturu Venkata Prasad said:
    We got the bit clock frequency and frame sync ( AFSX=39.06kHz, ACLKX=1.250MHz) and MCLK=20MHz.

    This doesn't look as correct sample rate for me. You have 39.06KHz sample rate, while supported frequencies are listed in below wiki:

    Multiple sample rates support (8KHz, 16KHz, 22.05KHz, 32KHz, 44.1KHz, 48KHz, 64KHz, 88.2KHz and 96KHz) for both capture and playback.

    How exactly you are playing audio files? Using aplay tool or playback application? Can you provide the console log when starting to play audio file?

    Regards,
    Pavel

  • Hi Sir.

    We are playing audio file using aplay as follows,

    root@am57xx-evm:~# aplay audio.wav
    Playing WAVE 'audio.wav' : [   21.519579] Enter davinci_mcasp_set_dai_fmt()
    Signed 16 bit Little Endian, Rate 44100 Hz, Stereo
    [   21.524874] case SND_SOC_DAIFMT_CBM_CFM
    [   21.595099] CM_L4PER2_MCASP3_CLKCTRL  7000002
    ^CAborted by signal Interrupt...
    root@am57xx-evm:~#

    Thanks & Regards
    Prasad.

  • Prasad,

    Your audio file default sample rate is 44.1KHz, while you are seeing 39.06KHz on that pin. This issue seems to be related to your audio codec AIC3x, as it seems audio codec can not produce 44.1KHz from 20MHz input. You need to check this in Audio forum, where AIC3x codec is supported.

    Other thing you can check is if you have any data signal on McASP data output pin mcasp3_axr0, you need to probe the pin with scope.

    Other thing to check is your pinmux. Seems like you are using McASP3, but making pinmux for McASP0. And pinmux is done only in SPL/MLO due to device errata, not in kernel DTS file.

    Regards,
    Pavel

  • Hi Sir,

    One thing we have observed that when we play different files we are getting different frequencies on AFSX.

    We are getting the data pulses on mcasp3_axr0 (DIN) pin.

    Thanks & Regards
    Prasad.

  • Hi Sir,

    The pinmux for MCASP3 is correct the same thing we were used in PSDK_02.00 audio is working fine and not in PSDK_05.02.

    We are getting the same frequencies(AFSX, ACLKX, MCLK and DIN) like old board (PSDK_02).

    When we try to probe the i2c bus we are getting as follows in uboot. Is i2c causes for not getting the audio?

    => i2c probe
    No I2C bus selected
    => i2c bus
    Bus 0:  i2c@48070000  (active 0)
       58: tps65917@58, offset len 1, flags 0
    =>

    Thanks & Regards
    Prasad.

  • Prasad,

    I am looking in latest PSDK v6.00 am57xx-beagle-x15-common.dtsi and we have some differences with your DTS file.

    Potturu Venkata Prasad said:
    simple-audio-card,cpu {
                            sound-dai = <&mcasp3>;
                            system-clock-frequency = <5644800>;
                    };

    We have no "system-clock-frequency" entry:

    simple-audio-card,cpu {
                sound-dai = <&mcasp3>;
            };


    Potturu Venkata Prasad said:
    mcasp3_pins_default: mcasp3_pins_default {

    This is done in SPL/MLO only.

    Potturu Venkata Prasad said:
    &mcasp3 {
        #sound-dai-cells = <0>;
        status = "okay";
        pinctrl-0 = <&mcasp3_pins_default>;
        assigned-clocks = <&mcasp3_ahclkx_mux>;
            assigned-clock-parents = <&sys_clkin2>;
            assigned-clock-rates = <22579200>;
        op-mode = <0>;    /* MCASP_IIS_MODE */
        tdm-slots = <2>;
        /* 4 serializers */
        serial-dir = <    /* 0: INACTIVE, 1: TX, 2: RX */
            1 2 0 0
        >;
        tx-num-evt = <8>;
        rx-num-evt = <8>;
    };

    We have:

    &mcasp3 {
        #sound-dai-cells = <0>;
        assigned-clocks = <&l4per_clkctrl DRA7_MCASP3_CLKCTRL 24>;
        assigned-clock-parents = <&sys_clkin2>;
        status = "okay";

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

     


    If you align your DTS file to PSDK Linux v6.00 DTS file, will be there any improvement?

    I would also suggest you to:

     - make register dump of McASP3 module registers in PSDK 2.00 and PSDK 5.02 and compare the values for differences

    - make register dump of McASP3 pinmux registers in PSDK 2.00 and PSDK 5.02 and compare the values for differences

    - make register dump of I2C1 pinmux registers in PSDK 2.00 and PSDK 5.02 and compare the values for differences

    - check register value of CM_L4PER2_MCASP3_CLKCTRL in PSDK 2.00 and PSDK 5.02 and compare the values for differences

    - dump AIC3x codec registers values with i2c tools in PSDK 2.00 and PSDK 5.02 and compare the values for differences

     

    For i2c tools usage you can refer to below user guides:

     

    Regards,
    Pavel