Commit e53f2f4b authored by Anup Patel's avatar Anup Patel Committed by Catalin Marinas

arm64: add support for 8250/16550 earlyprintk

This patch adds support for using earlyprintk with 8250/16550 UART
ports. The 8250/16550 UART can either have 8-bit or 32-bit aligned
registers which is HW vendor dependent.

Kernel args for 8-bit aligned regs: earlyprintk=uart8250-8bit,<phys_address>

Kernel args for 32-bit aligned regs: earlyprintk=uart8250-32bit,<phys_address>
Signed-off-by: default avatarAnup Patel <anup.patel@linaro.org>
Reviewed-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 0492f725
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/io.h> #include <linux/io.h>
#include <linux/amba/serial.h> #include <linux/amba/serial.h>
#include <linux/serial_reg.h>
static void __iomem *early_base; static void __iomem *early_base;
static void (*printch)(char ch); static void (*printch)(char ch);
...@@ -51,6 +52,26 @@ static void smh_printch(char ch) ...@@ -51,6 +52,26 @@ static void smh_printch(char ch)
: : "r" (&ch) : "x0", "x1", "memory"); : : "r" (&ch) : "x0", "x1", "memory");
} }
/*
* 8250/16550 (8-bit aligned registers) single character TX.
*/
static void uart8250_8bit_printch(char ch)
{
while (!(readb_relaxed(early_base + UART_LSR) & UART_LSR_THRE))
;
writeb_relaxed(ch, early_base + UART_TX);
}
/*
* 8250/16550 (32-bit aligned registers) single character TX.
*/
static void uart8250_32bit_printch(char ch)
{
while (!(readl_relaxed(early_base + (UART_LSR << 2)) & UART_LSR_THRE))
;
writel_relaxed(ch, early_base + (UART_TX << 2));
}
struct earlycon_match { struct earlycon_match {
const char *name; const char *name;
void (*printch)(char ch); void (*printch)(char ch);
...@@ -59,6 +80,8 @@ struct earlycon_match { ...@@ -59,6 +80,8 @@ struct earlycon_match {
static const struct earlycon_match earlycon_match[] __initconst = { static const struct earlycon_match earlycon_match[] __initconst = {
{ .name = "pl011", .printch = pl011_printch, }, { .name = "pl011", .printch = pl011_printch, },
{ .name = "smh", .printch = smh_printch, }, { .name = "smh", .printch = smh_printch, },
{ .name = "uart8250-8bit", .printch = uart8250_8bit_printch, },
{ .name = "uart8250-32bit", .printch = uart8250_32bit_printch, },
{} {}
}; };
......
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