sleep.S 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /*
  2. * Low-level PXA250/210 sleep/wakeUp support
  3. *
  4. * Initial SA1110 code:
  5. * Copyright (c) 2001 Cliff Brake <cbrake@accelent.com>
  6. *
  7. * Adapted for PXA by Nicolas Pitre:
  8. * Copyright (c) 2002 Monta Vista Software, Inc.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License.
  12. */
  13. #include <linux/linkage.h>
  14. #include <asm/assembler.h>
  15. #include <mach/hardware.h>
  16. #include <mach/smemc.h>
  17. #include <mach/pxa2xx-regs.h>
  18. #define MDREFR_KDIV 0x200a4000 // all banks
  19. #define CCCR_SLEEP 0x00000107 // L=7 2N=2 A=0 PPDIS=0 CPDIS=0
  20. .text
  21. #ifdef CONFIG_PXA3xx
  22. /*
  23. * pxa3xx_finish_suspend() - forces CPU into sleep state (S2D3C4)
  24. */
  25. ENTRY(pxa3xx_finish_suspend)
  26. mov r0, #0x06 @ S2D3C4 mode
  27. mcr p14, 0, r0, c7, c0, 0 @ enter sleep
  28. 20: b 20b @ waiting for sleep
  29. #endif /* CONFIG_PXA3xx */
  30. #ifdef CONFIG_PXA27x
  31. /*
  32. * pxa27x_finish_suspend()
  33. *
  34. * Forces CPU into sleep state.
  35. *
  36. * r0 = value for PWRMODE M field for desired sleep state
  37. */
  38. ENTRY(pxa27x_finish_suspend)
  39. @ Put the processor to sleep
  40. @ (also workaround for sighting 28071)
  41. @ prepare value for sleep mode
  42. mov r1, r0 @ sleep mode
  43. @ prepare pointer to physical address 0 (virtual mapping in generic.c)
  44. mov r2, #UNCACHED_PHYS_0
  45. @ prepare SDRAM refresh settings
  46. ldr r4, =MDREFR
  47. ldr r5, [r4]
  48. @ enable SDRAM self-refresh mode
  49. orr r5, r5, #MDREFR_SLFRSH
  50. @ set SDCLKx divide-by-2 bits (this is part of a workaround for Errata 50)
  51. ldr r6, =MDREFR_KDIV
  52. orr r5, r5, r6
  53. @ Intel PXA270 Specification Update notes problems sleeping
  54. @ with core operating above 91 MHz
  55. @ (see Errata 50, ...processor does not exit from sleep...)
  56. ldr r6, =CCCR
  57. ldr r8, [r6] @ keep original value for resume
  58. ldr r7, =CCCR_SLEEP @ prepare CCCR sleep value
  59. mov r0, #0x2 @ prepare value for CLKCFG
  60. @ align execution to a cache line
  61. b pxa_cpu_do_suspend
  62. #endif
  63. #ifdef CONFIG_PXA25x
  64. /*
  65. * pxa25x_finish_suspend()
  66. *
  67. * Forces CPU into sleep state.
  68. *
  69. * r0 = value for PWRMODE M field for desired sleep state
  70. */
  71. ENTRY(pxa25x_finish_suspend)
  72. @ prepare value for sleep mode
  73. mov r1, r0 @ sleep mode
  74. @ prepare pointer to physical address 0 (virtual mapping in generic.c)
  75. mov r2, #UNCACHED_PHYS_0
  76. @ prepare SDRAM refresh settings
  77. ldr r4, =MDREFR
  78. ldr r5, [r4]
  79. @ enable SDRAM self-refresh mode
  80. orr r5, r5, #MDREFR_SLFRSH
  81. @ Intel PXA255 Specification Update notes problems
  82. @ about suspending with PXBus operating above 133MHz
  83. @ (see Errata 31, GPIO output signals, ... unpredictable in sleep
  84. @
  85. @ We keep the change-down close to the actual suspend on SDRAM
  86. @ as possible to eliminate messing about with the refresh clock
  87. @ as the system will restore with the original speed settings
  88. @
  89. @ Ben Dooks, 13-Sep-2004
  90. ldr r6, =CCCR
  91. ldr r8, [r6] @ keep original value for resume
  92. @ ensure x1 for run and turbo mode with memory clock
  93. bic r7, r8, #CCCR_M_MASK | CCCR_N_MASK
  94. orr r7, r7, #(1<<5) | (2<<7)
  95. @ check that the memory frequency is within limits
  96. and r14, r7, #CCCR_L_MASK
  97. teq r14, #1
  98. bicne r7, r7, #CCCR_L_MASK
  99. orrne r7, r7, #1 @@ 99.53MHz
  100. @ get ready for the change
  101. @ note, turbo is not preserved over sleep so there is no
  102. @ point in preserving it here. we save it on the stack with the
  103. @ other CP registers instead.
  104. mov r0, #0
  105. mcr p14, 0, r0, c6, c0, 0
  106. orr r0, r0, #2 @ initiate change bit
  107. b pxa_cpu_do_suspend
  108. #endif
  109. .ltorg
  110. .align 5
  111. pxa_cpu_do_suspend:
  112. @ All needed values are now in registers.
  113. @ These last instructions should be in cache
  114. @ initiate the frequency change...
  115. str r7, [r6]
  116. mcr p14, 0, r0, c6, c0, 0
  117. @ restore the original cpu speed value for resume
  118. str r8, [r6]
  119. @ need 6 13-MHz cycles before changing PWRMODE
  120. @ just set frequency to 91-MHz... 6*91/13 = 42
  121. mov r0, #42
  122. 10: subs r0, r0, #1
  123. bne 10b
  124. @ Do not reorder...
  125. @ Intel PXA270 Specification Update notes problems performing
  126. @ external accesses after SDRAM is put in self-refresh mode
  127. @ (see Errata 38 ...hangs when entering self-refresh mode)
  128. @ force address lines low by reading at physical address 0
  129. ldr r3, [r2]
  130. @ put SDRAM into self-refresh
  131. str r5, [r4]
  132. @ enter sleep mode
  133. mcr p14, 0, r1, c7, c0, 0 @ PWRMODE
  134. 20: b 20b @ loop waiting for sleep