tty: serial: msm: Add earlycon support
Add support for DT based and command line based early console on platforms with the msm serial hardware. Cc: Rob Herring <robh@kernel.org> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
a86713b153
commit
0efe729634
3 changed files with 75 additions and 12 deletions
|
@ -942,6 +942,18 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
|
||||||
must already be setup and configured. Options are not
|
must already be setup and configured. Options are not
|
||||||
yet supported.
|
yet supported.
|
||||||
|
|
||||||
|
msm_serial,<addr>
|
||||||
|
Start an early, polled-mode console on an msm serial
|
||||||
|
port at the specified address. The serial port
|
||||||
|
must already be setup and configured. Options are not
|
||||||
|
yet supported.
|
||||||
|
|
||||||
|
msm_serial_dm,<addr>
|
||||||
|
Start an early, polled-mode console on an msm serial
|
||||||
|
dm port at the specified address. The serial port
|
||||||
|
must already be setup and configured. Options are not
|
||||||
|
yet supported.
|
||||||
|
|
||||||
smh Use ARM semihosting calls for early console.
|
smh Use ARM semihosting calls for early console.
|
||||||
|
|
||||||
earlyprintk= [X86,SH,BLACKFIN,ARM,M68k]
|
earlyprintk= [X86,SH,BLACKFIN,ARM,M68k]
|
||||||
|
|
|
@ -1070,6 +1070,7 @@ config SERIAL_MSM_CONSOLE
|
||||||
bool "MSM serial console support"
|
bool "MSM serial console support"
|
||||||
depends on SERIAL_MSM=y
|
depends on SERIAL_MSM=y
|
||||||
select SERIAL_CORE_CONSOLE
|
select SERIAL_CORE_CONSOLE
|
||||||
|
select SERIAL_EARLYCON
|
||||||
|
|
||||||
config SERIAL_MSM_HS
|
config SERIAL_MSM_HS
|
||||||
tristate "MSM UART High Speed: Serial Driver"
|
tristate "MSM UART High Speed: Serial Driver"
|
||||||
|
|
|
@ -845,22 +845,15 @@ static inline struct uart_port *get_port_from_line(unsigned int line)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SERIAL_MSM_CONSOLE
|
#ifdef CONFIG_SERIAL_MSM_CONSOLE
|
||||||
static void msm_console_write(struct console *co, const char *s,
|
static void __msm_console_write(struct uart_port *port, const char *s,
|
||||||
unsigned int count)
|
unsigned int count, bool is_uartdm)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct uart_port *port;
|
|
||||||
struct msm_port *msm_port;
|
|
||||||
int num_newlines = 0;
|
int num_newlines = 0;
|
||||||
bool replaced = false;
|
bool replaced = false;
|
||||||
void __iomem *tf;
|
void __iomem *tf;
|
||||||
|
|
||||||
BUG_ON(co->index < 0 || co->index >= UART_NR);
|
if (is_uartdm)
|
||||||
|
|
||||||
port = get_port_from_line(co->index);
|
|
||||||
msm_port = UART_TO_MSM(port);
|
|
||||||
|
|
||||||
if (msm_port->is_uartdm)
|
|
||||||
tf = port->membase + UARTDM_TF;
|
tf = port->membase + UARTDM_TF;
|
||||||
else
|
else
|
||||||
tf = port->membase + UART_TF;
|
tf = port->membase + UART_TF;
|
||||||
|
@ -872,7 +865,7 @@ static void msm_console_write(struct console *co, const char *s,
|
||||||
count += num_newlines;
|
count += num_newlines;
|
||||||
|
|
||||||
spin_lock(&port->lock);
|
spin_lock(&port->lock);
|
||||||
if (msm_port->is_uartdm)
|
if (is_uartdm)
|
||||||
reset_dm_count(port, count);
|
reset_dm_count(port, count);
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
@ -881,7 +874,7 @@ static void msm_console_write(struct console *co, const char *s,
|
||||||
unsigned int num_chars;
|
unsigned int num_chars;
|
||||||
char buf[4] = { 0 };
|
char buf[4] = { 0 };
|
||||||
|
|
||||||
if (msm_port->is_uartdm)
|
if (is_uartdm)
|
||||||
num_chars = min(count - i, (unsigned int)sizeof(buf));
|
num_chars = min(count - i, (unsigned int)sizeof(buf));
|
||||||
else
|
else
|
||||||
num_chars = 1;
|
num_chars = 1;
|
||||||
|
@ -910,6 +903,20 @@ static void msm_console_write(struct console *co, const char *s,
|
||||||
spin_unlock(&port->lock);
|
spin_unlock(&port->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void msm_console_write(struct console *co, const char *s,
|
||||||
|
unsigned int count)
|
||||||
|
{
|
||||||
|
struct uart_port *port;
|
||||||
|
struct msm_port *msm_port;
|
||||||
|
|
||||||
|
BUG_ON(co->index < 0 || co->index >= UART_NR);
|
||||||
|
|
||||||
|
port = get_port_from_line(co->index);
|
||||||
|
msm_port = UART_TO_MSM(port);
|
||||||
|
|
||||||
|
__msm_console_write(port, s, count, msm_port->is_uartdm);
|
||||||
|
}
|
||||||
|
|
||||||
static int __init msm_console_setup(struct console *co, char *options)
|
static int __init msm_console_setup(struct console *co, char *options)
|
||||||
{
|
{
|
||||||
struct uart_port *port;
|
struct uart_port *port;
|
||||||
|
@ -952,6 +959,49 @@ static int __init msm_console_setup(struct console *co, char *options)
|
||||||
return uart_set_options(port, co, baud, parity, bits, flow);
|
return uart_set_options(port, co, baud, parity, bits, flow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
msm_serial_early_write(struct console *con, const char *s, unsigned n)
|
||||||
|
{
|
||||||
|
struct earlycon_device *dev = con->data;
|
||||||
|
|
||||||
|
__msm_console_write(&dev->port, s, n, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int __init
|
||||||
|
msm_serial_early_console_setup(struct earlycon_device *device, const char *opt)
|
||||||
|
{
|
||||||
|
if (!device->port.membase)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
device->con->write = msm_serial_early_write;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EARLYCON_DECLARE(msm_serial, msm_serial_early_console_setup);
|
||||||
|
OF_EARLYCON_DECLARE(msm_serial, "qcom,msm-uart",
|
||||||
|
msm_serial_early_console_setup);
|
||||||
|
|
||||||
|
static void
|
||||||
|
msm_serial_early_write_dm(struct console *con, const char *s, unsigned n)
|
||||||
|
{
|
||||||
|
struct earlycon_device *dev = con->data;
|
||||||
|
|
||||||
|
__msm_console_write(&dev->port, s, n, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int __init
|
||||||
|
msm_serial_early_console_setup_dm(struct earlycon_device *device,
|
||||||
|
const char *opt)
|
||||||
|
{
|
||||||
|
if (!device->port.membase)
|
||||||
|
return -ENODEV;
|
||||||
|
|
||||||
|
device->con->write = msm_serial_early_write_dm;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EARLYCON_DECLARE(msm_serial_dm, msm_serial_early_console_setup_dm);
|
||||||
|
OF_EARLYCON_DECLARE(msm_serial_dm, "qcom,msm-uartdm",
|
||||||
|
msm_serial_early_console_setup_dm);
|
||||||
|
|
||||||
static struct uart_driver msm_uart_driver;
|
static struct uart_driver msm_uart_driver;
|
||||||
|
|
||||||
static struct console msm_console = {
|
static struct console msm_console = {
|
||||||
|
|
Loading…
Add table
Reference in a new issue