sram34xx.S 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /*
  2. * linux/arch/arm/mach-omap3/sram.S
  3. *
  4. * Omap3 specific functions that need to be run in internal SRAM
  5. *
  6. * (C) Copyright 2007
  7. * Texas Instruments Inc.
  8. * Rajendra Nayak <rnayak@ti.com>
  9. *
  10. * (C) Copyright 2004
  11. * Texas Instruments, <www.ti.com>
  12. * Richard Woodruff <r-woodruff2@ti.com>
  13. *
  14. * This program is free software; you can redistribute it and/or
  15. * modify it under the terms of the GNU General Public License as
  16. * published by the Free Software Foundation; either version 2 of
  17. * the License, or (at your option) any later version.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
  22. * GNU General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU General Public License
  25. * along with this program; if not, write to the Free Software
  26. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  27. * MA 02111-1307 USA
  28. */
  29. #include <linux/linkage.h>
  30. #include <asm/assembler.h>
  31. #include <mach/hardware.h>
  32. #include <mach/io.h>
  33. #include "sdrc.h"
  34. #include "cm.h"
  35. .text
  36. /*
  37. * Change frequency of core dpll
  38. * r0 = sdrc_rfr_ctrl r1 = sdrc_actim_ctrla r2 = sdrc_actim_ctrlb r3 = M2
  39. * r4 = Unlock SDRC DLL? (1 = yes, 0 = no) -- only unlock DLL for
  40. * SDRC rates < 83MHz
  41. * r5 = number of MPU cycles to wait for SDRC to stabilize after
  42. * reprogramming the SDRC when switching to a slower MPU speed
  43. * r6 = SDRC_MR_0 register value
  44. *
  45. */
  46. ENTRY(omap3_sram_configure_core_dpll)
  47. stmfd sp!, {r1-r12, lr} @ store regs to stack
  48. ldr r4, [sp, #52] @ pull extra args off the stack
  49. ldr r5, [sp, #56] @ load extra args from the stack
  50. ldr r6, [sp, #60] @ load extra args from the stack
  51. dsb @ flush buffered writes to interconnect
  52. cmp r3, #0x2
  53. blne configure_sdrc
  54. cmp r4, #0x1
  55. bleq unlock_dll
  56. blne lock_dll
  57. bl sdram_in_selfrefresh @ put the SDRAM in self refresh
  58. bl configure_core_dpll
  59. bl enable_sdrc
  60. cmp r4, #0x1
  61. bleq wait_dll_unlock
  62. blne wait_dll_lock
  63. cmp r3, #0x1
  64. beq return_to_sdram
  65. bl configure_sdrc
  66. mov r12, r5 @ if slowing, wait for SDRC to stabilize
  67. bl wait_clk_stable
  68. return_to_sdram:
  69. isb @ prevent speculative exec past here
  70. mov r0, #0 @ return value
  71. ldmfd sp!, {r1-r12, pc} @ restore regs and return
  72. unlock_dll:
  73. ldr r11, omap3_sdrc_dlla_ctrl
  74. ldr r12, [r11]
  75. orr r12, r12, #0x4
  76. str r12, [r11] @ (no OCP barrier needed)
  77. bx lr
  78. lock_dll:
  79. ldr r11, omap3_sdrc_dlla_ctrl
  80. ldr r12, [r11]
  81. bic r12, r12, #0x4
  82. str r12, [r11] @ (no OCP barrier needed)
  83. bx lr
  84. sdram_in_selfrefresh:
  85. ldr r11, omap3_sdrc_power @ read the SDRC_POWER register
  86. ldr r12, [r11] @ read the contents of SDRC_POWER
  87. mov r9, r12 @ keep a copy of SDRC_POWER bits
  88. orr r12, r12, #0x40 @ enable self refresh on idle req
  89. bic r12, r12, #0x4 @ clear PWDENA
  90. str r12, [r11] @ write back to SDRC_POWER register
  91. ldr r12, [r11] @ posted-write barrier for SDRC
  92. ldr r11, omap3_cm_iclken1_core @ read the CM_ICLKEN1_CORE reg
  93. ldr r12, [r11]
  94. bic r12, r12, #0x2 @ disable iclk bit for SDRC
  95. str r12, [r11]
  96. wait_sdrc_idle:
  97. ldr r11, omap3_cm_idlest1_core
  98. ldr r12, [r11]
  99. and r12, r12, #0x2 @ check for SDRC idle
  100. cmp r12, #2
  101. bne wait_sdrc_idle
  102. bx lr
  103. configure_core_dpll:
  104. ldr r11, omap3_cm_clksel1_pll
  105. ldr r12, [r11]
  106. ldr r10, core_m2_mask_val @ modify m2 for core dpll
  107. and r12, r12, r10
  108. orr r12, r12, r3, lsl #0x1B @ r3 contains the M2 val
  109. str r12, [r11]
  110. ldr r12, [r11] @ posted-write barrier for CM
  111. bx lr
  112. wait_clk_stable:
  113. subs r12, r12, #1
  114. bne wait_clk_stable
  115. bx lr
  116. enable_sdrc:
  117. ldr r11, omap3_cm_iclken1_core
  118. ldr r12, [r11]
  119. orr r12, r12, #0x2 @ enable iclk bit for SDRC
  120. str r12, [r11]
  121. wait_sdrc_idle1:
  122. ldr r11, omap3_cm_idlest1_core
  123. ldr r12, [r11]
  124. and r12, r12, #0x2
  125. cmp r12, #0
  126. bne wait_sdrc_idle1
  127. restore_sdrc_power_val:
  128. ldr r11, omap3_sdrc_power
  129. str r9, [r11] @ restore SDRC_POWER, no barrier needed
  130. bx lr
  131. wait_dll_lock:
  132. ldr r11, omap3_sdrc_dlla_status
  133. ldr r12, [r11]
  134. and r12, r12, #0x4
  135. cmp r12, #0x4
  136. bne wait_dll_lock
  137. bx lr
  138. wait_dll_unlock:
  139. ldr r11, omap3_sdrc_dlla_status
  140. ldr r12, [r11]
  141. and r12, r12, #0x4
  142. cmp r12, #0x0
  143. bne wait_dll_unlock
  144. bx lr
  145. configure_sdrc:
  146. ldr r11, omap3_sdrc_rfr_ctrl
  147. str r0, [r11]
  148. ldr r11, omap3_sdrc_actim_ctrla
  149. str r1, [r11]
  150. ldr r11, omap3_sdrc_actim_ctrlb
  151. str r2, [r11]
  152. ldr r11, omap3_sdrc_mr_0
  153. str r6, [r11]
  154. ldr r6, [r11] @ posted-write barrier for SDRC
  155. bx lr
  156. omap3_sdrc_power:
  157. .word OMAP34XX_SDRC_REGADDR(SDRC_POWER)
  158. omap3_cm_clksel1_pll:
  159. .word OMAP34XX_CM_REGADDR(PLL_MOD, CM_CLKSEL1)
  160. omap3_cm_idlest1_core:
  161. .word OMAP34XX_CM_REGADDR(CORE_MOD, CM_IDLEST)
  162. omap3_cm_iclken1_core:
  163. .word OMAP34XX_CM_REGADDR(CORE_MOD, CM_ICLKEN1)
  164. omap3_sdrc_rfr_ctrl:
  165. .word OMAP34XX_SDRC_REGADDR(SDRC_RFR_CTRL_0)
  166. omap3_sdrc_actim_ctrla:
  167. .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_A_0)
  168. omap3_sdrc_actim_ctrlb:
  169. .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_B_0)
  170. omap3_sdrc_mr_0:
  171. .word OMAP34XX_SDRC_REGADDR(SDRC_MR_0)
  172. omap3_sdrc_dlla_status:
  173. .word OMAP34XX_SDRC_REGADDR(SDRC_DLLA_STATUS)
  174. omap3_sdrc_dlla_ctrl:
  175. .word OMAP34XX_SDRC_REGADDR(SDRC_DLLA_CTRL)
  176. core_m2_mask_val:
  177. .word 0x07FFFFFF
  178. ENTRY(omap3_sram_configure_core_dpll_sz)
  179. .word . - omap3_sram_configure_core_dpll