原文地址:http://blog.sina.com.cn/s/blog_87f8cc4e01019zg0.html
要使用8250.c的驱动来实现UART1,需要做一下修改:
1,$KERNEL_DIR/arch/arm/mach-davinci/board-evm.c中修改:
Change #1:
Change: Instance of "static struct uart_port" for UART1 is added along with UART0 Code:
static struct plat_serial8250_port serial_platform_data[] = {{ .membase = (char *)IO_ADDRESS(DAVINCI_UART0_BASE), .mapbase = (unsigned long)DAVINCI_UART0_BASE, .irq = IRQ_UARTINT0, .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST, .iotype = UPIO_MEM, .regshift = 2, .uartclk = 27000000, }, { .membase = (char *)IO_ADDRESS(DAVINCI_UART1_BASE), .mapbase = (unsigned long)DAVINCI_UART1_BASE, //(IO_PHYS + 0x20400) //0x01c00000 .irq = IRQ_UARTINT1, .flags = UPF_SKIP_TEST, .iotype = UPIO_MEM, .regshift = 2, .uartclk = 27000000, } };
Change #2:
在static void dm644x_setup_pinmux(unsigned int id)增加
case DAVINCI_LPSC_UART1:davinci_cfg_reg(DM644X_UART1); break;
Change #3:
在static void __init davinci_psc_init(void)增加
davinci_psc_config(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_UART1, 1);//配置管脚复用
2.FILE: $KERNEL_DIR/arch/arm/mach-davinci/clock.c中修改: Change: Clock instance for UART1 Code:
Change #1:
在static struct clk davinci_dm644x_clks[]中增加
{.name = "UART1", //by anger .rate = &fixedrate, .usecount = 1, .lpsc = DAVINCI_LPSC_UART1, }
3.FILE: $KERNEL_DIRinclude\asm-arm\arch-davinci\mux.h中修改: Change: instance for UART1 Code:
Change #1:
在enum davinci_dm644x_index 中增加DM644X_UART1枚举变量
4,FILE: $KERNEL_DIR/arch/arm/mach-davinci/mux_cfg.c中修改: Change: instance for UART1 Code:
在struct pin_config __initdata_or_module davinci_dm644x_pins[]中修改:
#if 1 //ATA功能不用 ,与UART1共用引脚
MUX_CFG("HDIREN",0, 16, 1, 0, 1) MUX_CFG("ATAEN", 0, 17, 1, 0, 1) #else MUX_CFG("HDIREN", 0, 16, 1, 1, 1) MUX_CFG("ATAEN", 0, 17, 1, 1, 1)
#endif
MUX_CFG("UART1",1, 1, 1, 1, 0)
#if 0 //FPGA 没使用
MUX_CFG("VLINQEN",0, 15, 1, 1, 0) MUX_CFG("VLINQWD", 0, 12, 3, 3, 0) #endif
5,FILE:8250.c中修改: Change: instance for UART1 resat Code:
#define UART1_BASE_(0x01c00000 + 0x20400) #define kuart1_base UART1_BASE_
static void davinci_serial_out(unsigned int value, unsigned int reg) {davinci_writel(value, reg ); }
static void reset_uart1(void) {unsigned int reg_pwremu_mgmt;//, delay; reg_pwremu_mgmt = 0x0001; // Reset davinci_serial_out(reg_pwremu_mgmt, kuart1_base + 0x30); // UTRST = 1 - tx is active reg_pwremu_mgmt |= (1<<14 | 1<<13 | 1<<0); // Enable tx and rx and FREE davinci_serial_out(reg_pwremu_mgmt, kuart1_base + 0x30); // UTRST = 1 - tx is active }
在static int __init serial8250_init(void)中加上
reset_uart1();
。