All of lore.kernel.org
 help / color / mirror / Atom feed
From: geoff@infradead.org (Geoff Levand)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 06/13] arm64: Add new routine read_cpu_properties
Date: Tue, 09 Sep 2014 22:49:04 +0000	[thread overview]
Message-ID: <b68073fb2e816f97311b9a3547e3656164ae85d0.1410302383.git.geoff@infradead.org> (raw)
In-Reply-To: <cover.1410302383.git.geoff@infradead.org>

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 <geoff@infradead.org>
---
 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 <asm/memory.h>
+#include <asm/cputype.h>
+
+#define INVALID_ADDR UL(~0)
+
+#if !defined(__ASSEMBLY__)
+
+#include <linux/kernel.h>
+#include <linux/of.h>
+
+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
-- 
1.9.1

WARNING: multiple messages have this Message-ID (diff)
From: Geoff Levand <geoff@infradead.org>
To: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>
Cc: marc.zyngier@arm.com, kexec@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	christoffer.dall@linaro.org
Subject: [PATCH 06/13] arm64: Add new routine read_cpu_properties
Date: Tue, 09 Sep 2014 22:49:04 +0000	[thread overview]
Message-ID: <b68073fb2e816f97311b9a3547e3656164ae85d0.1410302383.git.geoff@infradead.org> (raw)
In-Reply-To: <cover.1410302383.git.geoff@infradead.org>

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 <geoff@infradead.org>
---
 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 <asm/memory.h>
+#include <asm/cputype.h>
+
+#define INVALID_ADDR UL(~0)
+
+#if !defined(__ASSEMBLY__)
+
+#include <linux/kernel.h>
+#include <linux/of.h>
+
+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
-- 
1.9.1



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  parent reply	other threads:[~2014-09-09 22:49 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-09 22:51 [PATCH 00/13] arm64 kexec kernel patches V2 Geoff Levand
2014-09-09 22:51 ` Geoff Levand
2014-09-09 22:49 ` [PATCH 04/13] arm64: Add new hcall HVC_CALL_FUNC Geoff Levand
2014-09-09 22:49   ` Geoff Levand
2014-09-10 17:07   ` Will Deacon
2014-09-10 17:07     ` Will Deacon
2014-09-10 17:23     ` Geoff Levand
2014-09-10 17:23       ` Geoff Levand
2014-09-10 17:35       ` Will Deacon
2014-09-10 17:35         ` Will Deacon
2014-09-10 18:11   ` [PATCH V2 " Geoff Levand
2014-09-10 18:11     ` Geoff Levand
2014-09-15 18:11   ` [PATCH " Mark Rutland
2014-09-15 18:11     ` Mark Rutland
2014-09-25  0:24     ` Geoff Levand
2014-09-25  0:24       ` Geoff Levand
2014-09-09 22:49 ` [PATCH 02/13] arm64/kvm: Fix assembler compatibility of macros Geoff Levand
2014-09-09 22:49   ` Geoff Levand
2014-09-10  8:40   ` Ard Biesheuvel
2014-09-10  8:40     ` Ard Biesheuvel
2014-09-10 16:35     ` Geoff Levand
2014-09-10 16:35       ` Geoff Levand
2014-09-10 17:09       ` Ard Biesheuvel
2014-09-10 17:09         ` Ard Biesheuvel
2014-09-15 16:14         ` Mark Rutland
2014-09-15 16:14           ` Mark Rutland
2014-09-10 18:04   ` [PATCH V2 " Geoff Levand
2014-09-10 18:04     ` Geoff Levand
2014-09-09 22:49 ` [PATCH 03/13] arm64: Convert hcalls to use ISS field Geoff Levand
2014-09-09 22:49   ` Geoff Levand
2014-09-11 16:14   ` Arun Chandran
2014-09-11 16:14     ` Arun Chandran
2014-09-15 17:57   ` Mark Rutland
2014-09-15 17:57     ` Mark Rutland
2014-09-22 21:46     ` Geoff Levand
2014-09-22 21:46       ` Geoff Levand
2014-09-09 22:49 ` Geoff Levand [this message]
2014-09-09 22:49   ` [PATCH 06/13] arm64: Add new routine read_cpu_properties Geoff Levand
2014-09-15 18:42   ` Mark Rutland
2014-09-15 18:42     ` Mark Rutland
2014-09-25  0:23     ` Geoff Levand
2014-09-25  0:23       ` Geoff Levand
2014-09-09 22:49 ` [PATCH 05/13] arm64: Add EL2 switch to soft_restart Geoff Levand
2014-09-09 22:49   ` Geoff Levand
2014-09-09 22:49 ` [PATCH 01/13] arm64: Add ESR_EL2_EC macros to hyp-stub Geoff Levand
2014-09-09 22:49   ` Geoff Levand
2014-09-15 16:10   ` Mark Rutland
2014-09-15 16:10     ` Mark Rutland
2014-09-22 21:45     ` Geoff Levand
2014-09-22 21:45       ` Geoff Levand
2014-09-09 22:49 ` [PATCH 07/13] arm64: Add new routine local_disable Geoff Levand
2014-09-09 22:49   ` Geoff Levand
2014-09-15 18:56   ` Mark Rutland
2014-09-15 18:56     ` Mark Rutland
2014-09-25  0:24     ` Geoff Levand
2014-09-25  0:24       ` Geoff Levand
2014-09-09 22:49 ` [PATCH 10/13] arm64/kexec: Revert change to machine_shutdown() Geoff Levand
2014-09-09 22:49   ` Geoff Levand
2014-09-15 19:20   ` Mark Rutland
2014-09-15 19:20     ` Mark Rutland
2014-09-09 22:49 ` [PATCH 11/13] arm64/kexec: Add core kexec support Geoff Levand
2014-09-09 22:49   ` Geoff Levand
2014-09-18  1:13   ` Mark Rutland
2014-09-18  1:13     ` Mark Rutland
2014-09-25  0:25     ` Geoff Levand
2014-09-25  0:25       ` Geoff Levand
2014-09-09 22:49 ` [PATCH 13/13] arm64/kexec: Add kexec_ignore_compat_check param Geoff Levand
2014-09-09 22:49   ` Geoff Levand
2014-09-09 22:49 ` [PATCH 12/13] arm64/kexec: Enable kexec in the arm64 defconfig Geoff Levand
2014-09-09 22:49   ` Geoff Levand
2014-09-09 22:49 ` [PATCH 09/13] arm64/kexec: Kexec expects cpu_die Geoff Levand
2014-09-09 22:49   ` Geoff Levand
2014-09-15 19:10   ` Mark Rutland
2014-09-15 19:10     ` Mark Rutland
2014-09-09 22:49 ` [PATCH 08/13] arm64: Use cpu_ops for smp_stop Geoff Levand
2014-09-09 22:49   ` Geoff Levand
2014-09-15 19:06   ` Mark Rutland
2014-09-15 19:06     ` Mark Rutland
2014-09-25  0:24     ` Geoff Levand
2014-09-25  0:24       ` Geoff Levand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b68073fb2e816f97311b9a3547e3656164ae85d0.1410302383.git.geoff@infradead.org \
    --to=geoff@infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.