aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r--drivers/tty/serial/earlycon.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index c92e83088adb..5131b5ee6164 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -15,6 +15,8 @@
15#include <linux/init.h> 15#include <linux/init.h>
16#include <linux/io.h> 16#include <linux/io.h>
17#include <linux/serial_core.h> 17#include <linux/serial_core.h>
18#include <linux/sizes.h>
19#include <linux/mod_devicetable.h>
18 20
19#ifdef CONFIG_FIX_EARLYCON_MEM 21#ifdef CONFIG_FIX_EARLYCON_MEM
20#include <asm/fixmap.h> 22#include <asm/fixmap.h>
@@ -32,6 +34,9 @@ static struct earlycon_device early_console_dev = {
32 .con = &early_con, 34 .con = &early_con,
33}; 35};
34 36
37static const struct of_device_id __earlycon_of_table_sentinel
38 __used __section(__earlycon_of_table_end);
39
35static void __iomem * __init earlycon_map(unsigned long paddr, size_t size) 40static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
36{ 41{
37 void __iomem *base; 42 void __iomem *base;
@@ -142,3 +147,26 @@ int __init setup_earlycon(char *buf, const char *match,
142 register_console(early_console_dev.con); 147 register_console(early_console_dev.con);
143 return 0; 148 return 0;
144} 149}
150
151int __init of_setup_earlycon(unsigned long addr,
152 int (*setup)(struct earlycon_device *, const char *))
153{
154 int err;
155 struct uart_port *port = &early_console_dev.port;
156
157 port->iotype = UPIO_MEM;
158 port->mapbase = addr;
159 port->uartclk = BASE_BAUD * 16;
160 port->membase = earlycon_map(addr, SZ_4K);
161
162 early_console_dev.con->data = &early_console_dev;
163 err = setup(&early_console_dev, NULL);
164 if (err < 0)
165 return err;
166 if (!early_console_dev.con->write)
167 return -ENODEV;
168
169
170 register_console(early_console_dev.con);
171 return 0;
172}