lowlevel_init.S 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. /**************************************************************************
  34. * cpy_clk_code: relocates clock code into SRAM where its safer to execute
  35. * R1 = SRAM destination address.
  36. *************************************************************************/
  37. .global cpy_clk_code
  38. cpy_clk_code:
  39. /* Copy DPLL code into SRAM */
  40. adr r0, go_to_speed /* get addr of clock setting code */
  41. mov r2, #384 /* r2 size to copy (div by 32 bytes) */
  42. mov r1, r1 /* r1 <- dest address (passed in) */
  43. add r2, r2, r0 /* r2 <- source end address */
  44. next2:
  45. ldmia r0!, {r3-r10} /* copy from source address [r0] */
  46. stmia r1!, {r3-r10} /* copy to target address [r1] */
  47. cmp r0, r2 /* until source end address [r2] */
  48. bne next2
  49. mov pc, lr /* back to caller */
  50. /* ****************************************************************************
  51. * go_to_speed: -Moves to bypass, -Commits clock dividers, -puts dpll at speed
  52. * -executed from SRAM.
  53. * R0 = PRCM_CLKCFG_CTRL - addr of valid reg
  54. * R1 = CM_CLKEN_PLL - addr dpll ctlr reg
  55. * R2 = dpll value
  56. * R3 = CM_IDLEST_CKGEN - addr dpll lock wait
  57. ******************************************************************************/
  58. .global go_to_speed
  59. go_to_speed:
  60. sub sp, sp, #0x4 /* get some stack space */
  61. str r4, [sp] /* save r4's value */
  62. /* move into fast relock bypass */
  63. ldr r8, pll_ctl_add
  64. mov r4, #0x2
  65. str r4, [r8]
  66. ldr r4, pll_stat
  67. block:
  68. ldr r8, [r4] /* wait for bypass to take effect */
  69. and r8, r8, #0x3
  70. cmp r8, #0x1
  71. bne block
  72. /* set new dpll dividers _after_ in bypass */
  73. ldr r4, pll_div_add
  74. ldr r8, pll_div_val
  75. str r8, [r4]
  76. /* now prepare GPMC (flash) for new dpll speed */
  77. /* flash needs to be stable when we jump back to it */
  78. ldr r4, cfg3_0_addr
  79. ldr r8, cfg3_0_val
  80. str r8, [r4]
  81. ldr r4, cfg4_0_addr
  82. ldr r8, cfg4_0_val
  83. str r8, [r4]
  84. ldr r4, cfg1_0_addr
  85. ldr r8, [r4]
  86. orr r8, r8, #0x3 /* up gpmc divider */
  87. str r8, [r4]
  88. /* setup to 2x loop though code. The first loop pre-loads the
  89. * icache, the 2nd commits the prcm config, and locks the dpll
  90. */
  91. mov r4, #0x1000 /* spin spin spin */
  92. mov r8, #0x4 /* first pass condition & set registers */
  93. cmp r8, #0x4
  94. 2:
  95. ldrne r8, [r3] /* DPLL lock check */
  96. and r8, r8, #0x7
  97. cmp r8, #0x2
  98. beq 4f
  99. 3:
  100. subeq r8, r8, #0x1
  101. streq r8, [r0] /* commit dividers (2nd time) */
  102. nop
  103. lloop1:
  104. sub r4, r4, #0x1 /* Loop currently necessary else bad jumps */
  105. nop
  106. cmp r4, #0x0
  107. bne lloop1
  108. mov r4, #0x40000
  109. cmp r8, #0x1
  110. nop
  111. streq r2, [r1] /* lock dpll (2nd time) */
  112. nop
  113. lloop2:
  114. sub r4, r4, #0x1 /* loop currently necessary else bad jumps */
  115. nop
  116. cmp r4, #0x0
  117. bne lloop2
  118. mov r4, #0x40000
  119. cmp r8, #0x1
  120. nop
  121. ldreq r8, [r3] /* get lock condition for dpll */
  122. cmp r8, #0x4 /* first time though? */
  123. bne 2b
  124. moveq r8, #0x2 /* set to dpll check condition. */
  125. beq 3b /* if condition not true branch */
  126. 4:
  127. ldr r4, [sp]
  128. add sp, sp, #0x4 /* return stack space */
  129. mov pc, lr /* back to caller, locked */
  130. _go_to_speed: .word go_to_speed
  131. /* these constants need to be close for PIC code */
  132. cfg3_0_addr:
  133. .word GPMC_CONFIG3_0
  134. cfg3_0_val:
  135. .word H4_24XX_GPMC_CONFIG3_0
  136. cfg4_0_addr:
  137. .word GPMC_CONFIG4_0
  138. cfg4_0_val:
  139. .word H4_24XX_GPMC_CONFIG4_0
  140. cfg1_0_addr:
  141. .word GPMC_CONFIG1_0
  142. pll_ctl_add:
  143. .word CM_CLKEN_PLL
  144. pll_stat:
  145. .word CM_IDLEST_CKGEN
  146. pll_div_add:
  147. .word CM_CLKSEL1_PLL
  148. pll_div_val:
  149. .word DPLL_VAL /* DPLL setting (300MHz default) */
  150. .globl lowlevel_init
  151. lowlevel_init:
  152. ldr sp, SRAM_STACK
  153. str ip, [sp] /* stash old link register */
  154. mov ip, lr /* save link reg across call */
  155. bl s_init /* go setup pll,mux,memory */
  156. ldr ip, [sp] /* restore save ip */
  157. mov lr, ip /* restore link reg */
  158. /* map interrupt controller */
  159. ldr r0, VAL_INTH_SETUP
  160. mcr p15, 0, r0, c15, c2, 4
  161. /* back to arch calling code */
  162. mov pc, lr
  163. /* the literal pools origin */
  164. .ltorg
  165. REG_CONTROL_STATUS:
  166. .word CONTROL_STATUS
  167. VAL_INTH_SETUP:
  168. .word PERIFERAL_PORT_BASE
  169. SRAM_STACK:
  170. .word LOW_LEVEL_SRAM_STACK