summaryrefslogtreecommitdiff
path: root/drivers/tty/serial/atmel_serial.c
diff options
context:
space:
mode:
authorMichael Walle <michael@walle.cc>2022-02-17 12:46:20 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-02-21 21:47:42 +0300
commitaab68e959b37eddfe6b1640636457e960f66db2c (patch)
tree6632bdbdd619a93f26f92184a3465600ed512d52 /drivers/tty/serial/atmel_serial.c
parent802d00bd774b77fe132e9e83462b96fb9919411c (diff)
downloadlinux-aab68e959b37eddfe6b1640636457e960f66db2c.tar.xz
tty: serial: atmel: add earlycon support
Add early console support which relies on the bootloader for the initialization of the UART. Please note, that the compatibles are taken from at91-usart MFD driver. Tested-by: Claudiu Beznea <claudiu.beznea@microchip.com> Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com> Acked-by: Richard Genoud <richard.genoud@gmail.com> Signed-off-by: Michael Walle <michael@walle.cc> Link: https://lore.kernel.org/r/20220217094620.1148571-1-michael@walle.cc Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/atmel_serial.c')
-rw-r--r--drivers/tty/serial/atmel_serial.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
index 2d09a89974a2..73d43919898d 100644
--- a/drivers/tty/serial/atmel_serial.c
+++ b/drivers/tty/serial/atmel_serial.c
@@ -2673,6 +2673,30 @@ static struct console atmel_console = {
.data = &atmel_uart,
};
+static void atmel_serial_early_write(struct console *con, const char *s,
+ unsigned int n)
+{
+ struct earlycon_device *dev = con->data;
+
+ uart_console_write(&dev->port, s, n, atmel_console_putchar);
+}
+
+static int __init atmel_early_console_setup(struct earlycon_device *device,
+ const char *options)
+{
+ if (!device->port.membase)
+ return -ENODEV;
+
+ device->con->write = atmel_serial_early_write;
+
+ return 0;
+}
+
+OF_EARLYCON_DECLARE(atmel_serial, "atmel,at91rm9200-usart",
+ atmel_early_console_setup);
+OF_EARLYCON_DECLARE(atmel_serial, "atmel,at91sam9260-usart",
+ atmel_early_console_setup);
+
#define ATMEL_CONSOLE_DEVICE (&atmel_console)
#else