From patchwork Tue Sep 9 22:49:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 4873201 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D4B7F9F50F for ; Tue, 9 Sep 2014 22:52:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E93562017E for ; Tue, 9 Sep 2014 22:52:39 +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 F2260201B4 for ; Tue, 9 Sep 2014 22:52:38 +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 1XRUEL-0004wZ-6C; Tue, 09 Sep 2014 22:49:45 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XRUDh-0004c2-SR; Tue, 09 Sep 2014 22:49:05 +0000 Received: from geoff by merlin.infradead.org with local (Exim 4.80.1 #2 (Red Hat Linux)) id 1XRUDg-0007Rc-LX; Tue, 09 Sep 2014 22:49:04 +0000 Message-Id: In-Reply-To: References: From: Geoff Levand Patch-Date: Tue, 9 Sep 2014 12:35:12 -0700 Subject: [PATCH 06/13] arm64: Add new routine read_cpu_properties To: Catalin Marinas , Will Deacon Date: Tue, 09 Sep 2014 22:49:04 +0000 Cc: marc.zyngier@arm.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, christoffer.dall@linaro.org 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: , MIME-Version: 1.0 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.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 The kexec re-boot support that will be added in a subsequent patch in this series will need to read the device tree CPU properties, and it is expected that a rework of the SMP spin table code to handle cpu_die will also need this functionality, so add two new common arm64 files cpu-properties.h and cpu-properties.c that define a new structure cpu_properties that hold the various CPU properties from a device tree, and the new routine read_cpu_properties() that fills the structure from a device tree CPU node. Signed-off-by: Geoff Levand --- arch/arm64/kernel/cpu-properties.c | 58 ++++++++++++++++++++++++++++++++++++++ arch/arm64/kernel/cpu-properties.h | 39 +++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 arch/arm64/kernel/cpu-properties.c create mode 100644 arch/arm64/kernel/cpu-properties.h diff --git a/arch/arm64/kernel/cpu-properties.c b/arch/arm64/kernel/cpu-properties.c new file mode 100644 index 0000000..e64b34b --- /dev/null +++ b/arch/arm64/kernel/cpu-properties.c @@ -0,0 +1,58 @@ +/* + * Copyright (C) Linaro. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include "cpu-properties.h" + +int read_cpu_properties(struct cpu_properties *p, const struct device_node *dn) +{ + const u32 *cell; + + memset(p, 0, sizeof(*p)); + p->hwid = INVALID_HWID; + p->cpu_release_addr = INVALID_ADDR; + + cell = of_get_property(dn, "reg", NULL); + + if (!cell) { + pr_err("%s: Error: %s: invalid reg property\n", + __func__, dn->full_name); + return -1; + } + + p->hwid = of_read_number(cell, + of_n_addr_cells((struct device_node *)dn)) & MPIDR_HWID_BITMASK; + + p->enable_method = of_get_property(dn, "enable-method", NULL); + + if (!p->enable_method) { + pr_err("%s: Error: %s: invalid enable-method\n", + __func__, dn->full_name); + return -1; + } + + if (!strcmp(p->enable_method, "psci")) { + p->type = cpu_enable_method_psci; + return 0; + } + + if (strcmp(p->enable_method, "spin-table")) { + p->type = cpu_enable_method_unknown; + return -1; + } + + p->type = cpu_enable_method_spin_table; + + if (of_property_read_u64(dn, "cpu-release-addr", + &p->cpu_release_addr)) { + pr_err("%s: Error: %s: invalid cpu-return-addr property\n", + __func__, dn->full_name); + return -1; + } + + return 0; +} diff --git a/arch/arm64/kernel/cpu-properties.h b/arch/arm64/kernel/cpu-properties.h new file mode 100644 index 0000000..b4218ef --- /dev/null +++ b/arch/arm64/kernel/cpu-properties.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) Linaro. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#if !defined(__ARM64_CPU_PROPERTIES_H) +#define __ARM64_CPU_PROPERTIES_H + +#include +#include + +#define INVALID_ADDR UL(~0) + +#if !defined(__ASSEMBLY__) + +#include +#include + +enum cpu_enable_method { + cpu_enable_method_unknown, + cpu_enable_method_psci, + cpu_enable_method_spin_table, +}; + +struct cpu_properties { + u64 hwid; + u64 cpu_release_addr; + const char *enable_method; + enum cpu_enable_method type; +}; + +int read_cpu_properties(struct cpu_properties *p, const struct device_node *dn); + +#endif /* !defined(__ASSEMBLY__) */ + +#endif