sram34xx.S 5.6 KB

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