]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
hvc: dcc: Add earlycon support
authorMichal Simek <michal.simek@xilinx.com>
Thu, 10 Sep 2015 10:57:59 +0000 (12:57 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Wed, 27 Mar 2019 13:46:25 +0000 (14:46 +0100)
Add DCC earlycon support for early printks.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
drivers/tty/hvc/hvc_dcc.c

index 02629a1f193d7ff5bd4343b1259c6a693284a2b4..8fedd2de1f680cc737a73e73e2375f997ae120ef 100644 (file)
@@ -6,12 +6,40 @@
 #include <asm/dcc.h>
 #include <asm/processor.h>
 
+#include <linux/serial.h>
+#include <linux/console.h>
+#include <linux/serial_core.h>
+
 #include "hvc_console.h"
 
 /* DCC Status Bits */
 #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;