diff options
author | Vladimir Murzin <vladimir.murzin@arm.com> | 2016-04-25 09:47:48 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-04-30 09:26:55 -0700 |
commit | bd8d257fa3371a284568b8ee04c2bcf4757238ed (patch) | |
tree | 2ca1be7d29853b680bf23ea1bc343f619c99ae99 /drivers/tty/serial/mps2-uart.c | |
parent | 041f031def330582108bc37f97525d9e7c0e2b2f (diff) |
serial: mps2-uart: add support for early console
This adds support early console for MPS2 UART which can be enabled via
earlycon=mps2,0x40004000
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/mps2-uart.c')
-rw-r--r-- | drivers/tty/serial/mps2-uart.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/tty/serial/mps2-uart.c b/drivers/tty/serial/mps2-uart.c index e571e4cdfab3..da9e27d3c263 100644 --- a/drivers/tty/serial/mps2-uart.c +++ b/drivers/tty/serial/mps2-uart.c @@ -450,6 +450,34 @@ static struct console mps2_uart_console = { #define MPS2_SERIAL_CONSOLE (&mps2_uart_console) +static void mps2_early_putchar(struct uart_port *port, int ch) +{ + while (readb(port->membase + UARTn_STATE) & UARTn_STATE_TX_FULL) + cpu_relax(); + + writeb((unsigned char)ch, port->membase + UARTn_DATA); +} + +static void mps2_early_write(struct console *con, const char *s, unsigned int n) +{ + struct earlycon_device *dev = con->data; + + uart_console_write(&dev->port, s, n, mps2_early_putchar); +} + +static int __init mps2_early_console_setup(struct earlycon_device *device, + const char *opt) +{ + if (!device->port.membase) + return -ENODEV; + + device->con->write = mps2_early_write; + + return 0; +} + +OF_EARLYCON_DECLARE(mps2, "arm,mps2-uart", mps2_early_console_setup); + #else #define MPS2_SERIAL_CONSOLE NULL #endif |