Skip to content

Commit

Permalink
serial: altera_uart: add earlycon support
Browse files Browse the repository at this point in the history
Nios2 currently uses its own early printk implementation, rather than
using unified earlycon support to show boot messages on altera_uart.

Add earlycon support to altera_uart so that other archs may use it.
Also, this (together with the corresponding patch for altera_jtaguart)
will allow the early printk implementation in arch/nios2 to be removed
in a future patch.

Cc: Ley Foon Tan <lftan@altera.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Tobias Klauser authored and Greg Kroah-Hartman committed Mar 31, 2017
1 parent a4199f5 commit 4d9d7d8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/tty/serial/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1392,6 +1392,7 @@ config SERIAL_ALTERA_UART_CONSOLE
bool "Altera UART console support"
depends on SERIAL_ALTERA_UART=y
select SERIAL_CORE_CONSOLE
select SERIAL_EARLYCON
help
Enable a Altera UART port to be the system console.

Expand Down
32 changes: 32 additions & 0 deletions drivers/tty/serial/altera_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,38 @@ console_initcall(altera_uart_console_init);

#define ALTERA_UART_CONSOLE (&altera_uart_console)

static void altera_uart_earlycon_write(struct console *co, const char *s,
unsigned int count)
{
struct earlycon_device *dev = co->data;

uart_console_write(&dev->port, s, count, altera_uart_console_putc);
}

static int __init altera_uart_earlycon_setup(struct earlycon_device *dev,
const char *options)
{
struct uart_port *port = &dev->port;

if (!port->membase)
return -ENODEV;

/* Enable RX interrupts now */
writel(ALTERA_UART_CONTROL_RRDY_MSK,
port->membase + ALTERA_UART_CONTROL_REG);

if (dev->baud) {
unsigned int baudclk = port->uartclk / dev->baud;

writel(baudclk, port->membase + ALTERA_UART_DIVISOR_REG);
}

dev->con->write = altera_uart_earlycon_write;
return 0;
}

OF_EARLYCON_DECLARE(uart, "altr,uart-1.0", altera_uart_earlycon_setup);

#else

#define ALTERA_UART_CONSOLE NULL
Expand Down

0 comments on commit 4d9d7d8

Please sign in to comment.