aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/powernv/opal-power.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-02-11 21:15:38 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-02-11 21:15:38 -0500
commitd3f180ea1a44aecba1b0dab2a253428e77f906bf (patch)
tree0be6eaf1eb3fd32c934bd070a3d758696f417c93 /arch/powerpc/platforms/powernv/opal-power.c
parent6b00f7efb5303418c231994c91fb8239f5ada260 (diff)
parenta6130ed253a931d2169c26ab0958d81b0dce4d6e (diff)
Merge tag 'powerpc-3.20-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux
Pull powerpc updates from Michael Ellerman: - Update of all defconfigs - Addition of a bunch of config options to modernise our defconfigs - Some PS3 updates from Geoff - Optimised memcmp for 64 bit from Anton - Fix for kprobes that allows 'perf probe' to work from Naveen - Several cxl updates from Ian & Ryan - Expanded support for the '24x7' PMU from Cody & Sukadev - Freescale updates from Scott: "Highlights include 8xx optimizations, some more work on datapath device tree content, e300 machine check support, t1040 corenet error reporting, and various cleanups and fixes" * tag 'powerpc-3.20-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux: (102 commits) cxl: Add missing return statement after handling AFU errror cxl: Fail AFU initialisation if an invalid configuration record is found cxl: Export optional AFU configuration record in sysfs powerpc/mm: Warn on flushing tlb page in kernel context powerpc/powernv: Add OPAL soft-poweroff routine powerpc/perf/hv-24x7: Document sysfs event description entries powerpc/perf/hv-gpci: add the remaining gpci requests powerpc/perf/{hv-gpci, hv-common}: generate requests with counters annotated powerpc/perf/hv-24x7: parse catalog and populate sysfs with events perf: define EVENT_DEFINE_RANGE_FORMAT_LITE helper perf: add PMU_EVENT_ATTR_STRING() helper perf: provide sysfs_show for struct perf_pmu_events_attr powerpc/kernel: Avoid initializing device-tree pointer twice powerpc: Remove old compile time disabled syscall tracing code powerpc/kernel: Make syscall_exit a local label cxl: Fix device_node reference counting powerpc/mm: bail out early when flushing TLB page powerpc: defconfigs: add MTD_SPI_NOR (new dependency for M25P80) perf/powerpc: reset event hw state when adding it to the PMU powerpc/qe: Use strlcpy() ...
Diffstat (limited to 'arch/powerpc/platforms/powernv/opal-power.c')
-rw-r--r--arch/powerpc/platforms/powernv/opal-power.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/powernv/opal-power.c b/arch/powerpc/platforms/powernv/opal-power.c
new file mode 100644
index 000000000000..48bf5b080bcf
--- /dev/null
+++ b/arch/powerpc/platforms/powernv/opal-power.c
@@ -0,0 +1,65 @@
1/*
2 * PowerNV OPAL power control for graceful shutdown handling
3 *
4 * Copyright 2015 IBM Corp.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/kernel.h>
13#include <linux/reboot.h>
14#include <linux/notifier.h>
15
16#include <asm/opal.h>
17#include <asm/machdep.h>
18
19#define SOFT_OFF 0x00
20#define SOFT_REBOOT 0x01
21
22static int opal_power_control_event(struct notifier_block *nb,
23 unsigned long msg_type, void *msg)
24{
25 struct opal_msg *power_msg = msg;
26 uint64_t type;
27
28 type = be64_to_cpu(power_msg->params[0]);
29
30 switch (type) {
31 case SOFT_REBOOT:
32 /* Fall through. The service processor is responsible for
33 * bringing the machine back up */
34 case SOFT_OFF:
35 pr_info("OPAL: poweroff requested\n");
36 orderly_poweroff(true);
37 break;
38 default:
39 pr_err("OPAL: power control type unexpected %016llx\n", type);
40 }
41
42 return 0;
43}
44
45static struct notifier_block opal_power_control_nb = {
46 .notifier_call = opal_power_control_event,
47 .next = NULL,
48 .priority = 0,
49};
50
51static int __init opal_power_control_init(void)
52{
53 int ret;
54
55 ret = opal_message_notifier_register(OPAL_MSG_SHUTDOWN,
56 &opal_power_control_nb);
57 if (ret) {
58 pr_err("%s: Can't register OPAL event notifier (%d)\n",
59 __func__, ret);
60 return ret;
61 }
62
63 return 0;
64}
65machine_subsys_initcall(powernv, opal_power_control_init);