sram34xx.S 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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. */
  42. ENTRY(omap3_sram_configure_core_dpll)
  43. stmfd sp!, {r1-r12, lr} @ store regs to stack
  44. ldr r4, [sp, #52] @ pull extra args off the stack
  45. dsb @ flush buffered writes to interconnect
  46. cmp r3, #0x2
  47. blne configure_sdrc
  48. cmp r4, #0x1
  49. bleq unlock_dll
  50. blne lock_dll
  51. bl sdram_in_selfrefresh @ put the SDRAM in self refresh
  52. bl configure_core_dpll
  53. bl enable_sdrc
  54. cmp r4, #0x1
  55. bleq wait_dll_unlock
  56. blne wait_dll_lock
  57. cmp r3, #0x1
  58. blne configure_sdrc
  59. isb @ prevent speculative exec past here
  60. mov r0, #0 @ return value
  61. ldmfd sp!, {r1-r12, pc} @ restore regs and return
  62. unlock_dll:
  63. ldr r11, omap3_sdrc_dlla_ctrl
  64. ldr r12, [r11]
  65. orr r12, r12, #0x4
  66. str r12, [r11] @ (no OCP barrier needed)
  67. bx lr
  68. lock_dll:
  69. ldr r11, omap3_sdrc_dlla_ctrl
  70. ldr r12, [r11]
  71. bic r12, r12, #0x4
  72. str r12, [r11] @ (no OCP barrier needed)
  73. bx lr
  74. sdram_in_selfrefresh:
  75. ldr r11, omap3_sdrc_power @ read the SDRC_POWER register
  76. ldr r12, [r11] @ read the contents of SDRC_POWER
  77. mov r9, r12 @ keep a copy of SDRC_POWER bits
  78. orr r12, r12, #0x40 @ enable self refresh on idle req
  79. bic r12, r12, #0x4 @ clear PWDENA
  80. str r12, [r11] @ write back to SDRC_POWER register
  81. ldr r12, [r11] @ posted-write barrier for SDRC
  82. ldr r11, omap3_cm_iclken1_core @ read the CM_ICLKEN1_CORE reg
  83. ldr r12, [r11]
  84. bic r12, r12, #0x2 @ disable iclk bit for SDRC
  85. str r12, [r11]
  86. wait_sdrc_idle:
  87. ldr r11, omap3_cm_idlest1_core
  88. ldr r12, [r11]
  89. and r12, r12, #0x2 @ check for SDRC idle
  90. cmp r12, #2
  91. bne wait_sdrc_idle
  92. bx lr
  93. configure_core_dpll:
  94. ldr r11, omap3_cm_clksel1_pll
  95. ldr r12, [r11]
  96. ldr r10, core_m2_mask_val @ modify m2 for core dpll
  97. and r12, r12, r10
  98. orr r12, r12, r3, lsl #0x1B @ r3 contains the M2 val
  99. str r12, [r11]
  100. ldr r12, [r11] @ posted-write barrier for CM
  101. mov r12, #0x800 @ wait for the clock to stabilise
  102. cmp r3, #2
  103. bne wait_clk_stable
  104. bx lr
  105. wait_clk_stable:
  106. subs r12, r12, #1
  107. bne wait_clk_stable
  108. nop
  109. nop
  110. nop
  111. nop
  112. nop
  113. nop
  114. nop
  115. nop
  116. nop
  117. nop
  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 r2, [r11] @ posted-write barrier for SDRC
  156. bx lr
  157. omap3_sdrc_power:
  158. .word OMAP34XX_SDRC_REGADDR(SDRC_POWER)
  159. omap3_cm_clksel1_pll:
  160. .word OMAP34XX_CM_REGADDR(PLL_MOD, CM_CLKSEL1)
  161. omap3_cm_idlest1_core:
  162. .word OMAP34XX_CM_REGADDR(CORE_MOD, CM_IDLEST)
  163. omap3_cm_iclken1_core:
  164. .word OMAP34XX_CM_REGADDR(CORE_MOD, CM_ICLKEN1)
  165. omap3_sdrc_rfr_ctrl:
  166. .word OMAP34XX_SDRC_REGADDR(SDRC_RFR_CTRL_0)
  167. omap3_sdrc_actim_ctrla:
  168. .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_A_0)
  169. omap3_sdrc_actim_ctrlb:
  170. .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_B_0)
  171. omap3_sdrc_dlla_status:
  172. .word OMAP34XX_SDRC_REGADDR(SDRC_DLLA_STATUS)
  173. omap3_sdrc_dlla_ctrl:
  174. .word OMAP34XX_SDRC_REGADDR(SDRC_DLLA_CTRL)
  175. core_m2_mask_val:
  176. .word 0x07FFFFFF
  177. ENTRY(omap3_sram_configure_core_dpll_sz)
  178. .word . - omap3_sram_configure_core_dpll