Link: https://lore.kernel.org/r/20260217200002.683975158@linuxfoundation.org Tested-by: Florian Fainelli <florian.fainelli@broadcom.com> Tested-by: Takeshi Ogasawara <takeshi.ogasawara@futuring-girl.com> Tested-by: Peter Schneider <pschneider1968@googlemail.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Tested-by: Salvatore Bonaccorso <carnil@debian.org> Tested-by: Brett A C Sheffield <bacs@librecast.net> Tested-by: Mark Brown <broonie@kernel.org> Tested-by: Luna Jernberg <droidbittin@gmail.com> Tested-by: Ronald Warsow <rwarsow@gmx.de> Tested-by: Justin M. Forbes <jforbes@fedoraproject.org> Tested-by: Ron Economos <re@w6rz.net> Tested-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
51 lines
1.3 KiB
C
51 lines
1.3 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright 2020 NXP
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/ioport.h>
|
|
#include <linux/init.h>
|
|
#include <linux/serial_core.h>
|
|
#include <linux/serial.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/of.h>
|
|
#include <linux/io.h>
|
|
|
|
#define URTX0 0x40 /* Transmitter Register */
|
|
#define UTS_TXFULL (1<<4) /* TxFIFO full */
|
|
#define IMX21_UTS 0xb4 /* UART Test Register on all other i.mx*/
|
|
|
|
static void imx_uart_console_early_putchar(struct uart_port *port, unsigned char ch)
|
|
{
|
|
while (readl_relaxed(port->membase + IMX21_UTS) & UTS_TXFULL)
|
|
cpu_relax();
|
|
|
|
writel_relaxed(ch, port->membase + URTX0);
|
|
}
|
|
|
|
static void imx_uart_console_early_write(struct console *con, const char *s,
|
|
unsigned count)
|
|
{
|
|
struct earlycon_device *dev = con->data;
|
|
|
|
uart_console_write(&dev->port, s, count, imx_uart_console_early_putchar);
|
|
}
|
|
|
|
static int __init
|
|
imx_console_early_setup(struct earlycon_device *dev, const char *opt)
|
|
{
|
|
if (!dev->port.membase)
|
|
return -ENODEV;
|
|
|
|
dev->con->write = imx_uart_console_early_write;
|
|
|
|
return 0;
|
|
}
|
|
OF_EARLYCON_DECLARE(ec_imx6q, "fsl,imx6q-uart", imx_console_early_setup);
|
|
OF_EARLYCON_DECLARE(ec_imx21, "fsl,imx21-uart", imx_console_early_setup);
|
|
|
|
MODULE_AUTHOR("NXP");
|
|
MODULE_DESCRIPTION("IMX earlycon driver");
|
|
MODULE_LICENSE("GPL");
|