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.

关于Board-am335xevm.c代码里面的PROFILE_XXX



在Board-am335xevm.c (arch\arm\mach-omap2) 中

/* General Purpose EVM */
static struct evm_dev_cfg gen_purp_evm_dev_cfg[] ={
    {am335x_rtc_init, DEV_ON_BASEBOARD, PROFILE_ALL},
    {clkout2_enable, DEV_ON_BASEBOARD, PROFILE_ALL},
    {enable_ecap0,    DEV_ON_DGHTR_BRD, (PROFILE_0 | PROFILE_1 |
                        PROFILE_2 | PROFILE_7) },

........

}

这里的PROFILE_XXX指的是什么,有什么作用呢?对应芯片手册里面的什么功能呢?

  • 具体可以看解析的函数,类似于case,和芯片好像没啥关系,软件方面的东西

  • 你好!可以查看下GP EVM 7寸液晶屏旁边有一个SW8,其作为profile selection,可以有8中profile

    详细可以参考u-boot源码下board\ti\am335x\mux.c中的定义

    The AM335x GP EVM can have one of 8 different profiles selected.  Each 
    profile has a different set of peripherals and requires different pinmux 
    configurations that conflict with other profiles.

  • TI的内核bsp是通过初始化evm_dev_cfg结构体来初始化cpu外设的。比如evm_sk_dev_cfg

    /* EVM - Starter Kit */
    static struct evm_dev_cfg evm_sk_dev_cfg[] = {
        {am335x_rtc_init, DEV_ON_BASEBOARD, PROFILE_ALL},
        {mmc1_wl12xx_init,    DEV_ON_BASEBOARD, PROFILE_ALL},
        {mmc0_init,    DEV_ON_BASEBOARD, PROFILE_ALL},
        {rgmii1_init,    DEV_ON_BASEBOARD, PROFILE_ALL},
        {rgmii2_init,    DEV_ON_BASEBOARD, PROFILE_ALL},
        {lcdc_init,     DEV_ON_BASEBOARD, PROFILE_ALL},
        {enable_ecap2,     DEV_ON_BASEBOARD, PROFILE_ALL},
        {mfd_tscadc_init,    DEV_ON_BASEBOARD, PROFILE_ALL},
        {gpio_keys_init,  DEV_ON_BASEBOARD, PROFILE_ALL},
        {gpio_led_init,  DEV_ON_BASEBOARD, PROFILE_ALL},
        {lis331dlh_init, DEV_ON_BASEBOARD, PROFILE_ALL},
        {mcasp1_init,   DEV_ON_BASEBOARD, PROFILE_ALL},
        {uart1_wl12xx_init, DEV_ON_BASEBOARD, PROFILE_ALL},
        {wl12xx_init,       DEV_ON_BASEBOARD, PROFILE_ALL},
        {gpio_ddr_vtt_enb_init,    DEV_ON_BASEBOARD, PROFILE_ALL},
        {sgx_init,       DEV_ON_BASEBOARD, PROFILE_ALL},
        {NULL, 0, 0},
    };


    evm_sk_dev_cfg被_configure_device函数读取,_configure_device(EVM_SK    , evm_sk_dev_cfg,  PROFILE_NONE);
    这里

    TI默认提供以下几种配置:
    gen_purp_evm_dev_cfg
    ind_auto_mtrl_evm_dev_cfg
    beaglebone_old_dev_cfg
    beaglebone_dev_cfg
    beaglebone_black_dev_cfg
    evm_sk_dev_cfg

    分析_configure_device
    static void _configure_device(int evm_id, struct evm_dev_cfg *dev_cfg,
        int profile)
    {
        int i;

        am335x_evm_set_id(evm_id);

        /*
        * Only General Purpose & Industrial Auto Motro Control
        * EVM has profiles. So check if this evm has profile.
        * If not, ignore the profile comparison
        */

        /*
        * If the device is on baseboard, directly configure it. Else (device on
        * Daughter board), check if the daughter card is detected.
        */
        if (profile == PROFILE_NONE) {
            for (i = 0; dev_cfg->device_init != NULL; dev_cfg++) {
                if (dev_cfg->device_on == DEV_ON_BASEBOARD)
                    dev_cfg->device_init(evm_id, profile);
                else if (daughter_brd_detected == true)
                    dev_cfg->device_init(evm_id, profile);
            }
        } else {
            for (i = 0; dev_cfg->device_init != NULL; dev_cfg++) {
                if (dev_cfg->profile & profile) {
                    if (dev_cfg->device_on == DEV_ON_BASEBOARD)
                        dev_cfg->device_init(evm_id, profile);
                    else if (daughter_brd_detected == true)
                        dev_cfg->device_init(evm_id, profile);
                }
            }
        }
    }

    可见,_configure_device分2种情形。
    一、当以PROFILE_NONE方式执行_configure_device时,需要符合2个条件之1才会执行dev_cfg->device_init(evm_id, profile);
    条件1:dev_cfg->device_on == DEV_ON_BASEBOARD ,即当前板子是母板
    条件2:daughter_brd_detected == true,子板被检测到,还要多判断一个条件:dev_cfg->profile & profile

    二、当_configure_device(int evm_id, struct evm_dev_cfg *dev_cfg,    int profile)的第3个参数profile不是PROFILE_NONE时,
    也就是指定了某种配置,这时先判断    dev_cfg->profile & profile,即dev_cfg里那些具有profile属性的成员才会被执行,
    根据TI的源码注释信息,似乎是am335_evm这个板子有8种底板,使用profile来区分使用哪种底板的功能。

    /*
     * The AM335x GP EVM, if daughter card(s) are connected, can have 8
     * different profiles.  These profiles determine what peripherals are
     * valid and need pinmux to be configured.
     */
    #define PROFILE_NONE    0x0
    #define PROFILE_0    (1 << 0)
    #define PROFILE_1    (1 << 1)
    #define PROFILE_2    (1 << 2)
    #define PROFILE_3    (1 << 3)
    #define PROFILE_4    (1 << 4)
    #define PROFILE_5    (1 << 5)
    #define PROFILE_6    (1 << 6)
    #define PROFILE_7    (1 << 7)
    #define PROFILE_MASK    0x7
    #define PROFILE_ALL    0xFF

    比如我写了一个mmc0_init来初始化mmc,这个功能所有子板都具备,那就可以使用 PROFILE_ALL来向 evm_sk_dev_cfg添加成员函数:

    {mmc0_init,    DEV_ON_BASEBOARD, PROFILE_ALL},

  • 软件方面的东西,作为功能选择的

    仔细看看它的分支就可以了,一般情况下可以无视

    不过为了保险起见,最好还是仔细一点,一般这个处理函数在上下文中会有所体现的