init.S 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /*
  2. * Copyright 2007 Freescale Semiconductor, Inc.
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <ppc_asm.tmpl>
  23. #include <ppc_defs.h>
  24. #include <asm/cache.h>
  25. #include <asm/mmu.h>
  26. #include <config.h>
  27. #include <mpc85xx.h>
  28. /*
  29. * TLB0 and TLB1 Entries
  30. *
  31. * Out of reset, TLB1's Entry 0 maps the highest 4K for CCSRBAR.
  32. * However, CCSRBAR is then relocated to CFG_CCSRBAR right after
  33. * these TLB entries are established.
  34. *
  35. * The TLB entries for DDR are dynamically setup in spd_sdram()
  36. * and use TLB1 Entries 8 through 15 as needed according to the
  37. * size of DDR memory.
  38. *
  39. * MAS0: tlbsel, esel, nv
  40. * MAS1: valid, iprot, tid, ts, tsize
  41. * MAS2: epn, x0, x1, w, i, m, g, e
  42. * MAS3: rpn, u0-u3, ux, sx, uw, sw, ur, sr
  43. */
  44. #define entry_start \
  45. mflr r1 ; \
  46. bl 0f ;
  47. #define entry_end \
  48. 0: mflr r0 ; \
  49. mtlr r1 ; \
  50. blr ;
  51. .section .bootpg, "ax"
  52. .globl tlb1_entry
  53. tlb1_entry:
  54. entry_start
  55. /*
  56. * Number of TLB0 and TLB1 entries in the following table
  57. */
  58. .long (2f-1f)/16
  59. 1:
  60. /*
  61. * TLB0 4K Non-cacheable, guarded
  62. * 0xff700000 4K Initial CCSRBAR mapping
  63. *
  64. * This ends up at a TLB0 Index==0 entry, and must not collide
  65. * with other TLB0 Entries.
  66. */
  67. .long FSL_BOOKE_MAS0(0, 0, 0)
  68. .long FSL_BOOKE_MAS1(1, 0, 0, 0, 0)
  69. .long FSL_BOOKE_MAS2(CFG_CCSRBAR_DEFAULT, (MAS2_I|MAS2_G))
  70. .long FSL_BOOKE_MAS3(CFG_CCSRBAR_DEFAULT, 0, (MAS3_SX|MAS3_SW|MAS3_SR))
  71. /*
  72. * TLB0 16K Cacheable, guarded
  73. * Temporary Global data for initialization
  74. *
  75. * Use four 4K TLB0 entries. These entries must be cacheable
  76. * as they provide the bootstrap memory before the memory
  77. * controler and real memory have been configured.
  78. *
  79. * These entries end up at TLB0 Indicies 0x10, 0x14, 0x18 and 0x1c,
  80. * and must not collide with other TLB0 entries.
  81. */
  82. .long FSL_BOOKE_MAS0(0, 0, 0)
  83. .long FSL_BOOKE_MAS1(1, 0, 0, 0, 0)
  84. .long FSL_BOOKE_MAS2(CFG_INIT_RAM_ADDR, (MAS2_G))
  85. .long FSL_BOOKE_MAS3(CFG_INIT_RAM_ADDR, 0, (MAS3_SX|MAS3_SW|MAS3_SR))
  86. .long FSL_BOOKE_MAS0(0, 0, 0)
  87. .long FSL_BOOKE_MAS1(1, 0, 0, 0, 0)
  88. .long FSL_BOOKE_MAS2(CFG_INIT_RAM_ADDR + 4 * 1024, (MAS2_G))
  89. .long FSL_BOOKE_MAS3(CFG_INIT_RAM_ADDR + 4 * 1024, 0, (MAS3_SX|MAS3_SW|MAS3_SR))
  90. .long FSL_BOOKE_MAS0(0, 0, 0)
  91. .long FSL_BOOKE_MAS1(1, 0, 0, 0, 0)
  92. .long FSL_BOOKE_MAS2(CFG_INIT_RAM_ADDR + 8 * 1024, (MAS2_G))
  93. .long FSL_BOOKE_MAS3(CFG_INIT_RAM_ADDR + 8 * 1024, 0, (MAS3_SX|MAS3_SW|MAS3_SR))
  94. .long FSL_BOOKE_MAS0(0, 0, 0)
  95. .long FSL_BOOKE_MAS1(1, 0, 0, 0, 0)
  96. .long FSL_BOOKE_MAS2(CFG_INIT_RAM_ADDR + 12 * 1024, (MAS2_G))
  97. .long FSL_BOOKE_MAS3(CFG_INIT_RAM_ADDR + 12 * 1024, 0, (MAS3_SX|MAS3_SW|MAS3_SR))
  98. /*
  99. * TLB 0: 64M Non-cacheable, guarded
  100. * 0xfc000000 64M Covers FLASH at 0xFE800000 and 0xFF800000
  101. * Out of reset this entry is only 4K.
  102. */
  103. .long FSL_BOOKE_MAS0(1, 0, 0)
  104. .long FSL_BOOKE_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_64M)
  105. .long FSL_BOOKE_MAS2(CFG_BOOT_BLOCK, (MAS2_I|MAS2_G))
  106. .long FSL_BOOKE_MAS3(CFG_BOOT_BLOCK, 0, (MAS3_SX|MAS3_SW|MAS3_SR))
  107. /*
  108. * TLB 1: 1G Non-cacheable, guarded
  109. * 0x80000000 1G PCIE 8,9,a,b
  110. */
  111. .long FSL_BOOKE_MAS0(1, 1, 0)
  112. .long FSL_BOOKE_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_1G)
  113. .long FSL_BOOKE_MAS2(CFG_PCIE_PHYS, (MAS2_I|MAS2_G))
  114. .long FSL_BOOKE_MAS3(CFG_PCIE_PHYS, 0, (MAS3_SX|MAS3_SW|MAS3_SR))
  115. /*
  116. * TLB 2: 256M Non-cacheable, guarded
  117. */
  118. .long FSL_BOOKE_MAS0(1, 2, 0)
  119. .long FSL_BOOKE_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_256M)
  120. .long FSL_BOOKE_MAS2(CFG_PCI_PHYS, (MAS2_I|MAS2_G))
  121. .long FSL_BOOKE_MAS3(CFG_PCI_PHYS, 0, (MAS3_SX|MAS3_SW|MAS3_SR))
  122. /*
  123. * TLB 3: 256M Non-cacheable, guarded
  124. */
  125. .long FSL_BOOKE_MAS0(1, 3, 0)
  126. .long FSL_BOOKE_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_256M)
  127. .long FSL_BOOKE_MAS2(CFG_PCI_PHYS + 0x10000000, (MAS2_I|MAS2_G))
  128. .long FSL_BOOKE_MAS3(CFG_PCI_PHYS + 0x10000000, 0, (MAS3_SX|MAS3_SW|MAS3_SR))
  129. /*
  130. * TLB 4: 64M Non-cacheable, guarded
  131. * 0xe000_0000 1M CCSRBAR
  132. * 0xe100_0000 255M PCI IO range
  133. */
  134. .long FSL_BOOKE_MAS0(1, 4, 0)
  135. .long FSL_BOOKE_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_64M)
  136. .long FSL_BOOKE_MAS2(CFG_CCSRBAR, (MAS2_I|MAS2_G))
  137. .long FSL_BOOKE_MAS3(CFG_CCSRBAR, 0, (MAS3_SX|MAS3_SW|MAS3_SR))
  138. #ifdef CFG_LBC_CACHE_BASE
  139. /*
  140. * TLB 5: 64M Cacheable, non-guarded
  141. */
  142. .long FSL_BOOKE_MAS0(1, 5, 0)
  143. .long FSL_BOOKE_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_64M)
  144. .long FSL_BOOKE_MAS2(CFG_LBC_CACHE_BASE, 0)
  145. .long FSL_BOOKE_MAS3(CFG_LBC_CACHE_BASE, 0, (MAS3_SX|MAS3_SW|MAS3_SR))
  146. #endif
  147. /*
  148. * TLB 6: 64M Non-cacheable, guarded
  149. * 0xf8000000 64M PIXIS 0xF8000000 - 0xFBFFFFFF
  150. */
  151. .long FSL_BOOKE_MAS0(1, 6, 0)
  152. .long FSL_BOOKE_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_64M)
  153. .long FSL_BOOKE_MAS2(CFG_LBC_NONCACHE_BASE, (MAS2_I|MAS2_G))
  154. .long FSL_BOOKE_MAS3(CFG_LBC_NONCACHE_BASE, 0, (MAS3_SX|MAS3_SW|MAS3_SR))
  155. 2:
  156. entry_end
  157. /*
  158. * LAW(Local Access Window) configuration:
  159. *
  160. *
  161. * Notes:
  162. * CCSRBAR and L2-as-SRAM don't need a configured Local Access Window.
  163. * If flash is 8M at default position (last 8M), no LAW needed.
  164. *
  165. * LAW 0 is reserved for boot mapping
  166. */
  167. .section .bootpg, "ax"
  168. .globl law_entry
  169. law_entry:
  170. entry_start
  171. .long (4f-3f)/8
  172. 3:
  173. .long 0
  174. .long (LAWAR_TRGT_IF_DDR | (LAWAR_SIZE & LAWAR_SIZE_128M)) & ~LAWAR_EN
  175. .long (CFG_PCI1_MEM_PHYS>>12) & 0xfffff
  176. .long LAWAR_EN | LAWAR_TRGT_IF_PCI1 | (LAWAR_SIZE & LAWAR_SIZE_512M)
  177. .long (CFG_PCI1_IO_PHYS>>12) & 0xfffff
  178. .long LAWAR_EN | LAWAR_TRGT_IF_PCI1 | (LAWAR_SIZE & LAWAR_SIZE_64K)
  179. .long (CFG_LBC_CACHE_BASE>>12) & 0xfffff
  180. .long LAWAR_EN | LAWAR_TRGT_IF_LBC | (LAWAR_SIZE & LAWAR_SIZE_256M)
  181. .long (CFG_PCIE1_MEM_PHYS>>12) & 0xfffff
  182. .long LAWAR_EN | LAWAR_TRGT_IF_PCIE1 | (LAWAR_SIZE & LAWAR_SIZE_256M)
  183. .long (CFG_PCIE1_IO_PHYS>>12) & 0xfffff
  184. .long LAWAR_EN | LAWAR_TRGT_IF_PCIE1 | (LAWAR_SIZE & LAWAR_SIZE_64K)
  185. .long (CFG_PCIE2_MEM_PHYS>>12) & 0xfffff
  186. .long LAWAR_EN | LAWAR_TRGT_IF_PCIE2 | (LAWAR_SIZE & LAWAR_SIZE_512M)
  187. .long (CFG_PCIE2_IO_PHYS>>12) & 0xfffff
  188. .long LAWAR_EN | LAWAR_TRGT_IF_PCIE2 | (LAWAR_SIZE & LAWAR_SIZE_64K)
  189. /* contains both PCIE3 MEM & IO space */
  190. .long (CFG_PCIE3_MEM_PHYS>>12) & 0xfffff
  191. .long LAWAR_EN | LAWAR_TRGT_IF_PCIE3 | (LAWAR_SIZE & LAWAR_SIZE_4M)
  192. 4:
  193. entry_end