]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
OMAP3: serial - allow platforms specify which UARTs to initialize
authorMika Westerberg <ext-mika.1.westerberg@nokia.com>
Sat, 12 Dec 2009 00:16:35 +0000 (16:16 -0800)
committerTony Lindgren <tony@atomide.com>
Sat, 12 Dec 2009 00:16:35 +0000 (16:16 -0800)
This patch adds new function: omap_serial_init_port(port) that can be
used to initialize only selected UARTs as serial ports. Platforms can
then in their board files call this function instead of omap_serial_init()
if they don't want to use all UARTs as serial ports.

Signed-off-by: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap2/serial.c
arch/arm/plat-omap/include/plat/serial.h

index 2e17b57f5b23bb6703a2d621103585af1d8d729b..6278fe585c050f648df37a9c112abc0570845d6e 100644 (file)
@@ -631,24 +631,64 @@ void __init omap_serial_early_init(void)
        }
 }
 
-void __init omap_serial_init(void)
+/**
+ * omap_serial_init_port() - initialize single serial port
+ * @port: serial port number (0-3)
+ *
+ * This function initialies serial driver for given @port only.
+ * Platforms can call this function instead of omap_serial_init()
+ * if they don't plan to use all available UARTs as serial ports.
+ *
+ * Don't mix calls to omap_serial_init_port() and omap_serial_init(),
+ * use only one of the two.
+ */
+void __init omap_serial_init_port(int port)
 {
-       int i;
+       struct omap_uart_state *uart;
+       struct platform_device *pdev;
+       struct device *dev;
 
-       for (i = 0; i < ARRAY_SIZE(omap_uart); i++) {
-               struct omap_uart_state *uart = &omap_uart[i];
-               struct platform_device *pdev = &uart->pdev;
-               struct device *dev = &pdev->dev;
+       BUG_ON(port < 0);
+       BUG_ON(port >= ARRAY_SIZE(omap_uart));
 
-               omap_uart_reset(uart);
-               omap_uart_idle_init(uart);
+       uart = &omap_uart[port];
+       pdev = &uart->pdev;
+       dev = &pdev->dev;
 
-               if (WARN_ON(platform_device_register(pdev)))
-                       continue;
-               if ((cpu_is_omap34xx() && uart->padconf) ||
-                   (uart->wk_en && uart->wk_mask)) {
-                       device_init_wakeup(dev, true);
-                       DEV_CREATE_FILE(dev, &dev_attr_sleep_timeout);
-               }
+       omap_uart_reset(uart);
+       omap_uart_idle_init(uart);
+
+       if (WARN_ON(platform_device_register(pdev)))
+               return;
+
+       if ((cpu_is_omap34xx() && uart->padconf) ||
+           (uart->wk_en && uart->wk_mask)) {
+               device_init_wakeup(dev, true);
+               DEV_CREATE_FILE(dev, &dev_attr_sleep_timeout);
        }
+
+       /* omap44xx: Never read empty UART fifo
+        * omap3xxx: Never read empty UART fifo on UARTs
+        * with IP rev >=0x52
+        */
+       if (cpu_is_omap44xx())
+               uart->p->serial_in = serial_in_override;
+       else if ((serial_read_reg(uart->p, UART_OMAP_MVER) & 0xFF)
+                       >= UART_OMAP_NO_EMPTY_FIFO_READ_IP_REV)
+               uart->p->serial_in = serial_in_override;
+}
+
+/**
+ * omap_serial_init() - intialize all supported serial ports
+ *
+ * Initializes all available UARTs as serial ports. Platforms
+ * can call this function when they want to have default behaviour
+ * for serial ports (e.g initialize them all as serial ports).
+ */
+void __init omap_serial_init(void)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(omap_uart); i++)
+               omap_serial_init_port(i);
 }
index 9951345a25d6ae1b17d901d461af6156393f33d1..f5a4a92393ef2f0c34261ee4eb606b362bcb4c53 100644 (file)
@@ -53,6 +53,7 @@
 #ifndef __ASSEMBLER__
 extern void __init omap_serial_early_init(void);
 extern void omap_serial_init(void);
+extern void omap_serial_init_port(int port);
 extern int omap_uart_can_sleep(void);
 extern void omap_uart_check_wakeup(void);
 extern void omap_uart_prepare_suspend(void);