Commit 97a8d8fa authored by Philippe Gerum's avatar Philippe Gerum

serial/pl011: enable raw console channel

Enable the serial driver for raw_printk() output.
parent f7951d04
......@@ -2206,6 +2206,42 @@ static void pl011_console_putchar(struct uart_port *port, int ch)
pl011_write(ch, uap, REG_DR);
}
#ifdef CONFIG_RAW_PRINTK
#define pl011_clk_setup(clk) clk_prepare_enable(clk)
#define pl011_clk_enable(clk) do { } while (0)
#define pl011_clk_disable(clk) do { } while (0)
static void
pl011_console_write_raw(struct console *co, const char *s, unsigned int count)
{
struct uart_amba_port *uap = amba_ports[co->index];
unsigned int old_cr, new_cr, status;
old_cr = readw(uap->port.membase + UART011_CR);
new_cr = old_cr & ~UART011_CR_CTSEN;
new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
writew(new_cr, uap->port.membase + UART011_CR);
while (count-- > 0) {
if (*s == '\n')
pl011_console_putchar(&uap->port, '\r');
pl011_console_putchar(&uap->port, *s++);
}
do
status = readw(uap->port.membase + UART01x_FR);
while (status & UART01x_FR_BUSY);
writew(old_cr, uap->port.membase + UART011_CR);
}
#else /* !CONFIG_RAW_PRINTK */
#define pl011_clk_setup(clk) clk_prepare(clk)
#define pl011_clk_enable(clk) clk_enable(clk)
#define pl011_clk_disable(clk) clk_disable(clk)
#endif /* !CONFIG_RAW_PRINTK */
static void
pl011_console_write(struct console *co, const char *s, unsigned int count)
{
......@@ -2214,7 +2250,7 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
unsigned long flags;
int locked = 1;
clk_enable(uap->clk);
pl011_clk_enable(uap->clk);
local_irq_save(flags);
if (uap->port.sysrq)
......@@ -2251,7 +2287,7 @@ pl011_console_write(struct console *co, const char *s, unsigned int count)
spin_unlock(&uap->port.lock);
local_irq_restore(flags);
clk_disable(uap->clk);
pl011_clk_disable(uap->clk);
}
static void __init
......@@ -2312,7 +2348,7 @@ static int __init pl011_console_setup(struct console *co, char *options)
/* Allow pins to be muxed in and configured */
pinctrl_pm_select_default_state(uap->port.dev);
ret = clk_prepare(uap->clk);
ret = pl011_clk_setup(uap->clk);
if (ret)
return ret;
......@@ -2406,7 +2442,12 @@ static struct console amba_console = {
.device = uart_console_device,
.setup = pl011_console_setup,
.match = pl011_console_match,
#ifdef CONFIG_RAW_PRINTK
.write_raw = pl011_console_write_raw,
.flags = CON_PRINTBUFFER | CON_RAW | CON_ANYTIME,
#else
.flags = CON_PRINTBUFFER | CON_ANYTIME,
#endif
.index = -1,
.data = &amba_reg,
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment