All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] serial/liteuart; Add support for earlycon
@ 2021-05-15  8:45 Stafford Horne
  2021-05-15  8:49 ` Stafford Horne
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Stafford Horne @ 2021-05-15  8:45 UTC (permalink / raw)
  To: LKML
  Cc: Stafford Horne, Florent Kermarrec, Mateusz Holenko, Joel Stanley,
	Gabriel L . Somlo, Jonathan Corbet, Greg Kroah-Hartman,
	Jiri Slaby, Karol Gugala, Paul E. McKenney, Randy Dunlap,
	Andrew Morton, Thomas Gleixner, 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.  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>
---
 .../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


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

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

I pulled the trigger a bit early, the subject needs a bit better/consistent
formatting.  It should be:

  serial: liteuart: Add support for earlycon

On Sat, May 15, 2021 at 05:45:18PM +0900, 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.  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>
> ---
>  .../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
> 

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

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

On Sat, May 15, 2021 at 05:45:18PM +0900, 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.  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>
> ---
>  .../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
 
FWIW:
Reviewed-and-tested-by: Gabriel Somlo <gsomlo@gmail.com>

Thanks,
--Gabriel

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

* Re: [PATCH] serial/liteuart; Add support for earlycon
  2021-05-15  8:45 [PATCH] serial/liteuart; Add support for earlycon Stafford Horne
  2021-05-15  8:49 ` Stafford Horne
  2021-05-15 12:17 ` Gabriel L. Somlo
@ 2021-05-17  8:16 ` Jiri Slaby
  2021-05-17  8:23   ` Stafford Horne
  2 siblings, 1 reply; 7+ messages in thread
From: Jiri Slaby @ 2021-05-17  8:16 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, Viresh Kumar, Mike Kravetz, Peter Zijlstra,
	linux-doc, linux-serial

On 15. 05. 21, 10:45, 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.  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>
> ---
>   .../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);

Hi,

am I missing something or this doesn't differ to liteuart_putchar?

> +}
> +
> +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;
> 


-- 
js
suse labs

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

* Re: [PATCH] serial/liteuart; Add support for earlycon
  2021-05-17  8:16 ` Jiri Slaby
@ 2021-05-17  8:23   ` Stafford Horne
  2021-05-17  8:25     ` Jiri Slaby
  0 siblings, 1 reply; 7+ messages in thread
From: Stafford Horne @ 2021-05-17  8:23 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: LKML, 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, Viresh Kumar, Mike Kravetz, Peter Zijlstra,
	linux-doc, linux-serial

On Mon, May 17, 2021 at 10:16:43AM +0200, Jiri Slaby wrote:
> On 15. 05. 21, 10:45, 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.  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>
> > ---
> >   .../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);
> 
> Hi,
> 
> am I missing something or this doesn't differ to liteuart_putchar?

Hi, No you are right, I missed that thanks for catching it.

I should be able to remove this function and use putchar below.

-Stafford

> > +}
> > +
> > +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;
> > 
> 
> 
> -- 
> js
> suse labs

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

* Re: [PATCH] serial/liteuart; Add support for earlycon
  2021-05-17  8:23   ` Stafford Horne
@ 2021-05-17  8:25     ` Jiri Slaby
  2021-05-17  8:53       ` Stafford Horne
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Slaby @ 2021-05-17  8:25 UTC (permalink / raw)
  To: Stafford Horne
  Cc: LKML, 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, Viresh Kumar, Mike Kravetz, Peter Zijlstra,
	linux-doc, linux-serial

On 17. 05. 21, 10:23, Stafford Horne wrote:
> On Mon, May 17, 2021 at 10:16:43AM +0200, Jiri Slaby wrote:
>> On 15. 05. 21, 10:45, 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.  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>
>>> ---
>>>    .../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);
>>
>> Hi,
>>
>> am I missing something or this doesn't differ to liteuart_putchar?
> 
> Hi, No you are right, I missed that thanks for catching it.
> 
> I should be able to remove this function and use putchar below.

OK.

I've just noticed you add an ifdef CONFIG_SERIAL_EARLYCON here, but you 
select SERIAL_EARLYCON in Kconfig above. So the ifdef is sort of 
pointless? (Or you shouldn't select SERIAL_EARLYCON.)

thanks,
-- 
js
suse labs

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

* Re: [PATCH] serial/liteuart; Add support for earlycon
  2021-05-17  8:25     ` Jiri Slaby
@ 2021-05-17  8:53       ` Stafford Horne
  0 siblings, 0 replies; 7+ messages in thread
From: Stafford Horne @ 2021-05-17  8:53 UTC (permalink / raw)
  To: Jiri Slaby
  Cc: LKML, 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, Viresh Kumar, Mike Kravetz, Peter Zijlstra,
	linux-doc, linux-serial

On Mon, May 17, 2021 at 10:25:46AM +0200, Jiri Slaby wrote:
> On 17. 05. 21, 10:23, Stafford Horne wrote:
> > On Mon, May 17, 2021 at 10:16:43AM +0200, Jiri Slaby wrote:
> > > On 15. 05. 21, 10:45, 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.  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>
> > > > ---
> > > >    .../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);
> > > 
> > > Hi,
> > > 
> > > am I missing something or this doesn't differ to liteuart_putchar?
> > 
> > Hi, No you are right, I missed that thanks for catching it.
> > 
> > I should be able to remove this function and use putchar below.
> 
> OK.
> 
> I've just noticed you add an ifdef CONFIG_SERIAL_EARLYCON here, but you
> select SERIAL_EARLYCON in Kconfig above. So the ifdef is sort of pointless?
> (Or you shouldn't select SERIAL_EARLYCON.)

Ah yes, this I thought might have been wrong when I wrote it.  I think my
problem here is I was just copying how some other patches implemented earlycon.

 omap-serial - has ifdefs, doesn't select SERIAL_EARLYCON - looks ok
 sifive - has ifdefs + select SERIAL_EARLYCON - maybe needs cleanup too

-Stafford

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

end of thread, other threads:[~2021-05-17  8:53 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-15  8:45 [PATCH] serial/liteuart; Add support for earlycon Stafford Horne
2021-05-15  8:49 ` Stafford Horne
2021-05-15 12:17 ` Gabriel L. Somlo
2021-05-17  8:16 ` Jiri Slaby
2021-05-17  8:23   ` Stafford Horne
2021-05-17  8:25     ` Jiri Slaby
2021-05-17  8:53       ` Stafford Horne

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.