sleep.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * Copyright (c) 2010-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_SLEEP_H
  17. #define __MACH_TEGRA_SLEEP_H
  18. #include "iomap.h"
  19. #define TEGRA_ARM_PERIF_VIRT (TEGRA_ARM_PERIF_BASE - IO_CPU_PHYS \
  20. + IO_CPU_VIRT)
  21. #define TEGRA_FLOW_CTRL_VIRT (TEGRA_FLOW_CTRL_BASE - IO_PPSB_PHYS \
  22. + IO_PPSB_VIRT)
  23. #define TEGRA_CLK_RESET_VIRT (TEGRA_CLK_RESET_BASE - IO_PPSB_PHYS \
  24. + IO_PPSB_VIRT)
  25. #define TEGRA_PMC_VIRT (TEGRA_PMC_BASE - IO_APB_PHYS + IO_APB_VIRT)
  26. /* PMC_SCRATCH37-39 and 41 are used for tegra_pen_lock and idle */
  27. #define PMC_SCRATCH37 0x130
  28. #define PMC_SCRATCH38 0x134
  29. #define PMC_SCRATCH39 0x138
  30. #define PMC_SCRATCH41 0x140
  31. #ifdef CONFIG_ARCH_TEGRA_2x_SOC
  32. #define CPU_RESETTABLE 2
  33. #define CPU_RESETTABLE_SOON 1
  34. #define CPU_NOT_RESETTABLE 0
  35. #endif
  36. #ifdef __ASSEMBLY__
  37. /* returns the offset of the flow controller halt register for a cpu */
  38. .macro cpu_to_halt_reg rd, rcpu
  39. cmp \rcpu, #0
  40. subne \rd, \rcpu, #1
  41. movne \rd, \rd, lsl #3
  42. addne \rd, \rd, #0x14
  43. moveq \rd, #0
  44. .endm
  45. /* returns the offset of the flow controller csr register for a cpu */
  46. .macro cpu_to_csr_reg rd, rcpu
  47. cmp \rcpu, #0
  48. subne \rd, \rcpu, #1
  49. movne \rd, \rd, lsl #3
  50. addne \rd, \rd, #0x18
  51. moveq \rd, #8
  52. .endm
  53. /* returns the ID of the current processor */
  54. .macro cpu_id, rd
  55. mrc p15, 0, \rd, c0, c0, 5
  56. and \rd, \rd, #0xF
  57. .endm
  58. /* loads a 32-bit value into a register without a data access */
  59. .macro mov32, reg, val
  60. movw \reg, #:lower16:\val
  61. movt \reg, #:upper16:\val
  62. .endm
  63. /* Macro to exit SMP coherency. */
  64. .macro exit_smp, tmp1, tmp2
  65. mrc p15, 0, \tmp1, c1, c0, 1 @ ACTLR
  66. bic \tmp1, \tmp1, #(1<<6) | (1<<0) @ clear ACTLR.SMP | ACTLR.FW
  67. mcr p15, 0, \tmp1, c1, c0, 1 @ ACTLR
  68. isb
  69. cpu_id \tmp1
  70. mov \tmp1, \tmp1, lsl #2
  71. mov \tmp2, #0xf
  72. mov \tmp2, \tmp2, lsl \tmp1
  73. mov32 \tmp1, TEGRA_ARM_PERIF_VIRT + 0xC
  74. str \tmp2, [\tmp1] @ invalidate SCU tags for CPU
  75. dsb
  76. .endm
  77. /* Macro to resume & re-enable L2 cache */
  78. #ifndef L2X0_CTRL_EN
  79. #define L2X0_CTRL_EN 1
  80. #endif
  81. #ifdef CONFIG_CACHE_L2X0
  82. .macro l2_cache_resume, tmp1, tmp2, tmp3, phys_l2x0_saved_regs
  83. adr \tmp1, \phys_l2x0_saved_regs
  84. ldr \tmp1, [\tmp1]
  85. ldr \tmp2, [\tmp1, #L2X0_R_PHY_BASE]
  86. ldr \tmp3, [\tmp2, #L2X0_CTRL]
  87. tst \tmp3, #L2X0_CTRL_EN
  88. bne exit_l2_resume
  89. ldr \tmp3, [\tmp1, #L2X0_R_TAG_LATENCY]
  90. str \tmp3, [\tmp2, #L2X0_TAG_LATENCY_CTRL]
  91. ldr \tmp3, [\tmp1, #L2X0_R_DATA_LATENCY]
  92. str \tmp3, [\tmp2, #L2X0_DATA_LATENCY_CTRL]
  93. ldr \tmp3, [\tmp1, #L2X0_R_PREFETCH_CTRL]
  94. str \tmp3, [\tmp2, #L2X0_PREFETCH_CTRL]
  95. ldr \tmp3, [\tmp1, #L2X0_R_PWR_CTRL]
  96. str \tmp3, [\tmp2, #L2X0_POWER_CTRL]
  97. ldr \tmp3, [\tmp1, #L2X0_R_AUX_CTRL]
  98. str \tmp3, [\tmp2, #L2X0_AUX_CTRL]
  99. mov \tmp3, #L2X0_CTRL_EN
  100. str \tmp3, [\tmp2, #L2X0_CTRL]
  101. exit_l2_resume:
  102. .endm
  103. #else /* CONFIG_CACHE_L2X0 */
  104. .macro l2_cache_resume, tmp1, tmp2, tmp3, phys_l2x0_saved_regs
  105. .endm
  106. #endif /* CONFIG_CACHE_L2X0 */
  107. #else
  108. void tegra_pen_lock(void);
  109. void tegra_pen_unlock(void);
  110. void tegra_resume(void);
  111. int tegra_sleep_cpu_finish(unsigned long);
  112. void tegra_disable_clean_inv_dcache(void);
  113. #ifdef CONFIG_HOTPLUG_CPU
  114. void tegra20_hotplug_init(void);
  115. void tegra30_hotplug_init(void);
  116. #else
  117. static inline void tegra20_hotplug_init(void) {}
  118. static inline void tegra30_hotplug_init(void) {}
  119. #endif
  120. void tegra20_cpu_shutdown(int cpu);
  121. int tegra20_cpu_is_resettable_soon(void);
  122. void tegra20_cpu_clear_resettable(void);
  123. #ifdef CONFIG_ARCH_TEGRA_2x_SOC
  124. void tegra20_cpu_set_resettable_soon(void);
  125. #else
  126. static inline void tegra20_cpu_set_resettable_soon(void) {}
  127. #endif
  128. int tegra20_sleep_cpu_secondary_finish(unsigned long);
  129. void tegra20_tear_down_cpu(void);
  130. int tegra30_sleep_cpu_secondary_finish(unsigned long);
  131. void tegra30_tear_down_cpu(void);
  132. #endif
  133. #endif