sleep24xx.S 3.4 KB

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