setup.S 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  1. /*
  2. * Board specific setup info
  3. *
  4. * (C) Copyright 2004 Ales Jindra <jindra@2n.cz>
  5. * (C) Copyright 2005 Ladislav Michl <michl@2n.cz>
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <config.h>
  26. #include <version.h>
  27. _TEXT_BASE:
  28. .word TEXT_BASE /* SDRAM load addr from config.mk */
  29. OMAP5910_LPG1_BASE: .word 0xfffbd000
  30. OMAP5910_TIPB_SWITCHES_BASE: .word 0xfffbc800
  31. OMAP5910_MPU_TC_BASE: .word 0xfffecc00
  32. OMAP5910_MPU_CLKM_BASE: .word 0xfffece00
  33. OMAP5910_ULPD_PWR_MNG_BASE: .word 0xfffe0800
  34. OMAP5910_DPLL1_BASE: .word 0xfffecf00
  35. OMAP5910_GPIO_BASE: .word 0xfffce000
  36. OMAP5910_MPU_WD_TIMER_BASE: .word 0xfffec800
  37. OMAP5910_MPUI_BASE: .word 0xfffec900
  38. _OMAP5910_ARM_CKCTL: .word OMAP5910_ARM_CKCTL
  39. _OMAP5910_ARM_EN_CLK: .word OMAP5910_ARM_EN_CLK
  40. OMAP5910_MPUI_CTRL: .word 0x0000ff1b
  41. VAL_EMIFS_CS0_CONFIG: .word 0x00009090
  42. VAL_EMIFS_CS1_CONFIG: .word 0x00003031
  43. VAL_EMIFS_CS2_CONFIG: .word 0x0000a0a1
  44. VAL_EMIFS_CS3_CONFIG: .word 0x0000c0c0
  45. VAL_EMIFS_DYN_WAIT: .word 0x00000000
  46. /* autorefresh counter 0x246 ((64000000/13.4)-400)/8192) */
  47. /* SLRF SD_RET ARE SDRAM_TYPE ARCV SDRAM_FREQUENCY PWD CLK */
  48. #if (PHYS_SDRAM_1_SIZE == SZ_32M)
  49. VAL_EMIFF_SDRAM_CONFIG: .word ((0 << 0) | (0 << 1) | (3 << 2) | (0xf << 4) | (0x246 << 8) | (0 << 24) | (0 << 26) | (0 << 27))
  50. #else
  51. VAL_EMIFF_SDRAM_CONFIG: .word ((0 << 0) | (0 << 1) | (3 << 2) | (0xd << 4) | (0x246 << 8) | (0 << 24) | (0 << 26) | (0 << 27))
  52. #endif
  53. VAL_EMIFF_SDRAM_CONFIG2: .word 0x00000003
  54. VAL_EMIFF_MRS: .word 0x00000037
  55. /*
  56. * GPIO04 - Green LED (Red LED is connected to LED Pulse Generator)
  57. * GPIO07 - LAN91C111 reset
  58. */
  59. GPIO_DIRECTION:
  60. .word 0x0000ff6f
  61. /*
  62. * Disable everything (green LED is connected via invertor)
  63. */
  64. GPIO_OUTPUT:
  65. .word 0x00000010
  66. MUX_CONFIG_BASE:
  67. .word 0xfffe1000
  68. MUX_CONFIG_VALUES:
  69. .align 4
  70. .word 0x00000000 @ FUNC_MUX_CTRL_0
  71. .word 0x00000000 @ FUNC_MUX_CTRL_1
  72. .word 0x00000000 @ FUNC_MUX_CTRL_2
  73. .word 0x00000000 @ FUNC_MUX_CTRL_3
  74. .word 0x00000000 @ FUNC_MUX_CTRL_4
  75. .word 0x02080480 @ FUNC_MUX_CTRL_5
  76. .word 0x0100001c @ FUNC_MUX_CTRL_6
  77. .word 0x0004800b @ FUNC_MUX_CTRL_7
  78. .word 0x10001200 @ FUNC_MUX_CTRL_8
  79. .word 0x01201012 @ FUNC_MUX_CTRL_9
  80. .word 0x02082248 @ FUNC_MUX_CTRL_A
  81. .word 0x00000248 @ FUNC_MUX_CTRL_B
  82. .word 0x12240000 @ FUNC_MUX_CTRL_C
  83. .word 0x00002000 @ FUNC_MUX_CTRL_D
  84. .word 0x00000000 @ PULL_DWN_CTRL_0
  85. .word 0x00000800 @ PULL_DWN_CTRL_1
  86. .word 0x01801000 @ PULL_DWN_CTRL_2
  87. .word 0x00000000 @ PULL_DWN_CTRL_3
  88. .word 0x00000000 @ GATE_INH_CTRL_0
  89. .word 0x00000000 @ VOLTAGE_CTRL_0
  90. .word 0x00000000 @ TEST_DBG_CTRL_0
  91. .word 0x00000006 @ MOD_CONF_CTRL_0
  92. .word 0x0000eaef @ COMP_MODE_CTRL_0
  93. MUX_CONFIG_OFFSETS:
  94. .align 1
  95. .byte 0x00 @ FUNC_MUX_CTRL_0
  96. .byte 0x04 @ FUNC_MUX_CTRL_1
  97. .byte 0x08 @ FUNC_MUX_CTRL_2
  98. .byte 0x10 @ FUNC_MUX_CTRL_3
  99. .byte 0x14 @ FUNC_MUX_CTRL_4
  100. .byte 0x18 @ FUNC_MUX_CTRL_5
  101. .byte 0x1c @ FUNC_MUX_CTRL_6
  102. .byte 0x20 @ FUNC_MUX_CTRL_7
  103. .byte 0x24 @ FUNC_MUX_CTRL_8
  104. .byte 0x28 @ FUNC_MUX_CTRL_9
  105. .byte 0x2c @ FUNC_MUX_CTRL_A
  106. .byte 0x30 @ FUNC_MUX_CTRL_B
  107. .byte 0x34 @ FUNC_MUX_CTRL_C
  108. .byte 0x38 @ FUNC_MUX_CTRL_D
  109. .byte 0x40 @ PULL_DWN_CTRL_0
  110. .byte 0x44 @ PULL_DWN_CTRL_1
  111. .byte 0x48 @ PULL_DWN_CTRL_2
  112. .byte 0x4c @ PULL_DWN_CTRL_3
  113. .byte 0x50 @ GATE_INH_CTRL_0
  114. .byte 0x60 @ VOLTAGE_CTRL_0
  115. .byte 0x70 @ TEST_DBG_CTRL_0
  116. .byte 0x80 @ MOD_CONF_CTRL_0
  117. .byte 0x0c @ COMP_MODE_CTRL_0
  118. .byte 0xff
  119. .globl lowlevel_init
  120. lowlevel_init:
  121. /* Improve performance a bit... */
  122. mrc p15, 0, r1, c0, c0, 0 @ read C15 ID register
  123. mrc p15, 0, r1, c0, c0, 1 @ read C15 Cache information register
  124. mrc p15, 0, r1, c1, c0, 0 @ read C15 Control register
  125. orr r1, r1, #0x1000 @ enable I-cache, map interrupt vector 0xffff0000
  126. mcr p15, 0, r1, c1, c0, 0 @ write C15 Control register
  127. mov r1, #0x00
  128. mcr p15, 0, r1, c7, c5, 0 @ Flush I-cache
  129. nop
  130. nop
  131. nop
  132. nop
  133. /* Setup clocking mode */
  134. ldr r0, OMAP5910_MPU_CLKM_BASE @ base of CLOCK unit
  135. ldrh r1, [r0, #0x18] @ ARM_SYST - get reset status
  136. bic r1, r1, #(7 << 11) @ clear clock select
  137. orr r1, r1, #(2 << 11) @ set synchronous scalable
  138. mov r2, #0
  139. loop:
  140. cmp r2, #1 @ this loop will wait for at least 100 cycles
  141. streqh r1, [r0, #0x18] @ before issuing next request from MPU
  142. add r2, r2, #1 @ on the 1st run code is loaded into I-cache
  143. cmp r2, #16 @ and second run will set clocking mode
  144. bne loop
  145. nop
  146. /* Setup clock dividers */
  147. ldr r1, _OMAP5910_ARM_CKCTL
  148. orr r1, r1, #0x2000 @ enable DSP clock
  149. strh r1, [r0] @ setup clock divisors
  150. /* Setup DPLL to generate requested freq */
  151. ldr r0, OMAP5910_DPLL1_BASE @ base of DPLL1 register
  152. mov r1, #0x0010 @ set PLL_ENABLE
  153. orr r1, r1, #0x2000 @ set IOB to new locking
  154. orr r1, r1, #(OMAP5910_DPLL_MUL << 7) @ setup multiplier CLKREF
  155. orr r1, r1, #(OMAP5910_DPLL_DIV << 5) @ setup divider CLKREF
  156. strh r1, [r0] @ write
  157. locking:
  158. ldrh r1, [r0] @ get DPLL value
  159. tst r1, #0x01
  160. beq locking @ while LOCK not set
  161. /* Enable clock */
  162. ldr r0, OMAP5910_MPU_CLKM_BASE @ base of CLOCK unit
  163. mov r1, #(1 << 10) @ disable idle mode do not check
  164. @ nWAKEUP pin, other remain active
  165. strh r1, [r0, #0x04]
  166. ldr r1, _OMAP5910_ARM_EN_CLK
  167. strh r1, [r0, #0x08]
  168. mov r1, #0x003f @ FLASH.RP not enabled in idle and
  169. strh r1, [r0, #0x0c] @ max delayed ( 32 x CLKIN )
  170. /* Configure 5910 pins functions to match our board. */
  171. ldr r0, MUX_CONFIG_BASE
  172. adr r1, MUX_CONFIG_VALUES
  173. adr r2, MUX_CONFIG_OFFSETS
  174. next_mux_cfg:
  175. ldrb r3, [r2], #1
  176. ldr r4, [r1], #4
  177. cmp r3, #0xff
  178. strne r4, [r0, r3]
  179. bne next_mux_cfg
  180. /* Configure GPIO pins (also disables Green LED) */
  181. ldr r0, OMAP5910_GPIO_BASE
  182. ldr r1, GPIO_OUTPUT
  183. strh r1, [r0, #0x04]
  184. ldr r1, GPIO_DIRECTION
  185. strh r1, [r0, #0x08]
  186. /* EnablePeripherals */
  187. ldr r0, OMAP5910_MPU_CLKM_BASE @ CLOCK unit
  188. mov r1, #0x0001 @ Peripheral enable
  189. strh r1, [r0, #0x14]
  190. /* Program LED Pulse Generator */
  191. ldr r0, OMAP5910_LPG1_BASE @ 1st LED Pulse Generator
  192. mov r1, #0x7F @ Set obscure frequency in
  193. strb r1, [r0, #0x00] @ LCR
  194. mov r1, #0x01 @ Enable clock (CLK_EN) in
  195. strb r1, [r0, #0x04] @ PMR
  196. /* TIPB Lock UART1 */
  197. ldr r0, OMAP5910_TIPB_SWITCHES_BASE @ prepare base of TIPB switches
  198. mov r1, #1 @ ARM allocated
  199. strh r1, [r0,#0x04] @ clear IRQ line and status bits
  200. strh r1, [r0,#0x00]
  201. ldrh r1, [r0,#0x04]
  202. /* Disable watchdog */
  203. ldr r0, OMAP5910_MPU_WD_TIMER_BASE
  204. mov r1, #0xf5
  205. strh r1, [r0, #0x8]
  206. mov r1, #0xa0
  207. strh r1, [r0, #0x8]
  208. /* Enable MCLK */
  209. ldr r0, OMAP5910_ULPD_PWR_MNG_BASE
  210. mov r1, #0x6
  211. strh r1, [r0, #0x34]
  212. strh r1, [r0, #0x34]
  213. /* Setup clock divisors */
  214. ldr r0, OMAP5910_ULPD_PWR_MNG_BASE @ base of ULDPL DPLL1 register
  215. mov r1, #0x0010 @ set PLL_ENABLE
  216. orr r1, r1, #0x2000 @ set IOB to new locking
  217. strh r1, [r0] @ write
  218. ulocking:
  219. ldrh r1, [r0] @ get DPLL value
  220. tst r1, #1
  221. beq ulocking @ while LOCK not set
  222. /* EMIF init */
  223. ldr r0, OMAP5910_MPU_TC_BASE
  224. ldrh r1, [r0, #0x0c] @ EMIFS_CONFIG_REG
  225. bic r1, r1, #0x0c @ pwr down disabled, flash WP
  226. orr r1, r1, #0x01
  227. str r1, [r0, #0x0c]
  228. ldr r1, VAL_EMIFS_CS0_CONFIG
  229. str r1, [r0, #0x10] @ EMIFS_CS0_CONFIG
  230. ldr r1, VAL_EMIFS_CS1_CONFIG
  231. str r1, [r0, #0x14] @ EMIFS_CS1_CONFIG
  232. ldr r1, VAL_EMIFS_CS2_CONFIG
  233. str r1, [r0, #0x18] @ EMIFS_CS2_CONFIG
  234. ldr r1, VAL_EMIFS_CS3_CONFIG
  235. str r1, [r0, #0x1c] @ EMIFS_CS3_CONFIG
  236. ldr r1, VAL_EMIFS_DYN_WAIT
  237. str r1, [r0, #0x40] @ EMIFS_CFG_DYN_WAIT
  238. /* Setup SDRAM */
  239. ldr r1, VAL_EMIFF_SDRAM_CONFIG
  240. str r1, [r0, #0x20] @ EMIFF_SDRAM_CONFIG
  241. ldr r1, VAL_EMIFF_SDRAM_CONFIG2
  242. str r1, [r0, #0x3c] @ EMIFF_SDRAM_CONFIG2
  243. ldr r1, VAL_EMIFF_MRS
  244. str r1, [r0, #0x24] @ EMIFF_MRS
  245. /* SDRAM needs 100us to stabilize */
  246. mov r0, #0x4000
  247. sdelay:
  248. subs r0, r0, #0x1
  249. bne sdelay
  250. /* back to arch calling code */
  251. mov pc, lr
  252. .end