serial/liteuart; Add support for earlycon
Subsystems (3)
PATCH 1/1 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.
--- .../admin-guide/kernel-parameters.txt | 5 +++ drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/liteuart.c | 31 +++++++++++++++++++ 3 files changed, 37 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +5 -0
@@ -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
drivers/tty/serial/Kconfig +1 -0
@@ -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.
drivers/tty/serial/liteuart.c +31 -0
@@ -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;
Signature · 1 line
2.31.1
I pulled the trigger a bit early, the subject needs a bit better/consistent formatting. It should be:
serial: liteuart: Add support for earlycon
Quoted 89 lines · Stafford Horne
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 <[email protected]>Cc Florent Kermarrec <[email protected]>Cc Mateusz Holenko <[email protected]>Cc Joel Stanley <[email protected]>Cc Gabriel L. Somlo <[email protected]>--- .../admin-guide/kernel-parameters.txt | 5 +++ drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/liteuart.c | 31 +++++++++++++++++++ 3 files changed, 37 insertions(+)Documentation/admin-guide/kernel-parameters.txt +5
-0@@ -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 mustdrivers/tty/serial/Kconfig +1
-0@@ -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.drivers/tty/serial/liteuart.c +31
-0@@ -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;Signature · 1 line
2.31.1
Quoted 88 lines · Stafford Horne
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 <[email protected]>Cc Florent Kermarrec <[email protected]>Cc Mateusz Holenko <[email protected]>Cc Joel Stanley <[email protected]>Cc Gabriel L. Somlo <[email protected]>--- .../admin-guide/kernel-parameters.txt | 5 +++ drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/liteuart.c | 31 +++++++++++++++++++ 3 files changed, 37 insertions(+)Documentation/admin-guide/kernel-parameters.txt +5
-0@@ -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 mustdrivers/tty/serial/Kconfig +1
-0@@ -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.drivers/tty/serial/liteuart.c +31
-0@@ -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;Signature · 1 line
2.31.1
FWIW:
Thanks,
--Gabriel
Jiri Slaby
maintainerQuoted 49 lines · Stafford Horne
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 <[email protected]>Cc Florent Kermarrec <[email protected]>Cc Mateusz Holenko <[email protected]>Cc Joel Stanley <[email protected]>Cc Gabriel L. Somlo <[email protected]>--- .../admin-guide/kernel-parameters.txt | 5 +++ drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/liteuart.c | 31 +++++++++++++++++++ 3 files changed, 37 insertions(+)Documentation/admin-guide/kernel-parameters.txt +5
-0@@ -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 mustdrivers/tty/serial/Kconfig +1
-0@@ -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.drivers/tty/serial/liteuart.c +0
-0
drivers/tty/serial/liteuart.c static int __init liteuart_console_init(void) · line 381
Quoted 10 lines
drivers/tty/serial/liteuart.c +7
-0@@ -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?
Quoted 28 lines
drivers/tty/serial/liteuart.c +24
-0+} + +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;
Signature · 2 lines
js suse labs
Quoted 61 lines · Jiri Slaby
Quoted 48 lines · Stafford Horne
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 <[email protected]>Cc Florent Kermarrec <[email protected]>Cc Mateusz Holenko <[email protected]>Cc Joel Stanley <[email protected]>Cc Gabriel L. Somlo <[email protected]>--- .../admin-guide/kernel-parameters.txt | 5 +++ drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/liteuart.c | 31 +++++++++++++++++++ 3 files changed, 37 insertions(+)Documentation/admin-guide/kernel-parameters.txt +5
-0@@ -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 mustdrivers/tty/serial/Kconfig +1
-0@@ -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.drivers/tty/serial/liteuart.c +0
-0drivers/tty/serial/liteuart.c static int __init liteuart_console_init(void) · line 380
Quoted 9 lines
drivers/tty/serial/liteuart.c +7
-0@@ -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,
Quoted 1 line
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
Quoted 33 lines
Quoted 28 lines
drivers/tty/serial/liteuart.c +24
-0+} + +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;Signature · 2 lines
js suse labs
Jiri Slaby
maintainerQuoted 62 lines · Stafford Horne
Quoted 61 lines · Jiri Slaby
Quoted 48 lines · Stafford Horne
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 <[email protected]>Cc Florent Kermarrec <[email protected]>Cc Mateusz Holenko <[email protected]>Cc Joel Stanley <[email protected]>Cc Gabriel L. Somlo <[email protected]>--- .../admin-guide/kernel-parameters.txt | 5 +++ drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/liteuart.c | 31 +++++++++++++++++++ 3 files changed, 37 insertions(+)Documentation/admin-guide/kernel-parameters.txt +5
-0@@ -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 mustdrivers/tty/serial/Kconfig +1
-0@@ -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.drivers/tty/serial/liteuart.c +0
-0drivers/tty/serial/liteuart.c static int __init liteuart_console_init(void) · line 380
Quoted 9 lines
drivers/tty/serial/liteuart.c +7
-0@@ -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,
Quoted 5 lines
Quoted 1 line
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,
Signature · 2 lines
js suse labs
Quoted 67 lines · Jiri Slaby
Quoted 66 lines · Stafford Horne
Quoted 61 lines · Jiri Slaby
Quoted 48 lines · Stafford Horne
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 <[email protected]>Cc Florent Kermarrec <[email protected]>Cc Mateusz Holenko <[email protected]>Cc Joel Stanley <[email protected]>Cc Gabriel L. Somlo <[email protected]>--- .../admin-guide/kernel-parameters.txt | 5 +++ drivers/tty/serial/Kconfig | 1 + drivers/tty/serial/liteuart.c | 31 +++++++++++++++++++ 3 files changed, 37 insertions(+)Documentation/admin-guide/kernel-parameters.txt +5
-0@@ -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 mustdrivers/tty/serial/Kconfig +1
-0@@ -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.drivers/tty/serial/liteuart.c +0
-0drivers/tty/serial/liteuart.c static int __init liteuart_console_init(void) · line 380
Quoted 9 lines
drivers/tty/serial/liteuart.c +7
-0@@ -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,
Quoted 1 line
am I missing something or this doesn't differ to
liteuart_putchar?Hi, No you are right, I missed that thanks for catching it.
Quoted 7 lines
Quoted 1 line
I should be able to remove this function and use putchar below.
OK.
I've just noticed you add an ifdef
CONFIG_SERIAL_EARLYCONhere, but you selectSERIAL_EARLYCONinKconfigabove. So the ifdef is sort of pointless? (Or you shouldn't selectSERIAL_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