diff mbox

[2/5] UBUNTU: SAUCE: ARM: highbank: add soft power and reset key event handling

Message ID 1344342928-20225-1-git-send-email-ike.pan@canonical.com
State New
Headers show

Commit Message

Ike Panhc Aug. 7, 2012, 12:35 p.m. UTC
From: Rob Herring <rob.herring@calxeda.com>

BugLink: http://launchpad.net/bugs/1033853

Power and reset keys come from management processor via ipc messages.
Passing them to userspace does not work in a non-desktop environment
as acpid is used in that case. So we handle the keys directly.

Signed-off-by: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Ike Panhc <ike.pan@canonical.com>
---
 arch/arm/mach-highbank/highbank.c |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
diff mbox

Patch

diff --git a/arch/arm/mach-highbank/highbank.c b/arch/arm/mach-highbank/highbank.c
index 689838c..cfca498 100644
--- a/arch/arm/mach-highbank/highbank.c
+++ b/arch/arm/mach-highbank/highbank.c
@@ -15,6 +15,7 @@ 
  */
 #include <linux/clk.h>
 #include <linux/clkdev.h>
+#include <linux/input.h>
 #include <linux/io.h>
 #include <linux/irq.h>
 #include <linux/irqdomain.h>
@@ -22,6 +23,7 @@ 
 #include <linux/of_irq.h>
 #include <linux/of_platform.h>
 #include <linux/of_address.h>
+#include <linux/reboot.h>
 #include <linux/smp.h>
 
 #include <asm/cacheflush.h>
@@ -34,6 +36,7 @@ 
 #include <asm/mach/map.h>
 #include <asm/mach/time.h>
 #include <mach/irqs.h>
+#include <mach/pl320-ipc.h>
 
 #include "core.h"
 #include "sysregs.h"
@@ -142,9 +145,28 @@  static void highbank_power_off(void)
 		cpu_do_idle();
 }
 
+static int hb_keys_notifier(struct notifier_block *nb, unsigned long event, void *data)
+{
+	u32 key = *(u32 *)data;
+
+	if (event != 0x1000)
+		return 0;
+
+	if (key == KEY_POWER)
+		orderly_poweroff(false);
+	else if (key == 0xffff)
+		ctrl_alt_del();
+
+	return 0;
+}
+static struct notifier_block hb_keys_nb = {
+	.notifier_call = hb_keys_notifier,
+};
+
 static void __init highbank_init(void)
 {
 	pm_power_off = highbank_power_off;
+	pl320_ipc_register_notifier(&hb_keys_nb);
 
 	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
 }