From: Trilok Soni <[EMAIL PROTECTED]>

- Update clock.c to add three UART clocks.
- Update serial.[ch] for using DAVINCI_TAG_UART
  support.

Signed-off-by: Trilok Soni <[EMAIL PROTECTED]>
---
 arch/arm/mach-davinci/clock.c         |   12 +++++-
 arch/arm/mach-davinci/serial.c        |   66 ++++++++++++++++++++++++++++----
 include/asm-arm/arch-davinci/common.h |    1 +
 include/asm-arm/arch-davinci/serial.h |    1 +
 4 files changed, 70 insertions(+), 10 deletions(-)

diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index b3092c1..14dac52 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -191,11 +191,21 @@ static struct clk davinci_clks[] = {
                .flags = ALWAYS_ENABLED,
        },
        {
-               .name = "UART",
+               .name = "UART0",
                .rate = &fixedrate,
                .lpsc = DAVINCI_LPSC_UART0,
        },
        {
+               .name = "UART1",
+               .rate = &fixedrate,
+               .lpsc = DAVINCI_LPSC_UART1,
+       },
+       {
+               .name = "UART2",
+               .rate = &fixedrate,
+               .lpsc = DAVINCI_LPSC_UART2,
+       },
+       {
                .name = "EMACCLK",
                .rate = &commonrate,
                .lpsc = DAVINCI_LPSC_EMAC_WRAPPER,
diff --git a/arch/arm/mach-davinci/serial.c b/arch/arm/mach-davinci/serial.c
index 99f133b..75fbd96 100644
--- a/arch/arm/mach-davinci/serial.c
+++ b/arch/arm/mach-davinci/serial.c
@@ -31,6 +31,7 @@
 #include <asm/irq.h>
 #include <asm/hardware.h>
 #include <asm/arch/serial.h>
+#include <asm/arch/board.h>
 #include <asm/arch/irqs.h>
 
 #define UART_DAVINCI_PWREMU 0x0c
@@ -67,6 +68,24 @@ static struct plat_serial8250_port serial_platform_data[] = {
                .uartclk        = 27000000,
        },
        {
+               .membase        = (char *)IO_ADDRESS(DAVINCI_UART1_BASE),
+               .mapbase        = (unsigned long)DAVINCI_UART1_BASE,
+               .irq            = IRQ_UARTINT1,
+               .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+               .iotype         = UPIO_MEM,
+               .regshift       = 2,
+               .uartclk        = 27000000,
+       },
+       {
+               .membase        = (char *)IO_ADDRESS(DAVINCI_UART2_BASE),
+               .mapbase        = (unsigned long)DAVINCI_UART2_BASE,
+               .irq            = IRQ_UARTINT2,
+               .flags          = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST,
+               .iotype         = UPIO_MEM,
+               .regshift       = 2,
+               .uartclk        = 27000000,
+       },
+       {
                .flags          = 0
        },
 };
@@ -78,7 +97,7 @@ static struct platform_device serial_device = {
                .platform_data  = serial_platform_data,
        },
 };
-  
+
 static void __init davinci_serial_reset(struct plat_serial8250_port *p)
 {
        /* reset both transmitter and receiver: bits 14,13 = UTRST, URRST */
@@ -94,19 +113,48 @@ static void __init davinci_serial_reset(struct 
plat_serial8250_port *p)
        davinci_serial_outs(p, UART_DAVINCI_PWREMU, pwremu);
 }
 
-static int __init davinci_init(void)
+void __init davinci_serial_init(void)
 {
+       int i;
+       const struct davinci_uart_config *info;
+       char name[16];
        struct clk *uart_clk;
        struct device *dev = &serial_device.dev;
 
-       uart_clk = clk_get(dev, "UART");
-       if (IS_ERR(uart_clk))
-               printk(KERN_ERR "%s:%d: failed to get UART clock\n",
-                      __FUNCTION__, __LINE__);
-       else
-               clk_enable(uart_clk);
+       /*
+        * Make sure the serial ports are muxed on at this point.
+        * You have to mux them off in device drivers later on
+        * if not needed.
+        */
+
+       info = davinci_get_config(DAVINCI_TAG_UART, struct davinci_uart_config);
+
+       if (info == NULL)
+               return;
+
+       for (i = 0; i < DAVINCI_MAX_NR_UARTS; i++) {
+               struct plat_serial8250_port *p = serial_platform_data + i;
 
-       davinci_serial_reset(&serial_platform_data[0]);
+               if (!(info->enabled_uarts & (1 << i))) {
+                       p->membase = 0;
+                       p->mapbase = 0;
+                       continue;
+               }
+
+               sprintf(name, "UART%d\n", i);
+               uart_clk = clk_get(dev, "UART");
+               if (IS_ERR(uart_clk))
+                       printk(KERN_ERR "%s:%d: failed to get UART%d clock\n",
+                                       __func__, __LINE__, i);
+               else {
+                       clk_enable(uart_clk);
+                       davinci_serial_reset(p);
+               }
+       }
+}
+
+static int __init davinci_init(void)
+{
        return platform_device_register(&serial_device);
 }
 
diff --git a/include/asm-arm/arch-davinci/common.h 
b/include/asm-arm/arch-davinci/common.h
index a97dfbb..1eea01d 100644
--- a/include/asm-arm/arch-davinci/common.h
+++ b/include/asm-arm/arch-davinci/common.h
@@ -15,5 +15,6 @@
 struct sys_timer;
 
 extern struct sys_timer davinci_timer;
+extern void davinci_serial_init(void);
 
 #endif /* __ARCH_ARM_MACH_DAVINCI_COMMON_H */
diff --git a/include/asm-arm/arch-davinci/serial.h 
b/include/asm-arm/arch-davinci/serial.h
index ed418ef..d1886e9 100644
--- a/include/asm-arm/arch-davinci/serial.h
+++ b/include/asm-arm/arch-davinci/serial.h
@@ -13,6 +13,7 @@
 
 #include <asm/arch/io.h>
 
+#define DAVINCI_MAX_NR_UARTS 3
 #define DAVINCI_UART0_BASE   (IO_PHYS + 0x20000)
 #define DAVINCI_UART1_BASE   (IO_PHYS + 0x20400)
 #define DAVINCI_UART2_BASE   (IO_PHYS + 0x20800)
-- 
1.5.5

_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to