linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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>
Subject: [PATCH 5/6] of/fdt: add FDT serial scanning for earlycon
Date: Thu,  8 May 2014 17:23:42 -0500	[thread overview]
Message-ID: <1399587823-17701-6-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 FDT parsing of {linux,}stdout-path to setup an early serial
console. Enabling of the early console is triggered with "earlycon"
(with no options) on the kernel command line.

Platforms must either have fixmap permanent mapping support,
have a functioning ioremap when early params are parsed, or explicitly
call early_init_dt_scan_chosen_serial from architecture code.

Signed-off-by: Rob Herring <robh@kernel.org>
Cc: Grant Likely <grant.likely@linaro.org>
---
 drivers/of/fdt.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c
index a6f83ea..1fbeab2 100644
--- a/drivers/of/fdt.c
+++ b/drivers/of/fdt.c
@@ -21,6 +21,7 @@
 #include <linux/slab.h>
 #include <linux/libfdt.h>
 #include <linux/debugfs.h>
+#include <linux/serial_core.h>
 
 #include <asm/setup.h>  /* for COMMAND_LINE_SIZE */
 #include <asm/page.h>
@@ -696,6 +697,61 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
 }
 #endif /* CONFIG_BLK_DEV_INITRD */
 
+#ifdef CONFIG_SERIAL_EARLYCON
+extern struct of_device_id __earlycon_of_table[];
+
+int __init early_init_dt_scan_chosen_serial(void)
+{
+	int offset;
+	const char *p;
+	int l;
+	const struct of_device_id *match = __earlycon_of_table;
+	const void *fdt = initial_boot_params;
+
+	offset = fdt_path_offset(fdt, "/chosen");
+	if (offset < 0)
+		offset = fdt_path_offset(fdt, "/chosen@0");
+	if (offset < 0)
+		return -ENOENT;
+
+	p = fdt_getprop(fdt, offset, "stdout-path", &l);
+	if (!p)
+		p = fdt_getprop(fdt, offset, "linux,stdout-path", &l);
+	if (!p || !l)
+		return -ENOENT;
+
+	/* Get the node specified by stdout-path */
+	offset = fdt_path_offset(fdt, p);
+	if (offset < 0)
+		return -ENODEV;
+
+	while (match->compatible) {
+		unsigned long addr;
+		if (fdt_node_check_compatible(fdt, offset, match->compatible)) {
+			match++;
+			continue;
+		}
+
+		addr = fdt_translate_address(fdt, offset);
+		if (!addr)
+			return -ENXIO;
+
+		of_setup_earlycon(addr, match->data);
+		return 0;
+	}
+	return -ENODEV;
+}
+
+static int __init setup_of_earlycon(char *buf)
+{
+	if (buf)
+		return 0;
+
+	return early_init_dt_scan_chosen_serial();
+}
+early_param("earlycon", setup_of_earlycon);
+#endif
+
 /**
  * early_init_dt_scan_root - fetch the top level address and size cells
  */
-- 
1.9.1


  parent reply	other threads:[~2014-05-08 22:24 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
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 ` [PATCH 3/6] serial: earlycon: add DT support Rob Herring
2014-05-08 22:23 ` [PATCH 4/6] of/fdt: add FDT address translation support Rob Herring
2014-05-08 22:23 ` Rob Herring [this message]
2014-05-08 22:23 ` [PATCH 6/6] tty/serial: pl011: add DT based earlycon support Rob Herring
2014-05-14 14:26 ` [PATCH 0/6] DT early console initialization Grant Likely
2014-05-28 16:30   ` Rob Herring
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-6-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=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).