]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/tty/serial/lantiq.c
Merge tag 'rtc-4.11' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
[karo-tx-linux.git] / drivers / tty / serial / lantiq.c
index b88832e8ee82273f3a1062f272980d6586b99300..22df94f107e5415f03a5b0c44983e39b3eb7b03d 100644 (file)
@@ -16,7 +16,7 @@
  *
  * Copyright (C) 2004 Infineon IFAP DC COM CPE
  * Copyright (C) 2007 Felix Fietkau <nbd@openwrt.org>
- * Copyright (C) 2007 John Crispin <blogic@openwrt.org>
+ * Copyright (C) 2007 John Crispin <john@phrozen.org>
  * Copyright (C) 2010 Thomas Langer, <thomas.langer@lantiq.com>
  */
 
@@ -557,7 +557,7 @@ lqasc_verify_port(struct uart_port *port,
        return ret;
 }
 
-static struct uart_ops lqasc_pops = {
+static const struct uart_ops lqasc_pops = {
        .tx_empty =     lqasc_tx_empty,
        .set_mctrl =    lqasc_set_mctrl,
        .get_mctrl =    lqasc_get_mctrl,
@@ -590,13 +590,20 @@ lqasc_console_putchar(struct uart_port *port, int ch)
        ltq_w8(ch, port->membase + LTQ_ASC_TBUF);
 }
 
+static void lqasc_serial_port_write(struct uart_port *port, const char *s,
+                                   u_int count)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&ltq_asc_lock, flags);
+       uart_console_write(port, s, count, lqasc_console_putchar);
+       spin_unlock_irqrestore(&ltq_asc_lock, flags);
+}
 
 static void
 lqasc_console_write(struct console *co, const char *s, u_int count)
 {
        struct ltq_uart_port *ltq_port;
-       struct uart_port *port;
-       unsigned long flags;
 
        if (co->index >= MAXPORTS)
                return;
@@ -605,11 +612,7 @@ lqasc_console_write(struct console *co, const char *s, u_int count)
        if (!ltq_port)
                return;
 
-       port = &ltq_port->port;
-
-       spin_lock_irqsave(&ltq_asc_lock, flags);
-       uart_console_write(port, s, count, lqasc_console_putchar);
-       spin_unlock_irqrestore(&ltq_asc_lock, flags);
+       lqasc_serial_port_write(&ltq_port->port, s, count);
 }
 
 static int __init
@@ -659,6 +662,27 @@ lqasc_console_init(void)
 }
 console_initcall(lqasc_console_init);
 
+static void lqasc_serial_early_console_write(struct console *co,
+                                            const char *s,
+                                            u_int count)
+{
+       struct earlycon_device *dev = co->data;
+
+       lqasc_serial_port_write(&dev->port, s, count);
+}
+
+static int __init
+lqasc_serial_early_console_setup(struct earlycon_device *device,
+                                const char *opt)
+{
+       if (!device->port.membase)
+               return -ENODEV;
+
+       device->con->write = lqasc_serial_early_console_write;
+       return 0;
+}
+OF_EARLYCON_DECLARE(lantiq, DRVNAME, lqasc_serial_early_console_setup);
+
 static struct uart_driver lqasc_reg = {
        .owner =        THIS_MODULE,
        .driver_name =  DRVNAME,