-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Fugang Duan
authored and
Greg Kroah-Hartman
committed
Jul 29, 2020
1 parent
0db4f9b
commit 699cc4d
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// 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, int 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"); |