suspend-imx53.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * Copyright (C) 2008-2011 Freescale Semiconductor, Inc.
  3. */
  4. /*
  5. * The code contained herein is licensed under the GNU General Public
  6. * License. You may obtain a copy of the GNU General Public License
  7. * Version 2 or later at the following locations:
  8. *
  9. * http://www.opensource.org/licenses/gpl-license.html
  10. * http://www.gnu.org/copyleft/gpl.html
  11. */
  12. #include <linux/linkage.h>
  13. #define M4IF_MCR0_OFFSET (0x008C)
  14. #define M4IF_MCR0_FDVFS (0x1 << 11)
  15. #define M4IF_MCR0_FDVACK (0x1 << 27)
  16. .align 3
  17. /*
  18. * ==================== low level suspend ====================
  19. *
  20. * On entry
  21. * r0: pm_info structure address;
  22. *
  23. * suspend ocram space layout:
  24. * ======================== high address ======================
  25. * .
  26. * .
  27. * .
  28. * ^
  29. * ^
  30. * ^
  31. * imx53_suspend code
  32. * PM_INFO structure(imx53_suspend_info)
  33. * ======================== low address =======================
  34. */
  35. /* Offsets of members of struct imx53_suspend_info */
  36. #define SUSPEND_INFO_MX53_M4IF_V_OFFSET 0x0
  37. #define SUSPEND_INFO_MX53_IOMUXC_V_OFFSET 0x4
  38. #define SUSPEND_INFO_MX53_IO_COUNT_OFFSET 0x8
  39. #define SUSPEND_INFO_MX53_IO_STATE_OFFSET 0xc
  40. ENTRY(imx53_suspend)
  41. stmfd sp!, {r4,r5,r6,r7}
  42. /* Save pad config */
  43. ldr r1, [r0, #SUSPEND_INFO_MX53_IO_COUNT_OFFSET]
  44. cmp r1, #0
  45. beq skip_pad_conf_1
  46. add r2, r0, #SUSPEND_INFO_MX53_IO_STATE_OFFSET
  47. ldr r3, [r0, #SUSPEND_INFO_MX53_IOMUXC_V_OFFSET]
  48. 1:
  49. ldr r5, [r2], #12 /* IOMUXC register offset */
  50. ldr r6, [r3, r5] /* current value */
  51. str r6, [r2], #4 /* save area */
  52. subs r1, r1, #1
  53. bne 1b
  54. skip_pad_conf_1:
  55. /* Set FDVFS bit of M4IF_MCR0 to request DDR to enter self-refresh */
  56. ldr r1, [r0, #SUSPEND_INFO_MX53_M4IF_V_OFFSET]
  57. ldr r2,[r1, #M4IF_MCR0_OFFSET]
  58. orr r2, r2, #M4IF_MCR0_FDVFS
  59. str r2,[r1, #M4IF_MCR0_OFFSET]
  60. /* Poll FDVACK bit of M4IF_MCR to wait for DDR to enter self-refresh */
  61. wait_sr_ack:
  62. ldr r2,[r1, #M4IF_MCR0_OFFSET]
  63. ands r2, r2, #M4IF_MCR0_FDVACK
  64. beq wait_sr_ack
  65. /* Set pad config */
  66. ldr r1, [r0, #SUSPEND_INFO_MX53_IO_COUNT_OFFSET]
  67. cmp r1, #0
  68. beq skip_pad_conf_2
  69. add r2, r0, #SUSPEND_INFO_MX53_IO_STATE_OFFSET
  70. ldr r3, [r0, #SUSPEND_INFO_MX53_IOMUXC_V_OFFSET]
  71. 2:
  72. ldr r5, [r2], #4 /* IOMUXC register offset */
  73. ldr r6, [r2], #4 /* clear */
  74. ldr r7, [r3, r5]
  75. bic r7, r7, r6
  76. ldr r6, [r2], #8 /* set */
  77. orr r7, r7, r6
  78. str r7, [r3, r5]
  79. subs r1, r1, #1
  80. bne 2b
  81. skip_pad_conf_2:
  82. /* Zzz, enter stop mode */
  83. wfi
  84. nop
  85. nop
  86. nop
  87. nop
  88. /* Restore pad config */
  89. ldr r1, [r0, #SUSPEND_INFO_MX53_IO_COUNT_OFFSET]
  90. cmp r1, #0
  91. beq skip_pad_conf_3
  92. add r2, r0, #SUSPEND_INFO_MX53_IO_STATE_OFFSET
  93. ldr r3, [r0, #SUSPEND_INFO_MX53_IOMUXC_V_OFFSET]
  94. 3:
  95. ldr r5, [r2], #12 /* IOMUXC register offset */
  96. ldr r6, [r2], #4 /* saved value */
  97. str r6, [r3, r5]
  98. subs r1, r1, #1
  99. bne 3b
  100. skip_pad_conf_3:
  101. /* Clear FDVFS bit of M4IF_MCR0 to request DDR to exit self-refresh */
  102. ldr r1, [r0, #SUSPEND_INFO_MX53_M4IF_V_OFFSET]
  103. ldr r2,[r1, #M4IF_MCR0_OFFSET]
  104. bic r2, r2, #M4IF_MCR0_FDVFS
  105. str r2,[r1, #M4IF_MCR0_OFFSET]
  106. /* Poll FDVACK bit of M4IF_MCR to wait for DDR to exit self-refresh */
  107. wait_ar_ack:
  108. ldr r2,[r1, #M4IF_MCR0_OFFSET]
  109. ands r2, r2, #M4IF_MCR0_FDVACK
  110. bne wait_ar_ack
  111. /* Restore registers */
  112. ldmfd sp!, {r4,r5,r6,r7}
  113. mov pc, lr
  114. ENDPROC(imx53_suspend)
  115. ENTRY(imx53_suspend_sz)
  116. .word . - imx53_suspend