海思3520d平台UART口拓展

Published: 30 Apr 2014 Category: linux

项目中要把海思3520d的四个UART口全部用上,但是用海思SDK里面的linux内核的话,默认只有两个口,分别是ttyAMA0 ttyAMA1。如果要把四个UART口全部都用上就要改内核源码。听起来挺吓人的,其实就是依葫芦画瓢的事儿,没什么技术含量。下面就切入主题。

修改

1:arch/arm/mach-hi3520d/core.c
2:arch/arm/mach-hi3520d/include/mach/irqs.h  

这两个文件即可,修改如下:

--- /mnt/hgfs/windows-F/Hi3520D/linux-3.0.y/arch/arm/mach-hi3520d/core.c        2013-05-15 11:44:29.000000000 +0800
+++ /root/3520d/osdrv/kernel/linux-3.0.y/arch/arm/mach-hi3520d/core.c   2014-01-13 15:38:47.000000000 +0800
@@ -309,15 +309,19 @@

 HIL_AMBA_DEVICE(uart0, "uart:0",  UART0,    NULL);
 HIL_AMBA_DEVICE(uart1, "uart:1",  UART1,    NULL);
+HIL_AMBA_DEVICE(uart2, "uart:2",  UART2,    NULL);
+HIL_AMBA_DEVICE(uart3, "uart:3",  UART3,    NULL);

 static struct amba_device *amba_devs[] __initdata = {
        &HIL_AMBADEV_NAME(uart0),
        &HIL_AMBADEV_NAME(uart1),
+       &HIL_AMBADEV_NAME(uart2),
+       &HIL_AMBADEV_NAME(uart3),
 };


 static struct clk uart_clk;
-static struct clk_lookup lookups[2];
+static struct clk_lookup lookups[4];

 static void  uart_clk_init(unsigned long clk)
 {
@@ -328,6 +332,12 @@

        lookups[1].dev_id = "uart:1";
        lookups[1].clk = &uart_clk;
+
+       lookups[2].dev_id = "uart:2";
+       lookups[2].clk = &uart_clk;
+
+       lookups[3].dev_id = "uart:3";
+       lookups[3].clk = &uart_clk;
 }

 void __init hi3520d_init(void)  

--- /mnt/hgfs/windows-F/Hi3520D/linux-3.0.y/arch/arm/mach-hi3520d/include/mach/irqs.h   2013-05-15 11:44:29.000000000 +0800
+++ /root/3520d/osdrv/kernel/linux-3.0.y/arch/arm/mach-hi3520d/include/mach/irqs.h      2014-01-13 15:55:51.000000000 +0800
@@ -8,6 +8,8 @@

 #define UART0_IRQ              (HI3520D_IRQ_START + 8)
 #define UART1_IRQ              (HI3520D_IRQ_START + 9)
+#define UART2_IRQ              (HI3520D_IRQ_START + 10)
+#define UART3_IRQ              (HI3520D_IRQ_START + 11)

 #define INTNR_L2CACHE_CHK0_INT (HI3520D_IRQ_START + 29)
 #define INTNR_L2CACHE_CHK1_INT (HI3520D_IRQ_START + 30)  

上述是用diff比较修改后与修改前的文件的结果,感觉这样子一目了然!