sleep.S 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * linux/arch/arm/mach-omap2/sleep.S
  3. *
  4. * (C) Copyright 2004
  5. * Texas Instruments, <www.ti.com>
  6. * Richard Woodruff <r-woodruff2@ti.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <linux/linkage.h>
  24. #include <asm/assembler.h>
  25. #include <mach/io.h>
  26. #include <mach/pm.h>
  27. #include "sdrc.h"
  28. /* First address of reserved address space? apparently valid for OMAP2 & 3 */
  29. #define A_SDRC0_V (0xC0000000)
  30. .text
  31. /*
  32. * Forces OMAP into idle state
  33. *
  34. * omap24xx_idle_loop_suspend() - This bit of code just executes the WFI
  35. * for normal idles.
  36. *
  37. * Note: This code get's copied to internal SRAM at boot. When the OMAP
  38. * wakes up it continues execution at the point it went to sleep.
  39. */
  40. ENTRY(omap24xx_idle_loop_suspend)
  41. stmfd sp!, {r0, lr} @ save registers on stack
  42. mov r0, #0 @ clear for mcr setup
  43. mcr p15, 0, r0, c7, c0, 4 @ wait for interrupt
  44. ldmfd sp!, {r0, pc} @ restore regs and return
  45. ENTRY(omap24xx_idle_loop_suspend_sz)
  46. .word . - omap24xx_idle_loop_suspend
  47. /*
  48. * omap242x_cpu_suspend() - Forces OMAP into deep sleep state by completing
  49. * SDRC shutdown then ARM shutdown. Upon wake MPU is back on so just restore
  50. * SDRC.
  51. *
  52. * Input:
  53. * R0 : DLL ctrl value pre-Sleep
  54. * R1 : Processor+Revision
  55. * 2420: 0x21 = 242xES1, 0x26 = 242xES2.2
  56. * 2430: 0x31 = 2430ES1, 0x32 = 2430ES2
  57. *
  58. * The if the DPLL is going to AutoIdle. It seems like the DPLL may be back on
  59. * when we get called, but the DLL probably isn't. We will wait a bit more in
  60. * case the DPLL isn't quite there yet. The code will wait on DLL for DDR even
  61. * if in unlocked mode.
  62. *
  63. * For less than 242x-ES2.2 upon wake from a sleep mode where the external
  64. * oscillator was stopped, a timing bug exists where a non-stabilized 12MHz
  65. * clock can pass into the PRCM can cause problems at DSP and IVA.
  66. * To work around this the code will switch to the 32kHz source prior to sleep.
  67. * Post sleep we will shift back to using the DPLL. Apparently,
  68. * CM_IDLEST_CLKGEN does not reflect the full clock change so you need to wait
  69. * 3x12MHz + 3x32kHz clocks for a full switch.
  70. *
  71. * The DLL load value is not kept in RETENTION or OFF. It needs to be restored
  72. * at wake
  73. */
  74. ENTRY(omap24xx_cpu_suspend)
  75. stmfd sp!, {r0 - r12, lr} @ save registers on stack
  76. mov r3, #0x0 @ clear for mrc call
  77. mcr p15, 0, r3, c7, c10, 4 @ memory barrier, hope SDR/DDR finished
  78. nop
  79. nop
  80. ldr r3, A_SDRC_POWER @ addr of sdrc power
  81. ldr r4, [r3] @ value of sdrc power
  82. orr r4, r4, #0x40 @ enable self refresh on idle req
  83. mov r5, #0x2000 @ set delay (DPLL relock + DLL relock)
  84. str r4, [r3] @ make it so
  85. mov r2, #0
  86. nop
  87. mcr p15, 0, r2, c7, c0, 4 @ wait for interrupt
  88. nop
  89. loop:
  90. subs r5, r5, #0x1 @ awake, wait just a bit
  91. bne loop
  92. /* The DPLL has on before we take the DDR out of self refresh */
  93. bic r4, r4, #0x40 @ now clear self refresh bit.
  94. str r4, [r3] @ put vlaue back.
  95. ldr r4, A_SDRC0 @ make a clock happen
  96. ldr r4, [r4]
  97. nop @ start auto refresh only after clk ok
  98. movs r0, r0 @ see if DDR or SDR
  99. ldrne r1, A_SDRC_DLLA_CTRL_S @ get addr of DLL ctrl
  100. strne r0, [r1] @ rewrite DLLA to force DLL reload
  101. addne r1, r1, #0x8 @ move to DLLB
  102. strne r0, [r1] @ rewrite DLLB to force DLL reload
  103. mov r5, #0x1000
  104. loop2:
  105. subs r5, r5, #0x1
  106. bne loop2
  107. /* resume*/
  108. ldmfd sp!, {r0 - r12, pc} @ restore regs and return
  109. A_SDRC_POWER:
  110. .word OMAP242X_SDRC_REGADDR(SDRC_POWER)
  111. A_SDRC0:
  112. .word A_SDRC0_V
  113. A_SDRC_DLLA_CTRL_S:
  114. .word OMAP242X_SDRC_REGADDR(SDRC_DLLA_CTRL)
  115. ENTRY(omap24xx_cpu_suspend_sz)
  116. .word . - omap24xx_cpu_suspend