lowlevel_init.S 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. /*
  2. * Copyright (C) 2007, Guennadi Liakhovetski <lg@denx.de>
  3. *
  4. * (C) Copyright 2009 Freescale Semiconductor, Inc.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License as
  8. * published by the Free Software Foundation; either version 2 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  19. * MA 02111-1307 USA
  20. */
  21. #include <config.h>
  22. #include <asm/arch/imx-regs.h>
  23. #include <asm/arch/asm-offsets.h>
  24. /*
  25. * L2CC Cache setup/invalidation/disable
  26. */
  27. .macro init_l2cc
  28. /* explicitly disable L2 cache */
  29. mrc 15, 0, r0, c1, c0, 1
  30. bic r0, r0, #0x2
  31. mcr 15, 0, r0, c1, c0, 1
  32. /* reconfigure L2 cache aux control reg */
  33. mov r0, #0xC0 /* tag RAM */
  34. add r0, r0, #0x4 /* data RAM */
  35. orr r0, r0, #(1 << 24) /* disable write allocate delay */
  36. orr r0, r0, #(1 << 23) /* disable write allocate combine */
  37. orr r0, r0, #(1 << 22) /* disable write allocate */
  38. cmp r3, #0x10 /* r3 contains the silicon rev */
  39. /* disable write combine for TO 2 and lower revs */
  40. orrls r0, r0, #(1 << 25)
  41. mcr 15, 1, r0, c9, c0, 2
  42. .endm /* init_l2cc */
  43. /* AIPS setup - Only setup MPROTx registers.
  44. * The PACR default values are good.*/
  45. .macro init_aips
  46. /*
  47. * Set all MPROTx to be non-bufferable, trusted for R/W,
  48. * not forced to user-mode.
  49. */
  50. ldr r0, =AIPS1_BASE_ADDR
  51. ldr r1, =0x77777777
  52. str r1, [r0, #0x0]
  53. str r1, [r0, #0x4]
  54. ldr r0, =AIPS2_BASE_ADDR
  55. str r1, [r0, #0x0]
  56. str r1, [r0, #0x4]
  57. /*
  58. * Clear the on and off peripheral modules Supervisor Protect bit
  59. * for SDMA to access them. Did not change the AIPS control registers
  60. * (offset 0x20) access type
  61. */
  62. .endm /* init_aips */
  63. /* M4IF setup */
  64. .macro init_m4if
  65. /* VPU and IPU given higher priority (0x4)
  66. * IPU accesses with ID=0x1 given highest priority (=0xA)
  67. */
  68. ldr r0, =M4IF_BASE_ADDR
  69. ldr r1, =0x00000203
  70. str r1, [r0, #0x40]
  71. ldr r1, =0x0
  72. str r1, [r0, #0x44]
  73. ldr r1, =0x00120125
  74. str r1, [r0, #0x9C]
  75. ldr r1, =0x001901A3
  76. str r1, [r0, #0x48]
  77. .endm /* init_m4if */
  78. .macro setup_pll pll, freq
  79. ldr r2, =\pll
  80. ldr r1, =0x00001232
  81. str r1, [r2, #PLL_DP_CTL] /* Set DPLL ON (set UPEN bit): BRMO=1 */
  82. mov r1, #0x2
  83. str r1, [r2, #PLL_DP_CONFIG] /* Enable auto-restart AREN bit */
  84. str r3, [r2, #PLL_DP_OP]
  85. str r3, [r2, #PLL_DP_HFS_OP]
  86. str r4, [r2, #PLL_DP_MFD]
  87. str r4, [r2, #PLL_DP_HFS_MFD]
  88. str r5, [r2, #PLL_DP_MFN]
  89. str r5, [r2, #PLL_DP_HFS_MFN]
  90. ldr r1, =0x00001232
  91. str r1, [r2, #PLL_DP_CTL]
  92. 1: ldr r1, [r2, #PLL_DP_CTL]
  93. ands r1, r1, #0x1
  94. beq 1b
  95. .endm
  96. .macro init_clock
  97. ldr r0, =CCM_BASE_ADDR
  98. /* Gate of clocks to the peripherals first */
  99. ldr r1, =0x3FFFFFFF
  100. str r1, [r0, #CLKCTL_CCGR0]
  101. ldr r1, =0x0
  102. str r1, [r0, #CLKCTL_CCGR1]
  103. str r1, [r0, #CLKCTL_CCGR2]
  104. str r1, [r0, #CLKCTL_CCGR3]
  105. ldr r1, =0x00030000
  106. str r1, [r0, #CLKCTL_CCGR4]
  107. ldr r1, =0x00FFF030
  108. str r1, [r0, #CLKCTL_CCGR5]
  109. ldr r1, =0x00000300
  110. str r1, [r0, #CLKCTL_CCGR6]
  111. /* Disable IPU and HSC dividers */
  112. mov r1, #0x60000
  113. str r1, [r0, #CLKCTL_CCDR]
  114. /* Make sure to switch the DDR away from PLL 1 */
  115. ldr r1, =0x19239145
  116. str r1, [r0, #CLKCTL_CBCDR]
  117. /* make sure divider effective */
  118. 1: ldr r1, [r0, #CLKCTL_CDHIPR]
  119. cmp r1, #0x0
  120. bne 1b
  121. /* Switch ARM to step clock */
  122. mov r1, #0x4
  123. str r1, [r0, #CLKCTL_CCSR]
  124. mov r3, #DP_OP_800
  125. mov r4, #DP_MFD_800
  126. mov r5, #DP_MFN_800
  127. setup_pll PLL1_BASE_ADDR
  128. mov r3, #DP_OP_665
  129. mov r4, #DP_MFD_665
  130. mov r5, #DP_MFN_665
  131. setup_pll PLL3_BASE_ADDR
  132. /* Switch peripheral to PLL 3 */
  133. ldr r0, =CCM_BASE_ADDR
  134. ldr r1, =0x000010C0
  135. str r1, [r0, #CLKCTL_CBCMR]
  136. ldr r1, =0x13239145
  137. str r1, [r0, #CLKCTL_CBCDR]
  138. mov r3, #DP_OP_665
  139. mov r4, #DP_MFD_665
  140. mov r5, #DP_MFN_665
  141. setup_pll PLL2_BASE_ADDR
  142. /* Switch peripheral to PLL2 */
  143. ldr r0, =CCM_BASE_ADDR
  144. ldr r1, =0x19239145
  145. str r1, [r0, #CLKCTL_CBCDR]
  146. ldr r1, =0x000020C0
  147. str r1, [r0, #CLKCTL_CBCMR]
  148. mov r3, #DP_OP_216
  149. mov r4, #DP_MFD_216
  150. mov r5, #DP_MFN_216
  151. setup_pll PLL3_BASE_ADDR
  152. /* Set the platform clock dividers */
  153. ldr r0, =ARM_BASE_ADDR
  154. ldr r1, =0x00000725
  155. str r1, [r0, #0x14]
  156. ldr r0, =CCM_BASE_ADDR
  157. /* Run 3.0 at Full speed, for other TO's wait till we increase VDDGP */
  158. ldr r1, =0x0
  159. ldr r3, [r1, #ROM_SI_REV]
  160. cmp r3, #0x10
  161. movls r1, #0x1
  162. movhi r1, #0
  163. str r1, [r0, #CLKCTL_CACRR]
  164. /* Switch ARM back to PLL 1 */
  165. mov r1, #0
  166. str r1, [r0, #CLKCTL_CCSR]
  167. /* setup the rest */
  168. /* Use lp_apm (24MHz) source for perclk */
  169. ldr r1, =0x000020C2
  170. str r1, [r0, #CLKCTL_CBCMR]
  171. /* ddr clock from PLL 1, all perclk dividers are 1 since using 24MHz */
  172. ldr r1, =0x59E35100
  173. str r1, [r0, #CLKCTL_CBCDR]
  174. /* Restore the default values in the Gate registers */
  175. ldr r1, =0xFFFFFFFF
  176. str r1, [r0, #CLKCTL_CCGR0]
  177. str r1, [r0, #CLKCTL_CCGR1]
  178. str r1, [r0, #CLKCTL_CCGR2]
  179. str r1, [r0, #CLKCTL_CCGR3]
  180. str r1, [r0, #CLKCTL_CCGR4]
  181. str r1, [r0, #CLKCTL_CCGR5]
  182. str r1, [r0, #CLKCTL_CCGR6]
  183. /* Use PLL 2 for UART's, get 66.5MHz from it */
  184. ldr r1, =0xA5A2A020
  185. str r1, [r0, #CLKCTL_CSCMR1]
  186. ldr r1, =0x00C30321
  187. str r1, [r0, #CLKCTL_CSCDR1]
  188. /* make sure divider effective */
  189. 1: ldr r1, [r0, #CLKCTL_CDHIPR]
  190. cmp r1, #0x0
  191. bne 1b
  192. mov r1, #0x0
  193. str r1, [r0, #CLKCTL_CCDR]
  194. /* for cko - for ARM div by 8 */
  195. mov r1, #0x000A0000
  196. add r1, r1, #0x00000F0
  197. str r1, [r0, #CLKCTL_CCOSR]
  198. .endm
  199. .macro setup_wdog
  200. ldr r0, =WDOG1_BASE_ADDR
  201. mov r1, #0x30
  202. strh r1, [r0]
  203. .endm
  204. .section ".text.init", "x"
  205. .globl lowlevel_init
  206. lowlevel_init:
  207. ldr r0, =GPIO1_BASE_ADDR
  208. ldr r1, [r0, #0x0]
  209. orr r1, r1, #(1 << 23)
  210. str r1, [r0, #0x0]
  211. ldr r1, [r0, #0x4]
  212. orr r1, r1, #(1 << 23)
  213. str r1, [r0, #0x4]
  214. #ifdef ENABLE_IMPRECISE_ABORT
  215. mrs r1, spsr /* save old spsr */
  216. mrs r0, cpsr /* read out the cpsr */
  217. bic r0, r0, #0x100 /* clear the A bit */
  218. msr spsr, r0 /* update spsr */
  219. add lr, pc, #0x8 /* update lr */
  220. movs pc, lr /* update cpsr */
  221. nop
  222. nop
  223. nop
  224. nop
  225. msr spsr, r1 /* restore old spsr */
  226. #endif
  227. init_l2cc
  228. init_aips
  229. init_m4if
  230. init_clock
  231. /* r12 saved upper lr*/
  232. mov pc,lr
  233. /* Board level setting value */
  234. DDR_PERCHARGE_CMD: .word 0x04008008
  235. DDR_REFRESH_CMD: .word 0x00008010
  236. DDR_LMR1_W: .word 0x00338018
  237. DDR_LMR_CMD: .word 0xB2220000
  238. DDR_TIMING_W: .word 0xB02567A9
  239. DDR_MISC_W: .word 0x000A0104