sleep.S 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * arch/arm/mach-tegra/sleep.S
  3. *
  4. * Copyright (c) 2010-2011, NVIDIA Corporation.
  5. * Copyright (c) 2011, Google, Inc.
  6. *
  7. * Author: Colin Cross <ccross@android.com>
  8. * Gary King <gking@nvidia.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful, but WITHOUT
  16. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  17. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  18. * more details.
  19. *
  20. * You should have received a copy of the GNU General Public License along
  21. * with this program; if not, write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  23. */
  24. #include <linux/linkage.h>
  25. #include <asm/assembler.h>
  26. #include <asm/cache.h>
  27. #include <asm/cp15.h>
  28. #include <asm/hardware/cache-l2x0.h>
  29. #include "iomap.h"
  30. #include "sleep.h"
  31. #define CLK_RESET_CCLK_BURST 0x20
  32. #define CLK_RESET_CCLK_DIVIDER 0x24
  33. #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_PM_SLEEP)
  34. /*
  35. * tegra_disable_clean_inv_dcache
  36. *
  37. * disable, clean & invalidate the D-cache
  38. *
  39. * Corrupted registers: r1-r3, r6, r8, r9-r11
  40. */
  41. ENTRY(tegra_disable_clean_inv_dcache)
  42. stmfd sp!, {r0, r4-r5, r7, r9-r11, lr}
  43. dmb @ ensure ordering
  44. /* Disable the D-cache */
  45. mrc p15, 0, r2, c1, c0, 0
  46. bic r2, r2, #CR_C
  47. mcr p15, 0, r2, c1, c0, 0
  48. isb
  49. /* Flush the D-cache */
  50. cmp r0, #TEGRA_FLUSH_CACHE_ALL
  51. blne v7_flush_dcache_louis
  52. bleq v7_flush_dcache_all
  53. /* Trun off coherency */
  54. exit_smp r4, r5
  55. ldmfd sp!, {r0, r4-r5, r7, r9-r11, pc}
  56. ENDPROC(tegra_disable_clean_inv_dcache)
  57. #endif
  58. #ifdef CONFIG_PM_SLEEP
  59. /*
  60. * tegra_init_l2_for_a15
  61. *
  62. * set up the correct L2 cache data RAM latency
  63. */
  64. ENTRY(tegra_init_l2_for_a15)
  65. mrc p15, 0, r0, c0, c0, 5
  66. ubfx r0, r0, #8, #4
  67. tst r0, #1 @ only need for cluster 0
  68. bne _exit_init_l2_a15
  69. mrc p15, 0x1, r0, c9, c0, 2
  70. and r0, r0, #7
  71. cmp r0, #2
  72. bicne r0, r0, #7
  73. orrne r0, r0, #2
  74. mcrne p15, 0x1, r0, c9, c0, 2
  75. _exit_init_l2_a15:
  76. ret lr
  77. ENDPROC(tegra_init_l2_for_a15)
  78. /*
  79. * tegra_sleep_cpu_finish(unsigned long v2p)
  80. *
  81. * enters suspend in LP2 by turning off the mmu and jumping to
  82. * tegra?_tear_down_cpu
  83. */
  84. ENTRY(tegra_sleep_cpu_finish)
  85. mov r4, r0
  86. /* Flush and disable the L1 data cache */
  87. mov r0, #TEGRA_FLUSH_CACHE_ALL
  88. bl tegra_disable_clean_inv_dcache
  89. mov r0, r4
  90. mov32 r6, tegra_tear_down_cpu
  91. ldr r1, [r6]
  92. add r1, r1, r0
  93. mov32 r3, tegra_shut_off_mmu
  94. add r3, r3, r0
  95. mov r0, r1
  96. ret r3
  97. ENDPROC(tegra_sleep_cpu_finish)
  98. /*
  99. * tegra_shut_off_mmu
  100. *
  101. * r0 = physical address to jump to with mmu off
  102. *
  103. * called with VA=PA mapping
  104. * turns off MMU, icache, dcache and branch prediction
  105. */
  106. .align L1_CACHE_SHIFT
  107. .pushsection .idmap.text, "ax"
  108. ENTRY(tegra_shut_off_mmu)
  109. mrc p15, 0, r3, c1, c0, 0
  110. movw r2, #CR_I | CR_Z | CR_C | CR_M
  111. bic r3, r3, r2
  112. dsb
  113. mcr p15, 0, r3, c1, c0, 0
  114. isb
  115. #ifdef CONFIG_CACHE_L2X0
  116. /* Disable L2 cache */
  117. check_cpu_part_num 0xc09, r9, r10
  118. movweq r2, #:lower16:(TEGRA_ARM_PERIF_BASE + 0x3000)
  119. movteq r2, #:upper16:(TEGRA_ARM_PERIF_BASE + 0x3000)
  120. moveq r3, #0
  121. streq r3, [r2, #L2X0_CTRL]
  122. #endif
  123. ret r0
  124. ENDPROC(tegra_shut_off_mmu)
  125. .popsection
  126. /*
  127. * tegra_switch_cpu_to_pllp
  128. *
  129. * In LP2 the normal cpu clock pllx will be turned off. Switch the CPU to pllp
  130. */
  131. ENTRY(tegra_switch_cpu_to_pllp)
  132. /* in LP2 idle (SDRAM active), set the CPU burst policy to PLLP */
  133. mov32 r5, TEGRA_CLK_RESET_BASE
  134. mov r0, #(2 << 28) @ burst policy = run mode
  135. orr r0, r0, #(4 << 4) @ use PLLP in run mode burst
  136. str r0, [r5, #CLK_RESET_CCLK_BURST]
  137. mov r0, #0
  138. str r0, [r5, #CLK_RESET_CCLK_DIVIDER]
  139. ret lr
  140. ENDPROC(tegra_switch_cpu_to_pllp)
  141. #endif