2 * PowerNV OPAL power control for graceful shutdown handling
4 * Copyright 2015 IBM Corp.
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.
12 #include <linux/kernel.h>
13 #include <linux/reboot.h>
14 #include <linux/notifier.h>
17 #include <asm/machdep.h>
20 #define SOFT_REBOOT 0x01
22 static int opal_power_control_event(struct notifier_block *nb,
23 unsigned long msg_type, void *msg)
25 struct opal_msg *power_msg = msg;
28 type = be64_to_cpu(power_msg->params[0]);
32 pr_info("OPAL: reboot requested\n");
36 pr_info("OPAL: poweroff requested\n");
37 orderly_poweroff(true);
40 pr_err("OPAL: power control type unexpected %016llx\n", type);
46 static struct notifier_block opal_power_control_nb = {
47 .notifier_call = opal_power_control_event,
52 static int __init opal_power_control_init(void)
56 ret = opal_message_notifier_register(OPAL_MSG_SHUTDOWN,
57 &opal_power_control_nb);
59 pr_err("%s: Can't register OPAL event notifier (%d)\n",
66 machine_subsys_initcall(powernv, opal_power_control_init);