Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

serial: altera_uart: add earlycon support

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>

authored by

Tobias Klauser and committed by
Greg Kroah-Hartman
4d9d7d89 a4199f5e

+33
+1
drivers/tty/serial/Kconfig
··· 1392 1392 bool "Altera UART console support" 1393 1393 depends on SERIAL_ALTERA_UART=y 1394 1394 select SERIAL_CORE_CONSOLE 1395 + select SERIAL_EARLYCON 1395 1396 help 1396 1397 Enable a Altera UART port to be the system console. 1397 1398
+32
drivers/tty/serial/altera_uart.c
··· 489 489 490 490 #define ALTERA_UART_CONSOLE (&altera_uart_console) 491 491 492 + static void altera_uart_earlycon_write(struct console *co, const char *s, 493 + unsigned int count) 494 + { 495 + struct earlycon_device *dev = co->data; 496 + 497 + uart_console_write(&dev->port, s, count, altera_uart_console_putc); 498 + } 499 + 500 + static int __init altera_uart_earlycon_setup(struct earlycon_device *dev, 501 + const char *options) 502 + { 503 + struct uart_port *port = &dev->port; 504 + 505 + if (!port->membase) 506 + return -ENODEV; 507 + 508 + /* Enable RX interrupts now */ 509 + writel(ALTERA_UART_CONTROL_RRDY_MSK, 510 + port->membase + ALTERA_UART_CONTROL_REG); 511 + 512 + if (dev->baud) { 513 + unsigned int baudclk = port->uartclk / dev->baud; 514 + 515 + writel(baudclk, port->membase + ALTERA_UART_DIVISOR_REG); 516 + } 517 + 518 + dev->con->write = altera_uart_earlycon_write; 519 + return 0; 520 + } 521 + 522 + OF_EARLYCON_DECLARE(uart, "altr,uart-1.0", altera_uart_earlycon_setup); 523 + 492 524 #else 493 525 494 526 #define ALTERA_UART_CONSOLE NULL