Browse Source

sh: Add notifiers chains for cpu/board code

This patch adds atomic notifier chains for pre/post
sleep events. Useful for cpu code and boards that
need to save and restore register state before and
after entering a sleep mode.

Signed-off-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Magnus Damm 15 years ago
parent
commit
49f42644fd
2 changed files with 23 additions and 0 deletions
  1. 11 0
      arch/sh/include/asm/suspend.h
  2. 12 0
      arch/sh/kernel/cpu/shmobile/pm.c

+ 11 - 0
arch/sh/include/asm/suspend.h

@@ -2,6 +2,7 @@
 #define _ASM_SH_SUSPEND_H
 #define _ASM_SH_SUSPEND_H
 
 
 #ifndef __ASSEMBLY__
 #ifndef __ASSEMBLY__
+#include <linux/notifier.h>
 static inline int arch_prepare_suspend(void) { return 0; }
 static inline int arch_prepare_suspend(void) { return 0; }
 
 
 #include <asm/ptrace.h>
 #include <asm/ptrace.h>
@@ -19,6 +20,16 @@ void sh_mobile_setup_cpuidle(void);
 static inline void sh_mobile_setup_cpuidle(void) {}
 static inline void sh_mobile_setup_cpuidle(void) {}
 #endif
 #endif
 
 
+/* notifier chains for pre/post sleep hooks */
+extern struct atomic_notifier_head sh_mobile_pre_sleep_notifier_list;
+extern struct atomic_notifier_head sh_mobile_post_sleep_notifier_list;
+
+/* priority levels for notifiers */
+#define SH_MOBILE_SLEEP_BOARD	0
+#define SH_MOBILE_SLEEP_CPU	1
+#define SH_MOBILE_PRE(x)	(x)
+#define SH_MOBILE_POST(x)	(-(x))
+
 #endif
 #endif
 
 
 /* flags passed to assembly suspend code */
 /* flags passed to assembly suspend code */

+ 12 - 0
arch/sh/kernel/cpu/shmobile/pm.c

@@ -16,6 +16,12 @@
 #include <asm/suspend.h>
 #include <asm/suspend.h>
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 
 
+/*
+ * Notifier lists for pre/post sleep notification
+ */
+ATOMIC_NOTIFIER_HEAD(sh_mobile_pre_sleep_notifier_list);
+ATOMIC_NOTIFIER_HEAD(sh_mobile_post_sleep_notifier_list);
+
 /*
 /*
  * Sleep modes available on SuperH Mobile:
  * Sleep modes available on SuperH Mobile:
  *
  *
@@ -44,8 +50,14 @@ void sh_mobile_call_standby(unsigned long mode)
 	void *onchip_mem = (void *)ILRAM_BASE;
 	void *onchip_mem = (void *)ILRAM_BASE;
 	void (*standby_onchip_mem)(unsigned long, unsigned long) = onchip_mem;
 	void (*standby_onchip_mem)(unsigned long, unsigned long) = onchip_mem;
 
 
+	atomic_notifier_call_chain(&sh_mobile_pre_sleep_notifier_list,
+				   mode, NULL);
+
 	/* Let assembly snippet in on-chip memory handle the rest */
 	/* Let assembly snippet in on-chip memory handle the rest */
 	standby_onchip_mem(mode, ILRAM_BASE);
 	standby_onchip_mem(mode, ILRAM_BASE);
+
+	atomic_notifier_call_chain(&sh_mobile_post_sleep_notifier_list,
+				   mode, NULL);
 }
 }
 
 
 static int sh_pm_enter(suspend_state_t state)
 static int sh_pm_enter(suspend_state_t state)