tegra.h 3.0 KB

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