head-ram.S 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. /* arch/m68knommu/platform/68360/head-ram.S
  2. *
  3. * Startup code for Motorola 68360
  4. *
  5. * Copyright 2001 (C) SED Systems, a Division of Calian Ltd.
  6. * Based on: arch/m68knommu/platform/68328/pilot/crt0_rom.S
  7. * Based on: arch/m68knommu/platform/68360/uCquicc/crt0_rom.S, 2.0.38.1.pre7
  8. * uClinux Kernel
  9. * Copyright (C) Michael Leslie <mleslie@lineo.com>
  10. * Based on: arch/m68knommu/platform/68EZ328/ucsimm/crt0_rom.S
  11. * Copyright (C) 1998 D. Jeff Dionne <jeff@uclinux.org>,
  12. *
  13. */
  14. #define ASSEMBLY
  15. .global _stext
  16. .global _start
  17. .global _rambase
  18. .global _ramvec
  19. .global _ramstart
  20. .global _ramend
  21. .global _quicc_base
  22. .global _periph_base
  23. #define RAMEND (CONFIG_RAMBASE + CONFIG_RAMSIZE)
  24. #define ROMEND (CONFIG_ROMBASE + CONFIG_ROMSIZE)
  25. #define REGB 0x1000
  26. #define PEPAR (_dprbase + REGB + 0x0016)
  27. #define GMR (_dprbase + REGB + 0x0040)
  28. #define OR0 (_dprbase + REGB + 0x0054)
  29. #define BR0 (_dprbase + REGB + 0x0050)
  30. #define OR1 (_dprbase + REGB + 0x0064)
  31. #define BR1 (_dprbase + REGB + 0x0060)
  32. #define OR4 (_dprbase + REGB + 0x0094)
  33. #define BR4 (_dprbase + REGB + 0x0090)
  34. #define OR6 (_dprbase + REGB + 0x00b4)
  35. #define BR6 (_dprbase + REGB + 0x00b0)
  36. #define OR7 (_dprbase + REGB + 0x00c4)
  37. #define BR7 (_dprbase + REGB + 0x00c0)
  38. #define MCR (_dprbase + REGB + 0x0000)
  39. #define AVR (_dprbase + REGB + 0x0008)
  40. #define SYPCR (_dprbase + REGB + 0x0022)
  41. #define PLLCR (_dprbase + REGB + 0x0010)
  42. #define CLKOCR (_dprbase + REGB + 0x000C)
  43. #define CDVCR (_dprbase + REGB + 0x0014)
  44. #define BKAR (_dprbase + REGB + 0x0030)
  45. #define BKCR (_dprbase + REGB + 0x0034)
  46. #define SWIV (_dprbase + REGB + 0x0023)
  47. #define PICR (_dprbase + REGB + 0x0026)
  48. #define PITR (_dprbase + REGB + 0x002A)
  49. /* Define for all memory configuration */
  50. #define MCU_SIM_GMR 0x00000000
  51. #define SIM_OR_MASK 0x0fffffff
  52. /* Defines for chip select zero - the flash */
  53. #define SIM_OR0_MASK 0x20000002
  54. #define SIM_BR0_MASK 0x00000001
  55. /* Defines for chip select one - the RAM */
  56. #define SIM_OR1_MASK 0x10000000
  57. #define SIM_BR1_MASK 0x00000001
  58. #define MCU_SIM_MBAR_ADRS 0x0003ff00
  59. #define MCU_SIM_MBAR_BA_MASK 0xfffff000
  60. #define MCU_SIM_MBAR_AS_MASK 0x00000001
  61. #define MCU_SIM_PEPAR 0x00B4
  62. #define MCU_DISABLE_INTRPTS 0x2700
  63. #define MCU_SIM_AVR 0x00
  64. #define MCU_SIM_MCR 0x00005cff
  65. #define MCU_SIM_CLKOCR 0x00
  66. #define MCU_SIM_PLLCR 0x8000
  67. #define MCU_SIM_CDVCR 0x0000
  68. #define MCU_SIM_SYPCR 0x0000
  69. #define MCU_SIM_SWIV 0x00
  70. #define MCU_SIM_PICR 0x0000
  71. #define MCU_SIM_PITR 0x0000
  72. #include <asm/m68360_regs.h>
  73. /*
  74. * By the time this RAM specific code begins to execute, DPRAM
  75. * and DRAM should already be mapped and accessible.
  76. */
  77. .text
  78. _start:
  79. _stext:
  80. nop
  81. ori.w #MCU_DISABLE_INTRPTS, %sr /* disable interrupts: */
  82. /* We should not need to setup the boot stack the reset should do it. */
  83. movea.l #RAMEND, %sp /*set up stack at the end of DRAM:*/
  84. set_mbar_register:
  85. moveq.l #0x07, %d1 /* Setup MBAR */
  86. movec %d1, %dfc
  87. lea.l MCU_SIM_MBAR_ADRS, %a0
  88. move.l #_dprbase, %d0
  89. andi.l #MCU_SIM_MBAR_BA_MASK, %d0
  90. ori.l #MCU_SIM_MBAR_AS_MASK, %d0
  91. moves.l %d0, %a0@
  92. moveq.l #0x05, %d1
  93. movec.l %d1, %dfc
  94. /* Now we can begin to access registers in DPRAM */
  95. set_sim_mcr:
  96. /* Set Module Configuration Register */
  97. move.l #MCU_SIM_MCR, MCR
  98. /* to do: Determine cause of reset */
  99. /*
  100. * configure system clock MC68360 p. 6-40
  101. * (value +1)*osc/128 = system clock
  102. */
  103. set_sim_clock:
  104. move.w #MCU_SIM_PLLCR, PLLCR
  105. move.b #MCU_SIM_CLKOCR, CLKOCR
  106. move.w #MCU_SIM_CDVCR, CDVCR
  107. /* Wait for the PLL to settle */
  108. move.w #16384, %d0
  109. pll_settle_wait:
  110. subi.w #1, %d0
  111. bne pll_settle_wait
  112. /* Setup the system protection register, and watchdog timer register */
  113. move.b #MCU_SIM_SWIV, SWIV
  114. move.w #MCU_SIM_PICR, PICR
  115. move.w #MCU_SIM_PITR, PITR
  116. move.w #MCU_SIM_SYPCR, SYPCR
  117. /* Clear DPRAM - system + parameter */
  118. movea.l #_dprbase, %a0
  119. movea.l #_dprbase+0x2000, %a1
  120. /* Copy 0 to %a0 until %a0 == %a1 */
  121. clear_dpram:
  122. movel #0, %a0@+
  123. cmpal %a0, %a1
  124. bhi clear_dpram
  125. configure_memory_controller:
  126. /* Set up Global Memory Register (GMR) */
  127. move.l #MCU_SIM_GMR, %d0
  128. move.l %d0, GMR
  129. configure_chip_select_0:
  130. move.l #RAMEND, %d0
  131. subi.l #__ramstart, %d0
  132. subq.l #0x01, %d0
  133. eori.l #SIM_OR_MASK, %d0
  134. ori.l #SIM_OR0_MASK, %d0
  135. move.l %d0, OR0
  136. move.l #__ramstart, %d0
  137. ori.l #SIM_BR0_MASK, %d0
  138. move.l %d0, BR0
  139. configure_chip_select_1:
  140. move.l #ROMEND, %d0
  141. subi.l #__rom_start, %d0
  142. subq.l #0x01, %d0
  143. eori.l #SIM_OR_MASK, %d0
  144. ori.l #SIM_OR1_MASK, %d0
  145. move.l %d0, OR1
  146. move.l #__rom_start, %d0
  147. ori.l #SIM_BR1_MASK, %d0
  148. move.l %d0, BR1
  149. move.w #MCU_SIM_PEPAR, PEPAR
  150. /* point to vector table: */
  151. move.l #_romvec, %a0
  152. move.l #_ramvec, %a1
  153. copy_vectors:
  154. move.l %a0@, %d0
  155. move.l %d0, %a1@
  156. move.l %a0@, %a1@
  157. addq.l #0x04, %a0
  158. addq.l #0x04, %a1
  159. cmp.l #_start, %a0
  160. blt copy_vectors
  161. move.l #_ramvec, %a1
  162. movec %a1, %vbr
  163. /* Copy data segment from ROM to RAM */
  164. moveal #_stext, %a0
  165. moveal #_sdata, %a1
  166. moveal #_edata, %a2
  167. /* Copy %a0 to %a1 until %a1 == %a2 */
  168. LD1:
  169. move.l %a0@, %d0
  170. addq.l #0x04, %a0
  171. move.l %d0, %a1@
  172. addq.l #0x04, %a1
  173. cmp.l #_edata, %a1
  174. blt LD1
  175. moveal #_sbss, %a0
  176. moveal #_ebss, %a1
  177. /* Copy 0 to %a0 until %a0 == %a1 */
  178. L1:
  179. movel #0, %a0@+
  180. cmpal %a0, %a1
  181. bhi L1
  182. load_quicc:
  183. move.l #_dprbase, _quicc_base
  184. store_ram_size:
  185. /* Set ram size information */
  186. move.l #_sdata, _rambase
  187. move.l #_ebss, _ramstart
  188. move.l #RAMEND, %d0
  189. sub.l #0x1000, %d0 /* Reserve 4K for stack space.*/
  190. move.l %d0, _ramend /* Different from RAMEND.*/
  191. pea 0
  192. pea env
  193. pea %sp@(4)
  194. pea 0
  195. lea init_thread_union, %a2
  196. lea 0x2000(%a2), %sp
  197. lp:
  198. jsr start_kernel
  199. _exit:
  200. jmp _exit
  201. .data
  202. .align 4
  203. env:
  204. .long 0
  205. _quicc_base:
  206. .long 0
  207. _periph_base:
  208. .long 0
  209. _ramvec:
  210. .long 0
  211. _rambase:
  212. .long 0
  213. _ramstart:
  214. .long 0
  215. _ramend:
  216. .long 0
  217. _dprbase:
  218. .long 0xffffe000
  219. .text
  220. /*
  221. * These are the exception vectors at boot up, they are copied into RAM
  222. * and then overwritten as needed.
  223. */
  224. .section ".data..initvect","awx"
  225. .long RAMEND /* Reset: Initial Stack Pointer - 0. */
  226. .long _start /* Reset: Initial Program Counter - 1. */
  227. .long buserr /* Bus Error - 2. */
  228. .long trap /* Address Error - 3. */
  229. .long trap /* Illegal Instruction - 4. */
  230. .long trap /* Divide by zero - 5. */
  231. .long trap /* CHK, CHK2 Instructions - 6. */
  232. .long trap /* TRAPcc, TRAPV Instructions - 7. */
  233. .long trap /* Privilege Violation - 8. */
  234. .long trap /* Trace - 9. */
  235. .long trap /* Line 1010 Emulator - 10. */
  236. .long trap /* Line 1111 Emualtor - 11. */
  237. .long trap /* Harware Breakpoint - 12. */
  238. .long trap /* (Reserved for Coprocessor Protocol Violation)- 13. */
  239. .long trap /* Format Error - 14. */
  240. .long trap /* Uninitialized Interrupt - 15. */
  241. .long trap /* (Unassigned, Reserver) - 16. */
  242. .long trap /* (Unassigned, Reserver) - 17. */
  243. .long trap /* (Unassigned, Reserver) - 18. */
  244. .long trap /* (Unassigned, Reserver) - 19. */
  245. .long trap /* (Unassigned, Reserver) - 20. */
  246. .long trap /* (Unassigned, Reserver) - 21. */
  247. .long trap /* (Unassigned, Reserver) - 22. */
  248. .long trap /* (Unassigned, Reserver) - 23. */
  249. .long trap /* Spurious Interrupt - 24. */
  250. .long trap /* Level 1 Interrupt Autovector - 25. */
  251. .long trap /* Level 2 Interrupt Autovector - 26. */
  252. .long trap /* Level 3 Interrupt Autovector - 27. */
  253. .long trap /* Level 4 Interrupt Autovector - 28. */
  254. .long trap /* Level 5 Interrupt Autovector - 29. */
  255. .long trap /* Level 6 Interrupt Autovector - 30. */
  256. .long trap /* Level 7 Interrupt Autovector - 31. */
  257. .long system_call /* Trap Instruction Vectors 0 - 32. */
  258. .long trap /* Trap Instruction Vectors 1 - 33. */
  259. .long trap /* Trap Instruction Vectors 2 - 34. */
  260. .long trap /* Trap Instruction Vectors 3 - 35. */
  261. .long trap /* Trap Instruction Vectors 4 - 36. */
  262. .long trap /* Trap Instruction Vectors 5 - 37. */
  263. .long trap /* Trap Instruction Vectors 6 - 38. */
  264. .long trap /* Trap Instruction Vectors 7 - 39. */
  265. .long trap /* Trap Instruction Vectors 8 - 40. */
  266. .long trap /* Trap Instruction Vectors 9 - 41. */
  267. .long trap /* Trap Instruction Vectors 10 - 42. */
  268. .long trap /* Trap Instruction Vectors 11 - 43. */
  269. .long trap /* Trap Instruction Vectors 12 - 44. */
  270. .long trap /* Trap Instruction Vectors 13 - 45. */
  271. .long trap /* Trap Instruction Vectors 14 - 46. */
  272. .long trap /* Trap Instruction Vectors 15 - 47. */
  273. .long 0 /* (Reserved for Coprocessor) - 48. */
  274. .long 0 /* (Reserved for Coprocessor) - 49. */
  275. .long 0 /* (Reserved for Coprocessor) - 50. */
  276. .long 0 /* (Reserved for Coprocessor) - 51. */
  277. .long 0 /* (Reserved for Coprocessor) - 52. */
  278. .long 0 /* (Reserved for Coprocessor) - 53. */
  279. .long 0 /* (Reserved for Coprocessor) - 54. */
  280. .long 0 /* (Reserved for Coprocessor) - 55. */
  281. .long 0 /* (Reserved for Coprocessor) - 56. */
  282. .long 0 /* (Reserved for Coprocessor) - 57. */
  283. .long 0 /* (Reserved for Coprocessor) - 58. */
  284. .long 0 /* (Unassigned, Reserved) - 59. */
  285. .long 0 /* (Unassigned, Reserved) - 60. */
  286. .long 0 /* (Unassigned, Reserved) - 61. */
  287. .long 0 /* (Unassigned, Reserved) - 62. */
  288. .long 0 /* (Unassigned, Reserved) - 63. */
  289. /* The assignment of these vectors to the CPM is */
  290. /* dependent on the configuration of the CPM vba */
  291. /* fields. */
  292. .long 0 /* (User-Defined Vectors 1) CPM Error - 64. */
  293. .long 0 /* (User-Defined Vectors 2) CPM Parallel IO PC11- 65. */
  294. .long 0 /* (User-Defined Vectors 3) CPM Parallel IO PC10- 66. */
  295. .long 0 /* (User-Defined Vectors 4) CPM SMC2 / PIP - 67. */
  296. .long 0 /* (User-Defined Vectors 5) CPM SMC1 - 68. */
  297. .long 0 /* (User-Defined Vectors 6) CPM SPI - 69. */
  298. .long 0 /* (User-Defined Vectors 7) CPM Parallel IO PC9 - 70. */
  299. .long 0 /* (User-Defined Vectors 8) CPM Timer 4 - 71. */
  300. .long 0 /* (User-Defined Vectors 9) CPM Reserved - 72. */
  301. .long 0 /* (User-Defined Vectors 10) CPM Parallel IO PC8- 73. */
  302. .long 0 /* (User-Defined Vectors 11) CPM Parallel IO PC7- 74. */
  303. .long 0 /* (User-Defined Vectors 12) CPM Parallel IO PC6- 75. */
  304. .long 0 /* (User-Defined Vectors 13) CPM Timer 3 - 76. */
  305. .long 0 /* (User-Defined Vectors 14) CPM Reserved - 77. */
  306. .long 0 /* (User-Defined Vectors 15) CPM Parallel IO PC5- 78. */
  307. .long 0 /* (User-Defined Vectors 16) CPM Parallel IO PC4- 79. */
  308. .long 0 /* (User-Defined Vectors 17) CPM Reserved - 80. */
  309. .long 0 /* (User-Defined Vectors 18) CPM RISC Timer Tbl - 81. */
  310. .long 0 /* (User-Defined Vectors 19) CPM Timer 2 - 82. */
  311. .long 0 /* (User-Defined Vectors 21) CPM Reserved - 83. */
  312. .long 0 /* (User-Defined Vectors 22) CPM IDMA2 - 84. */
  313. .long 0 /* (User-Defined Vectors 23) CPM IDMA1 - 85. */
  314. .long 0 /* (User-Defined Vectors 24) CPM SDMA Bus Err - 86. */
  315. .long 0 /* (User-Defined Vectors 25) CPM Parallel IO PC3- 87. */
  316. .long 0 /* (User-Defined Vectors 26) CPM Parallel IO PC2- 88. */
  317. .long 0 /* (User-Defined Vectors 27) CPM Timer 1 - 89. */
  318. .long 0 /* (User-Defined Vectors 28) CPM Parallel IO PC1- 90. */
  319. .long 0 /* (User-Defined Vectors 29) CPM SCC 4 - 91. */
  320. .long 0 /* (User-Defined Vectors 30) CPM SCC 3 - 92. */
  321. .long 0 /* (User-Defined Vectors 31) CPM SCC 2 - 93. */
  322. .long 0 /* (User-Defined Vectors 32) CPM SCC 1 - 94. */
  323. .long 0 /* (User-Defined Vectors 33) CPM Parallel IO PC0- 95. */
  324. /* I don't think anything uses the vectors after here. */
  325. .long 0 /* (User-Defined Vectors 34) - 96. */
  326. .long 0,0,0,0,0 /* (User-Defined Vectors 35 - 39). */
  327. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 40 - 49). */
  328. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 50 - 59). */
  329. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 60 - 69). */
  330. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 70 - 79). */
  331. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 80 - 89). */
  332. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 90 - 99). */
  333. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 100 - 109). */
  334. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 110 - 119). */
  335. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 120 - 129). */
  336. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 130 - 139). */
  337. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 140 - 149). */
  338. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 150 - 159). */
  339. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 160 - 169). */
  340. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 170 - 179). */
  341. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 180 - 189). */
  342. .long 0,0,0 /* (User-Defined Vectors 190 - 192). */
  343. .text
  344. ignore: rte