phylib: Properly reinitialize PHYs after hibernation
[safe/jmp/linux-2.6] / include / linux / suspend.h
index c634350..5e781d8 100644 (file)
@@ -1,9 +1,6 @@
 #ifndef _LINUX_SUSPEND_H
 #define _LINUX_SUSPEND_H
 
-#if defined(CONFIG_X86) || defined(CONFIG_FRV) || defined(CONFIG_PPC32) || defined(CONFIG_PPC64)
-#include <asm/suspend.h>
-#endif
 #include <linux/swap.h>
 #include <linux/notifier.h>
 #include <linux/init.h>
@@ -61,10 +58,17 @@ typedef int __bitwise suspend_state_t;
  *     by @begin().
  *     @prepare() is called right after devices have been suspended (ie. the
  *     appropriate .suspend() method has been executed for each device) and
- *     before the nonboot CPUs are disabled (it is executed with IRQs enabled).
- *     This callback is optional.  It returns 0 on success or a negative
- *     error code otherwise, in which case the system cannot enter the desired
- *     sleep state (@enter() and @finish() will not be called in that case).
+ *     before device drivers' late suspend callbacks are executed.  It returns
+ *     0 on success or a negative error code otherwise, in which case the
+ *     system cannot enter the desired sleep state (@prepare_late(), @enter(),
+ *     @wake(), and @finish() will not be called in that case).
+ *
+ * @prepare_late: Finish preparing the platform for entering the system sleep
+ *     state indicated by @begin().
+ *     @prepare_late is called before disabling nonboot CPUs and after
+ *     device drivers' late suspend callbacks have been executed.  It returns
+ *     0 on success or a negative error code otherwise, in which case the
+ *     system cannot enter the desired sleep state (@enter() and @wake()).
  *
  * @enter: Enter the system sleep state indicated by @begin() or represented by
  *     the argument if @begin() is not implemented.
@@ -72,19 +76,26 @@ typedef int __bitwise suspend_state_t;
  *     error code otherwise, in which case the system cannot enter the desired
  *     sleep state.
  *
- * @finish: Called when the system has just left a sleep state, right after
- *     the nonboot CPUs have been enabled and before devices are resumed (it is
- *     executed with IRQs enabled).
+ * @wake: Called when the system has just left a sleep state, right after
+ *     the nonboot CPUs have been enabled and before device drivers' early
+ *     resume callbacks are executed.
+ *     This callback is optional, but should be implemented by the platforms
+ *     that implement @prepare_late().  If implemented, it is always called
+ *     after @enter(), even if @enter() fails.
+ *
+ * @finish: Finish wake-up of the platform.
+ *     @finish is called right prior to calling device drivers' regular suspend
+ *     callbacks.
  *     This callback is optional, but should be implemented by the platforms
  *     that implement @prepare().  If implemented, it is always called after
- *     @enter() (even if @enter() fails).
+ *     @enter() and @wake(), if implemented, even if any of them fails.
  *
  * @end: Called by the PM core right after resuming devices, to indicate to
  *     the platform that the system has returned to the working state or
  *     the transition to the sleep state has been aborted.
  *     This callback is optional, but should be implemented by the platforms
- *     that implement @begin(), but platforms implementing @begin() should
- *     also provide a @end() which cleans up transitions aborted before
+ *     that implement @begin().  Accordingly, platforms implementing @begin()
+ *     should also provide a @end() which cleans up transitions aborted before
  *     @enter().
  *
  * @recover: Recover the platform from a suspend failure.
@@ -96,7 +107,9 @@ struct platform_suspend_ops {
        int (*valid)(suspend_state_t state);
        int (*begin)(suspend_state_t state);
        int (*prepare)(void);
+       int (*prepare_late)(void);
        int (*enter)(suspend_state_t state);
+       void (*wake)(void);
        void (*finish)(void);
        void (*end)(void);
        void (*recover)(void);
@@ -217,11 +230,11 @@ struct platform_hibernation_ops {
 #ifdef CONFIG_HIBERNATION
 /* kernel/power/snapshot.c */
 extern void __register_nosave_region(unsigned long b, unsigned long e, int km);
-static inline void register_nosave_region(unsigned long b, unsigned long e)
+static inline void __init register_nosave_region(unsigned long b, unsigned long e)
 {
        __register_nosave_region(b, e, 0);
 }
-static inline void register_nosave_region_late(unsigned long b, unsigned long e)
+static inline void __init register_nosave_region_late(unsigned long b, unsigned long e)
 {
        __register_nosave_region(b, e, 1);
 }
@@ -232,6 +245,7 @@ extern unsigned long get_safe_page(gfp_t gfp_mask);
 
 extern void hibernation_set_ops(struct platform_hibernation_ops *ops);
 extern int hibernate(void);
+extern bool system_entering_hibernation(void);
 #else /* CONFIG_HIBERNATION */
 static inline int swsusp_page_is_forbidden(struct page *p) { return 0; }
 static inline void swsusp_set_page_free(struct page *p) {}
@@ -239,8 +253,26 @@ static inline void swsusp_unset_page_free(struct page *p) {}
 
 static inline void hibernation_set_ops(struct platform_hibernation_ops *ops) {}
 static inline int hibernate(void) { return -ENOSYS; }
+static inline bool system_entering_hibernation(void) { return false; }
 #endif /* CONFIG_HIBERNATION */
 
+#ifdef CONFIG_HIBERNATION_NVS
+extern int hibernate_nvs_register(unsigned long start, unsigned long size);
+extern int hibernate_nvs_alloc(void);
+extern void hibernate_nvs_free(void);
+extern void hibernate_nvs_save(void);
+extern void hibernate_nvs_restore(void);
+#else /* CONFIG_HIBERNATION_NVS */
+static inline int hibernate_nvs_register(unsigned long a, unsigned long b)
+{
+       return 0;
+}
+static inline int hibernate_nvs_alloc(void) { return 0; }
+static inline void hibernate_nvs_free(void) {}
+static inline void hibernate_nvs_save(void) {}
+static inline void hibernate_nvs_restore(void) {}
+#endif /* CONFIG_HIBERNATION_NVS */
+
 #ifdef CONFIG_PM_SLEEP
 void save_processor_state(void);
 void restore_processor_state(void);
@@ -269,6 +301,8 @@ static inline int unregister_pm_notifier(struct notifier_block *nb)
 #define pm_notifier(fn, pri)   do { (void)(fn); } while (0)
 #endif /* !CONFIG_PM_SLEEP */
 
+extern struct mutex pm_mutex;
+
 #ifndef CONFIG_HIBERNATION
 static inline void register_nosave_region(unsigned long b, unsigned long e)
 {
@@ -276,8 +310,23 @@ static inline void register_nosave_region(unsigned long b, unsigned long e)
 static inline void register_nosave_region_late(unsigned long b, unsigned long e)
 {
 }
-#endif
 
-extern struct mutex pm_mutex;
+static inline void lock_system_sleep(void) {}
+static inline void unlock_system_sleep(void) {}
+
+#else
+
+/* Let some subsystems like memory hotadd exclude hibernation */
+
+static inline void lock_system_sleep(void)
+{
+       mutex_lock(&pm_mutex);
+}
+
+static inline void unlock_system_sleep(void)
+{
+       mutex_unlock(&pm_mutex);
+}
+#endif
 
 #endif /* _LINUX_SUSPEND_H */