From patchwork Mon Jul 6 20:26:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 6727701 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 4E0A0C05AC for ; Mon, 6 Jul 2015 20:29:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 648702053D for ; Mon, 6 Jul 2015 20:29:05 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 909522052F for ; Mon, 6 Jul 2015 20:29:04 +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 1ZCCzF-0005t3-ES; Mon, 06 Jul 2015 20:27:33 +0000 Received: from mail-wg0-x232.google.com ([2a00:1450:400c:c00::232]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZCCyr-0005WV-IB for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2015 20:27:10 +0000 Received: by wgjx7 with SMTP id x7so150019997wgj.2 for ; Mon, 06 Jul 2015 13:26:48 -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 :mime-version:content-type:content-transfer-encoding; bh=w0xxQQXiAad9vvuxt7g8Wk8Hw2IRcHZ2CuUGzrqMo1c=; b=wkFYRpOh6t2S3ObKTckbOPsaFGzkYWxEakTlDhUduXtWM+BD3kFRTz8vebbYKxokXL 6p/+bGgJg+nnIARa8hjN+P8ILu0q7JM8ws9RR98Jjv8+b2jZOmKT4xDxV/397dqqSwdz dMq8YX7zAS/JKR4kTvS9AwRmzZVeUbJXbpbMuSKbV64Fk47auREMN+dRnUdGjkQ5Kl4L 1Ja29GhMgjbcibyT8XeaEzhSzwSUVRbEB8euCOAGJVpWaz5wwPb7RjTVSDDQiD7ga+qv PylD0wg7/rytYdNG0fHVinuZw963EEWmpSOTxZLXgSfU5wpnnom3hmBwYTvoEyygTfUC F0pg== X-Received: by 10.180.98.134 with SMTP id ei6mr90342524wib.49.1436214407947; Mon, 06 Jul 2015 13:26:47 -0700 (PDT) Received: from Pali-Latitude.kolej.mff.cuni.cz (pali.kolej.mff.cuni.cz. [78.128.193.202]) by mx.google.com with ESMTPSA id ck18sm29869344wjb.47.2015.07.06.13.26.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Jul 2015 13:26:47 -0700 (PDT) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Russell King , Laura Abbott , Grant Likely , Rob Herring , Will Deacon , Ivaylo Dimitrov , Sebastian Reichel , Pavel Machek , Tony Lindgren , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [PATCH 4/5] arm: devtree: Read ATAGs structure from DT "/chosen/linux, atags" entry Date: Mon, 6 Jul 2015 22:26:12 +0200 Message-Id: <1436214373-12969-5-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1436214373-12969-1-git-send-email-pali.rohar@gmail.com> References: <1436214373-12969-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150706_132709_759608_4895B8AF X-CRM114-Status: GOOD ( 16.70 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 With this patch when linux kernel is compiled with ARM_ATAG_DTB_COMPAT it reads ATAGs structure from "/chosen/linux,atags" entry and store it into /proc/atags file. ATAGs structure is not parsed or evaluated, just kernel exports it to userspace via procfs. It is needed for legacy userspace application which expect some data from bootloader in /proc/atags file. This patch keeps them running also on DT kernel if DT "/chosen/linux,atags" entry exists. TODO: add documentation Signed-off-by: Pali Rohár --- arch/arm/kernel/devtree.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c index 7d82749..69ff048 100644 --- a/arch/arm/kernel/devtree.c +++ b/arch/arm/kernel/devtree.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -29,6 +30,7 @@ #include #include +#include "atags.h" #ifdef CONFIG_SMP extern struct of_cpu_method __cpu_method_of_table[]; @@ -208,6 +210,11 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) const struct machine_desc *mdesc, *mdesc_best = NULL; unsigned long dt_root; const u32 *rev; + void *dt_virt; +#ifdef CONFIG_ARM_ATAG_DTB_COMPAT + const void *atags; + unsigned long dt_chosen; +#endif #ifdef CONFIG_ARCH_MULTIPLATFORM DT_MACHINE_START(GENERIC_DT, "Generic DT based system") @@ -216,7 +223,12 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) mdesc_best = &__mach_desc_GENERIC_DT; #endif - if (!dt_phys || !early_init_dt_verify(phys_to_virt(dt_phys))) + if (!dt_phys) + return NULL; + + dt_virt = phys_to_virt(dt_phys); + + if (!early_init_dt_verify(dt_virt)) return NULL; dt_root = of_get_flat_dt_root(); @@ -254,5 +266,15 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) if (rev) system_rev = fdt32_to_cpu(*rev); +#ifdef CONFIG_ARM_ATAG_DTB_COMPAT + /* Store DT /chosen/linux,atags into /proc/atags */ + dt_chosen = fdt_path_offset(dt_virt, "/chosen"); + if (dt_chosen >= 0) { + atags = of_get_flat_dt_prop(dt_chosen, "linux,atags", NULL); + if (atags) + save_atags(atags); + } +#endif + return mdesc; }