]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/tty/hvc/hvc_dcc.c
Merge branch 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
[linux.git] / drivers / tty / hvc / hvc_dcc.c
index 02629a1f193d7ff5bd4343b1259c6a693284a2b4..8e0edb7d93fdaff3243868a5a1da0f85c3ca5d94 100644 (file)
@@ -1,7 +1,10 @@
 // SPDX-License-Identifier: GPL-2.0
 /* Copyright (c) 2010, 2014 The Linux Foundation. All rights reserved.  */
 
+#include <linux/console.h>
 #include <linux/init.h>
+#include <linux/serial.h>
+#include <linux/serial_core.h>
 
 #include <asm/dcc.h>
 #include <asm/processor.h>
 #define DCC_STATUS_RX          (1 << 30)
 #define DCC_STATUS_TX          (1 << 29)
 
+static void dcc_uart_console_putchar(struct uart_port *port, int ch)
+{
+       while (__dcc_getstatus() & DCC_STATUS_TX)
+               cpu_relax();
+
+       __dcc_putchar(ch);
+}
+
+static void dcc_early_write(struct console *con, const char *s, unsigned n)
+{
+       struct earlycon_device *dev = con->data;
+
+       uart_console_write(&dev->port, s, n, dcc_uart_console_putchar);
+}
+
+static int __init dcc_early_console_setup(struct earlycon_device *device,
+                                         const char *opt)
+{
+       device->con->write = dcc_early_write;
+
+       return 0;
+}
+
+EARLYCON_DECLARE(dcc, dcc_early_console_setup);
+
 static int hvc_dcc_put_chars(uint32_t vt, const char *buf, int count)
 {
        int i;