serial: altera_jtaguart: add earlycon support
authorTobias Klauser <tklauser@distanz.ch>
Tue, 14 Mar 2017 13:11:25 +0000 (14:11 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Mar 2017 05:14:00 +0000 (14:14 +0900)
Nios2 currently uses its own early printk implementation, rather than
using unified earlycon support to show boot messages on altera_jtaguart
(and altera_uart for that matter).

Add earlycon support to altera_jtaguart so that other archs may use it. Also,
this will allow the early printk implementation in arch/nios2 to eventually be
removed in a future patch.

Cc: Ley Foon Tan <lftan@altera.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/Kconfig
drivers/tty/serial/altera_jtaguart.c

index 6117ac8da48f739fc4bf904b5a52db31b5861b50..d8495b9fd0ce2adca89f344af693ce4088989ca6 100644 (file)
@@ -1343,6 +1343,7 @@ config SERIAL_ALTERA_JTAGUART_CONSOLE
        bool "Altera JTAG UART console support"
        depends on SERIAL_ALTERA_JTAGUART=y
        select SERIAL_CORE_CONSOLE
+       select SERIAL_EARLYCON
        help
          Enable a Altera JTAG UART port to be the system console.
 
index e409d7dac7abfd5800a5b9a56d013cb569ca26f1..18e3f8342b8554ae4e7d414dd39653fb3a33b26f 100644 (file)
@@ -383,6 +383,26 @@ console_initcall(altera_jtaguart_console_init);
 
 #define        ALTERA_JTAGUART_CONSOLE (&altera_jtaguart_console)
 
+static void altera_jtaguart_earlycon_write(struct console *co, const char *s,
+                                          unsigned int count)
+{
+       struct earlycon_device *dev = co->data;
+
+       uart_console_write(&dev->port, s, count, altera_jtaguart_console_putc);
+}
+
+static int __init altera_jtaguart_earlycon_setup(struct earlycon_device *dev,
+                                                const char *options)
+{
+       if (!dev->port.membase)
+               return -ENODEV;
+
+       dev->con->write = altera_jtaguart_earlycon_write;
+       return 0;
+}
+
+OF_EARLYCON_DECLARE(juart, "altr,juart-1.0", altera_jtaguart_earlycon_setup);
+
 #else
 
 #define        ALTERA_JTAGUART_CONSOLE NULL