Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Stafford Horne and committed by
Greg Kroah-Hartman
4bc2bd5a 758dfe3d

+27
+5
Documentation/admin-guide/kernel-parameters.txt
··· 1092 1092 the driver will use only 32-bit accessors to read/write 1093 1093 the device registers. 1094 1094 1095 + liteuart,<addr> 1096 + Start an early console on a litex serial port at the 1097 + specified address. The serial port must already be 1098 + setup and configured. Options are not yet supported. 1099 + 1095 1100 meson,<addr> 1096 1101 Start an early, polled-mode console on a meson serial 1097 1102 port at the specified address. The serial port must
+1
drivers/tty/serial/Kconfig
··· 1553 1553 bool "LiteUART serial port console support" 1554 1554 depends on SERIAL_LITEUART=y 1555 1555 select SERIAL_CORE_CONSOLE 1556 + select SERIAL_EARLYCON 1556 1557 help 1557 1558 Say 'Y' or 'M' here if you wish to use the FPGA-based LiteUART serial 1558 1559 controller from LiteX SoC builder as the system console
+21
drivers/tty/serial/liteuart.c
··· 370 370 return 0; 371 371 } 372 372 console_initcall(liteuart_console_init); 373 + 374 + static void early_liteuart_write(struct console *console, const char *s, 375 + unsigned int count) 376 + { 377 + struct earlycon_device *device = console->data; 378 + struct uart_port *port = &device->port; 379 + 380 + uart_console_write(port, s, count, liteuart_putchar); 381 + } 382 + 383 + static int __init early_liteuart_setup(struct earlycon_device *device, 384 + const char *options) 385 + { 386 + if (!device->port.membase) 387 + return -ENODEV; 388 + 389 + device->con->write = early_liteuart_write; 390 + return 0; 391 + } 392 + 393 + OF_EARLYCON_DECLARE(liteuart, "litex,liteuart", early_liteuart_setup); 373 394 #endif /* CONFIG_SERIAL_LITEUART_CONSOLE */ 374 395 375 396 static int __init liteuart_init(void)