cpu_pm.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * Copyright (C) 2011 Google, Inc.
  3. *
  4. * Author:
  5. * Colin Cross <ccross@android.com>
  6. *
  7. * This software is licensed under the terms of the GNU General Public
  8. * License version 2, as published by the Free Software Foundation, and
  9. * may be copied, distributed, and modified under those terms.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17. #ifndef _LINUX_CPU_PM_H
  18. #define _LINUX_CPU_PM_H
  19. #include <linux/kernel.h>
  20. #include <linux/notifier.h>
  21. /*
  22. * When a CPU goes to a low power state that turns off power to the CPU's
  23. * power domain, the contents of some blocks (floating point coprocessors,
  24. * interrupt controllers, caches, timers) in the same power domain can
  25. * be lost. The cpm_pm notifiers provide a method for platform idle, suspend,
  26. * and hotplug implementations to notify the drivers for these blocks that
  27. * they may be reset.
  28. *
  29. * All cpu_pm notifications must be called with interrupts disabled.
  30. *
  31. * The notifications are split into two classes: CPU notifications and CPU
  32. * cluster notifications.
  33. *
  34. * CPU notifications apply to a single CPU and must be called on the affected
  35. * CPU. They are used to save per-cpu context for affected blocks.
  36. *
  37. * CPU cluster notifications apply to all CPUs in a single power domain. They
  38. * are used to save any global context for affected blocks, and must be called
  39. * after all the CPUs in the power domain have been notified of the low power
  40. * state.
  41. */
  42. /*
  43. * Event codes passed as unsigned long val to notifier calls
  44. */
  45. enum cpu_pm_event {
  46. /* A single cpu is entering a low power state */
  47. CPU_PM_ENTER,
  48. /* A single cpu failed to enter a low power state */
  49. CPU_PM_ENTER_FAILED,
  50. /* A single cpu is exiting a low power state */
  51. CPU_PM_EXIT,
  52. /* A cpu power domain is entering a low power state */
  53. CPU_CLUSTER_PM_ENTER,
  54. /* A cpu power domain failed to enter a low power state */
  55. CPU_CLUSTER_PM_ENTER_FAILED,
  56. /* A cpu power domain is exiting a low power state */
  57. CPU_CLUSTER_PM_EXIT,
  58. };
  59. #ifdef CONFIG_CPU_PM
  60. int cpu_pm_register_notifier(struct notifier_block *nb);
  61. int cpu_pm_unregister_notifier(struct notifier_block *nb);
  62. int cpu_pm_enter(void);
  63. int cpu_pm_exit(void);
  64. int cpu_cluster_pm_enter(void);
  65. int cpu_cluster_pm_exit(void);
  66. #else
  67. static inline int cpu_pm_register_notifier(struct notifier_block *nb)
  68. {
  69. return 0;
  70. }
  71. static inline int cpu_pm_unregister_notifier(struct notifier_block *nb)
  72. {
  73. return 0;
  74. }
  75. static inline int cpu_pm_enter(void)
  76. {
  77. return 0;
  78. }
  79. static inline int cpu_pm_exit(void)
  80. {
  81. return 0;
  82. }
  83. static inline int cpu_cluster_pm_enter(void)
  84. {
  85. return 0;
  86. }
  87. static inline int cpu_cluster_pm_exit(void)
  88. {
  89. return 0;
  90. }
  91. #endif
  92. #endif