lowlevel_init.S 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. #ifdef CONFIG_MX51
  66. /* VPU and IPU given higher priority (0x4)
  67. * IPU accesses with ID=0x1 given highest priority (=0xA)
  68. */
  69. ldr r0, =M4IF_BASE_ADDR
  70. ldr r1, =0x00000203
  71. str r1, [r0, #0x40]
  72. ldr r1, =0x0
  73. str r1, [r0, #0x44]
  74. ldr r1, =0x00120125
  75. str r1, [r0, #0x9C]
  76. ldr r1, =0x001901A3
  77. str r1, [r0, #0x48]
  78. #endif
  79. .endm /* init_m4if */
  80. .macro setup_pll pll, freq
  81. ldr r0, =\pll
  82. ldr r1, =0x00001232
  83. str r1, [r0, #PLL_DP_CTL] /* Set DPLL ON (set UPEN bit): BRMO=1 */
  84. mov r1, #0x2
  85. str r1, [r0, #PLL_DP_CONFIG] /* Enable auto-restart AREN bit */
  86. ldr r1, W_DP_OP_\freq
  87. str r1, [r0, #PLL_DP_OP]
  88. str r1, [r0, #PLL_DP_HFS_OP]
  89. ldr r1, W_DP_MFD_\freq
  90. str r1, [r0, #PLL_DP_MFD]
  91. str r1, [r0, #PLL_DP_HFS_MFD]
  92. ldr r1, W_DP_MFN_\freq
  93. str r1, [r0, #PLL_DP_MFN]
  94. str r1, [r0, #PLL_DP_HFS_MFN]
  95. ldr r1, =0x00001232
  96. str r1, [r0, #PLL_DP_CTL]
  97. 1: ldr r1, [r0, #PLL_DP_CTL]
  98. ands r1, r1, #0x1
  99. beq 1b
  100. .endm
  101. .macro init_clock
  102. ldr r0, =CCM_BASE_ADDR
  103. #if defined(CONFIG_MX51)
  104. /* Gate of clocks to the peripherals first */
  105. ldr r1, =0x3FFFFFFF
  106. str r1, [r0, #CLKCTL_CCGR0]
  107. ldr r1, =0x0
  108. str r1, [r0, #CLKCTL_CCGR1]
  109. str r1, [r0, #CLKCTL_CCGR2]
  110. str r1, [r0, #CLKCTL_CCGR3]
  111. ldr r1, =0x00030000
  112. str r1, [r0, #CLKCTL_CCGR4]
  113. ldr r1, =0x00FFF030
  114. str r1, [r0, #CLKCTL_CCGR5]
  115. ldr r1, =0x00000300
  116. str r1, [r0, #CLKCTL_CCGR6]
  117. /* Disable IPU and HSC dividers */
  118. mov r1, #0x60000
  119. str r1, [r0, #CLKCTL_CCDR]
  120. /* Make sure to switch the DDR away from PLL 1 */
  121. ldr r1, =0x19239145
  122. str r1, [r0, #CLKCTL_CBCDR]
  123. /* make sure divider effective */
  124. 1: ldr r1, [r0, #CLKCTL_CDHIPR]
  125. cmp r1, #0x0
  126. bne 1b
  127. #endif
  128. /* Switch ARM to step clock */
  129. mov r1, #0x4
  130. str r1, [r0, #CLKCTL_CCSR]
  131. setup_pll PLL1_BASE_ADDR, 800
  132. #if defined(CONFIG_MX51)
  133. setup_pll PLL3_BASE_ADDR, 665
  134. /* Switch peripheral to PLL 3 */
  135. ldr r0, =CCM_BASE_ADDR
  136. ldr r1, =0x000010C0
  137. orr r1,r1,#CONFIG_SYS_DDR_CLKSEL
  138. str r1, [r0, #CLKCTL_CBCMR]
  139. ldr r1, =0x13239145
  140. str r1, [r0, #CLKCTL_CBCDR]
  141. setup_pll PLL2_BASE_ADDR, 665
  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. orr r1,r1,#CONFIG_SYS_DDR_CLKSEL
  148. str r1, [r0, #CLKCTL_CBCMR]
  149. #endif
  150. setup_pll PLL3_BASE_ADDR, 216
  151. /* Set the platform clock dividers */
  152. ldr r0, =ARM_BASE_ADDR
  153. ldr r1, =0x00000725
  154. str r1, [r0, #0x14]
  155. ldr r0, =CCM_BASE_ADDR
  156. #if defined(CONFIG_MX51)
  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. #else
  164. mov r1, #0
  165. #endif
  166. str r1, [r0, #CLKCTL_CACRR]
  167. /* Switch ARM back to PLL 1 */
  168. mov r1, #0
  169. str r1, [r0, #CLKCTL_CCSR]
  170. #if defined(CONFIG_MX51)
  171. /* setup the rest */
  172. /* Use lp_apm (24MHz) source for perclk */
  173. ldr r1, =0x000020C2
  174. orr r1,r1,#CONFIG_SYS_DDR_CLKSEL
  175. str r1, [r0, #CLKCTL_CBCMR]
  176. /* ddr clock from PLL 1, all perclk dividers are 1 since using 24MHz */
  177. ldr r1, =CONFIG_SYS_CLKTL_CBCDR
  178. str r1, [r0, #CLKCTL_CBCDR]
  179. #endif
  180. /* Restore the default values in the Gate registers */
  181. ldr r1, =0xFFFFFFFF
  182. str r1, [r0, #CLKCTL_CCGR0]
  183. str r1, [r0, #CLKCTL_CCGR1]
  184. str r1, [r0, #CLKCTL_CCGR2]
  185. str r1, [r0, #CLKCTL_CCGR3]
  186. str r1, [r0, #CLKCTL_CCGR4]
  187. str r1, [r0, #CLKCTL_CCGR5]
  188. str r1, [r0, #CLKCTL_CCGR6]
  189. #if defined(CONFIG_MX53)
  190. str r1, [r0, #CLKCTL_CCGR7]
  191. #endif
  192. #if defined(CONFIG_MX51)
  193. /* Use PLL 2 for UART's, get 66.5MHz from it */
  194. ldr r1, =0xA5A2A020
  195. str r1, [r0, #CLKCTL_CSCMR1]
  196. ldr r1, =0x00C30321
  197. str r1, [r0, #CLKCTL_CSCDR1]
  198. #elif defined(CONFIG_MX53)
  199. ldr r1, [r0, #CLKCTL_CSCDR1]
  200. orr r1, r1, #0x3f
  201. eor r1, r1, #0x3f
  202. orr r1, r1, #0x21
  203. str r1, [r0, #CLKCTL_CSCDR1]
  204. #endif
  205. /* make sure divider effective */
  206. 1: ldr r1, [r0, #CLKCTL_CDHIPR]
  207. cmp r1, #0x0
  208. bne 1b
  209. mov r1, #0x0
  210. str r1, [r0, #CLKCTL_CCDR]
  211. /* for cko - for ARM div by 8 */
  212. mov r1, #0x000A0000
  213. add r1, r1, #0x00000F0
  214. str r1, [r0, #CLKCTL_CCOSR]
  215. .endm
  216. .macro setup_wdog
  217. ldr r0, =WDOG1_BASE_ADDR
  218. mov r1, #0x30
  219. strh r1, [r0]
  220. .endm
  221. .section ".text.init", "x"
  222. .globl lowlevel_init
  223. lowlevel_init:
  224. #if defined(CONFIG_MX51)
  225. ldr r0, =GPIO1_BASE_ADDR
  226. ldr r1, [r0, #0x0]
  227. orr r1, r1, #(1 << 23)
  228. str r1, [r0, #0x0]
  229. ldr r1, [r0, #0x4]
  230. orr r1, r1, #(1 << 23)
  231. str r1, [r0, #0x4]
  232. #endif
  233. init_l2cc
  234. init_aips
  235. init_m4if
  236. init_clock
  237. /* r12 saved upper lr*/
  238. mov pc,lr
  239. /* Board level setting value */
  240. W_DP_OP_800: .word DP_OP_800
  241. W_DP_MFD_800: .word DP_MFD_800
  242. W_DP_MFN_800: .word DP_MFN_800
  243. W_DP_OP_665: .word DP_OP_665
  244. W_DP_MFD_665: .word DP_MFD_665
  245. W_DP_MFN_665: .word DP_MFN_665
  246. W_DP_OP_216: .word DP_OP_216
  247. W_DP_MFD_216: .word DP_MFD_216
  248. W_DP_MFN_216: .word DP_MFN_216