sleep.S 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * arch/arm/mach-tegra/sleep.S
  4. *
  5. * Copyright (c) 2010-2011, NVIDIA Corporation.
  6. * Copyright (c) 2011, Google, Inc.
  7. *
  8. * Author: Colin Cross <[email protected]>
  9. * Gary King <[email protected]>
  10. */
  11. #include <linux/linkage.h>
  12. #include <asm/assembler.h>
  13. #include <asm/cache.h>
  14. #include <asm/cp15.h>
  15. #include <asm/hardware/cache-l2x0.h>
  16. #include "iomap.h"
  17. #include "sleep.h"
  18. #define CLK_RESET_CCLK_BURST 0x20
  19. #define CLK_RESET_CCLK_DIVIDER 0x24
  20. #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_PM_SLEEP)
  21. /*
  22. * tegra_disable_clean_inv_dcache
  23. *
  24. * disable, clean & invalidate the D-cache
  25. *
  26. * Corrupted registers: r1-r3, r6, r8, r9-r11
  27. */
  28. ENTRY(tegra_disable_clean_inv_dcache)
  29. stmfd sp!, {r0, r4-r5, r7, r9-r11, lr}
  30. dmb @ ensure ordering
  31. /* Disable the D-cache */
  32. mrc p15, 0, r2, c1, c0, 0
  33. tst r2, #CR_C @ see tegra_sleep_cpu()
  34. bic r2, r2, #CR_C
  35. mcrne p15, 0, r2, c1, c0, 0
  36. isb
  37. /* Flush the D-cache */
  38. cmp r0, #TEGRA_FLUSH_CACHE_ALL
  39. blne v7_flush_dcache_louis
  40. bleq v7_flush_dcache_all
  41. /* Trun off coherency */
  42. exit_smp r4, r5
  43. ldmfd sp!, {r0, r4-r5, r7, r9-r11, pc}
  44. ENDPROC(tegra_disable_clean_inv_dcache)
  45. #endif
  46. #ifdef CONFIG_PM_SLEEP
  47. /*
  48. * tegra_init_l2_for_a15
  49. *
  50. * set up the correct L2 cache data RAM latency
  51. */
  52. ENTRY(tegra_init_l2_for_a15)
  53. mrc p15, 0, r0, c0, c0, 5
  54. ubfx r0, r0, #8, #4
  55. tst r0, #1 @ only need for cluster 0
  56. bne _exit_init_l2_a15
  57. mrc p15, 0x1, r0, c9, c0, 2
  58. and r0, r0, #7
  59. cmp r0, #2
  60. bicne r0, r0, #7
  61. orrne r0, r0, #2
  62. mcrne p15, 0x1, r0, c9, c0, 2
  63. _exit_init_l2_a15:
  64. ret lr
  65. ENDPROC(tegra_init_l2_for_a15)
  66. /*
  67. * tegra_sleep_cpu_finish(unsigned long v2p)
  68. *
  69. * enters suspend in LP2 by turning off the mmu and jumping to
  70. * tegra?_tear_down_cpu
  71. */
  72. ENTRY(tegra_sleep_cpu_finish)
  73. mov r4, r0
  74. /* Flush and disable the L1 data cache */
  75. mov r0, #TEGRA_FLUSH_CACHE_ALL
  76. bl tegra_disable_clean_inv_dcache
  77. mov r0, r4
  78. mov32 r6, tegra_tear_down_cpu
  79. ldr r1, [r6]
  80. add r1, r1, r0
  81. mov32 r3, tegra_shut_off_mmu
  82. add r3, r3, r0
  83. mov r0, r1
  84. ret r3
  85. ENDPROC(tegra_sleep_cpu_finish)
  86. /*
  87. * tegra_shut_off_mmu
  88. *
  89. * r0 = physical address to jump to with mmu off
  90. *
  91. * called with VA=PA mapping
  92. * turns off MMU, icache, dcache and branch prediction
  93. */
  94. .align L1_CACHE_SHIFT
  95. .pushsection .idmap.text, "ax"
  96. ENTRY(tegra_shut_off_mmu)
  97. mrc p15, 0, r3, c1, c0, 0
  98. movw r2, #CR_I | CR_Z | CR_C | CR_M
  99. bic r3, r3, r2
  100. dsb
  101. mcr p15, 0, r3, c1, c0, 0
  102. isb
  103. #ifdef CONFIG_CACHE_L2X0
  104. /* Disable L2 cache */
  105. check_cpu_part_num 0xc09, r9, r10
  106. retne r0
  107. mov32 r2, TEGRA_ARM_PERIF_BASE + 0x3000
  108. ldr r3, [r2, #L2X0_CTRL]
  109. tst r3, #L2X0_CTRL_EN @ see tegra_sleep_cpu()
  110. mov r3, #0
  111. strne r3, [r2, #L2X0_CTRL]
  112. #endif
  113. ret r0
  114. ENDPROC(tegra_shut_off_mmu)
  115. .popsection
  116. /*
  117. * tegra_switch_cpu_to_pllp
  118. *
  119. * In LP2 the normal cpu clock pllx will be turned off. Switch the CPU to pllp
  120. */
  121. ENTRY(tegra_switch_cpu_to_pllp)
  122. /* in LP2 idle (SDRAM active), set the CPU burst policy to PLLP */
  123. mov32 r5, TEGRA_CLK_RESET_BASE
  124. mov r0, #(2 << 28) @ burst policy = run mode
  125. orr r0, r0, #(4 << 4) @ use PLLP in run mode burst
  126. str r0, [r5, #CLK_RESET_CCLK_BURST]
  127. mov r0, #0
  128. str r0, [r5, #CLK_RESET_CCLK_DIVIDER]
  129. ret lr
  130. ENDPROC(tegra_switch_cpu_to_pllp)
  131. #endif