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

tty: serial: imx: add imx earlycon driver

Split imx earlycon driver from imx serial driver "imx.c" as
separated driver. imx serial driver can be built as module,
but earlycon driver only support build in.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Link: https://lore.kernel.org/r/20200724070815.11445-3-fugang.duan@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Fugang Duan and committed by
Greg Kroah-Hartman
699cc4df 0db4f9b9

+58
+8
drivers/tty/serial/Kconfig
··· 515 515 "console=ttymxc0". (Try "man bootparam" or see the documentation of 516 516 your bootloader about how to pass options to the kernel at boot time.) 517 517 518 + config SERIAL_IMX_EARLYCON 519 + bool "Earlycon on IMX serial port" 520 + depends on OF 521 + select SERIAL_EARLYCON 522 + help 523 + If you have enabled the earlycon on the Freescale IMX 524 + CPU you can make it the earlycon by answering Y to this option. 525 + 518 526 config SERIAL_UARTLITE 519 527 tristate "Xilinx uartlite serial port support" 520 528 depends on HAS_IOMEM
+50
drivers/tty/serial/imx_earlycon.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Copyright 2020 NXP 4 + */ 5 + 6 + #include <linux/module.h> 7 + #include <linux/ioport.h> 8 + #include <linux/init.h> 9 + #include <linux/serial_core.h> 10 + #include <linux/serial.h> 11 + #include <linux/delay.h> 12 + #include <linux/of.h> 13 + #include <linux/io.h> 14 + 15 + #define URTX0 0x40 /* Transmitter Register */ 16 + #define UTS_TXFULL (1<<4) /* TxFIFO full */ 17 + #define IMX21_UTS 0xb4 /* UART Test Register on all other i.mx*/ 18 + 19 + static void imx_uart_console_early_putchar(struct uart_port *port, int ch) 20 + { 21 + while (readl_relaxed(port->membase + IMX21_UTS) & UTS_TXFULL) 22 + cpu_relax(); 23 + 24 + writel_relaxed(ch, port->membase + URTX0); 25 + } 26 + 27 + static void imx_uart_console_early_write(struct console *con, const char *s, 28 + unsigned count) 29 + { 30 + struct earlycon_device *dev = con->data; 31 + 32 + uart_console_write(&dev->port, s, count, imx_uart_console_early_putchar); 33 + } 34 + 35 + static int __init 36 + imx_console_early_setup(struct earlycon_device *dev, const char *opt) 37 + { 38 + if (!dev->port.membase) 39 + return -ENODEV; 40 + 41 + dev->con->write = imx_uart_console_early_write; 42 + 43 + return 0; 44 + } 45 + OF_EARLYCON_DECLARE(ec_imx6q, "fsl,imx6q-uart", imx_console_early_setup); 46 + OF_EARLYCON_DECLARE(ec_imx21, "fsl,imx21-uart", imx_console_early_setup); 47 + 48 + MODULE_AUTHOR("NXP"); 49 + MODULE_DESCRIPTION("IMX earlycon driver"); 50 + MODULE_LICENSE("GPL");