linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] serial: liteuart: Add support for earlycon
@ 2021-05-17 11:54 Stafford Horne
  2021-05-18  4:57 ` Jiri Slaby
  2021-05-18 12:02 ` Joel Stanley
  0 siblings, 2 replies; 4+ messages in thread
From: Stafford Horne @ 2021-05-17 11:54 UTC (permalink / raw)
  To: LKML
  Cc: jirislaby, Stafford Horne, Florent Kermarrec, Mateusz Holenko,
	Joel Stanley, Gabriel L . Somlo, Jonathan Corbet,
	Greg Kroah-Hartman, Karol Gugala, Paul E. McKenney, Randy Dunlap,
	Andrew Morton, Thomas Gleixner, Vlastimil Babka, Viresh Kumar,
	Mike Kravetz, Peter Zijlstra, linux-doc, linux-serial

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.

Signed-off-by: Stafford Horne <shorne@gmail.com>
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>
---
Changes since v1:
 - Fixed subject
 - Fixed ifdef and config issues pointed out by Jiri
 - Use liteuart_putchar instead of early_liteuart_putc

 .../admin-guide/kernel-parameters.txt         |  5 +++++
 drivers/tty/serial/Kconfig                    |  1 +
 drivers/tty/serial/liteuart.c                 | 21 +++++++++++++++++++
 3 files changed, 27 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..af41e534483c 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1550,6 +1550,7 @@ config SERIAL_LITEUART_CONSOLE
 	bool "LiteUART serial port console support"
 	depends on SERIAL_LITEUART=y
 	select SERIAL_CORE_CONSOLE
+	select SERIAL_EARLYCON
 	help
 	  Say 'Y' or 'M' here if you wish to use the FPGA-based LiteUART serial
 	  controller from LiteX SoC builder as the system console
diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c
index 64842f3539e1..1b75a4bf7c56 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)
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] serial: liteuart: Add support for earlycon
  2021-05-17 11:54 [PATCH v2] serial: liteuart: Add support for earlycon Stafford Horne
@ 2021-05-18  4:57 ` Jiri Slaby
  2021-05-18 12:02 ` Joel Stanley
  1 sibling, 0 replies; 4+ messages in thread
From: Jiri Slaby @ 2021-05-18  4:57 UTC (permalink / raw)
  To: Stafford Horne, LKML
  Cc: Florent Kermarrec, Mateusz Holenko, Joel Stanley,
	Gabriel L . Somlo, Jonathan Corbet, Greg Kroah-Hartman,
	Karol Gugala, Paul E. McKenney, Randy Dunlap, Andrew Morton,
	Thomas Gleixner, Vlastimil Babka, Viresh Kumar, Mike Kravetz,
	Peter Zijlstra, linux-doc, linux-serial

On 17. 05. 21, 13:54, Stafford Horne wrote:
> 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.
> 
> Signed-off-by: Stafford Horne <shorne@gmail.com>
> 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>

> ---
> Changes since v1:
>   - Fixed subject
>   - Fixed ifdef and config issues pointed out by Jiri
>   - Use liteuart_putchar instead of early_liteuart_putc
> 
>   .../admin-guide/kernel-parameters.txt         |  5 +++++
>   drivers/tty/serial/Kconfig                    |  1 +
>   drivers/tty/serial/liteuart.c                 | 21 +++++++++++++++++++
>   3 files changed, 27 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..af41e534483c 100644
> --- a/drivers/tty/serial/Kconfig
> +++ b/drivers/tty/serial/Kconfig
> @@ -1550,6 +1550,7 @@ config SERIAL_LITEUART_CONSOLE
>   	bool "LiteUART serial port console support"
>   	depends on SERIAL_LITEUART=y
>   	select SERIAL_CORE_CONSOLE
> +	select SERIAL_EARLYCON
>   	help
>   	  Say 'Y' or 'M' here if you wish to use the FPGA-based LiteUART serial
>   	  controller from LiteX SoC builder as the system console
> diff --git a/drivers/tty/serial/liteuart.c b/drivers/tty/serial/liteuart.c
> index 64842f3539e1..1b75a4bf7c56 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)
> 

thanks,
-- 
js
suse labs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] serial: liteuart: Add support for earlycon
  2021-05-17 11:54 [PATCH v2] serial: liteuart: Add support for earlycon Stafford Horne
  2021-05-18  4:57 ` Jiri Slaby
@ 2021-05-18 12:02 ` Joel Stanley
  2021-05-18 21:36   ` Stafford Horne
  1 sibling, 1 reply; 4+ messages in thread
From: Joel Stanley @ 2021-05-18 12:02 UTC (permalink / raw)
  To: Stafford Horne
  Cc: LKML, Jiri Slaby, Florent Kermarrec, Mateusz Holenko,
	Gabriel L . Somlo, Jonathan Corbet, Greg Kroah-Hartman,
	Karol Gugala, Paul E. McKenney, Randy Dunlap, Andrew Morton,
	Thomas Gleixner, Vlastimil Babka, Viresh Kumar, Mike Kravetz,
	Peter Zijlstra, linux-doc, linux-serial

On Mon, 17 May 2021 at 11:55, Stafford Horne <shorne@gmail.com> wrote:
>
> 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.
>
> Signed-off-by: Stafford Horne <shorne@gmail.com>
> 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: Joel Stanley <joel@jms.id.au>

Cheers,

Joel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] serial: liteuart: Add support for earlycon
  2021-05-18 12:02 ` Joel Stanley
@ 2021-05-18 21:36   ` Stafford Horne
  0 siblings, 0 replies; 4+ messages in thread
From: Stafford Horne @ 2021-05-18 21:36 UTC (permalink / raw)
  To: Joel Stanley
  Cc: LKML, Jiri Slaby, Florent Kermarrec, Mateusz Holenko,
	Gabriel L . Somlo, Jonathan Corbet, Greg Kroah-Hartman,
	Karol Gugala, Paul E. McKenney, Randy Dunlap, Andrew Morton,
	Thomas Gleixner, Vlastimil Babka, Viresh Kumar, Mike Kravetz,
	Peter Zijlstra, linux-doc, linux-serial

On Tue, May 18, 2021 at 12:02:57PM +0000, Joel Stanley wrote:
> On Mon, 17 May 2021 at 11:55, Stafford Horne <shorne@gmail.com> wrote:
> >
> > 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.
> >
> > Signed-off-by: Stafford Horne <shorne@gmail.com>
> > 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: Joel Stanley <joel@jms.id.au>

Thanks for reviewing.

-Stafford

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-05-18 21:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-17 11:54 [PATCH v2] serial: liteuart: Add support for earlycon Stafford Horne
2021-05-18  4:57 ` Jiri Slaby
2021-05-18 12:02 ` Joel Stanley
2021-05-18 21:36   ` Stafford Horne

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).