sleep.S 3.2 KB

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