在TI814x设备中,复位时,默认的引脚复用配置被设置为Mode0(FUNCTION 1)。如果想将某些引脚配置成其他的功能而不是Mode0,或者说重载在U-Boot中已经设置好的引脚配置,内核需要重新配置。
引脚配置可以有两种方法:
1、在arch/arm/mach-omap2/board-ti8148evm.c中的board_mux数组中添加特定的复用入口。比如在board_mux中添加
TI814X_MUX(MTSI_DCLK, OMAP_MUX_MODE1|OMAP_PULL_UP)或TI814X_MUX(MTSI_DCLK, OMAP_MUX_MODE1),要注意必须放在{.reg_offset=OMAP_MUX_TERMINATOR}之前。
2、在arch/arm/mach-omap2/devices.c中的初始化omap2_init_devices()函数中调用函数omap_mux_init_signal()。比如:omap_mux_init_signal("gmiil_rxclk",OMAP_PULL_UP)或omap_mux_init_signal("gmiil_rxclk",0)。
其中引脚复用信号的名字及其使用的模式种类在内核源码目录中的arch/arm/mach-omap2/mux814x.c中的muxmodes[]数组指定。
查看引脚的复用情况,可以使用debugfs。
# mount -t debugfs none /sys/kernel/debug
# cat /sys/kernel/debug/omap_mux/clkin32
关于引脚复用有比较特殊的几个IO需要注意。比如GP0[1]、GP1[7]~GP1[10],要使用其GPIO的功能,需要做如下配置。
首先,使能时钟:
//enable GP0 GP1 Clock,见TMS320DM816x Technical Reference Manual.pdf中的RCM_ALWON_GPIO_0_CLKCTRL Register
/* PRCM Base Address */
#define PRCM_BASE 0x48180000
#define CM_ALWON_GPIO_0_CLKCTRL (PRCM_BASE + 0x155c)
#define CM_ALWON_GPIO_1_CLKCTRL (PRCM_BASE + 0x1560)
__raw_write(0x102,CM_ALWON_GPIO_0_CLKCTRL);
while((__raw_read(CM_ALWON_GPIO_0_CLKCTRL)&0x03)!=0x2);
__raw_write(0x102,CM_ALWON_GPIO_1_CLKCTRL);
while((__raw_read(CM_ALWON_GPIO_1_CLKCTRL)&0x03)!=0x2);
//GP0_1 Mode7
__raw_write(0x00040080,0x4818081c);
其次,在U-Boot中定义如下变量:
#define MLBP_SIG_IO_CTRL_FOR_GPb7b8 0x48140E18
#define MLBP_SIG_IO_CTRL_FOR_GPb9b10 0x48140E1C
#define MLBP_SIG_IO_CTRL_VAL 0x3F //set 3LB to enable;2 lvcmos buffer, padn receiver, padp receiver
#define GPIO1_OE 0x4804C134
#define GPIO1_SETDATAOUT 0x4804C194
#define GPIO1_CLEARDATAOUT 0x4804C190
#define GPIO1_DATAOUT 0x4804C13C
#define WR_MEM_32(addr,data) *(unsigned int *)(addr)=(unsigned int)(data)
#define RD_MEM_32(addr) *(unsigned int *)addr
WR_MEM_32(MLBP_SIG_IO_CTRL_FOR_GPb7b8, MLBP_SIG_IO_CTRL_VAL);
WR_MEM_32(MLBP_SIG_IO_CTRL_FOR_GPb9b10, MLBP_SIG_IO_CTRL_VAL);
//将引脚配置成GPIO功能并上拉
(*(volatile unsigned int *)(0x481408F4))=(volatile unsigned int)((1<<19)|(1<<18)|(1<<17)|(1<<7)); //GP1_7
(*(volatile unsigned int *)(0x481408F8))=(volatile unsigned int)((1<<19)|(1<<18)|(1<<17)|(1<<7)); //GP1_8
(*(volatile unsigned int *)(0x481408FC))=(volatile unsigned int)((1<<19)|(1<<18)|(1<<17)|(1<<7)); //GP1_9
//输出使能
val=__raw_readl(GPIO1_OE);
val&=(~((1<<7)|(1<<8)|(1<<9)));
__raw_writel(val, GPIO1_OE);
//置位
val=__raw_readl(GPIO1_SETDATAOUT);
val|=((1<<7)|(1<<8)|(1<<9));
__raw_writel(val, GPIO1_SETDATAOUT);
//清零
val=__raw_readl(GPIO1_CLEARDATAOUT);
val|=((1<<7)|(1<<8)|(1<<9));
__raw_writel(val, GPIO1_CLEARDATAOUT);
Reference:
http://repository.timesys.com/buildsources/u/u-boot/u-boot-2010.06/u-boot-2010.06-ti81xx-201202011623.patch
http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/716/t/153934.aspx
转载地址:http://weimenlove.blog.163.com/blog/static/177754732012101311230450/