release.S 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /*
  2. * Copyright 2008-2009 Freescale Semiconductor, Inc.
  3. * Kumar Gala <kumar.gala@freescale.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <config.h>
  24. #include <mpc85xx.h>
  25. #include <version.h>
  26. #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
  27. #include <ppc_asm.tmpl>
  28. #include <ppc_defs.h>
  29. #include <asm/cache.h>
  30. #include <asm/mmu.h>
  31. /* To boot secondary cpus, we need a place for them to start up.
  32. * Normally, they start at 0xfffffffc, but that's usually the
  33. * firmware, and we don't want to have to run the firmware again.
  34. * Instead, the primary cpu will set the BPTR to point here to
  35. * this page. We then set up the core, and head to
  36. * start_secondary. Note that this means that the code below
  37. * must never exceed 1023 instructions (the branch at the end
  38. * would then be the 1024th).
  39. */
  40. .globl __secondary_start_page
  41. .align 12
  42. __secondary_start_page:
  43. /* First do some preliminary setup */
  44. lis r3, HID0_EMCP@h /* enable machine check */
  45. #ifndef CONFIG_E500MC
  46. ori r3,r3,HID0_TBEN@l /* enable Timebase */
  47. #endif
  48. #ifdef CONFIG_PHYS_64BIT
  49. ori r3,r3,HID0_ENMAS7@l /* enable MAS7 updates */
  50. #endif
  51. mtspr SPRN_HID0,r3
  52. #ifndef CONFIG_E500MC
  53. li r3,(HID1_ASTME|HID1_ABE)@l /* Addr streaming & broadcast */
  54. mtspr SPRN_HID1,r3
  55. #endif
  56. /* Enable branch prediction */
  57. li r3,0x201
  58. mtspr SPRN_BUCSR,r3
  59. /* Ensure TB is 0 */
  60. li r3,0
  61. mttbl r3
  62. mttbu r3
  63. /* Enable/invalidate the I-Cache */
  64. mfspr r0,SPRN_L1CSR1
  65. ori r0,r0,(L1CSR1_ICFI|L1CSR1_ICE)
  66. mtspr SPRN_L1CSR1,r0
  67. isync
  68. /* Enable/invalidate the D-Cache */
  69. mfspr r0,SPRN_L1CSR0
  70. ori r0,r0,(L1CSR0_DCFI|L1CSR0_DCE)
  71. msync
  72. isync
  73. mtspr SPRN_L1CSR0,r0
  74. isync
  75. #define toreset(x) (x - __secondary_start_page + 0xfffff000)
  76. /* get our PIR to figure out our table entry */
  77. lis r3,toreset(__spin_table)@h
  78. ori r3,r3,toreset(__spin_table)@l
  79. /* r10 has the base address for the entry */
  80. mfspr r0,SPRN_PIR
  81. #ifdef CONFIG_E500MC
  82. rlwinm r4,r0,27,27,31
  83. #else
  84. mr r4,r0
  85. #endif
  86. slwi r8,r4,5
  87. add r10,r3,r8
  88. #if defined(CONFIG_E500MC) && defined(CONFIG_SYS_CACHE_STASHING)
  89. /* set stash id to (coreID) * 2 + 32 + L1 CT (0) */
  90. slwi r8,r4,1
  91. addi r8,r8,32
  92. mtspr L1CSR2,r8
  93. #endif
  94. #ifdef CONFIG_BACKSIDE_L2_CACHE
  95. /* Enable/invalidate the L2 cache */
  96. msync
  97. lis r2,(L2CSR0_L2FI|L2CSR0_L2LFC)@h
  98. ori r2,r2,(L2CSR0_L2FI|L2CSR0_L2LFC)@l
  99. mtspr SPRN_L2CSR0,r2
  100. 1:
  101. mfspr r3,SPRN_L2CSR0
  102. and. r1,r3,r2
  103. bne 1b
  104. #ifdef CONFIG_SYS_CACHE_STASHING
  105. /* set stash id to (coreID) * 2 + 32 + L2 (1) */
  106. addi r3,r8,1
  107. mtspr SPRN_L2CSR1,r3
  108. #endif
  109. lis r3,CONFIG_SYS_INIT_L2CSR0@h
  110. ori r3,r3,CONFIG_SYS_INIT_L2CSR0@l
  111. mtspr SPRN_L2CSR0,r3
  112. isync
  113. 2:
  114. mfspr r3,SPRN_L2CSR0
  115. andis. r1,r3,L2CSR0_L2E@h
  116. beq 2b
  117. #endif
  118. #define EPAPR_MAGIC (0x45504150)
  119. #define ENTRY_ADDR_UPPER 0
  120. #define ENTRY_ADDR_LOWER 4
  121. #define ENTRY_R3_UPPER 8
  122. #define ENTRY_R3_LOWER 12
  123. #define ENTRY_RESV 16
  124. #define ENTRY_PIR 20
  125. #define ENTRY_R6_UPPER 24
  126. #define ENTRY_R6_LOWER 28
  127. #define ENTRY_SIZE 32
  128. /* setup the entry */
  129. li r3,0
  130. li r8,1
  131. stw r0,ENTRY_PIR(r10)
  132. stw r3,ENTRY_ADDR_UPPER(r10)
  133. stw r8,ENTRY_ADDR_LOWER(r10)
  134. stw r3,ENTRY_R3_UPPER(r10)
  135. stw r4,ENTRY_R3_LOWER(r10)
  136. stw r3,ENTRY_R6_UPPER(r10)
  137. stw r3,ENTRY_R6_LOWER(r10)
  138. /* load r13 with the address of the 'bootpg' in SDRAM */
  139. lis r13,toreset(__bootpg_addr)@h
  140. ori r13,r13,toreset(__bootpg_addr)@l
  141. lwz r13,0(r13)
  142. /* setup mapping for AS = 1, and jump there */
  143. lis r11,(MAS0_TLBSEL(1)|MAS0_ESEL(1))@h
  144. mtspr SPRN_MAS0,r11
  145. lis r11,(MAS1_VALID|MAS1_IPROT)@h
  146. ori r11,r11,(MAS1_TS|MAS1_TSIZE(BOOKE_PAGESZ_4K))@l
  147. mtspr SPRN_MAS1,r11
  148. oris r11,r13,(MAS2_I)@h
  149. ori r11,r13,(MAS2_I)@l
  150. mtspr SPRN_MAS2,r11
  151. oris r11,r13,(MAS3_SX|MAS3_SW|MAS3_SR)@h
  152. ori r11,r13,(MAS3_SX|MAS3_SW|MAS3_SR)@l
  153. mtspr SPRN_MAS3,r11
  154. tlbwe
  155. bl 1f
  156. 1: mflr r11
  157. /*
  158. * OR in 0xfff to create a mask of the bootpg SDRAM address. We use
  159. * this mask to fixup the cpu spin table and the address that we want
  160. * to jump to, eg change them from 0xfffffxxx to 0x7ffffxxx if the
  161. * bootpg is at 0x7ffff000 in SDRAM.
  162. */
  163. ori r13,r13,0xfff
  164. and r11, r11, r13
  165. and r10, r10, r13
  166. addi r11,r11,(2f-1b)
  167. mfmsr r13
  168. ori r12,r13,MSR_IS|MSR_DS@l
  169. mtspr SPRN_SRR0,r11
  170. mtspr SPRN_SRR1,r12
  171. rfi
  172. /* spin waiting for addr */
  173. 2:
  174. lwz r4,ENTRY_ADDR_LOWER(r10)
  175. andi. r11,r4,1
  176. bne 2b
  177. isync
  178. /* setup IVORs to match fixed offsets */
  179. #include "fixed_ivor.S"
  180. /* get the upper bits of the addr */
  181. lwz r11,ENTRY_ADDR_UPPER(r10)
  182. /* setup branch addr */
  183. mtspr SPRN_SRR0,r4
  184. /* mark the entry as released */
  185. li r8,3
  186. stw r8,ENTRY_ADDR_LOWER(r10)
  187. /* mask by ~64M to setup our tlb we will jump to */
  188. rlwinm r12,r4,0,0,5
  189. /* setup r3, r4, r5, r6, r7, r8, r9 */
  190. lwz r3,ENTRY_R3_LOWER(r10)
  191. li r4,0
  192. li r5,0
  193. lwz r6,ENTRY_R6_LOWER(r10)
  194. lis r7,(64*1024*1024)@h
  195. li r8,0
  196. li r9,0
  197. /* load up the pir */
  198. lwz r0,ENTRY_PIR(r10)
  199. mtspr SPRN_PIR,r0
  200. mfspr r0,SPRN_PIR
  201. stw r0,ENTRY_PIR(r10)
  202. mtspr IVPR,r12
  203. /*
  204. * Coming here, we know the cpu has one TLB mapping in TLB1[0]
  205. * which maps 0xfffff000-0xffffffff one-to-one. We set up a
  206. * second mapping that maps addr 1:1 for 64M, and then we jump to
  207. * addr
  208. */
  209. lis r10,(MAS0_TLBSEL(1)|MAS0_ESEL(0))@h
  210. mtspr SPRN_MAS0,r10
  211. lis r10,(MAS1_VALID|MAS1_IPROT)@h
  212. ori r10,r10,(MAS1_TSIZE(BOOKE_PAGESZ_64M))@l
  213. mtspr SPRN_MAS1,r10
  214. /* WIMGE = 0b00000 for now */
  215. mtspr SPRN_MAS2,r12
  216. ori r12,r12,(MAS3_SX|MAS3_SW|MAS3_SR)
  217. mtspr SPRN_MAS3,r12
  218. #ifdef CONFIG_ENABLE_36BIT_PHYS
  219. mtspr SPRN_MAS7,r11
  220. #endif
  221. tlbwe
  222. /* Now we have another mapping for this page, so we jump to that
  223. * mapping
  224. */
  225. mtspr SPRN_SRR1,r13
  226. rfi
  227. /*
  228. * Allocate some space for the SDRAM address of the bootpg.
  229. * This variable has to be in the boot page so that it can
  230. * be accessed by secondary cores when they come out of reset.
  231. */
  232. .globl __bootpg_addr
  233. __bootpg_addr:
  234. .long 0
  235. .align L1_CACHE_SHIFT
  236. .globl __spin_table
  237. __spin_table:
  238. .space CONFIG_MAX_CPUS*ENTRY_SIZE
  239. /* Fill in the empty space. The actual reset vector is
  240. * the last word of the page */
  241. __secondary_start_code_end:
  242. .space 4092 - (__secondary_start_code_end - __secondary_start_page)
  243. __secondary_reset_vector:
  244. b __secondary_start_page