tegra_cpu_car.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or modify it
  5. * under the terms and conditions of the GNU General Public License,
  6. * version 2, as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope it will be useful, but WITHOUT
  9. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  11. * more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef __MACH_TEGRA_CPU_CAR_H
  17. #define __MACH_TEGRA_CPU_CAR_H
  18. /*
  19. * Tegra CPU clock and reset control ops
  20. *
  21. * wait_for_reset:
  22. * keep waiting until the CPU in reset state
  23. * put_in_reset:
  24. * put the CPU in reset state
  25. * out_of_reset:
  26. * release the CPU from reset state
  27. * enable_clock:
  28. * CPU clock un-gate
  29. * disable_clock:
  30. * CPU clock gate
  31. * rail_off_ready:
  32. * CPU is ready for rail off
  33. * suspend:
  34. * save the clock settings when CPU go into low-power state
  35. * resume:
  36. * restore the clock settings when CPU exit low-power state
  37. */
  38. struct tegra_cpu_car_ops {
  39. void (*wait_for_reset)(u32 cpu);
  40. void (*put_in_reset)(u32 cpu);
  41. void (*out_of_reset)(u32 cpu);
  42. void (*enable_clock)(u32 cpu);
  43. void (*disable_clock)(u32 cpu);
  44. #ifdef CONFIG_PM_SLEEP
  45. bool (*rail_off_ready)(void);
  46. void (*suspend)(void);
  47. void (*resume)(void);
  48. #endif
  49. };
  50. extern struct tegra_cpu_car_ops *tegra_cpu_car_ops;
  51. static inline void tegra_wait_cpu_in_reset(u32 cpu)
  52. {
  53. if (WARN_ON(!tegra_cpu_car_ops->wait_for_reset))
  54. return;
  55. tegra_cpu_car_ops->wait_for_reset(cpu);
  56. }
  57. static inline void tegra_put_cpu_in_reset(u32 cpu)
  58. {
  59. if (WARN_ON(!tegra_cpu_car_ops->put_in_reset))
  60. return;
  61. tegra_cpu_car_ops->put_in_reset(cpu);
  62. }
  63. static inline void tegra_cpu_out_of_reset(u32 cpu)
  64. {
  65. if (WARN_ON(!tegra_cpu_car_ops->out_of_reset))
  66. return;
  67. tegra_cpu_car_ops->out_of_reset(cpu);
  68. }
  69. static inline void tegra_enable_cpu_clock(u32 cpu)
  70. {
  71. if (WARN_ON(!tegra_cpu_car_ops->enable_clock))
  72. return;
  73. tegra_cpu_car_ops->enable_clock(cpu);
  74. }
  75. static inline void tegra_disable_cpu_clock(u32 cpu)
  76. {
  77. if (WARN_ON(!tegra_cpu_car_ops->disable_clock))
  78. return;
  79. tegra_cpu_car_ops->disable_clock(cpu);
  80. }
  81. #ifdef CONFIG_PM_SLEEP
  82. static inline bool tegra_cpu_rail_off_ready(void)
  83. {
  84. if (WARN_ON(!tegra_cpu_car_ops->rail_off_ready))
  85. return false;
  86. return tegra_cpu_car_ops->rail_off_ready();
  87. }
  88. static inline void tegra_cpu_clock_suspend(void)
  89. {
  90. if (WARN_ON(!tegra_cpu_car_ops->suspend))
  91. return;
  92. tegra_cpu_car_ops->suspend();
  93. }
  94. static inline void tegra_cpu_clock_resume(void)
  95. {
  96. if (WARN_ON(!tegra_cpu_car_ops->resume))
  97. return;
  98. tegra_cpu_car_ops->resume();
  99. }
  100. #endif
  101. void tegra20_cpu_car_ops_init(void);
  102. void tegra30_cpu_car_ops_init(void);
  103. #endif /* __MACH_TEGRA_CPU_CAR_H */