sleep24xx.S 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /*
  3. * linux/arch/arm/mach-omap2/sleep.S
  4. *
  5. * (C) Copyright 2004
  6. * Texas Instruments, <www.ti.com>
  7. * Richard Woodruff <[email protected]>
  8. *
  9. * (C) Copyright 2006 Nokia Corporation
  10. * Fixed idle loop sleep
  11. * Igor Stoppa <[email protected]>
  12. */
  13. #include <linux/linkage.h>
  14. #include <asm/assembler.h>
  15. #include "omap24xx.h"
  16. #include "sdrc.h"
  17. /* First address of reserved address space? apparently valid for OMAP2 & 3 */
  18. #define A_SDRC0_V (0xC0000000)
  19. .text
  20. /*
  21. * omap24xx_cpu_suspend() - Forces OMAP into deep sleep state by completing
  22. * SDRC shutdown then ARM shutdown. Upon wake MPU is back on so just restore
  23. * SDRC.
  24. *
  25. * Input:
  26. * R0 : DLL ctrl value pre-Sleep
  27. * R1 : SDRC_DLLA_CTRL
  28. * R2 : SDRC_POWER
  29. *
  30. * The if the DPLL is going to AutoIdle. It seems like the DPLL may be back on
  31. * when we get called, but the DLL probably isn't. We will wait a bit more in
  32. * case the DPLL isn't quite there yet. The code will wait on DLL for DDR even
  33. * if in unlocked mode.
  34. *
  35. * For less than 242x-ES2.2 upon wake from a sleep mode where the external
  36. * oscillator was stopped, a timing bug exists where a non-stabilized 12MHz
  37. * clock can pass into the PRCM can cause problems at DSP and IVA.
  38. * To work around this the code will switch to the 32kHz source prior to sleep.
  39. * Post sleep we will shift back to using the DPLL. Apparently,
  40. * CM_IDLEST_CLKGEN does not reflect the full clock change so you need to wait
  41. * 3x12MHz + 3x32kHz clocks for a full switch.
  42. *
  43. * The DLL load value is not kept in RETENTION or OFF. It needs to be restored
  44. * at wake
  45. */
  46. .align 3
  47. ENTRY(omap24xx_cpu_suspend)
  48. stmfd sp!, {r0 - r12, lr} @ save registers on stack
  49. mov r3, #0x0 @ clear for mcr call
  50. mcr p15, 0, r3, c7, c10, 4 @ memory barrier, hope SDR/DDR finished
  51. nop
  52. nop
  53. ldr r4, [r2] @ read SDRC_POWER
  54. orr r4, r4, #0x40 @ enable self refresh on idle req
  55. mov r5, #0x2000 @ set delay (DPLL relock + DLL relock)
  56. str r4, [r2] @ make it so
  57. nop
  58. mcr p15, 0, r3, c7, c0, 4 @ wait for interrupt
  59. nop
  60. loop:
  61. subs r5, r5, #0x1 @ awake, wait just a bit
  62. bne loop
  63. /* The DPLL has to be on before we take the DDR out of self refresh */
  64. bic r4, r4, #0x40 @ now clear self refresh bit.
  65. str r4, [r2] @ write to SDRC_POWER
  66. ldr r4, A_SDRC0 @ make a clock happen
  67. ldr r4, [r4] @ read A_SDRC0
  68. nop @ start auto refresh only after clk ok
  69. movs r0, r0 @ see if DDR or SDR
  70. strne r0, [r1] @ rewrite DLLA to force DLL reload
  71. addne r1, r1, #0x8 @ move to DLLB
  72. strne r0, [r1] @ rewrite DLLB to force DLL reload
  73. mov r5, #0x1000
  74. loop2:
  75. subs r5, r5, #0x1
  76. bne loop2
  77. /* resume*/
  78. ldmfd sp!, {r0 - r12, pc} @ restore regs and return
  79. A_SDRC0:
  80. .word A_SDRC0_V
  81. ENTRY(omap24xx_cpu_suspend_sz)
  82. .word . - omap24xx_cpu_suspend