From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754930AbbB0Pzs (ORCPT ); Fri, 27 Feb 2015 10:55:48 -0500 Received: from mail-wi0-f173.google.com ([209.85.212.173]:43273 "EHLO mail-wi0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932220AbbB0Pzq (ORCPT ); Fri, 27 Feb 2015 10:55:46 -0500 From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Rob Herring , Russell King , Will Deacon , Ivaylo Dimitrov , Sebastian Reichel , Pavel Machek , Tony Lindgren , =?UTF-8?q?Andreas=20F=C3=A4rber?= Cc: "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [PATCH v2 1/2] arm: devtree: Set system_rev from DT revision Date: Fri, 27 Feb 2015 16:55:27 +0100 Message-Id: <1425052528-18995-2-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1425052528-18995-1-git-send-email-pali.rohar@gmail.com> References: <201502271645.58765@pali> <1425052528-18995-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 With this patch "revision" DT string entry is used to set global system_rev variable. DT "revision" is expected to be string with one hexadecimal number. So "Revision" line in /proc/cpuinfo will be same as "revision" DT value. Signed-off-by: Pali Rohár --- arch/arm/kernel/devtree.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c index 11c54de..7e13e27 100644 --- a/arch/arm/kernel/devtree.c +++ b/arch/arm/kernel/devtree.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -26,6 +27,7 @@ #include #include #include +#include #ifdef CONFIG_SMP @@ -204,6 +206,9 @@ static const void * __init arch_get_next_mach(const char *const **match) 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 char *prop; + int size; #ifdef CONFIG_ARCH_MULTIPLATFORM DT_MACHINE_START(GENERIC_DT, "Generic DT based system") @@ -215,17 +220,13 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) if (!dt_phys || !early_init_dt_verify(phys_to_virt(dt_phys))) return NULL; + dt_root = of_get_flat_dt_root(); mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach); if (!mdesc) { - const char *prop; - int size; - unsigned long dt_root; - early_print("\nError: unrecognized/unsupported " "device tree compatible list:\n[ "); - dt_root = of_get_flat_dt_root(); prop = of_get_flat_dt_prop(dt_root, "compatible", &size); while (size > 0) { early_print("'%s' ", prop); @@ -246,5 +247,14 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) /* Change machine number to match the mdesc we're using */ __machine_arch_type = mdesc->nr; + /* Set system revision from DT */ + prop = of_get_flat_dt_prop(dt_root, "revision", &size); + if (prop && size > 0) { + char revision[11]; + strlcpy(revision, prop, min(size, (int)sizeof(revision))); + if (kstrtouint(revision, 16, &system_rev) != 0) + system_rev = 0; + } + return mdesc; } -- 1.7.9.5 From mboxrd@z Thu Jan 1 00:00:00 1970 From: pali.rohar@gmail.com (=?UTF-8?q?Pali=20Roh=C3=A1r?=) Date: Fri, 27 Feb 2015 16:55:27 +0100 Subject: [PATCH v2 1/2] arm: devtree: Set system_rev from DT revision In-Reply-To: <1425052528-18995-1-git-send-email-pali.rohar@gmail.com> References: <201502271645.58765@pali> <1425052528-18995-1-git-send-email-pali.rohar@gmail.com> Message-ID: <1425052528-18995-2-git-send-email-pali.rohar@gmail.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org With this patch "revision" DT string entry is used to set global system_rev variable. DT "revision" is expected to be string with one hexadecimal number. So "Revision" line in /proc/cpuinfo will be same as "revision" DT value. Signed-off-by: Pali Roh?r --- arch/arm/kernel/devtree.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c index 11c54de..7e13e27 100644 --- a/arch/arm/kernel/devtree.c +++ b/arch/arm/kernel/devtree.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -26,6 +27,7 @@ #include #include #include +#include #ifdef CONFIG_SMP @@ -204,6 +206,9 @@ static const void * __init arch_get_next_mach(const char *const **match) 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 char *prop; + int size; #ifdef CONFIG_ARCH_MULTIPLATFORM DT_MACHINE_START(GENERIC_DT, "Generic DT based system") @@ -215,17 +220,13 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) if (!dt_phys || !early_init_dt_verify(phys_to_virt(dt_phys))) return NULL; + dt_root = of_get_flat_dt_root(); mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach); if (!mdesc) { - const char *prop; - int size; - unsigned long dt_root; - early_print("\nError: unrecognized/unsupported " "device tree compatible list:\n[ "); - dt_root = of_get_flat_dt_root(); prop = of_get_flat_dt_prop(dt_root, "compatible", &size); while (size > 0) { early_print("'%s' ", prop); @@ -246,5 +247,14 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) /* Change machine number to match the mdesc we're using */ __machine_arch_type = mdesc->nr; + /* Set system revision from DT */ + prop = of_get_flat_dt_prop(dt_root, "revision", &size); + if (prop && size > 0) { + char revision[11]; + strlcpy(revision, prop, min(size, (int)sizeof(revision))); + if (kstrtouint(revision, 16, &system_rev) != 0) + system_rev = 0; + } + return mdesc; } -- 1.7.9.5