0001
0002
0003
0004
0005
0006 #include <linux/module.h>
0007 #include <linux/ioport.h>
0008 #include <linux/init.h>
0009 #include <linux/serial_core.h>
0010 #include <linux/serial.h>
0011 #include <linux/delay.h>
0012 #include <linux/of.h>
0013 #include <linux/io.h>
0014
0015 #define URTX0 0x40
0016 #define UTS_TXFULL (1<<4)
0017 #define IMX21_UTS 0xb4
0018
0019 static void imx_uart_console_early_putchar(struct uart_port *port, unsigned char ch)
0020 {
0021 while (readl_relaxed(port->membase + IMX21_UTS) & UTS_TXFULL)
0022 cpu_relax();
0023
0024 writel_relaxed(ch, port->membase + URTX0);
0025 }
0026
0027 static void imx_uart_console_early_write(struct console *con, const char *s,
0028 unsigned count)
0029 {
0030 struct earlycon_device *dev = con->data;
0031
0032 uart_console_write(&dev->port, s, count, imx_uart_console_early_putchar);
0033 }
0034
0035 static int __init
0036 imx_console_early_setup(struct earlycon_device *dev, const char *opt)
0037 {
0038 if (!dev->port.membase)
0039 return -ENODEV;
0040
0041 dev->con->write = imx_uart_console_early_write;
0042
0043 return 0;
0044 }
0045 OF_EARLYCON_DECLARE(ec_imx6q, "fsl,imx6q-uart", imx_console_early_setup);
0046 OF_EARLYCON_DECLARE(ec_imx21, "fsl,imx21-uart", imx_console_early_setup);
0047
0048 MODULE_AUTHOR("NXP");
0049 MODULE_DESCRIPTION("IMX earlycon driver");
0050 MODULE_LICENSE("GPL");