omap: headers: Move remaining headers from include/mach to include/plat
[linux-2.6.git] / arch / arm / mach-omap2 / serial.c
index a7421a5..f14a1a1 100644 (file)
 #include <linux/clk.h>
 #include <linux/io.h>
 
-#include <mach/common.h>
-#include <mach/board.h>
-#include <mach/clock.h>
-#include <mach/control.h>
+#include <plat/common.h>
+#include <plat/board.h>
+#include <plat/clock.h>
+#include <plat/control.h>
 
 #include "prm.h"
 #include "pm.h"
@@ -73,7 +73,6 @@ static LIST_HEAD(uart_list);
 
 static struct plat_serial8250_port serial_platform_data0[] = {
        {
-               .membase        = IO_ADDRESS(OMAP_UART1_BASE),
                .mapbase        = OMAP_UART1_BASE,
                .irq            = 72,
                .flags          = UPF_BOOT_AUTOCONF,
@@ -87,7 +86,6 @@ static struct plat_serial8250_port serial_platform_data0[] = {
 
 static struct plat_serial8250_port serial_platform_data1[] = {
        {
-               .membase        = IO_ADDRESS(OMAP_UART2_BASE),
                .mapbase        = OMAP_UART2_BASE,
                .irq            = 73,
                .flags          = UPF_BOOT_AUTOCONF,
@@ -101,7 +99,6 @@ static struct plat_serial8250_port serial_platform_data1[] = {
 
 static struct plat_serial8250_port serial_platform_data2[] = {
        {
-               .membase        = IO_ADDRESS(OMAP_UART3_BASE),
                .mapbase        = OMAP_UART3_BASE,
                .irq            = 74,
                .flags          = UPF_BOOT_AUTOCONF,
@@ -109,10 +106,34 @@ static struct plat_serial8250_port serial_platform_data2[] = {
                .regshift       = 2,
                .uartclk        = OMAP24XX_BASE_BAUD * 16,
        }, {
+#ifdef CONFIG_ARCH_OMAP4
+               .membase        = OMAP2_IO_ADDRESS(OMAP_UART4_BASE),
+               .mapbase        = OMAP_UART4_BASE,
+               .irq            = 70,
+               .flags          = UPF_BOOT_AUTOCONF,
+               .iotype         = UPIO_MEM,
+               .regshift       = 2,
+               .uartclk        = OMAP24XX_BASE_BAUD * 16,
+       }, {
+#endif
                .flags          = 0
        }
 };
 
+#ifdef CONFIG_ARCH_OMAP4
+static struct plat_serial8250_port serial_platform_data3[] = {
+       {
+               .mapbase        = OMAP_UART4_BASE,
+               .irq            = 70,
+               .flags          = UPF_BOOT_AUTOCONF,
+               .iotype         = UPIO_MEM,
+               .regshift       = 2,
+               .uartclk        = OMAP24XX_BASE_BAUD * 16,
+       }, {
+               .flags          = 0
+       }
+};
+#endif
 static inline unsigned int serial_read_reg(struct plat_serial8250_port *up,
                                           int offset)
 {
@@ -460,7 +481,7 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
                uart->padconf = 0;
        }
 
-       p->flags |= UPF_SHARE_IRQ;
+       p->irqflags |= IRQF_SHARED;
        ret = request_irq(p->irq, omap_uart_interrupt, IRQF_SHARED,
                          "serial idle", (void *)uart);
        WARN_ON(ret);
@@ -550,12 +571,22 @@ static struct omap_uart_state omap_uart[OMAP_MAX_NR_PORTS] = {
                        },
                },
        },
+#ifdef CONFIG_ARCH_OMAP4
+       {
+               .pdev = {
+                       .name                   = "serial8250",
+                       .id                     = 3,
+                       .dev                    = {
+                               .platform_data  = serial_platform_data3,
+                       },
+               },
+       },
+#endif
 };
 
-void __init omap_serial_init(void)
+void __init omap_serial_early_init(void)
 {
        int i;
-       const struct omap_uart_config *info;
        char name[16];
 
        /*
@@ -564,20 +595,19 @@ void __init omap_serial_init(void)
         * 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 omap_uart_state *uart = &omap_uart[i];
                struct platform_device *pdev = &uart->pdev;
                struct device *dev = &pdev->dev;
                struct plat_serial8250_port *p = dev->platform_data;
 
-               if (!(info->enabled_uarts & (1 << i))) {
-                       p->membase = NULL;
-                       p->mapbase = 0;
+               /*
+                * Module 4KB + L4 interconnect 4KB
+                * Static mapping, never released
+                */
+               p->membase = ioremap(p->mapbase, SZ_8K);
+               if (!p->membase) {
+                       printk(KERN_ERR "ioremap failed for uart%i\n", i + 1);
                        continue;
                }
 
@@ -595,8 +625,11 @@ void __init omap_serial_init(void)
                        uart->fck = NULL;
                }
 
-               if (!uart->ick || !uart->fck)
-                       continue;
+               /* FIXME: Remove this once the clkdev is ready */
+               if (!cpu_is_omap44xx()) {
+                       if (!uart->ick || !uart->fck)
+                               continue;
+               }
 
                uart->num = i;
                p->private_data = uart;
@@ -607,6 +640,18 @@ void __init omap_serial_init(void)
                        p->irq += 32;
 
                omap_uart_enable_clocks(uart);
+       }
+}
+
+void __init omap_serial_init(void)
+{
+       int i;
+
+       for (i = 0; i < OMAP_MAX_NR_PORTS; i++) {
+               struct omap_uart_state *uart = &omap_uart[i];
+               struct platform_device *pdev = &uart->pdev;
+               struct device *dev = &pdev->dev;
+
                omap_uart_reset(uart);
                omap_uart_idle_init(uart);