From patchwork Thu May 8 22:23:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Herring X-Patchwork-Id: 4139111 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 06A69BFF02 for ; Thu, 8 May 2014 22:26:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3AA37202DD for ; Thu, 8 May 2014 22:26:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A1016202EB for ; Thu, 8 May 2014 22:26:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WiWjx-0004jn-Fl; Thu, 08 May 2014 22:24:33 +0000 Received: from mail-ob0-x22c.google.com ([2607:f8b0:4003:c01::22c]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WiWjn-0004ZL-Lr for linux-arm-kernel@lists.infradead.org; Thu, 08 May 2014 22:24:24 +0000 Received: by mail-ob0-f172.google.com with SMTP id wp18so3837388obc.17 for ; Thu, 08 May 2014 15:24:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kNaSwYQiKOx+NFjSBZcAQpe0J44zEDjF9a2uOJfqdVg=; b=0pA78ji6o7bUc35oPH18IgqdSQbcJV0/SSXxCwUFU/VrseuQMs2ZpWFWuYVmgyD1Ik QAcoXu7WyH96hqrQ3ygH3+TCXVBjj6MvtTKBTQmu3qMIRHQq/EhuWBrcnTYMVjX/r+88 CIvGpdhk9EjYdts5ri1nFu0dE22l/CcMNrRIqLHF1T/ik/lFOaNd74UVJ7l3/Z1+c3U6 VfgmqmCQkS0LLK/V5XtJvJxHL3EzyTQPSENQDz8l8M2SSctwczxvTLLGyxoUeAEBzH5z /KX6E7/yODGTTsSuOYjJqbQKpIPjrUWimcbbmnKnSgSMbxzjZ/bnYZ9KQ28hUIyWmd0V INUg== X-Received: by 10.60.83.232 with SMTP id t8mr8793341oey.16.1399587842562; Thu, 08 May 2014 15:24:02 -0700 (PDT) Received: from localhost.localdomain (72-48-77-163.dyn.grandenetworks.net. [72.48.77.163]) by mx.google.com with ESMTPSA id fj9sm9311932oeb.6.2014.05.08.15.24.01 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 May 2014 15:24:01 -0700 (PDT) From: Rob Herring To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 5/6] of/fdt: add FDT serial scanning for earlycon Date: Thu, 8 May 2014 17:23:42 -0500 Message-Id: <1399587823-17701-6-git-send-email-robherring2@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1399587823-17701-1-git-send-email-robherring2@gmail.com> References: <1399587823-17701-1-git-send-email-robherring2@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140508_152423_798665_C01C22A5 X-CRM114-Status: GOOD ( 14.50 ) X-Spam-Score: 0.1 (/) Cc: Grant Likely , benh@kernel.crashing.org, Rob Herring , Arnd Bergmann , Greg Kroah-Hartman X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Rob Herring 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 Cc: Grant Likely --- 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 #include #include +#include #include /* for COMMAND_LINE_SIZE */ #include @@ -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 */