aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Herring <robh@kernel.org>2014-03-27 09:06:16 -0400
committerRob Herring <robh@kernel.org>2014-05-20 16:19:25 -0400
commitb0b6abd34c1b508d4ac95dbc614f36c49d29e65a (patch)
tree153b298e55c0ba79dc0ff1ad7f3d308f8d9ed32f
parent54196ccbe0ba1f268a646059473313589db35b01 (diff)
serial: earlycon: add DT support
This adds the infrastructure to generic earlycon for earlycon setup using DT. The actual setup is not enabled until a following commit to add the FDT parsing. Signed-off-by: Rob Herring <robh@kernel.org> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Cc: Jiri Slaby <jslaby@suse.cz> Cc: Arnd Bergmann <arnd@arndb.de> Acked-by: Grant Likely <grant.likely@linaro.org>
-rw-r--r--drivers/tty/serial/earlycon.c28
-rw-r--r--include/asm-generic/vmlinux.lds.h4
-rw-r--r--include/linux/serial_core.h6
3 files changed, 37 insertions, 1 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}
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index b9404f6590f1..d647637cd699 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -155,6 +155,7 @@
155#define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk) 155#define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk)
156#define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem) 156#define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
157#define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method) 157#define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method)
158#define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon)
158 159
159#define KERNEL_DTB() \ 160#define KERNEL_DTB() \
160 STRUCT_ALIGN(); \ 161 STRUCT_ALIGN(); \
@@ -483,7 +484,8 @@
483 CLKSRC_OF_TABLES() \ 484 CLKSRC_OF_TABLES() \
484 CPU_METHOD_OF_TABLES() \ 485 CPU_METHOD_OF_TABLES() \
485 KERNEL_DTB() \ 486 KERNEL_DTB() \
486 IRQCHIP_OF_MATCH_TABLE() 487 IRQCHIP_OF_MATCH_TABLE() \
488 EARLYCON_OF_TABLES()
487 489
488#define INIT_TEXT \ 490#define INIT_TEXT \
489 *(.init.text) \ 491 *(.init.text) \
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 7a15b5b24c0b..5bbb809ee197 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -294,6 +294,9 @@ struct earlycon_device {
294int setup_earlycon(char *buf, const char *match, 294int setup_earlycon(char *buf, const char *match,
295 int (*setup)(struct earlycon_device *, const char *)); 295 int (*setup)(struct earlycon_device *, const char *));
296 296
297extern int of_setup_earlycon(unsigned long addr,
298 int (*setup)(struct earlycon_device *, const char *));
299
297#define EARLYCON_DECLARE(name, func) \ 300#define EARLYCON_DECLARE(name, func) \
298static int __init name ## _setup_earlycon(char *buf) \ 301static int __init name ## _setup_earlycon(char *buf) \
299{ \ 302{ \
@@ -301,6 +304,9 @@ static int __init name ## _setup_earlycon(char *buf) \
301} \ 304} \
302early_param("earlycon", name ## _setup_earlycon); 305early_param("earlycon", name ## _setup_earlycon);
303 306
307#define OF_EARLYCON_DECLARE(name, compat, fn) \
308 _OF_DECLARE(earlycon, name, compat, fn, void *)
309
304struct uart_port *uart_get_console(struct uart_port *ports, int nr, 310struct uart_port *uart_get_console(struct uart_port *ports, int nr,
305 struct console *c); 311 struct console *c);
306void uart_parse_options(char *options, int *baud, int *parity, int *bits, 312void uart_parse_options(char *options, int *baud, int *parity, int *bits,