History

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.

Fugang Duan committed 6 years ago

Commit 699cc4d1 parent 0db4f9b2 files · +58 −0Browse files

Unified · Split

2 files
  1. drivers/tty/serial/Kconfig +8 −0
  2. drivers/tty/serial/imx_earlycon.c +50 −0
drivers/tty/serial/Kconfig+8−0
@@ -515,6 +515,14 @@ config SERIAL_IMX_CONSOLE · 514 unmodified lines
515 "console=ttymxc0". (Try "man bootparam" or see the documentation of515 "console=ttymxc0". (Try "man bootparam" or see the documentation of
516 your bootloader about how to pass options to the kernel at boot time.)516 your bootloader about how to pass options to the kernel at boot time.)
517 517
518config 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
518config SERIAL_UARTLITE526config SERIAL_UARTLITE
519 tristate "Xilinx uartlite serial port support"527 tristate "Xilinx uartlite serial port support"
520 depends on HAS_IOMEM528 depends on HAS_IOMEM
drivers/tty/serial/imx_earlycon.c+50−0
@@ -0,0 +1,50 @@
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
19static 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
27static 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
35static int __init
36imx_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}
45OF_EARLYCON_DECLARE(ec_imx6q, "fsl,imx6q-uart", imx_console_early_setup);
46OF_EARLYCON_DECLARE(ec_imx21, "fsl,imx21-uart", imx_console_early_setup);
47
48MODULE_AUTHOR("NXP");
49MODULE_DESCRIPTION("IMX earlycon driver");
50MODULE_LICENSE("GPL");