在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指的是什么,有什么作用呢?对应芯片手册里面的什么功能呢?
leo chen:
具体可以看解析的函数,类似于case,和芯片好像没啥关系,软件方面的东西
Richard.T:
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_cfgind_auto_mtrl_evm_dev_cfgbeaglebone_old_dev_cfgbeaglebone_dev_cfgbeaglebone_black_dev_cfgevm_sk_dev_cfg分析_configure_devicestatic 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},
leo chen:
回复 Richard.T:
软件方面的东西,作为功能选择的
仔细看看它的分支就可以了,一般情况下可以无视
不过为了保险起见,最好还是仔细一点,一般这个处理函数在上下文中会有所体现的