serial/arc: Use generic earlycon infrastructure
authorVineet Gupta <Vineet.Gupta1@synopsys.com>
Tue, 24 Jun 2014 08:25:09 +0000 (13:55 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 10 Jul 2014 22:43:27 +0000 (15:43 -0700)
With this change both earlyprintk and earlycon coexist
We switch over to latter in next patch

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/Kconfig
drivers/tty/serial/arc_uart.c

index 7039238b134ffcfd4b75668896db8f1c45bf9a69..7f12a005c6cb03934b84f1a3354e1a812405a8ff 100644 (file)
@@ -1472,6 +1472,7 @@ config SERIAL_ARC_CONSOLE
        bool "Console on ARC UART"
        depends on SERIAL_ARC=y
        select SERIAL_CORE_CONSOLE
+       select SERIAL_EARLYCON
        help
          Enable system Console on ARC UART
 
index ea954c3be18bfa6a40911af1592c12131596d22d..41d2e351c06d8945c9b0a6170b2c8057afb4fac8 100644 (file)
@@ -638,6 +638,36 @@ static int __init arc_serial_probe_earlyprintk(struct platform_device *pdev)
        register_console(&arc_early_serial_console);
        return 0;
 }
+
+static __init void arc_early_serial_write(struct console *con, const char *s,
+                                         unsigned int n)
+{
+       struct earlycon_device *dev = con->data;
+
+       uart_console_write(&dev->port, s, n, arc_serial_poll_putchar);
+}
+
+static int __init arc_early_console_setup(struct earlycon_device *dev,
+                                         const char *opt)
+{
+       struct uart_port *port = &dev->port;
+       unsigned int l, h, hw_val;
+
+       if (!dev->port.membase)
+               return -ENODEV;
+
+       hw_val = port->uartclk / (dev->baud * 4) - 1;
+       l = hw_val & 0xFF;
+       h = (hw_val >> 8) & 0xFF;
+
+       UART_SET_BAUDL(port, l);
+       UART_SET_BAUDH(port, h);
+
+       dev->con->write = arc_early_serial_write;
+       return 0;
+}
+EARLYCON_DECLARE(arc_uart, arc_early_console_setup);
+
 #endif /* CONFIG_SERIAL_ARC_CONSOLE */
 
 static int arc_serial_probe(struct platform_device *pdev)