From patchwork Fri Feb 27 15:55:27 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: 5901691 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D667E9F36A for ; Fri, 27 Feb 2015 15:58:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EF7C320260 for ; Fri, 27 Feb 2015 15:58:35 +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 320A520219 for ; Fri, 27 Feb 2015 15:58:35 +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 1YRNGv-000574-G5; Fri, 27 Feb 2015 15:56:13 +0000 Received: from mail-wg0-x236.google.com ([2a00:1450:400c:c00::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YRNGr-0004pe-OT for linux-arm-kernel@lists.infradead.org; Fri, 27 Feb 2015 15:56:10 +0000 Received: by wghl18 with SMTP id l18so21238550wgh.7 for ; Fri, 27 Feb 2015 07:55:47 -0800 (PST) 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=40Ds7QWWcBs2z/j/Ii4DmAtWxC7t+3suIl5SSYpUAsY=; b=Qhq11y6/qWIzPbRqb/+LDPP0qAELpUmlifxIsrboHss8qB1Q8dfktjSGBUr5DG6foA wTCHp0GzGsnBDtqeuoPPx6BQ91HsS3ehQ4RzaouVAlyDwmGC830f8EEZXZWG5ea3455b 9IkeDHx+MKGPrZLo3oia6HYB1UBoMQ9K0Vq7eRPxaJmLTRNqYy147uL40LY4cMqtfWwX tLb0rJRWK8sn5guxgkCNyT2hRfAUWmPeXOXsLeKZYBxDxiedox5X7V9qAoutbFhLCRs+ jGm+82Q0ELXBQrwFFD9z8XeQRkpuI7ul/AX69yDhctzmlO/lfN4woEnIgf7dC1bNPaot Br0Q== X-Received: by 10.180.72.98 with SMTP id c2mr7713617wiv.87.1425052545905; Fri, 27 Feb 2015 07:55:45 -0800 (PST) Received: from Pali-Latitude.kolej.mff.cuni.cz (pali.kolej.mff.cuni.cz. [78.128.193.202]) by mx.google.com with ESMTPSA id fs8sm3369310wib.8.2015.02.27.07.55.44 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 27 Feb 2015 07:55:44 -0800 (PST) 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?= 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150227_075609_958074_C7F9C850 X-CRM114-Status: GOOD ( 15.80 ) X-Spam-Score: -0.8 (/) Cc: "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , =?UTF-8?q?Pali=20Roh=C3=A1r?= X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 "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; }