sleep.S 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /* linux/arch/arm/plat-s5p/sleep.S
  2. *
  3. * Copyright (c) 2010 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com
  5. *
  6. * S5PV210 power Manager (Suspend-To-RAM) support
  7. * Based on S3C2410 sleep code by:
  8. * Ben Dooks, (c) 2004 Simtec Electronics
  9. *
  10. * Based on PXA/SA1100 sleep code by:
  11. * Nicolas Pitre, (c) 2002 Monta Vista Software Inc
  12. * Cliff Brake, (c) 2001
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License as published by
  16. * the Free Software Foundation; either version 2 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  27. */
  28. #include <linux/linkage.h>
  29. #include <asm/assembler.h>
  30. #include <asm/memory.h>
  31. .text
  32. /* s3c_cpu_save
  33. *
  34. * entry:
  35. * r0 = save address (virtual addr of s3c_sleep_save_phys)
  36. */
  37. ENTRY(s3c_cpu_save)
  38. stmfd sp!, { r3 - r12, lr }
  39. mrc p15, 0, r4, c13, c0, 0 @ FCSE/PID
  40. mrc p15, 0, r5, c3, c0, 0 @ Domain ID
  41. mrc p15, 0, r6, c2, c0, 0 @ Translation Table BASE0
  42. mrc p15, 0, r7, c2, c0, 1 @ Translation Table BASE1
  43. mrc p15, 0, r8, c2, c0, 2 @ Translation Table Control
  44. mrc p15, 0, r9, c1, c0, 0 @ Control register
  45. mrc p15, 0, r10, c1, c0, 1 @ Auxiliary control register
  46. mrc p15, 0, r11, c1, c0, 2 @ Co-processor access controls
  47. mrc p15, 0, r12, c10, c2, 0 @ Read PRRR
  48. mrc p15, 0, r3, c10, c2, 1 @ READ NMRR
  49. stmia r0, { r3 - r13 }
  50. bl s3c_pm_cb_flushcache
  51. ldr r0, =pm_cpu_sleep
  52. ldr r0, [ r0 ]
  53. mov pc, r0
  54. resume_with_mmu:
  55. /*
  56. * After MMU is turned on, restore the previous MMU table.
  57. */
  58. ldr r9 , =(PAGE_OFFSET - PHYS_OFFSET)
  59. add r4, r4, r9
  60. str r12, [r4]
  61. ldmfd sp!, { r3 - r12, pc }
  62. .ltorg
  63. .data
  64. .global s3c_sleep_save_phys
  65. s3c_sleep_save_phys:
  66. .word 0
  67. /* sleep magic, to allow the bootloader to check for an valid
  68. * image to resume to. Must be the first word before the
  69. * s3c_cpu_resume entry.
  70. */
  71. .word 0x2bedf00d
  72. /* s3c_cpu_resume
  73. *
  74. * resume code entry for bootloader to call
  75. *
  76. * we must put this code here in the data segment as we have no
  77. * other way of restoring the stack pointer after sleep, and we
  78. * must not write to the code segment (code is read-only)
  79. */
  80. ENTRY(s3c_cpu_resume)
  81. mov r0, #PSR_I_BIT | PSR_F_BIT | SVC_MODE
  82. msr cpsr_c, r0
  83. mov r1, #0
  84. mcr p15, 0, r1, c8, c7, 0 @ invalidate TLBs
  85. mcr p15, 0, r1, c7, c5, 0 @ invalidate I Cache
  86. ldr r0, s3c_sleep_save_phys @ address of restore block
  87. ldmia r0, { r3 - r13 }
  88. mcr p15, 0, r4, c13, c0, 0 @ FCSE/PID
  89. mcr p15, 0, r5, c3, c0, 0 @ Domain ID
  90. mcr p15, 0, r8, c2, c0, 2 @ Translation Table Control
  91. mcr p15, 0, r7, c2, c0, 1 @ Translation Table BASE1
  92. mcr p15, 0, r6, c2, c0, 0 @ Translation Table BASE0
  93. mcr p15, 0, r10, c1, c0, 1 @ Auxiliary control register
  94. mov r0, #0
  95. mcr p15, 0, r0, c8, c7, 0 @ Invalidate I & D TLB
  96. mov r0, #0 @ restore copro access
  97. mcr p15, 0, r11, c1, c0, 2 @ Co-processor access
  98. mcr p15, 0, r0, c7, c5, 4
  99. mcr p15, 0, r12, c10, c2, 0 @ write PRRR
  100. mcr p15, 0, r3, c10, c2, 1 @ write NMRR
  101. /*
  102. * In Cortex-A8, when MMU is turned on, the pipeline is flushed.
  103. * And there are no valid entries in the MMU table at this point.
  104. * So before turning on the MMU, the MMU entry for the DRAM address
  105. * range is added. After the MMU is turned on, the other entries
  106. * in the MMU table will be restored.
  107. */
  108. /* r6 = Translation Table BASE0 */
  109. mov r4, r6
  110. mov r4, r4, LSR #14
  111. mov r4, r4, LSL #14
  112. /* Load address for adding to MMU table list */
  113. ldr r11, =0xE010F000 @ INFORM0 reg.
  114. ldr r10, [r11, #0]
  115. mov r10, r10, LSR #18
  116. bic r10, r10, #0x3
  117. orr r4, r4, r10
  118. /* Calculate MMU table entry */
  119. mov r10, r10, LSL #18
  120. ldr r5, =0x40E
  121. orr r10, r10, r5
  122. /* Back up originally data */
  123. ldr r12, [r4]
  124. /* Add calculated MMU table entry into MMU table list */
  125. str r10, [r4]
  126. ldr r2, =resume_with_mmu
  127. mcr p15, 0, r9, c1, c0, 0 @ turn on MMU, etc
  128. nop
  129. nop
  130. nop
  131. nop
  132. nop @ second-to-last before mmu
  133. mov pc, r2 @ go back to virtual address
  134. .ltorg