From: Rob Herring <robherring2@gmail.com>
To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Cc: Grant Likely <grant.likely@linaro.org>,
benh@kernel.crashing.org, Arnd Bergmann <arnd@arndb.de>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rob Herring <robh@kernel.org>, Jiri Slaby <jslaby@suse.cz>
Subject: [PATCH 3/6] serial: earlycon: add DT support
Date: Thu, 8 May 2014 17:23:40 -0500 [thread overview]
Message-ID: <1399587823-17701-4-git-send-email-robherring2@gmail.com> (raw)
In-Reply-To: <1399587823-17701-1-git-send-email-robherring2@gmail.com>
From: Rob Herring <robh@kernel.org>
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>
---
drivers/tty/serial/earlycon.c | 27 +++++++++++++++++++++++++++
include/asm-generic/vmlinux.lds.h | 4 +++-
include/linux/serial_core.h | 6 ++++++
3 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/earlycon.c b/drivers/tty/serial/earlycon.c
index c92e830..021fe5f 100644
--- a/drivers/tty/serial/earlycon.c
+++ b/drivers/tty/serial/earlycon.c
@@ -15,6 +15,7 @@
#include <linux/init.h>
#include <linux/io.h>
#include <linux/serial_core.h>
+#include <linux/mod_devicetable.h>
#ifdef CONFIG_FIX_EARLYCON_MEM
#include <asm/fixmap.h>
@@ -32,6 +33,9 @@ static struct earlycon_device early_console_dev = {
.con = &early_con,
};
+static const struct of_device_id __earlycon_of_table_sentinel
+ __used __section(__earlycon_of_table_end);
+
static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
{
void __iomem *base;
@@ -142,3 +146,26 @@ int __init setup_earlycon(char *buf, const char *match,
register_console(early_console_dev.con);
return 0;
}
+
+int __init of_setup_earlycon(unsigned long addr,
+ int (*setup)(struct earlycon_device *, const char *))
+{
+ int err;
+ struct uart_port *port = &early_console_dev.port;
+
+ port->iotype = UPIO_MEM;
+ port->mapbase = addr;
+ port->uartclk = BASE_BAUD * 16;
+ port->membase = earlycon_map(addr, SZ_4K);
+
+ early_console_dev.con->data = &early_console_dev;
+ err = setup(&early_console_dev, NULL);
+ if (err < 0)
+ return err;
+ if (!early_console_dev.con->write)
+ return -ENODEV;
+
+
+ register_console(early_console_dev.con);
+ return 0;
+}
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index 120ccb9..f5249c4 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -129,6 +129,7 @@
#define CLK_OF_TABLES() OF_TABLE(CONFIG_COMMON_CLK, clk)
#define RESERVEDMEM_OF_TABLES() OF_TABLE(CONFIG_OF_RESERVED_MEM, reservedmem)
#define CPU_METHOD_OF_TABLES() OF_TABLE(CONFIG_SMP, cpu_method)
+#define EARLYCON_OF_TABLES() OF_TABLE(CONFIG_SERIAL_EARLYCON, earlycon)
#define KERNEL_DTB() \
STRUCT_ALIGN(); \
@@ -458,7 +459,8 @@
CLKSRC_OF_TABLES() \
CPU_METHOD_OF_TABLES() \
KERNEL_DTB() \
- IRQCHIP_OF_MATCH_TABLE()
+ IRQCHIP_OF_MATCH_TABLE() \
+ EARLYCON_OF_TABLES()
#define INIT_TEXT \
*(.init.text) \
diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 7a15b5b..5bbb809 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -294,6 +294,9 @@ struct earlycon_device {
int setup_earlycon(char *buf, const char *match,
int (*setup)(struct earlycon_device *, const char *));
+extern int of_setup_earlycon(unsigned long addr,
+ int (*setup)(struct earlycon_device *, const char *));
+
#define EARLYCON_DECLARE(name, func) \
static int __init name ## _setup_earlycon(char *buf) \
{ \
@@ -301,6 +304,9 @@ static int __init name ## _setup_earlycon(char *buf) \
} \
early_param("earlycon", name ## _setup_earlycon);
+#define OF_EARLYCON_DECLARE(name, compat, fn) \
+ _OF_DECLARE(earlycon, name, compat, fn, void *)
+
struct uart_port *uart_get_console(struct uart_port *ports, int nr,
struct console *c);
void uart_parse_options(char *options, int *baud, int *parity, int *bits,
--
1.9.1
next prev parent reply other threads:[~2014-05-08 22:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-08 22:23 [PATCH 0/6] DT early console initialization Rob Herring
2014-05-08 22:23 ` [PATCH 1/6] of: align RESERVEDMEM_OF_DECLARE function callbacks to other callbacks Rob Herring
[not found] ` <1399587823-17701-2-git-send-email-robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-09 10:46 ` Marek Szyprowski
2014-05-08 22:23 ` [PATCH 2/6] of: consolidate linker section OF match table declarations Rob Herring
2014-05-14 14:24 ` Grant Likely
2014-05-08 22:23 ` Rob Herring [this message]
2014-05-08 22:23 ` [PATCH 4/6] of/fdt: add FDT address translation support Rob Herring
2014-05-08 22:23 ` [PATCH 5/6] of/fdt: add FDT serial scanning for earlycon Rob Herring
2014-05-08 22:23 ` [PATCH 6/6] tty/serial: pl011: add DT based earlycon support Rob Herring
[not found] ` <1399587823-17701-1-git-send-email-robherring2-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-05-14 14:26 ` [PATCH 0/6] DT early console initialization Grant Likely
[not found] ` <20140514142644.1C922C4153D-WNowdnHR2B42iJbIjFUEsiwD8/FfD2ys@public.gmane.org>
2014-05-28 16:30 ` Rob Herring
[not found] ` <CAL_JsqK9nifPWW5jnzYifsMuvRjhD9wTT+YbE0sPM6N4xaj1yA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-05-28 20:30 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1399587823-17701-4-git-send-email-robherring2@gmail.com \
--to=robherring2@gmail.com \
--cc=arnd@arndb.de \
--cc=benh@kernel.crashing.org \
--cc=devicetree@vger.kernel.org \
--cc=grant.likely@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.cz \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).