lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 15 May 2021 17:45:18 +0900
From:   Stafford Horne <shorne@...il.com>
To:     LKML <linux-kernel@...r.kernel.org>
Cc:     Stafford Horne <shorne@...il.com>,
        Florent Kermarrec <florent@...oy-digital.fr>,
        Mateusz Holenko <mholenko@...micro.com>,
        Joel Stanley <joel@....id.au>,
        "Gabriel L . Somlo" <gsomlo@...il.com>,
        Jonathan Corbet <corbet@....net>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Jiri Slaby <jirislaby@...nel.org>,
        Karol Gugala <kgugala@...micro.com>,
        "Paul E. McKenney" <paulmck@...nel.org>,
        Randy Dunlap <rdunlap@...radead.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Viresh Kumar <viresh.kumar@...aro.org>,
        Mike Kravetz <mike.kravetz@...cle.com>,
        Peter Zijlstra <peterz@...radead.org>,
        linux-doc@...r.kernel.org, linux-serial@...r.kernel.org
Subject: [PATCH] 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.  This patch enables
earlycon for liteuart which is available on all Litex SoC's making
support for earycon debugging more widely available.

Signed-off-by: Stafford Horne <shorne@...il.com>
Cc: Florent Kermarrec <florent@...oy-digital.fr>
Cc: Mateusz Holenko <mholenko@...micro.com>
Cc: Joel Stanley <joel@....id.au>
Cc: Gabriel L. Somlo <gsomlo@...il.com>
---
 .../admin-guide/kernel-parameters.txt         |  5 +++
 drivers/tty/serial/Kconfig                    |  1 +
 drivers/tty/serial/liteuart.c                 | 31 +++++++++++++++++++
 3 files changed, 37 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index 04545725f187..2d4a43af8de2 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -1084,6 +1084,11 @@
 			the driver will use only 32-bit accessors to read/write
 			the device registers.
 
+		liteuart,<addr>
+			Start an early console on a litex serial port at the
+			specified address. The serial port must already be
+			setup and configured. Options are not yet supported.
+
 		meson,<addr>
 			Start an early, polled-mode console on a meson serial
 			port at the specified address. The serial port must
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 0c4cd4a348f4..9ceffe6ab6fd 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1531,6 +1531,7 @@ config SERIAL_LITEUART
 	depends on OF || COMPILE_TEST
 	depends on LITEX
 	select SERIAL_CORE
+	select SERIAL_EARLYCON
 	help
 	  This driver is for the FPGA-based LiteUART serial controller from LiteX
 	  SoC builder.
diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c
index 64842f3539e1..38c472487e68 100644
--- a/drivers/tty/serial/liteuart.c
+++ b/drivers/tty/serial/liteuart.c
@@ -372,6 +372,37 @@ static int __init liteuart_console_init(void)
 console_initcall(liteuart_console_init);
 #endif /* CONFIG_SERIAL_LITEUART_CONSOLE */
 
+#ifdef CONFIG_SERIAL_EARLYCON
+static void early_liteuart_putc(struct uart_port *port, int c)
+{
+	while (litex_read8(port->membase + OFF_TXFULL))
+		cpu_relax();
+
+	litex_write8(port->membase + OFF_RXTX, c);
+}
+
+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, early_liteuart_putc);
+}
+
+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_EARLYCON */
+
 static int __init liteuart_init(void)
 {
 	int res;
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ