Skip to content

Commit

Permalink
tty: serial: imx: enable imx serial console port as module
Browse files Browse the repository at this point in the history
Add support for building i.MX serial driver as module.

The changes of the patch:
- imx console driver can be built as module.
- move out earlycon code to separated driver like imx_earlycon.c,
  and imx earlycon driver only support build-in.

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Link: https://lore.kernel.org/r/20200724070815.11445-2-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 a5e0691 commit 0db4f9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 40 deletions.
9 changes: 4 additions & 5 deletions drivers/tty/serial/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -502,15 +502,14 @@ config SERIAL_IMX
can enable its onboard serial port by enabling this option.

config SERIAL_IMX_CONSOLE
bool "Console on IMX serial port"
depends on SERIAL_IMX=y
tristate "Console on IMX serial port"
depends on SERIAL_IMX
select SERIAL_CORE_CONSOLE
select SERIAL_EARLYCON if OF
help
If you have enabled the serial port on the Freescale IMX
CPU you can make it the console by answering Y to this option.
CPU you can make it the console by answering Y/M to this option.

Even if you say Y here, the currently visible virtual console
Even if you say Y/M here, the currently visible virtual console
(/dev/tty0) will still be used as the system console by default, but
you can alter that using a kernel command line option such as
"console=ttymxc0". (Try "man bootparam" or see the documentation of
Expand Down
37 changes: 2 additions & 35 deletions drivers/tty/serial/imx.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ static inline int imx_uart_is_imx6q(struct imx_port *sport)
/*
* Save and restore functions for UCR1, UCR2 and UCR3 registers
*/
#if defined(CONFIG_SERIAL_IMX_CONSOLE)
#if IS_ENABLED(CONFIG_SERIAL_IMX_CONSOLE)
static void imx_uart_ucrs_save(struct imx_port *sport,
struct imx_port_ucrs *ucr)
{
Expand Down Expand Up @@ -1979,7 +1979,7 @@ static const struct uart_ops imx_uart_pops = {

static struct imx_port *imx_uart_ports[UART_NR];

#ifdef CONFIG_SERIAL_IMX_CONSOLE
#if IS_ENABLED(CONFIG_SERIAL_IMX_CONSOLE)
static void imx_uart_console_putchar(struct uart_port *port, int ch)
{
struct imx_port *sport = (struct imx_port *)port;
Expand Down Expand Up @@ -2176,39 +2176,6 @@ static struct console imx_uart_console = {

#define IMX_CONSOLE &imx_uart_console

#ifdef CONFIG_OF
static void imx_uart_console_early_putchar(struct uart_port *port, int ch)
{
struct imx_port *sport = (struct imx_port *)port;

while (imx_uart_readl(sport, IMX21_UTS) & UTS_TXFULL)
cpu_relax();

imx_uart_writel(sport, ch, 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);
#endif

#else
#define IMX_CONSOLE NULL
#endif
Expand Down

0 comments on commit 0db4f9b

Please sign in to comment.