cpu_pm.h 2.4 KB

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