From: robherring2@gmail.com (Rob Herring)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/7] ARM: PSCI: add ops for system restart and power off
Date: Sun, 28 Jul 2013 16:56:34 -0500 [thread overview]
Message-ID: <1375048598-15637-4-git-send-email-robherring2@gmail.com> (raw)
In-Reply-To: <1375048598-15637-1-git-send-email-robherring2@gmail.com>
From: Rob Herring <rob.herring@calxeda.com>
In PSCI v0.2 spec, operations for system level restart and power off are
added. This adds kernel support for those operations. The behavior for
picking restart function matches the psci_smp_ops such that the PSCI
restart function will be used when present even if a platform defines
a mdesc->restart entry. As pm_power_off depends on platform init code to
setup, using the PSCI version relies on the platform code to not override
it.
Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Cc: Russell King <linux@arm.linux.org.uk>
---
arch/arm/include/asm/psci.h | 2 ++
arch/arm/kernel/psci.c | 40 ++++++++++++++++++++++++++++++++++++++++
2 files changed, 42 insertions(+)
diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
index c4ae171..04ee1b2 100644
--- a/arch/arm/include/asm/psci.h
+++ b/arch/arm/include/asm/psci.h
@@ -29,6 +29,8 @@ struct psci_operations {
int (*cpu_off)(struct psci_power_state state);
int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
int (*migrate)(unsigned long cpuid);
+ void (*system_off)(void);
+ void (*system_reset)(void);
};
extern struct psci_operations psci_ops;
diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
index 4693188..ffc4a7c 100644
--- a/arch/arm/kernel/psci.c
+++ b/arch/arm/kernel/psci.c
@@ -17,12 +17,14 @@
#include <linux/init.h>
#include <linux/of.h>
+#include <linux/pm.h>
#include <asm/compiler.h>
#include <asm/errno.h>
#include <asm/opcodes-sec.h>
#include <asm/opcodes-virt.h>
#include <asm/psci.h>
+#include <asm/system_misc.h>
struct psci_operations psci_ops;
@@ -33,6 +35,8 @@ enum psci_function {
PSCI_FN_CPU_ON,
PSCI_FN_CPU_OFF,
PSCI_FN_MIGRATE,
+ PSCI_FN_SYS_OFF,
+ PSCI_FN_SYS_RESET,
PSCI_FN_MAX,
};
@@ -153,6 +157,30 @@ static int psci_migrate(unsigned long cpuid)
return psci_to_linux_errno(err);
}
+static void psci_system_off(void)
+{
+ u32 fn = psci_function_id[PSCI_FN_SYS_OFF];
+ invoke_psci_fn(fn, 0, 0, 0);
+}
+
+static void psci_system_reset(void)
+{
+ u32 fn = psci_function_id[PSCI_FN_SYS_RESET];
+ invoke_psci_fn(fn, 0, 0, 0);
+}
+
+void psci_pm_power_off(void)
+{
+ if (psci_ops.system_off)
+ psci_ops.system_off();
+}
+
+void psci_restart(enum reboot_mode reboot_mode, const char *cmd)
+{
+ if (psci_ops.system_off)
+ psci_ops.system_reset();
+}
+
static const struct of_device_id psci_of_match[] __initconst = {
{ .compatible = "arm,psci", },
{},
@@ -204,6 +232,18 @@ void __init psci_init(void)
psci_ops.migrate = psci_migrate;
}
+ if (!of_property_read_u32(np, "system_off", &id)) {
+ psci_function_id[PSCI_FN_SYS_OFF] = id;
+ psci_ops.system_off = psci_system_off;
+ pm_power_off = psci_pm_power_off;
+ }
+
+ if (!of_property_read_u32(np, "system_reset", &id)) {
+ psci_function_id[PSCI_FN_SYS_RESET] = id;
+ psci_ops.system_reset = psci_system_reset;
+ arm_pm_restart = psci_restart;
+ }
+
out_put_node:
of_node_put(np);
return;
--
1.8.1.2
next prev parent reply other threads:[~2013-07-28 21:56 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-28 21:56 [PATCH v3 0/7] PSCI support for highbank Rob Herring
2013-07-28 21:56 ` [PATCH 1/7] dt: update PSCI binding documentation for v0.2 Rob Herring
2013-07-29 10:13 ` Mark Rutland
2013-07-29 20:18 ` Rob Herring
2013-07-30 9:49 ` Mark Rutland
2013-07-30 12:42 ` Rob Herring
2013-07-30 12:56 ` Mark Rutland
2013-07-30 13:44 ` Mark Rutland
2013-07-30 14:33 ` Stefano Stabellini
2013-07-30 14:42 ` Ian Campbell
2013-07-30 17:48 ` Matt Sealey
2013-07-31 8:55 ` Ian Campbell
2013-07-31 13:49 ` Mark Rutland
2013-07-31 17:24 ` Matt Sealey
2013-07-31 17:49 ` Rob Herring
2013-08-01 17:51 ` Dave Martin
2013-08-01 19:02 ` Rob Herring
2013-08-01 21:04 ` Matt Sealey
2013-07-31 13:07 ` Mark Rutland
2013-07-30 19:34 ` Rob Herring
2013-07-31 8:57 ` Ian Campbell
2013-07-31 13:05 ` Mark Rutland
2013-07-30 10:01 ` Dave Martin
2013-07-28 21:56 ` [PATCH 2/7] ARM: PSCI: remove unnecessary include of arm-gic.h Rob Herring
2013-07-28 21:56 ` Rob Herring [this message]
2013-07-28 21:56 ` [PATCH 4/7] cpuidle: calxeda: add support to use PSCI calls Rob Herring
2013-07-29 14:14 ` Daniel Lezcano
2013-07-29 14:39 ` Rob Herring
2013-07-29 14:46 ` Daniel Lezcano
2013-07-28 21:56 ` [PATCH 5/7] ARM: highbank: clean-up some unused includes Rob Herring
2013-07-28 21:56 ` [PATCH 6/7] ARM: highbank: adapt to use ARM PSCI calls Rob Herring
2013-07-28 21:56 ` [PATCH 7/7] dts: calxeda: add ARM PSCI binding Rob Herring
2013-07-29 10:24 ` Mark Rutland
2013-07-29 13:13 ` Rob Herring
2013-07-29 14:30 ` Mark Rutland
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=1375048598-15637-4-git-send-email-robherring2@gmail.com \
--to=robherring2@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).