sram34xx.S 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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. cmp r3, #0x2
  43. blne configure_sdrc
  44. cmp r3, #0x2
  45. blne lock_dll
  46. cmp r3, #0x1
  47. blne unlock_dll
  48. bl sdram_in_selfrefresh @ put the SDRAM in self refresh
  49. bl configure_core_dpll
  50. bl enable_sdrc
  51. cmp r3, #0x1
  52. blne wait_dll_unlock
  53. cmp r3, #0x2
  54. blne wait_dll_lock
  55. cmp r3, #0x1
  56. blne configure_sdrc
  57. mov r0, #0 @ return value
  58. ldmfd sp!, {r1-r12, pc} @ restore regs and return
  59. unlock_dll:
  60. ldr r4, omap3_sdrc_dlla_ctrl
  61. ldr r5, [r4]
  62. orr r5, r5, #0x4
  63. str r5, [r4]
  64. bx lr
  65. lock_dll:
  66. ldr r4, omap3_sdrc_dlla_ctrl
  67. ldr r5, [r4]
  68. bic r5, r5, #0x4
  69. str r5, [r4]
  70. bx lr
  71. sdram_in_selfrefresh:
  72. mov r5, #0x0 @ Move 0 to R5
  73. mcr p15, 0, r5, c7, c10, 5 @ memory barrier
  74. ldr r4, omap3_sdrc_power @ read the SDRC_POWER register
  75. ldr r5, [r4] @ read the contents of SDRC_POWER
  76. orr r5, r5, #0x40 @ enable self refresh on idle req
  77. str r5, [r4] @ write back to SDRC_POWER register
  78. ldr r4, omap3_cm_iclken1_core @ read the CM_ICLKEN1_CORE reg
  79. ldr r5, [r4]
  80. bic r5, r5, #0x2 @ disable iclk bit for SRDC
  81. str r5, [r4]
  82. wait_sdrc_idle:
  83. ldr r4, omap3_cm_idlest1_core
  84. ldr r5, [r4]
  85. and r5, r5, #0x2 @ check for SDRC idle
  86. cmp r5, #2
  87. bne wait_sdrc_idle
  88. bx lr
  89. configure_core_dpll:
  90. ldr r4, omap3_cm_clksel1_pll
  91. ldr r5, [r4]
  92. ldr r6, core_m2_mask_val @ modify m2 for core dpll
  93. and r5, r5, r6
  94. orr r5, r5, r3, lsl #0x1B @ r3 contains the M2 val
  95. str r5, [r4]
  96. mov r5, #0x800 @ wait for the clock to stabilise
  97. cmp r3, #2
  98. bne wait_clk_stable
  99. bx lr
  100. wait_clk_stable:
  101. subs r5, r5, #1
  102. bne wait_clk_stable
  103. nop
  104. nop
  105. nop
  106. nop
  107. nop
  108. nop
  109. nop
  110. nop
  111. nop
  112. nop
  113. bx lr
  114. enable_sdrc:
  115. ldr r4, omap3_cm_iclken1_core
  116. ldr r5, [r4]
  117. orr r5, r5, #0x2 @ enable iclk bit for SDRC
  118. str r5, [r4]
  119. wait_sdrc_idle1:
  120. ldr r4, omap3_cm_idlest1_core
  121. ldr r5, [r4]
  122. and r5, r5, #0x2
  123. cmp r5, #0
  124. bne wait_sdrc_idle1
  125. ldr r4, omap3_sdrc_power
  126. ldr r5, [r4]
  127. bic r5, r5, #0x40
  128. str r5, [r4]
  129. bx lr
  130. wait_dll_lock:
  131. ldr r4, omap3_sdrc_dlla_status
  132. ldr r5, [r4]
  133. and r5, r5, #0x4
  134. cmp r5, #0x4
  135. bne wait_dll_lock
  136. bx lr
  137. wait_dll_unlock:
  138. ldr r4, omap3_sdrc_dlla_status
  139. ldr r5, [r4]
  140. and r5, r5, #0x4
  141. cmp r5, #0x0
  142. bne wait_dll_unlock
  143. bx lr
  144. configure_sdrc:
  145. ldr r4, omap3_sdrc_rfr_ctrl
  146. str r0, [r4]
  147. ldr r4, omap3_sdrc_actim_ctrla
  148. str r1, [r4]
  149. ldr r4, omap3_sdrc_actim_ctrlb
  150. str r2, [r4]
  151. bx lr
  152. omap3_sdrc_power:
  153. .word OMAP34XX_SDRC_REGADDR(SDRC_POWER)
  154. omap3_cm_clksel1_pll:
  155. .word OMAP34XX_CM_REGADDR(PLL_MOD, CM_CLKSEL1)
  156. omap3_cm_idlest1_core:
  157. .word OMAP34XX_CM_REGADDR(CORE_MOD, CM_IDLEST)
  158. omap3_cm_iclken1_core:
  159. .word OMAP34XX_CM_REGADDR(CORE_MOD, CM_ICLKEN1)
  160. omap3_sdrc_rfr_ctrl:
  161. .word OMAP34XX_SDRC_REGADDR(SDRC_RFR_CTRL_0)
  162. omap3_sdrc_actim_ctrla:
  163. .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_A_0)
  164. omap3_sdrc_actim_ctrlb:
  165. .word OMAP34XX_SDRC_REGADDR(SDRC_ACTIM_CTRL_B_0)
  166. omap3_sdrc_dlla_status:
  167. .word OMAP34XX_SDRC_REGADDR(SDRC_DLLA_STATUS)
  168. omap3_sdrc_dlla_ctrl:
  169. .word OMAP34XX_SDRC_REGADDR(SDRC_DLLA_CTRL)
  170. core_m2_mask_val:
  171. .word 0x07FFFFFF
  172. ENTRY(omap3_sram_configure_core_dpll_sz)
  173. .word . - omap3_sram_configure_core_dpll