sram34xx.S 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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. */
  40. ENTRY(omap3_sram_configure_core_dpll)
  41. stmfd sp!, {r1-r12, lr} @ store regs to stack
  42. dsb @ flush buffered writes to interconnect
  43. cmp r3, #0x2
  44. blne configure_sdrc
  45. cmp r3, #0x2
  46. blne lock_dll
  47. cmp r3, #0x1
  48. blne unlock_dll
  49. bl sdram_in_selfrefresh @ put the SDRAM in self refresh
  50. bl configure_core_dpll
  51. bl enable_sdrc
  52. cmp r3, #0x1
  53. blne wait_dll_unlock
  54. cmp r3, #0x2
  55. blne wait_dll_lock
  56. cmp r3, #0x1
  57. blne configure_sdrc
  58. isb @ prevent speculative exec past here
  59. mov r0, #0 @ return value
  60. ldmfd sp!, {r1-r12, pc} @ restore regs and return
  61. unlock_dll:
  62. ldr r11, omap3_sdrc_dlla_ctrl
  63. ldr r12, [r11]
  64. orr r12, r12, #0x4
  65. str r12, [r11] @ (no OCP barrier needed)
  66. bx lr
  67. lock_dll:
  68. ldr r11, omap3_sdrc_dlla_ctrl
  69. ldr r12, [r11]
  70. bic r12, r12, #0x4
  71. str r12, [r11] @ (no OCP barrier needed)
  72. bx lr
  73. sdram_in_selfrefresh:
  74. ldr r11, omap3_sdrc_power @ read the SDRC_POWER register
  75. ldr r12, [r11] @ read the contents of SDRC_POWER
  76. mov r9, r12 @ keep a copy of SDRC_POWER bits
  77. orr r12, r12, #0x40 @ enable self refresh on idle req
  78. bic r12, r12, #0x4 @ clear PWDENA
  79. str r12, [r11] @ write back to SDRC_POWER register
  80. ldr r12, [r11] @ posted-write barrier for SDRC
  81. ldr r11, omap3_cm_iclken1_core @ read the CM_ICLKEN1_CORE reg
  82. ldr r12, [r11]
  83. bic r12, r12, #0x2 @ disable iclk bit for SDRC
  84. str r12, [r11]
  85. wait_sdrc_idle:
  86. ldr r11, omap3_cm_idlest1_core
  87. ldr r12, [r11]
  88. and r12, r12, #0x2 @ check for SDRC idle
  89. cmp r12, #2
  90. bne wait_sdrc_idle
  91. bx lr
  92. configure_core_dpll:
  93. ldr r11, omap3_cm_clksel1_pll
  94. ldr r12, [r11]
  95. ldr r10, core_m2_mask_val @ modify m2 for core dpll
  96. and r12, r12, r10
  97. orr r12, r12, r3, lsl #0x1B @ r3 contains the M2 val
  98. str r12, [r11]
  99. ldr r12, [r11] @ posted-write barrier for CM
  100. mov r12, #0x800 @ wait for the clock to stabilise
  101. cmp r3, #2
  102. bne wait_clk_stable
  103. bx lr
  104. wait_clk_stable:
  105. subs r12, r12, #1
  106. bne wait_clk_stable
  107. nop
  108. nop
  109. nop
  110. nop
  111. nop
  112. nop
  113. nop
  114. nop
  115. nop
  116. nop
  117. bx lr
  118. enable_sdrc:
  119. ldr r11, omap3_cm_iclken1_core
  120. ldr r12, [r11]
  121. orr r12, r12, #0x2 @ enable iclk bit for SDRC
  122. str r12, [r11]
  123. wait_sdrc_idle1:
  124. ldr r11, omap3_cm_idlest1_core
  125. ldr r12, [r11]
  126. and r12, r12, #0x2
  127. cmp r12, #0
  128. bne wait_sdrc_idle1
  129. restore_sdrc_power_val:
  130. ldr r11, omap3_sdrc_power
  131. str r9, [r11] @ restore SDRC_POWER, no barrier needed
  132. bx lr
  133. wait_dll_lock:
  134. ldr r11, omap3_sdrc_dlla_status
  135. ldr r12, [r11]
  136. and r12, r12, #0x4
  137. cmp r12, #0x4
  138. bne wait_dll_lock
  139. bx lr
  140. wait_dll_unlock:
  141. ldr r11, omap3_sdrc_dlla_status
  142. ldr r12, [r11]
  143. and r12, r12, #0x4
  144. cmp r12, #0x0
  145. bne wait_dll_unlock
  146. bx lr
  147. configure_sdrc:
  148. ldr r11, omap3_sdrc_rfr_ctrl
  149. str r0, [r11]
  150. ldr r11, omap3_sdrc_actim_ctrla
  151. str r1, [r11]
  152. ldr r11, omap3_sdrc_actim_ctrlb
  153. str r2, [r11]
  154. ldr r2, [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_dlla_status:
  171. .word OMAP34XX_SDRC_REGADDR(SDRC_DLLA_STATUS)
  172. omap3_sdrc_dlla_ctrl:
  173. .word OMAP34XX_SDRC_REGADDR(SDRC_DLLA_CTRL)
  174. core_m2_mask_val:
  175. .word 0x07FFFFFF
  176. ENTRY(omap3_sram_configure_core_dpll_sz)
  177. .word . - omap3_sram_configure_core_dpll