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.

AM335x McASP0 interface to AIC34

Other Parts Discussed in Thread: TLV320AIC34, TLV320AIC3106

Hi all,

We are interfacing the AIC34 to beaglebone AM335x McASP0(as we do not have McASP1 lines accessible in the beaglebone).
In TI AM335x EVM McASP1 is interfaced with the codec AIC3106.

Following are the changes made in order to configure the McASP0 and to interface with AIC34.


arch/arm/mach-omap2/board-am335xevm.c

static struct pinmux_config mcasp0_pin_mux[] = {
        {"lcd_data8.mcasp0_aclkx", OMAP_MUX_MODE3 |AM33XX_PIN_INPUT_PULLDOWN},
        {"lcd_data9.mcasp0_fsx", OMAP_MUX_MODE3   |AM33XX_PIN_INPUT_PULLDOWN},
        {"lcd_data12.mcasp0_axr2", OMAP_MUX_MODE4 |AM33XX_PIN_INPUT_PULLDOWN},
        {"lcd_data13.mcasp0_axr3", OMAP_MUX_MODE4 |AM33XX_PIN_INPUT_PULLDOWN},
        {NULL, 0},
};

static u8 am335x_iis_serializer_direction1[] = {
        INACTIVE_MODE,  INACTIVE_MODE,  TX_MODE,        RX_MODE,
        INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
        INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
        INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,  INACTIVE_MODE,
};


static struct snd_platform_data am335x_evm_snd_data0 = {
        .tx_dma_offset  = 0x46000000,   /* McASP0 */
        .rx_dma_offset  = 0x46000000,
        .op_mode        = DAVINCI_MCASP_IIS_MODE,
        .num_serializer = ARRAY_SIZE(am335x_iis_serializer_direction1),
        .tdm_slots      = 2,
        .serial_dir     = am335x_iis_serializer_direction1,
        .asp_chan_q     = EVENTQ_2,
        .version        = MCASP_VERSION_3,
        .txnumevt       = 1,
        .rxnumevt       = 1,
};

/* Setup McASP 0 */
static void mcasp0_init(int evm_id, int profile)
{
        /* Configure McASP */
        setup_pin_mux(mcasp0_pin_mux);
        am335x_register_mcasp0(&am335x_evm_snd_data0);
        return;
}


arch/arm/mach-omap2/devices.c


static struct resource am335x_mcasp0_resource[] = {
        {
                .name = "mcasp0",
                .start = AM33XX_ASP0_BASE,
                .end = AM33XX_ASP0_BASE + (SZ_1K * 12) - 1,
                .flags = IORESOURCE_MEM,
        },
        /* TX event */  
        {
                .start = AM33XX_DMA_MCASP0_X,
                .end = AM33XX_DMA_MCASP0_X,
                .flags = IORESOURCE_DMA,
        },
        /* RX event */
        {
                .start = AM33XX_DMA_MCASP0_R,
                .end = AM33XX_DMA_MCASP0_R,
                .flags = IORESOURCE_DMA,
        },
};      
        
static struct platform_device am335x_mcasp0_device = {
        .name = "davinci-mcasp",
        .id = 0,
        .num_resources = ARRAY_SIZE(am335x_mcasp0_resource),
        .resource = am335x_mcasp0_resource,
};
        
void __init am335x_register_mcasp0(struct snd_platform_data *pdata)
{       
        am335x_mcasp0_device.dev.platform_data = pdata;
        platform_device_register(&am335x_mcasp0_device);
}

sound/soc/davinci/davinci-evm.c

static struct snd_soc_dai_link am335x_evm_dai = {
        .name = "TLV320AIC3X",
        .stream_name = "AIC3X",        
        .cpu_dai_name = "davinci-mcasp.0",
        .codec_dai_name = "tlv320aic3x-hifi",        
        .codec_name = "tlv320aic3x-codec.2-001a",
        .platform_name = "davinci-pcm-audio",
        .init = evm_aic3x_init,
        .ops = &evm_ops,
};

With the above mentioned changes I am able to register the McASP0

[    1.276813] asoc: tlv320aic3x-hifi <-> davinci-mcasp.0 mapping ok

when I try to play song using aplay I am getting the following error.

aplay: pcm_write:1575: write error: Input/output error

Please suggest.

Regards,

Vishwas HC

  • Hi All,

    In relation with the above question, I am able to find out the place where exactly request is failing.

    In sound/soc/davinci/davinci-mcasp.c file "mcasp_start_tx" function.

           /* wait for TX ready */
            cnt = 0;
            while (!(mcasp_get_reg(dev->base + DAVINCI_MCASP_XRSRCTL_REG(offset)) &
                     TXSTATE) && (cnt < 100000))
                    cnt++;

    Here
    (mcasp_get_reg(dev->base + DAVINCI_MCASP_XRSRCTL_REG(offset)) & TXSTATE) is always returning ZERO and when the cnt reaches 100000 control is coming out. This is happening when I use McASP0.

    In case of EVM where McASP1 is interfaced, cnt value is around 160 and (mcasp_get_reg(dev->base + DAVINCI_MCASP_XRSRCTL_REG(offset)) & TXSTATE) is returning ONE.

    I think McASP0 is not configured properly, Please suggest if I am missing anything while configuring McASP0. 

    Regards,

    Vishwas HC

  • Vishwas,

    I did your changes except below one.

    I had to chance mcasp0_pin_mux like below,

    /* Module pin mux for mcasp0 */
    static struct pinmux_config mcasp0_pin_mux[] = {
    {"mcasp0_aclkx.mcasp0_aclkx", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
    {"mcasp0_fsx.mcasp0_fsx", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
    {"mcasp0_ahclkr.mcasp0_axr2", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
    {"mcasp0_ahclkx.mcasp0_axr3", OMAP_MUX_MODE1 | AM33XX_PIN_INPUT_PULLDOWN},
    {NULL, 0},
    };
    All the rest of changes is like yours.
    But I couldn't get mcasp.0 mapping message.

    " asoc: tlv320aic3x-hifi <-> davinci-mcasp.0 mapping ok"

    Can you help please?
    
    
    Mehmet


  • Hi Mehmet,

    Are you using the beaglebone for interface with AIC34?

    Please let me know the reason behind the change in the mcasp0_pin_mux structure.

    Also I did the changes as mentioned in the above post(if I have missed anything, I will check and let you know) and I am using Linux-3.1.0-rc8 kernel version form TI SDK for AM335X EVM.

    Regards,

    Vishwas HC

  • Vishwas,

    Thanks for reply.

    I didn't understand what you mean with AIC34. We have beaglebone board and We use tlv320aic3x codec. 

    We didn't use mcasp0 pins like you, because we use lcd. So we used mcasp0 pins like beaglebone-dvi-d schematic. I think there is no any change about pins except  mcasp0_pin_mux[] structure.

    Thanks

    Mehmet

  • I mean tlv320aic34 codec interface with McASP0.

    Regards,

    Vishwas HC

  • Vishwas,

    So it likes same. If so, How can't I see "asoc: tlv320aic3x-hifi <-> davinci-mcasp.0 mapping ok". Is there anything  that I miss.

    Thanks

    Mehmet

  • Hi Mehmet,

    I think you are missing initialization of McASP0 in arch/arm/mach-omap2/board-am335xevm.c

    /* Beaglebone Rev A3 and after */
    static struct evm_dev_cfg beaglebone_dev_cfg[] = {
            {mii1_init,     DEV_ON_BASEBOARD, PROFILE_NONE},
            {usb0_init,     DEV_ON_BASEBOARD, PROFILE_NONE},
            {usb1_init,     DEV_ON_BASEBOARD, PROFILE_NONE},
            {mmc0_init,     DEV_ON_BASEBOARD, PROFILE_NONE},
            {i2c1_init,     DEV_ON_BASEBOARD, PROFILE_NONE},
            {mcasp0_init,   DEV_ON_BASEBOARD, PROFILE_NONE},
            {NULL, 0, 0},
    };

    and i2c slave address should match in structure am335x_i2c_boardinfo1[ ](present in arch/arm/mach-omap2/board-am335xevm.c ) and in am335x_evm_dai structure(present in sound/soc/davinci/davinci-evm.c)  .codec_name="tlv320aic3x-codec.2-0x001a"

    Regards,

    Vishwas HC

  • Hi All,

    Can I get some guidelines to solve the problem as mentioned in the above post.

    Here it is for quick reference:

    In relation with the above question, I am able to find out the place where exactly request is failing.

    In sound/soc/davinci/davinci-mcasp.c file "mcasp_start_tx" function.

           /* wait for TX ready */
            cnt = 0;
            while (!(mcasp_get_reg(dev->base + DAVINCI_MCASP_XRSRCTL_REG(offset)) &
                     TXSTATE) && (cnt < 100000))
                    cnt++;

    Here
    (mcasp_get_reg(dev->base + DAVINCI_MCASP_XRSRCTL_REG(offset)) & TXSTATE) is always returning ZERO and when the cnt reaches 100000 control is coming out. This is happening when I use McASP0.

    In case of EVM where McASP1 is interfaced, cnt value is around 160 and (mcasp_get_reg(dev->base + DAVINCI_MCASP_XRSRCTL_REG(offset)) & TXSTATE) is returning ONE.

    I think McASP0 is not configured properly, Please suggest if I am missing anything while configuring McASP0. 

    Regards,

    Vishwas HC

  • Hi Vishwas,

    I did mcasp0_init in arch/arm/mach-omap2/board-am335xevm.c file.

    And i2c slave address is 0x1b in in structure am335x_i2c_boardinfo1[ ](present in arch/arm/mach-omap2/board-am335xevm.c ) and in am335x_evm_dai structure(present in sound/soc/davinci/davinci-evm.c)  .codec_name="tlv320aic3x-codec.2-0x001b"

    Thanks

    Mehmet

  • Vishwas,

    It is ok, I can hear audio. And I want to try it on android. I have done same changes but I couldn't hear anything. While kernel is booting I see audio debugs. But codec doesn't run properly. There is no frame sync. and data clock on codec. Do you have any idea? Do you use android? 

    [    1.379332] asoc: tlv320aic3x-hifi <-> davinci-mcasp.0 mapping ok            
    [ 1.386528] ALSA device list:
    [ 1.389665] #0: AM335X EVM
    
    
    Thanks
    Mehmet
  • No I do not use Android.

  • Vishwas HC said:
      {"lcd_data12.mcasp0_axr2", OMAP_MUX_MODE4 |AM33XX_PIN_INPUT_PULLDOWN},

    Looking at the serializer direction that you have given this needs to be output.

    Regards,

    Vaibhav

  • Hi Vaibhav,

    This is simillar to mcasp1 muxing in ti EVM, which is working perfect.

    Also i tried by changing it to output but the result is same.

    Regards,

    Vishwas HC

  • Hi Vaibhav,

    Now McASP0 interface with AIC34 is working fine.

    The issue was the default value of Page0/Register 0 in AIC34. It is being set to 1 after reset. Writing 0 to this register solved the issue for me.

    Regards,

    Vishwas HC

  • That's great. Which driver are you using? Is it a custom driver?

    Regards,

    Vaibhav

  • yes, customized using TI PSP.

    Regards,

    Vishwas HC

  • Hi, Vishwas

    Are you customizing your drivers from package ti-sdk-am335x-evm-05.03.02.00-Linux-x86-Install from TI website?

    When I installed this package to my host, I found there is only release notes and user guide AM35X/OMAP35X 04.02.00.07 under Docs folder. These documents apparantly are not for AM335x board. Looks like TI distribute their software package in different name but same content? do you meet same issue when you install this package for your beaglebone board? 

    I looked throught source code and found there is only one board-am335xevm.c file and one config file am335x-evm-defconfig may applicable for beagbone board. Do we need any futher changes if we want to build a linux image for beaglebone board?

    Thanks in advance for your answers

  • Finally I found the document sitara-linuxsdk-sdg-05.03.02.00.pdf should be start point of all Sitara Processores. Thanks

  • Hi, Mehmet

    I used same pinmux configuration as yours for McASP0 on beaglebone. Currently I met a problem that there is no signal out on mcasp0_ahclkx.mcasp0_axr3. Had you ever met same issue when you debug your hardware?

    Thanks in advance for your commets

    Weidong

    I created a new thread for more details of my issue -->

    http://e2e.ti.com/support/embedded/linux/f/354/t/167636.aspx


  • Hi,

    I try to interface TLV320AIC3106 with BEAGLEBONE, I have a DVI cape with CODEC installed.

    My setup is:

    Schematic:

            AUD_IN   ---- A14 - mode 2 - MCASP0_AXR3
            AUD_OUT  ---- C12 - mode 2 - MCASP0_AXR2
            AUD_FSX  ---- B13 - mode 0 - MCASP0_FSX
            AUD_BCLK ---- A13 - mode 0 - MCASP0_ACLKX

            I2C_SDA  ---- B16 - mode 2 - I2C1_SDA
            I2C_SCL  ---- A16 - mode 2 - I2C1_SCL

    MUX config:

        // MCASP0
        static struct pinmux_config mcasp0_pin_mux[] = {
          {"mcasp0_ahclkx.mcasp0_axr3", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
          {"mcasp0_ahclkr.mcasp0_axr2", OMAP_MUX_MODE2 | AM33XX_PIN_INPUT_PULLDOWN},
          {"mcasp0_fsx.mcasp0_fsx", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
          {"mcasp0_aclkx.mcasp0_aclkx", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},
          {NULL, 0},
        };


        // I2C1
        static struct pinmux_config i2c1_pin_mux[] = {
            {"spi0_d1.i2c1_sda",    OMAP_MUX_MODE2 | AM33XX_SLEWCTRL_SLOW |
                                            AM33XX_PULL_ENBL | AM33XX_INPUT_EN},
            {"spi0_cs0.i2c1_scl",   OMAP_MUX_MODE2 | AM33XX_SLEWCTRL_SLOW |
                                            AM33XX_PULL_ENBL | AM33XX_INPUT_EN},
            {NULL, 0},
        };

        Kernel 3.1.0 from Texas SDK - Arago toolchain


    I suppose that the control I2C part is right because when I try to play a wave file I hear a BUMP on the speaker.

    The I2S part don't work fine because I don't hear the wave file.

    I check the presence of the clock on TLV pin and other voltage signal on the same chip.

    Questions:

        Can you post your schematic?
        Can you check my mux configuration?
        
     Thanks a lot in advance
     Have a nice day

     Luigi

  • Hi Vishwas,

    Can you please tell me where you write the register to 0 to solve the audio issue, because i too facing the same issue.

    I'm interfacing audio through mcasp0. I did all the changes which you mentioned in your thread and then i got the below message also

    [ 3.984497] asoc: tlv320aic3x-hifi <-> davinci-mcasp.0 mapping ok
    [ 3.992279] ALSA device list:
    [ 3.995422] #0: AM335X EVM

    But though i couldn't hear it. Can you please tell me where you did the above changes to fix it

    Thanks

    Vinoth

  • Hi Vishwas,

    Can you please tell me where you write the register to 0 to solve the audio issue, because i too facing the same issue.

    I'm interfacing audio through mcasp0. I did all the changes which you mentioned in your thread and then i got the below message also

    [ 3.984497] asoc: tlv320aic3x-hifi <-> davinci-mcasp.0 mapping ok
    [ 3.992279] ALSA device list:
    [ 3.995422] #0: AM335X EVM

    But though i couldn't hear it. Can you please tell me where you did the above changes to fix it

    Thanks

    Vinoth