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.

Porting new audio codec in ti sdk 6

Other Parts Discussed in Thread: TPS65217

Dear TI E2E community,

Actually I was using dts was unable to succeeed TI sdk 7 BSP,

since my reference uda134x.c driver code is already implemented based on board file concept so I switched to ti sdk 6 & did the necessary changes as below hoping should work staright forward,

I am porting uda134x.c audio codec driver (already ported for mach-mini2440.c & s3c24xx_uda134x.c based on board file) in TI SDK 6 for which I have added the platform data in the board-am335xevm.c & I have done the necessary changes that is to be done in davinci-evm.c as shown below, but the problem is my client driver i., uda134x.c is not getting invoked, & I have attached the logs also below,

Could anybody please kindly do the needful & would appreciate a lot if anybody points out whether am missing any configuration in this board file ie.,board-am335xevm.c or davinci-evm.c file inorder to get my client driver invoked  & get sound card registered & pcm nodes created

Kindly do the needful as early as possible, as am struggling from past 4 weeks & stuck with it, still am unable to proceed further


board-am335xevm.c
==================
#include <sound/uda134x.h>

struct am335x_uda134x_platform_data {
    int l3_clk;
    int l3_mode;
    int l3_data;
    void (*power) (int);
    int model;
};


static struct am335x_uda134x_platform_data am335x_audio_pins = {
    .l3_clk = GPIO_TO_PIN(0, 10), //10,//S3C2410_GPB(4),GPIO_TO_PIN(0, 10)
    .l3_mode = GPIO_TO_PIN(2, 17),//81,//S3C2410_GPB(2),GPIO_TO_PIN(2, 17)
    .l3_data = GPIO_TO_PIN(0, 8),//8,//S3C2410_GPB(3),GPIO_TO_PIN(0, 8)
    .model = UDA134X_UDA1345
};

static struct platform_device am335x_audio = {
    .name        = "davinci_evm",
    .id        = 0,
    .dev        = {
        .platform_data    = &am335x_audio_pins,
    },
};

static struct platform_device uda1345_codec = {
        .name = "uda134x-codec",
        .id = -1,
};

static void am335x_audio_init(int evm_id, int profile)
{
    int err;


    err = platform_device_register(&am335x_audio);
    if (err) {
        printk("failed to register am335x_audio_init PLATFORM DATA FOR UDA134X IN AM335X BOARD FILE\n");
    }
    else
    {
        printk("SUCCESSFULL am335x_audio_init PLATFORM DATA FOR UDA134X IN AM335X BOARD FILE\n");

    }
}

static void uda134x_audio_init(int evm_id, int profile)
{
    int err;


    err = platform_device_register(&uda1345_codec);
    if (err) {
        printk("failed to register uda134x_audio_init PLATFORM DATA FOR UDA134X IN AM335X BOARD FILE\n");
    }
    else
    {
        printk("SUCCESSFULL uda134x_audio_init PLATFORM DATA FOR UDA134X IN AM335X BOARD FILE\n");

    }
}


static u8 am335x_iis_serializer_direction0[] = {
    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_direction0),
    .tdm_slots    = 2,
    .serial_dir    = am335x_iis_serializer_direction0,
    .asp_chan_q    = EVENTQ_2,
    .version    = MCASP_VERSION_3,
    .txnumevt    = 32,
    .rxnumevt    = 32,
    .get_context_loss_count    =
            omap_pm_get_dev_context_loss_count,
};

/* Module pin mux for mcasp0 */
static struct pinmux_config mcasp0_pin_mux[] = {
    {"mcasp0_ahclkx.mcasp0_ahclkx", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN}, //sysclk / mclk
    {"mcasp0_aclkx.mcasp0_aclkx", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN}, // bck
    {"mcasp0_fsx.mcasp0_fsx", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN}, //ws
    {"mcasp0_axr0.mcasp0_axr0", OMAP_MUX_MODE0 | AM33XX_PIN_INPUT_PULLDOWN},//datao
    {"mcasp0_axr1.mcasp0_axr1", OMAP_MUX_MODE0 |
                        AM33XX_PIN_INPUT_PULLDOWN}, // datai
    {NULL, 0},
};


/* Setup McASP 0 */
static void mcasp0_init(int evm_id, int profile)
{
    /* Configure McASP */
    setup_pin_mux(mcasp0_pin_mux);
    switch (evm_id) {
    case EVM_SK:
        am335x_register_mcasp(&am335x_evm_sk_snd_data1, 1);
        break;
    default:
        am335x_register_mcasp(&am335x_evm_snd_data0, 1);
    }

    return;
}


/* Beaglebone Black */
static struct evm_dev_cfg beagleboneblack_dev_cfg[] = {
    {am335x_rtc_init, DEV_ON_BASEBOARD, PROFILE_NONE},
    {clkout2_enable, DEV_ON_BASEBOARD, PROFILE_NONE},
    {tps65217_init,    DEV_ON_BASEBOARD, PROFILE_NONE},
    {mii1_init,    DEV_ON_BASEBOARD, PROFILE_NONE},
    {usb0_init,    DEV_ON_BASEBOARD, PROFILE_NONE},
    {usb1_init,    DEV_ON_BASEBOARD, PROFILE_NONE},
    {mmc1_emmc_init,    DEV_ON_BASEBOARD, PROFILE_NONE},
    {mcasp1_init,    DEV_ON_DGHTR_BRD, PROFILE_NONE},
    {mcasp0_init,    DEV_ON_DGHTR_BRD, PROFILE_NONE},
    {am335x_audio_init, DEV_ON_DGHTR_BRD, PROFILE_NONE},
    {uda134x_audio_init, DEV_ON_DGHTR_BRD, PROFILE_NONE},
    {mmc0_init,    DEV_ON_BASEBOARD, PROFILE_NONE},
    {i2c1_init,    DEV_ON_BASEBOARD, PROFILE_NONE},
    {i2c2_init,    DEV_ON_BASEBOARD, PROFILE_NONE},
    {sgx_init,    DEV_ON_BASEBOARD, PROFILE_NONE},
    {NULL, 0, 0},
};



static struct platform_device *audio_devices[] __initdata = {

    &am335x_audio,
    &uda1345_codec,
    
};


/* BeagleBone Black */
static void setup_beagleboneblack(void)
{
    pr_info("The board is a AM335x Beaglebone Black.\n");

    /* Beagle Bone has Micro-SD slot which doesn't have Write Protect pin */
    am335x_mmc[0].gpio_wp = -EINVAL;

    platform_add_devices(audio_devices, ARRAY_SIZE(audio_devices));

    _configure_device(BEAGLE_BONE_BLACK, beagleboneblack_dev_cfg,
                PROFILE_NONE);

    /* TPS65217 regulator has full constraints */
    regulator_has_full_constraints();

    am33xx_cpsw_init(AM33XX_CPSW_MODE_MII, NULL, NULL);
}


sound/soc/davinci/davinci-evm.c
===============================

#include <linux/gpio.h>
#include <sound/uda134x.h>
#include <sound/l3.h>
//#include "uda134x.h"

#define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \
        SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF)

struct am335x_uda134x_platform_data {
    int l3_clk;
    int l3_mode;
    int l3_data;
    void (*power) (int);
    int model;
};

static struct am335x_uda134x_platform_data *am335x_uda134x_l3_pins;


/* Common DAPM widgets */
static const struct snd_soc_dapm_widget uda134x_dapm_widgets[] = {
    SND_SOC_DAPM_INPUT("VINL1"),
    SND_SOC_DAPM_INPUT("VINR1"),
    //SND_SOC_DAPM_INPUT("VINL2"),
    //SND_SOC_DAPM_INPUT("VINR2"),
    SND_SOC_DAPM_OUTPUT("VOUTL"),
    SND_SOC_DAPM_OUTPUT("VOUTR"),
};

static const struct snd_soc_dapm_route uda134x_dapm_routes[] = {
    { "ADC", NULL, "VINL1" },
    { "ADC", NULL, "VINR1" },
    //{ "ADC", NULL, "VINL2" },
    //{ "ADC", NULL, "VINR2" },
    { "VOUTL", NULL, "DAC" },
    { "VOUTR", NULL, "DAC" },
};


static int evm_uda134x_init(struct snd_soc_pcm_runtime *rtd)
{
    struct snd_soc_codec *codec = rtd->codec;
    struct snd_soc_dapm_context *dapm = &codec->dapm;
    //struct device_node *np = codec->card->dev->of_node;
    //int ret;
printk(KERN_ALERT "evm_uda134x_init DAVINCIEVM.C DEBUG: Passed %s %d \n",__FUNCTION__,__LINE__);
    snd_soc_dapm_new_controls(dapm, uda134x_dapm_widgets,
                  ARRAY_SIZE(uda134x_dapm_widgets));

        /* Set up davinci-evm specific audio path audio_map */
    printk("DAVINCIIIIIIIIIII UDA134XXXXX  DAPM ROUTING\n");
    snd_soc_dapm_add_routes(dapm, uda134x_dapm_routes, ARRAY_SIZE(uda134x_dapm_routes));


#if 0

    /* not connected */
    snd_soc_dapm_disable_pin(dapm, "MONO_LOUT");
    snd_soc_dapm_disable_pin(dapm, "HPLCOM");
    snd_soc_dapm_disable_pin(dapm, "HPRCOM");

    /* always connected */
    snd_soc_dapm_enable_pin(dapm, "Headphone Jack");
    snd_soc_dapm_enable_pin(dapm, "Line Out");
    snd_soc_dapm_enable_pin(dapm, "Mic Jack");
    snd_soc_dapm_enable_pin(dapm, "Line In");

#endif

    return 0;
}


static struct snd_soc_dai_link am335x_evm_dai = {
    .name = "UDA134X",
    .stream_name = "UDA134X",
    .codec_name = "uda134x-codec",
    .codec_dai_name = "uda134x-hifi",
    .cpu_dai_name = "davinci-mcasp.0",
    .ops = &evm_ops,
    .platform_name    = "davinci-pcm-audio",
    .init = evm_uda134x_init,
};

static void setdat(int v)
{
    gpio_set_value(am335x_uda134x_l3_pins->l3_data, v > 0);
}

static void setclk(int v)
{
    gpio_set_value(am335x_uda134x_l3_pins->l3_clk, v > 0);
}

static void setmode(int v)
{
    gpio_set_value(am335x_uda134x_l3_pins->l3_mode, v > 0);
}

/* FIXME - This must be codec platform data but in which board file ?? */
static struct uda134x_platform_data am335x_uda134x = {
    .l3 = {
        .setdat = setdat,
        .setclk = setclk,
        .setmode = setmode,
        .data_hold = 1,
        .data_setup = 1,
        .clock_high = 1,
        .mode_hold = 1,
        .mode = 1,
        .mode_setup = 1,
    },
};

static int am335x_uda134x_setup_pin(int pin, char *fun)
{
    if (gpio_request(pin, "am335x_uda134x") < 0) {
        printk(KERN_ERR "AM335X_UDA134X SoC Audio: "
               "l3 %s pin already in use", fun);
        return -EBUSY;
    }
    gpio_direction_output(pin, 0);
    return 0;
}

static int davinci_evm_probe(struct platform_device *pdev)
{

    struct snd_soc_card *evm_snd_dev_data;
    int index = 0;
    int ret;

    printk(KERN_INFO "DAVINCIIIIIIIII_EVMMM_PROBEEEEEEEEEE SoC Audio driver\n");

    if (machine_is_am335xevm()) {
        printk(KERN_INFO "davinci_evm_probe machine_is_am335xevm SoC Audio driver\n");
        evm_snd_dev_data = &am335x_snd_soc_card;
        index = 0;
    }
    else{
        printk(KERN_INFO "NOTTTTTTTTTTTTT machine_is_am335xevm())))))))))))))))))))))))))))) SoC Audio driver\n");
        return -EINVAL;
    }    


#if 1
    
    am335x_uda134x_l3_pins = pdev->dev.platform_data;
    if (am335x_uda134x_l3_pins == NULL) {
        printk(KERN_ERR "AM335X_UDA134X SoC Audio: "
               "unable to find platform data\n");
        return -ENODEV;
    }
    am335x_uda134x.power = am335x_uda134x_l3_pins->power;
    am335x_uda134x.model = am335x_uda134x_l3_pins->model;

        printk("am335x_uda134x_l3_pins->l3_clk %d\n",am335x_uda134x_l3_pins->l3_clk);
        printk("am335x_uda134x_l3_pins->l3_data %d\n", am335x_uda134x_l3_pins->l3_data);
        printk("am335x_uda134x_l3_pins->l3_mode %d\n", am335x_uda134x_l3_pins->l3_mode);
        printk("am335x_uda134x_l3_pins->power %d\n", am335x_uda134x_l3_pins->power);
        printk("am335x_uda134x_l3_pins->model %d\n", am335x_uda134x_l3_pins->model);

        printk("am335x_uda134x.power %d\n", am335x_uda134x.power);
        printk("am335x_uda134x.model %d\n", am335x_uda134x.model);
        

    if (am335x_uda134x_setup_pin(am335x_uda134x_l3_pins->l3_data,
                      "data") < 0)
        return -EBUSY;
    if (am335x_uda134x_setup_pin(am335x_uda134x_l3_pins->l3_clk,
                      "clk") < 0) {
        gpio_free(am335x_uda134x_l3_pins->l3_data);
        return -EBUSY;
    }
    if (am335x_uda134x_setup_pin(am335x_uda134x_l3_pins->l3_mode,
                      "mode") < 0) {
        gpio_free(am335x_uda134x_l3_pins->l3_data);
        gpio_free(am335x_uda134x_l3_pins->l3_clk);
        return -EBUSY;
    }

#endif

    evm_snd_device = platform_device_alloc("soc-audio", -1);
    if (!evm_snd_device)
    {
        printk(KERN_ALERT "FAILUREEEEEE davinci_evm_probe DAVINCIEVM.C DEBUG: Passed %s %d \n",__FUNCTION__,__LINE__);
        return -ENOMEM;
    }
    else
    {
        printk(KERN_ALERT "SUCCESSFULLL davinci_evm_probe DAVINCIEVM.C DEBUG: Passed %s %d \n",__FUNCTION__,__LINE__);

    }
        

    platform_set_drvdata(evm_snd_device, evm_snd_dev_data);
    ret = platform_device_add_data(evm_snd_device, &am335x_uda134x, sizeof(am335x_uda134x));
    printk(KERN_ALERT " davinci_evm_probe platform_device_add_data %d \n",ret);
        
    ret = platform_device_add(evm_snd_device); /////problemmmmmmmmmmm
    if (ret)
    {
        printk(KERN_ALERT "SUCCESSFULLL davinci_evm_probe platform_device_add %d \n",ret);
        platform_device_put(evm_snd_device);
        
    }    
    else
    {
        printk(KERN_ALERT "FAILUREEEEEEE davinci_evm_probe platform_device_add %d \n",ret);

    }

    return ret;
}


static int davinci_evm_remove(struct platform_device *pdev)
{

#if 1
    gpio_free(am335x_uda134x_l3_pins->l3_data);
    gpio_free(am335x_uda134x_l3_pins->l3_clk);
    gpio_free(am335x_uda134x_l3_pins->l3_mode);
#endif

    return 0;
}

static struct platform_driver davinci_evm_driver = {
    .probe        = davinci_evm_probe,
    .remove        = davinci_evm_remove,
    .driver        = {
        .name    = "davinci_evm",
        .owner    = THIS_MODULE,
        .pm    = &snd_soc_pm_ops,
    },
};

static int __init evm_init(void)
{
    struct snd_soc_card *evm_snd_dev_data;
    int index;
    int ret;

    printk(KERN_INFO "DAVINCIIIIIIII_EVMMMMMMM_INITTTTTT_UDA134X SoC Audio driver\n");

      return platform_driver_register(&davinci_evm_driver); // added for uda134x

    if (machine_is_davinci_evm()) {
        evm_snd_dev_data = &dm6446_snd_soc_card_evm;
        index = 0;
    } else if (machine_is_davinci_dm355_evm()) {
        evm_snd_dev_data = &dm355_snd_soc_card_evm;
        index = 1;
    } else if (machine_is_davinci_dm365_evm()) {
        evm_snd_dev_data = &dm365_snd_soc_card_evm;
        index = 0;
    } else if (machine_is_davinci_dm6467_evm()) {
        evm_snd_dev_data = &dm6467_snd_soc_card_evm;
        index = 0;
    } else if (machine_is_davinci_da830_evm()) {
        evm_snd_dev_data = &da830_snd_soc_card;
        index = 1;
    } else if (machine_is_davinci_da850_evm()) {
        evm_snd_dev_data = &da850_snd_soc_card;
        index = 0;
    } else if (machine_is_am335xevm()) {
        evm_snd_dev_data = &am335x_snd_soc_card;
#ifdef CONFIG_MACH_AM335XEVM
        if (am335x_evm_get_id() == EVM_SK)
            evm_snd_dev_data = &am335x_evm_sk_snd_soc_card;
#endif
        index = 0;
    } else
        return -EINVAL;



    evm_snd_device = platform_device_alloc("soc-audio", index);
    if (!evm_snd_device)
        return -ENOMEM;

    platform_set_drvdata(evm_snd_device, evm_snd_dev_data);
    ret = platform_device_add(evm_snd_device);
    if (ret)
        platform_device_put(evm_snd_device);

    return ret;

}


logs:
[   13.625000] DAVINCIIIIIIII_EVMMMMMMM_INITTTTTT_UDA134X SoC Audio driver
[   13.631958] DAVINCIIIIIIIII_EVMMM_PROBEEEEEEEEEE SoC Audio driver
[   13.638336] davinci_evm_probe machine_is_am335xevm SoC Audio driver
[   13.644897] am335x_uda134x_l3_pins->l3_clk 10
[   13.649444] am335x_uda134x_l3_pins->l3_data 8
[   13.653991] am335x_uda134x_l3_pins->l3_mode 81
[   13.658630] am335x_uda134x_l3_pins->power 0
[   13.662994] am335x_uda134x_l3_pins->model 4
[   13.667388] am335x_uda134x.power 0
[   13.670928] am335x_uda134x.model 4
[   13.674499] SUCCESSFULLL davinci_evm_probe DAVINCIEVM.C DEBUG: Passed davinci_evm_probe 524
[   13.683319]  davinci_evm_probe platform_device_add_data 0
[   13.689056] SUCCESSFULLLL platform_device_add  if (!pdev) DEBUG: Passed platform_device_add 275
[   13.698272] pdev->id == -1 platform_device_add DEBUG: Passed platform_device_add 294 0
[   13.706542] Registering platform device 'soc-audio'. Parent at platform
[   13.713684] FAILUREEEEEEE davinci_evm_probe platform_device_add 0



Awaiting for your replies,
Many Many thanks in advance

  • Please avoid creating multiple posts because it is difficult to track for follow up also and I understand your urgencies.
    I ask our AM335x experts to look into this and they would provide suggestions for that.

    http://e2e.ti.com/support/embedded/linux/f/354/t/390265
    http://e2e.ti.com/support/embedded/linux/f/354/t/391864
  • Dear Titus,

    Many Thanks a lot for all your support for supporting all my issues,

    Many Many Thanks for your quick replies,

    Once again sorry for duplicating the threads, as I didn't get any replies from many days, I thought that my query was n't posted properly so I created these threads,

    I have only two queries w.r.t audio codec porting which porting new audio codec uda134x.c in TI SDK 7 & TI SDK 6, & finally I want this to be ported in TI sdk 7 as this takes time, For initial verification of codec I want this to be ported in sdk 6

    Could you please ask your am335x audio experts to address this two threads as early as possible, as am stuck with these from more than 3 weeks & I understand hope the vaccations might have delayed in responding to my queries

    Kindly do the needful as early possible,

    Many Many Thanks in advance again,
  • Hi Srini,

    Would you change line:
    ret = platform_device_add_data(evm_snd_device, &am335x_uda134x, sizeof(am335x_uda134x)); with:
    ret = platform_device_add(evm_snd_device);

    BR
    Ivan
  • Thanks very much Ivan for your quick responses

    I'm not very much clear with your above statements , could you please reconfirm that, does the above statements means that 

    The statement ie.,  ret = platform_device_add_data(evm_snd_device, &am335x_uda134x, sizeof(am335x_uda134x)); should be replaced with

    ret = platform_device_add(evm_snd_device); ???? 

    If it is replaced with  ret = platform_device_add(evm_snd_device);  then how arguments &am335x_uda134x, sizeof(am335x_uda134x) information is passed, where am trying to do the  porting from s3c24xx_uda134x.c similar to s3c24xx_uda134x_probe to platform_device_add??????

    Kindly do the needful as early as possible as this is getting delayed from many weeks

    Many many Thanks in advance again Ivan