platform.S 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. /*
  2. * Board specific setup info
  3. *
  4. * (C) Copyright 2004
  5. * Texas Instruments, <www.ti.com>
  6. * Richard Woodruff <r-woodruff2@ti.com>
  7. *
  8. * See file CREDITS for list of people who contributed to this
  9. * project.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License as
  13. * published by the Free Software Foundation; either version 2 of
  14. * the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  24. * MA 02111-1307 USA
  25. */
  26. #include <config.h>
  27. #include <version.h>
  28. #include <asm/arch/omap2420.h>
  29. #include <asm/arch/mem.h>
  30. #include <asm/arch/clocks.h>
  31. _TEXT_BASE:
  32. .word TEXT_BASE /* sdram load addr from config.mk */
  33. #ifdef CONFIG_PARTIAL_SRAM
  34. /**************************************************************************
  35. * cpy_clk_code: relocates clock code into SRAM where its safer to execute
  36. * R1 = SRAM destination address.
  37. *************************************************************************/
  38. .global cpy_clk_code
  39. cpy_clk_code:
  40. /* Copy DPLL code into SRAM */
  41. adr r0, go_to_speed /* get addr of clock setting code */
  42. mov r2, #384 /* r2 size to copy (div by 32 bytes) */
  43. mov r1, r1 /* r1 <- dest address (passed in) */
  44. add r2, r2, r0 /* r2 <- source end address */
  45. next2:
  46. ldmia r0!, {r3-r10} /* copy from source address [r0] */
  47. stmia r1!, {r3-r10} /* copy to target address [r1] */
  48. cmp r0, r2 /* until source end address [r2] */
  49. bne next2
  50. mov pc, lr /* back to caller */
  51. /* ****************************************************************************
  52. * go_to_speed: -Moves to bypass, -Commits clock dividers, -puts dpll at speed
  53. * -executed from SRAM.
  54. * R0 = PRCM_CLKCFG_CTRL - addr of valid reg
  55. * R1 = CM_CLKEN_PLL - addr dpll ctlr reg
  56. * R2 = dpll value
  57. * R3 = CM_IDLEST_CKGEN - addr dpll lock wait
  58. ******************************************************************************/
  59. .global go_to_speed
  60. go_to_speed:
  61. sub sp, sp, #0x4 /* get some stack space */
  62. str r4, [sp] /* save r4's value */
  63. /* move into fast relock bypass */
  64. ldr r8, pll_ctl_add
  65. mov r4, #0x2
  66. str r4, [r8]
  67. ldr r4, pll_stat
  68. block:
  69. ldr r8, [r4] /* wait for bypass to take effect */
  70. and r8, r8, #0x3
  71. cmp r8, #0x1
  72. bne block
  73. /* set new dpll dividers _after_ in bypass */
  74. ldr r4, pll_div_add
  75. ldr r8, pll_div_val
  76. str r8, [r4]
  77. /* now prepare GPMC (flash) for new dpll speed */
  78. /* flash needs to be stable when we jump back to it */
  79. ldr r4, cfg3_0_addr
  80. ldr r8, cfg3_0_val
  81. str r8, [r4]
  82. ldr r4, cfg4_0_addr
  83. ldr r8, cfg4_0_val
  84. str r8, [r4]
  85. ldr r4, cfg1_0_addr
  86. ldr r8, [r4]
  87. orr r8, r8, #0x3 /* up gpmc divider */
  88. str r8, [r4]
  89. /* setup to 2x loop though code. The first loop pre-loads the
  90. * icache, the 2nd commits the prcm config, and locks the dpll
  91. */
  92. mov r4, #0x1000 /* spin spin spin */
  93. mov r8, #0x4 /* first pass condition & set registers */
  94. cmp r8, #0x4
  95. 2:
  96. ldrne r8, [r3] /* DPLL lock check */
  97. and r8, r8, #0x7
  98. cmp r8, #0x2
  99. beq 4f
  100. 3:
  101. subeq r8, r8, #0x1
  102. streq r8, [r0] /* commit dividers (2nd time) */
  103. nop
  104. lloop1:
  105. sub r4, r4, #0x1 /* Loop currently necessary else bad jumps */
  106. nop
  107. cmp r4, #0x0
  108. bne lloop1
  109. mov r4, #0x40000
  110. cmp r8, #0x1
  111. nop
  112. streq r2, [r1] /* lock dpll (2nd time) */
  113. nop
  114. lloop2:
  115. sub r4, r4, #0x1 /* loop currently necessary else bad jumps */
  116. nop
  117. cmp r4, #0x0
  118. bne lloop2
  119. mov r4, #0x40000
  120. cmp r8, #0x1
  121. nop
  122. ldreq r8, [r3] /* get lock condition for dpll */
  123. cmp r8, #0x4 /* first time though? */
  124. bne 2b
  125. moveq r8, #0x2 /* set to dpll check condition. */
  126. beq 3b /* if condition not true branch */
  127. 4:
  128. ldr r4, [sp]
  129. add sp, sp, #0x4 /* return stack space */
  130. mov pc, lr /* back to caller, locked */
  131. _go_to_speed: .word go_to_speed
  132. /* these constants need to be close for PIC code */
  133. cfg3_0_addr:
  134. .word GPMC_CONFIG3_0
  135. cfg3_0_val:
  136. .word H4_24XX_GPMC_CONFIG3_0
  137. cfg4_0_addr:
  138. .word GPMC_CONFIG4_0
  139. cfg4_0_val:
  140. .word H4_24XX_GPMC_CONFIG4_0
  141. cfg1_0_addr:
  142. .word GPMC_CONFIG1_0
  143. pll_ctl_add:
  144. .word CM_CLKEN_PLL
  145. pll_stat:
  146. .word CM_IDLEST_CKGEN
  147. pll_div_add:
  148. .word CM_CLKSEL1_PLL
  149. pll_div_val:
  150. .word DPLL_VAL /* DPLL setting (300MHz default) */
  151. #endif
  152. .globl platformsetup
  153. platformsetup:
  154. mov r3, r0 /* save skip information */
  155. #ifdef CONFIG_APTIX
  156. ldr r0, REG_SDRC_MCFG_0
  157. ldr r1, VAL_SDRC_MCFG_0
  158. str r1, [r0]
  159. ldr r0, REG_SDRC_MR_0
  160. ldr r1, VAL_SDRC_MR_0
  161. str r1, [r0]
  162. /* a ddr needs emr1 set here */
  163. ldr r0, REG_SDRC_SHARING
  164. ldr r1, VAL_SDRC_SHARING
  165. str r1, [r0]
  166. ldr r0, REG_SDRC_RFR_CTRL_0
  167. ldr r1, VAL_SDRC_RFR_CTRL_0
  168. str r1, [r0]
  169. /* little delay after init */
  170. mov r2, #0x1800
  171. 1:
  172. subs r2, r2, #0x1
  173. bne 1b
  174. #endif
  175. #ifdef CONFIG_PARTIAL_SRAM
  176. ldr sp, SRAM_STACK
  177. str ip, [sp] /* stash old link register */
  178. mov ip, lr /* save link reg across call */
  179. mov r0, r3 /* pass skip info to s_init */
  180. bl s_init /* go setup pll,mux,memory */
  181. ldr ip, [sp] /* restore save ip */
  182. mov lr, ip /* restore link reg */
  183. #endif
  184. /* map interrupt controller */
  185. ldr r0, VAL_INTH_SETUP
  186. mcr p15, 0, r0, c15, c2, 4
  187. /* back to arch calling code */
  188. mov pc, lr
  189. /* the literal pools origin */
  190. .ltorg
  191. REG_CONTROL_STATUS:
  192. .word CONTROL_STATUS
  193. VAL_INTH_SETUP:
  194. .word PERIFERAL_PORT_BASE
  195. SRAM_STACK:
  196. .word LOW_LEVEL_SRAM_STACK
  197. #ifdef CONFIG_APTIX
  198. REG_SDRC_SHARING:
  199. .word SDRC_SHARING
  200. REG_SDRC_MCFG_0:
  201. .word SDRC_MCFG_0
  202. REG_SDRC_MR_0:
  203. .word SDRC_MR_0
  204. REG_SDRC_RFR_CTRL_0:
  205. .word SDRC_RFR_CTRL
  206. VAL_SDRC_SHARING:
  207. .word VAL_H4_SDRC_SHARING
  208. VAL_SDRC_MCFG_0:
  209. .word VAL_H4_SDRC_MCFG_0
  210. VAL_SDRC_MR_0:
  211. .word VAL_H4_SDRC_MR_0
  212. VAL_SDRC_RFR_CTRL_0:
  213. .word VAL_H4_SDRC_RFR_CTRL_0
  214. #endif