summaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/liteuart.c
diff options
context:
space:
mode:
authorStafford Horne <shorne@gmail.com>2021-05-17 20:54:52 +0900
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-05-20 16:35:01 +0200
commit4bc2bd5aefd60a2837a20b1e88e89eaaa677d229 (patch)
tree241992a1e59ccc796929c0912dad36088792464b /drivers/tty/serial/liteuart.c
parent758dfe3ddcae59b337d4109331f9be39da53b0ed (diff)
downloadlinux-stable-4bc2bd5aefd60a2837a20b1e88e89eaaa677d229.tar.gz
linux-stable-4bc2bd5aefd60a2837a20b1e88e89eaaa677d229.tar.bz2
linux-stable-4bc2bd5aefd60a2837a20b1e88e89eaaa677d229.zip
serial: liteuart: Add support for earlycon
Most litex boards using RISC-V soft cores us the sbi earlycon, however this is not available for non RISC-V litex SoC's. This patch enables earlycon for liteuart which is available on all Litex SoC's making support for earycon debugging more widely available. Cc: Florent Kermarrec <florent@enjoy-digital.fr> Cc: Mateusz Holenko <mholenko@antmicro.com> Cc: Joel Stanley <joel@jms.id.au> Cc: Gabriel L. Somlo <gsomlo@gmail.com> Reviewed-and-tested-by: Gabriel Somlo <gsomlo@gmail.com> Reviewed-by: Jiri Slaby <jirislaby@kernel.org> Reviewed-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Stafford Horne <shorne@gmail.com> Link: https://lore.kernel.org/r/20210517115453.24365-1-shorne@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/liteuart.c')
-rw-r--r--drivers/tty/serial/liteuart.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c
index 0b06770642cb..dbc0559a9157 100644
--- a/drivers/tty/serial/liteuart.c
+++ b/drivers/tty/serial/liteuart.c
@@ -370,6 +370,27 @@ static int __init liteuart_console_init(void)
return 0;
}
console_initcall(liteuart_console_init);
+
+static void early_liteuart_write(struct console *console, const char *s,
+ unsigned int count)
+{
+ struct earlycon_device *device = console->data;
+ struct uart_port *port = &device->port;
+
+ uart_console_write(port, s, count, liteuart_putchar);
+}
+
+static int __init early_liteuart_setup(struct earlycon_device *device,
+ const char *options)
+{
+ if (!device->port.membase)
+ return -ENODEV;
+
+ device->con->write = early_liteuart_write;
+ return 0;
+}
+
+OF_EARLYCON_DECLARE(liteuart, "litex,liteuart", early_liteuart_setup);
#endif /* CONFIG_SERIAL_LITEUART_CONSOLE */
static int __init liteuart_init(void)