1 // SPDX-License-Identifier: GPL-2.0+
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>
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*/
19 static void imx_uart_console_early_putchar(struct uart_port
*port
, int ch
)
21 while (readl_relaxed(port
->membase
+ IMX21_UTS
) & UTS_TXFULL
)
24 writel_relaxed(ch
, port
->membase
+ URTX0
);
27 static void imx_uart_console_early_write(struct console
*con
, const char *s
,
30 struct earlycon_device
*dev
= con
->data
;
32 uart_console_write(&dev
->port
, s
, count
, imx_uart_console_early_putchar
);
36 imx_console_early_setup(struct earlycon_device
*dev
, const char *opt
)
38 if (!dev
->port
.membase
)
41 dev
->con
->write
= imx_uart_console_early_write
;
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
);
49 MODULE_DESCRIPTION("IMX earlycon driver");
50 MODULE_LICENSE("GPL");