summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Blumenstingl2016-12-11 21:42:23 +0100
committerGreg Kroah-Hartman2017-01-12 11:51:24 +0100
commitec84aa0a920192df56624961cb146947d7d9e11e (patch)
tree1249b3ff2d740f9e444c28b5688e829ec6aa173b
parentserial: pic32_uart: Fix 'request_irq' and 'free_irq' inconsistancy (diff)
downloadkernel-qcow2-linux-ec84aa0a920192df56624961cb146947d7d9e11e.tar.gz
kernel-qcow2-linux-ec84aa0a920192df56624961cb146947d7d9e11e.tar.xz
kernel-qcow2-linux-ec84aa0a920192df56624961cb146947d7d9e11e.zip
tty: serial: lantiq: implement earlycon support
This allows enabling earlycon for devices with a Lantiq serial console by splitting lqasc_serial_port_write() from lqasc_console_write() and re-using the new function for earlycon's write callback. The kernel-parameter name matches the driver name ("lantiq"), similar to how other drivers implement this. Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--Documentation/admin-guide/kernel-parameters.txt6
-rw-r--r--drivers/tty/serial/Kconfig1
-rw-r--r--drivers/tty/serial/lantiq.c38
3 files changed, 38 insertions, 7 deletions
diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentation/admin-guide/kernel-parameters.txt
index be7c0d9506b1..52f13674bc21 100644
--- a/Documentation/admin-guide/kernel-parameters.txt
+++ b/Documentation/admin-guide/kernel-parameters.txt
@@ -966,6 +966,12 @@
serial port must already be setup and configured.
Options are not yet supported.
+ lantiq,<addr>
+ Start an early, polled-mode console on a lantiq serial
+ (lqasc) port at the specified address. The serial port
+ must already be setup and configured. Options are not
+ yet supported.
+
lpuart,<addr>
lpuart32,<addr>
Use early console provided by Freescale LP UART driver
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index e9cf5b67f1b7..6117ac8da48f 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -1161,6 +1161,7 @@ config SERIAL_LANTIQ
depends on LANTIQ
select SERIAL_CORE
select SERIAL_CORE_CONSOLE
+ select SERIAL_EARLYCON
help
Support for console and UART on Lantiq SoCs.
diff --git a/drivers/tty/serial/lantiq.c b/drivers/tty/serial/lantiq.c
index b88832e8ee82..7c9a3f244935 100644
--- a/drivers/tty/serial/lantiq.c
+++ b/drivers/tty/serial/lantiq.c
@@ -590,13 +590,20 @@ lqasc_console_putchar(struct uart_port *port, int ch)
ltq_w8(ch, port->membase + LTQ_ASC_TBUF);
}
+static void lqasc_serial_port_write(struct uart_port *port, const char *s,
+ u_int count)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&ltq_asc_lock, flags);
+ uart_console_write(port, s, count, lqasc_console_putchar);
+ spin_unlock_irqrestore(&ltq_asc_lock, flags);
+}
static void
lqasc_console_write(struct console *co, const char *s, u_int count)
{
struct ltq_uart_port *ltq_port;
- struct uart_port *port;
- unsigned long flags;
if (co->index >= MAXPORTS)
return;
@@ -605,11 +612,7 @@ lqasc_console_write(struct console *co, const char *s, u_int count)
if (!ltq_port)
return;
- port = &ltq_port->port;
-
- spin_lock_irqsave(&ltq_asc_lock, flags);
- uart_console_write(port, s, count, lqasc_console_putchar);
- spin_unlock_irqrestore(&ltq_asc_lock, flags);
+ lqasc_serial_port_write(&ltq_port->port, s, count);
}
static int __init
@@ -659,6 +662,27 @@ lqasc_console_init(void)
}
console_initcall(lqasc_console_init);
+static void lqasc_serial_early_console_write(struct console *co,
+ const char *s,
+ u_int count)
+{
+ struct earlycon_device *dev = co->data;
+
+ lqasc_serial_port_write(&dev->port, s, count);
+}
+
+static int __init
+lqasc_serial_early_console_setup(struct earlycon_device *device,
+ const char *opt)
+{
+ if (!device->port.membase)
+ return -ENODEV;
+
+ device->con->write = lqasc_serial_early_console_write;
+ return 0;
+}
+OF_EARLYCON_DECLARE(lantiq, DRVNAME, lqasc_serial_early_console_setup);
+
static struct uart_driver lqasc_reg = {
.owner = THIS_MODULE,
.driver_name = DRVNAME,