]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/mach-omap2/serial.c
Cleanup patch to sync with mainline kernel
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / serial.c
index e86b41b6c9e62b976ec30179a9c9589d0535692b..0884bc7c23b7f31635266ff8a10c0c15cb701e61 100644 (file)
 #include <linux/init.h>
 #include <linux/serial_8250.h>
 #include <linux/serial_reg.h>
+#include <linux/clk.h>
+
 #include <asm/io.h>
 
+#include <asm/arch/common.h>
+#include <asm/arch/board.h>
+
+static struct clk * uart1_ick = NULL;
+static struct clk * uart1_fck = NULL;
+static struct clk * uart2_ick = NULL;
+static struct clk * uart2_fck = NULL;
+static struct clk * uart3_ick = NULL;
+static struct clk * uart3_fck = NULL;
+
 static struct plat_serial8250_port serial_platform_data[] = {
        {
                .membase        = (char *)IO_ADDRESS(OMAP_UART1_BASE),
@@ -75,26 +87,87 @@ static inline void __init omap_serial_reset(struct plat_serial8250_port *p)
        serial_write_reg(p, UART_OMAP_SYSC, 0x01);
 }
 
-void __init omap_serial_init(int ports[OMAP_MAX_NR_PORTS])
+void __init omap_serial_init()
 {
        int i;
+       const struct omap_uart_config *info;
+
+       /*
+        * 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 = omap_get_config(OMAP_TAG_UART,
+                              struct omap_uart_config);
+
+       if (info == NULL)
+               return;
 
        for (i = 0; i < OMAP_MAX_NR_PORTS; i++) {
                struct plat_serial8250_port *p = serial_platform_data + i;
 
-               if (ports[i] == 0) {
+               if (!(info->enabled_uarts & (1 << i))) {
                        p->membase = 0;
                        p->mapbase = 0;
                        continue;
                }
 
+               switch (i) {
+               case 0:
+                       uart1_ick = clk_get(NULL, "uart1_ick");
+                       if (IS_ERR(uart1_ick))
+                               printk("Could not get uart1_ick\n");
+                       else {
+                               clk_enable(uart1_ick);
+                       }
+
+                       uart1_fck = clk_get(NULL, "uart1_fck");
+                       if (IS_ERR(uart1_fck))
+                               printk("Could not get uart1_fck\n");
+                       else {
+                               clk_enable(uart1_fck);
+                       }
+                       break;
+               case 1:
+                       uart2_ick = clk_get(NULL, "uart2_ick");
+                       if (IS_ERR(uart2_ick))
+                               printk("Could not get uart2_ick\n");
+                       else {
+                               clk_enable(uart2_ick);
+                       }
+
+                       uart2_fck = clk_get(NULL, "uart2_fck");
+                       if (IS_ERR(uart2_fck))
+                               printk("Could not get uart2_fck\n");
+                       else {
+                               clk_enable(uart2_fck);
+                       }
+                       break;
+               case 2:
+                       uart3_ick = clk_get(NULL, "uart3_ick");
+                       if (IS_ERR(uart3_ick))
+                               printk("Could not get uart3_ick\n");
+                       else {
+                               clk_enable(uart3_ick);
+                       }
+
+                       uart3_fck = clk_get(NULL, "uart3_fck");
+                       if (IS_ERR(uart3_fck))
+                               printk("Could not get uart3_fck\n");
+                       else {
+                               clk_enable(uart3_fck);
+                       }
+                       break;
+               }
+
                omap_serial_reset(p);
        }
 }
 
 static struct platform_device serial_device = {
        .name                   = "serial8250",
-       .id                     = 0,
+       .id                     = PLAT8250_DEV_PLATFORM,
        .dev                    = {
                .platform_data  = serial_platform_data,
        },