serial: mps2-uart: Initialize early console
Subsystems (2)
PATCH 1/1 serial: mps2-uart: Initialize early console
The early console code for mps2-uart assumes that the serial hardware is enabled for transmit when the system boots. However, this is not the case after reset. This results in a hang in mps2_early_putchar() if the serial transmitter is not enabled by a boot loader or ROM monitor.
--- drivers/tty/serial/mps2-uart.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/tty/serial/mps2-uart.c +9 -0
@@ -448,6 +448,14 @@ static struct console mps2_uart_console = {#define MPS2_SERIAL_CONSOLE (&mps2_uart_console) +static void mps2_early_init (struct uart_port *port) +{ +u8 control =readb (port->membase + UARTn_CTRL); + + control |= UARTn_CTRL_TX_ENABLE; +writeb (control, port->membase + UARTn_CTRL); +} +static void mps2_early_putchar (struct uart_port *port,int ch) {while (readb (port->membase + UARTn_STATE) & UARTn_STATE_TX_FULL)
@@ -469,6 +477,7 @@ static int __init mps2_early_console_setup(struct earlycon_device *device,if (!device->port.membase)return -ENODEV ; +mps2_early_init (&device->port); device->con->write = mps2_early_write;return 0 ;
Signature · 1 line
2.7.4
Hi Guenter,
Quoted 4 lines · Guenter Roeck
The early console code for mps2-uart assumes that the serial hardware is enabled for transmit when the system boots. However, this is not the case after reset. This results in a hang in
mps2_early_putchar()if the serial transmitter is not enabled by a boot loader or ROM monitor.
I was under impression that for earlycon there is an assumption/requirement that the serial port must already be setup and configured. For instance, I see such requirement for pl011. So it looks like boot code's fault not to enable serial (for mps2 it needs to setup BAUDDIV as well).
I'm not against the patch per se, but I'd like to hear if my understanding of earlycon requirements is correct or not.
Cheers
Vladimir
Quoted 34 lines
Signed-off-by Guenter Roeck <[email protected]>--- drivers/tty/serial/mps2-uart.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/tty/serial/mps2-uart.c +9
-0@@ -448,6 +448,14 @@ static struct console mps2_uart_console = {#define MPS2_SERIAL_CONSOLE (&mps2_uart_console) +static void mps2_early_init (struct uart_port *port) +{ +u8 control =readb (port->membase + UARTn_CTRL); + + control |= UARTn_CTRL_TX_ENABLE; +writeb (control, port->membase + UARTn_CTRL); +} +static void mps2_early_putchar (struct uart_port *port,int ch) {while (readb (port->membase + UARTn_STATE) & UARTn_STATE_TX_FULL)@@ -469,6 +477,7 @@ static int __init mps2_early_console_setup(struct earlycon_device *device,if (!device->port.membase)return -ENODEV ; +mps2_early_init (&device->port); device->con->write = mps2_early_write;return 0 ;
Quoted 8 lines · Vladimir Murzin
Hi Guenter,
Quoted 4 lines · Guenter Roeck
The early console code for mps2-uart assumes that the serial hardware is enabled for transmit when the system boots. However, this is not the case after reset. This results in a hang in
mps2_early_putchar()if the serial transmitter is not enabled by a boot loader or ROM monitor.
Quoted 5 lines
I was under impression that for earlycon there is an assumption/requirement that the serial port must already be setup and configured. For instance, I see such requirement for pl011. So it looks like boot code's fault not to enable serial (for mps2 it needs to setup BAUDDIV as well).
Good to know. Fine with me as well; I wasn't aware that such a requirement existed.
Guenter
Quoted 42 lines
I'm not against the patch per se, but I'd like to hear if my understanding of earlycon requirements is correct or not.
Cheers
VladimirQuoted 34 lines
Signed-off-by Guenter Roeck <[email protected]>--- drivers/tty/serial/mps2-uart.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/tty/serial/mps2-uart.c +9
-0@@ -448,6 +448,14 @@ static struct console mps2_uart_console = {#define MPS2_SERIAL_CONSOLE (&mps2_uart_console) +static void mps2_early_init (struct uart_port *port) +{ +u8 control =readb (port->membase + UARTn_CTRL); + + control |= UARTn_CTRL_TX_ENABLE; +writeb (control, port->membase + UARTn_CTRL); +} +static void mps2_early_putchar (struct uart_port *port,int ch) {while (readb (port->membase + UARTn_STATE) & UARTn_STATE_TX_FULL)@@ -469,6 +477,7 @@ static int __init mps2_early_console_setup(struct earlycon_device *device,if (!device->port.membase)return -ENODEV ; +mps2_early_init (&device->port); device->con->write = mps2_early_write;return 0 ;