tegra.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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 __LINUX_CLK_TEGRA_H_
  17. #define __LINUX_CLK_TEGRA_H_
  18. #include <linux/clk.h>
  19. /*
  20. * Tegra CPU clock and reset control ops
  21. *
  22. * wait_for_reset:
  23. * keep waiting until the CPU in reset state
  24. * put_in_reset:
  25. * put the CPU in reset state
  26. * out_of_reset:
  27. * release the CPU from reset state
  28. * enable_clock:
  29. * CPU clock un-gate
  30. * disable_clock:
  31. * CPU clock gate
  32. * rail_off_ready:
  33. * CPU is ready for rail off
  34. * suspend:
  35. * save the clock settings when CPU go into low-power state
  36. * resume:
  37. * restore the clock settings when CPU exit low-power state
  38. */
  39. struct tegra_cpu_car_ops {
  40. void (*wait_for_reset)(u32 cpu);
  41. void (*put_in_reset)(u32 cpu);
  42. void (*out_of_reset)(u32 cpu);
  43. void (*enable_clock)(u32 cpu);
  44. void (*disable_clock)(u32 cpu);
  45. #ifdef CONFIG_PM_SLEEP
  46. bool (*rail_off_ready)(void);
  47. void (*suspend)(void);
  48. void (*resume)(void);
  49. #endif
  50. };
  51. extern struct tegra_cpu_car_ops *tegra_cpu_car_ops;
  52. static inline void tegra_wait_cpu_in_reset(u32 cpu)
  53. {
  54. if (WARN_ON(!tegra_cpu_car_ops->wait_for_reset))
  55. return;
  56. tegra_cpu_car_ops->wait_for_reset(cpu);
  57. }
  58. static inline void tegra_put_cpu_in_reset(u32 cpu)
  59. {
  60. if (WARN_ON(!tegra_cpu_car_ops->put_in_reset))
  61. return;
  62. tegra_cpu_car_ops->put_in_reset(cpu);
  63. }
  64. static inline void tegra_cpu_out_of_reset(u32 cpu)
  65. {
  66. if (WARN_ON(!tegra_cpu_car_ops->out_of_reset))
  67. return;
  68. tegra_cpu_car_ops->out_of_reset(cpu);
  69. }
  70. static inline void tegra_enable_cpu_clock(u32 cpu)
  71. {
  72. if (WARN_ON(!tegra_cpu_car_ops->enable_clock))
  73. return;
  74. tegra_cpu_car_ops->enable_clock(cpu);
  75. }
  76. static inline void tegra_disable_cpu_clock(u32 cpu)
  77. {
  78. if (WARN_ON(!tegra_cpu_car_ops->disable_clock))
  79. return;
  80. tegra_cpu_car_ops->disable_clock(cpu);
  81. }
  82. #ifdef CONFIG_PM_SLEEP
  83. static inline bool tegra_cpu_rail_off_ready(void)
  84. {
  85. if (WARN_ON(!tegra_cpu_car_ops->rail_off_ready))
  86. return false;
  87. return tegra_cpu_car_ops->rail_off_ready();
  88. }
  89. static inline void tegra_cpu_clock_suspend(void)
  90. {
  91. if (WARN_ON(!tegra_cpu_car_ops->suspend))
  92. return;
  93. tegra_cpu_car_ops->suspend();
  94. }
  95. static inline void tegra_cpu_clock_resume(void)
  96. {
  97. if (WARN_ON(!tegra_cpu_car_ops->resume))
  98. return;
  99. tegra_cpu_car_ops->resume();
  100. }
  101. #endif
  102. #ifdef CONFIG_ARCH_TEGRA
  103. void tegra_periph_reset_deassert(struct clk *c);
  104. void tegra_periph_reset_assert(struct clk *c);
  105. #else
  106. static inline void tegra_periph_reset_deassert(struct clk *c) {}
  107. static inline void tegra_periph_reset_assert(struct clk *c) {}
  108. #endif
  109. void tegra_clocks_apply_init_table(void);
  110. #endif /* __LINUX_CLK_TEGRA_H_ */