Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755964AbbGFU1L (ORCPT ); Mon, 6 Jul 2015 16:27:11 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:37660 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755512AbbGFU0t (ORCPT ); Mon, 6 Jul 2015 16:26:49 -0400 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?= Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, =?UTF-8?q?Pali=20Roh=C3=A1r?= 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2631 Lines: 85 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; } -- 1.7.9.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/