From patchwork Mon Jun 3 15:51:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: PranavkumarSawargaonkar X-Patchwork-Id: 2653571 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id E0692DF24C for ; Mon, 3 Jun 2013 15:52:23 +0000 (UTC) Received: from merlin.infradead.org ([205.233.59.134]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjX3L-00019y-JC; Mon, 03 Jun 2013 15:52:12 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjX39-00040c-Ju; Mon, 03 Jun 2013 15:51:59 +0000 Received: from mail-pb0-f48.google.com ([209.85.160.48]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjX36-0003zq-LG for linux-arm-kernel@lists.infradead.org; Mon, 03 Jun 2013 15:51:57 +0000 Received: by mail-pb0-f48.google.com with SMTP id md4so5884283pbc.35 for ; Mon, 03 Jun 2013 08:51:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=SMuWBhMudZB5r4BQqa5V1Q+AJiFIu2EfBhbQco56/r4=; b=UQNZWU2ge3P0fF3d29ytJpIQ0aMlJoj+jWAPgXj2cB8BMSk6oOrsfG7VEMsicAxJlW 9if3sJNrwGX0HRMM/Pz0mSXJZ9D3RBQUQgb3Jwuc9WgcG7jQboC/X9fTz86lGiRJFqnj sOh4Zoo80xGCuSBAwKyFqy8nAqyc2rWwXl3PlhcDhWDhGbcAdIUtzP+r2pkt/aPPzg+/ KnLjRmOeziY59h++v8BlMky8n9KJPCiIPFR/AVEU74wRjU5k6qmGDGOcOlIJKkVqamRm xZhzmRZhExr7el3TzmhrS5vy+/eVBWuMqKjqlGkoUcyZc21f37T0xtXip4mlQyC/eiI3 05SQ== X-Received: by 10.68.0.66 with SMTP id 2mr24672517pbc.15.1370274690692; Mon, 03 Jun 2013 08:51:30 -0700 (PDT) Received: from pnqlab006.amcc.com ([182.73.239.130]) by mx.google.com with ESMTPSA id de14sm12030481pac.10.2013.06.03.08.51.27 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Jun 2013 08:51:30 -0700 (PDT) From: Pranavkumar Sawargaonkar To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm64: Add support to pass earlyprintk argument via device tree Date: Mon, 3 Jun 2013 21:21:11 +0530 Message-Id: <1370274671-23812-1-git-send-email-pranavkumar@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQny4USFnGo9KBiC3eAcWeFQgfyLYDbmXgCgNIhOp7gDcVL988BSP3e8Kpi8JQOU7o7XHgVG X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130603_115156_769763_BF36B3CF X-CRM114-Status: GOOD ( 15.42 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.48 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: linaro-kernel@lists.linaro.org, Anup Patel , patches@linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, Pranavkumar Sawargaonkar 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 This patch adds support for defining and passing earlyprintk related information i.e. device and address information via device tree by adding it inside "chosen" node. This will help user to just specify "earlyprintk" from bootargs without actually knowing the address and device to enable earlyprintk. Mechanism: One can just append earlyprintk=device-type,address (same as we pass through command line) in "/chosen" node to notify kernel which is the earlyprintk device and what is its address. Backward Compatibility: This patch also allows existing method of specifying earlyprintk parameter via bootargs. Existing method i.e. passing via bootargs will still have precedence over device tree i.e. if one specifies earlyprintk=device-type,address in bootargs then kernel will use information from bootargs instead of device tree. If user just specifies earlyprintk (without =...) then kernel will look for device tree earlyprintk parameter. Signed-off-by: Pranavkumar Sawargaonkar Signed-off-by: Anup Patel --- arch/arm64/kernel/early_printk.c | 7 +++++++ arch/arm64/kernel/setup.c | 21 ++++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/arch/arm64/kernel/early_printk.c b/arch/arm64/kernel/early_printk.c index fbb6e18..4e6f845 100644 --- a/arch/arm64/kernel/early_printk.c +++ b/arch/arm64/kernel/early_printk.c @@ -29,6 +29,8 @@ static void __iomem *early_base; static void (*printch)(char ch); +extern char *earlyprintk_dt_args; + /* * PL011 single character TX. */ @@ -116,6 +118,11 @@ static int __init setup_early_printk(char *buf) phys_addr_t paddr = 0; if (!buf) { + /* Try to check if Device Tree has this argument or not ? */ + buf = earlyprintk_dt_args; + } + + if (!buf) { pr_warning("No earlyprintk arguments passed.\n"); return 0; } diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 6a9a532..fb2d56f 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -60,6 +60,8 @@ EXPORT_SYMBOL(processor_id); unsigned int elf_hwcap __read_mostly; EXPORT_SYMBOL_GPL(elf_hwcap); +char *earlyprintk_dt_args; + static const char *cpu_name; static const char *machine_name; phys_addr_t __fdt_pointer __initdata; @@ -122,6 +124,23 @@ static void __init setup_processor(void) elf_hwcap = 0; } +int __init early_init_dt_scan_chosen_arm64(unsigned long node, + const char *uname, + int depth, void *data) +{ + char *prop; + + /* Check if this is chosen node */ + if (early_init_dt_scan_chosen(node, uname, depth, data) == 0) + return 0; + + prop = of_get_flat_dt_prop(node, "earlyprintk", NULL); + if (prop) + earlyprintk_dt_args = prop; + + return 1; +} + static void __init setup_machine_fdt(phys_addr_t dt_phys) { struct boot_param_header *devtree; @@ -165,7 +184,7 @@ static void __init setup_machine_fdt(phys_addr_t dt_phys) pr_info("Machine: %s\n", machine_name); /* Retrieve various information from the /chosen node */ - of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); + of_scan_flat_dt(early_init_dt_scan_chosen_arm64, boot_command_line); /* Initialize {size,address}-cells info */ of_scan_flat_dt(early_init_dt_scan_root, NULL); /* Setup memory, calling early_init_dt_add_memory_arch */