init.S 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. #define LAWAR_TRGT_PCI1 0x00000000
  29. #define LAWAR_TRGT_PCIE1 0x00200000
  30. #define LAWAR_TRGT_PCIE2 0x00100000
  31. #define LAWAR_TRGT_PCIE3 0x00300000
  32. #define LAWAR_TRGT_LBC 0x00400000
  33. #define LAWAR_TRGT_DDR 0x00f00000
  34. /*
  35. * TLB0 and TLB1 Entries
  36. *
  37. * Out of reset, TLB1's Entry 0 maps the highest 4K for CCSRBAR.
  38. * However, CCSRBAR is then relocated to CFG_CCSRBAR right after
  39. * these TLB entries are established.
  40. *
  41. * The TLB entries for DDR are dynamically setup in spd_sdram()
  42. * and use TLB1 Entries 8 through 15 as needed according to the
  43. * size of DDR memory.
  44. *
  45. * MAS0: tlbsel, esel, nv
  46. * MAS1: valid, iprot, tid, ts, tsize
  47. * MAS2: epn, sharen, x0, x1, w, i, m, g, e
  48. * MAS3: rpn, u0-u3, ux, sx, uw, sw, ur, sr
  49. */
  50. #define entry_start \
  51. mflr r1 ; \
  52. bl 0f ;
  53. #define entry_end \
  54. 0: mflr r0 ; \
  55. mtlr r1 ; \
  56. blr ;
  57. .section .bootpg, "ax"
  58. .globl tlb1_entry
  59. tlb1_entry:
  60. entry_start
  61. /*
  62. * Number of TLB0 and TLB1 entries in the following table
  63. */
  64. .long (2f-1f)/16
  65. 1:
  66. /*
  67. * TLB0 4K Non-cacheable, guarded
  68. * 0xff700000 4K Initial CCSRBAR mapping
  69. *
  70. * This ends up at a TLB0 Index==0 entry, and must not collide
  71. * with other TLB0 Entries.
  72. */
  73. .long TLB1_MAS0(0, 0, 0)
  74. .long TLB1_MAS1(1, 0, 0, 0, 0)
  75. .long TLB1_MAS2(E500_TLB_EPN(CFG_CCSRBAR_DEFAULT), 0,0,0,0,1,0,1,0)
  76. .long TLB1_MAS3(E500_TLB_RPN(CFG_CCSRBAR_DEFAULT), 0,0,0,0,0,1,0,1,0,1)
  77. /*
  78. * TLB0 16K Cacheable, guarded
  79. * Temporary Global data for initialization
  80. *
  81. * Use four 4K TLB0 entries. These entries must be cacheable
  82. * as they provide the bootstrap memory before the memory
  83. * controler and real memory have been configured.
  84. *
  85. * These entries end up at TLB0 Indicies 0x10, 0x14, 0x18 and 0x1c,
  86. * and must not collide with other TLB0 entries.
  87. */
  88. .long TLB1_MAS0(0, 0, 0)
  89. .long TLB1_MAS1(1, 0, 0, 0, 0)
  90. .long TLB1_MAS2(E500_TLB_EPN(CFG_INIT_RAM_ADDR),
  91. 0,0,0,0,0,0,1,0)
  92. .long TLB1_MAS3(E500_TLB_RPN(CFG_INIT_RAM_ADDR),
  93. 0,0,0,0,0,1,0,1,0,1)
  94. .long TLB1_MAS0(0, 0, 0)
  95. .long TLB1_MAS1(1, 0, 0, 0, 0)
  96. .long TLB1_MAS2(E500_TLB_EPN(CFG_INIT_RAM_ADDR + 4 * 1024),
  97. 0,0,0,0,0,0,1,0)
  98. .long TLB1_MAS3(E500_TLB_RPN(CFG_INIT_RAM_ADDR + 4 * 1024),
  99. 0,0,0,0,0,1,0,1,0,1)
  100. .long TLB1_MAS0(0, 0, 0)
  101. .long TLB1_MAS1(1, 0, 0, 0, 0)
  102. .long TLB1_MAS2(E500_TLB_EPN(CFG_INIT_RAM_ADDR + 8 * 1024),
  103. 0,0,0,0,0,0,1,0)
  104. .long TLB1_MAS3(E500_TLB_RPN(CFG_INIT_RAM_ADDR + 8 * 1024),
  105. 0,0,0,0,0,1,0,1,0,1)
  106. .long TLB1_MAS0(0, 0, 0)
  107. .long TLB1_MAS1(1, 0, 0, 0, 0)
  108. .long TLB1_MAS2(E500_TLB_EPN(CFG_INIT_RAM_ADDR + 12 * 1024),
  109. 0,0,0,0,0,0,1,0)
  110. .long TLB1_MAS3(E500_TLB_RPN(CFG_INIT_RAM_ADDR + 12 * 1024),
  111. 0,0,0,0,0,1,0,1,0,1)
  112. /*
  113. * TLB 0: 64M Non-cacheable, guarded
  114. * 0xfc000000 64M Covers FLASH at 0xFE800000 and 0xFF800000
  115. * Out of reset this entry is only 4K.
  116. */
  117. .long TLB1_MAS0(1, 0, 0)
  118. .long TLB1_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_64M)
  119. .long TLB1_MAS2(E500_TLB_EPN(CFG_BOOT_BLOCK), 0,0,0,0,1,0,1,0)
  120. .long TLB1_MAS3(E500_TLB_RPN(CFG_BOOT_BLOCK), 0,0,0,0,0,1,0,1,0,1)
  121. /*
  122. * TLB 1: 1G Non-cacheable, guarded
  123. * 0x80000000 1G PCIE 8,9,a,b
  124. */
  125. .long TLB1_MAS0(1, 1, 0)
  126. .long TLB1_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_1G)
  127. .long TLB1_MAS2(E500_TLB_EPN(CFG_PCIE_PHYS),
  128. 0,0,0,0,1,0,1,0)
  129. .long TLB1_MAS3(E500_TLB_RPN(CFG_PCIE_PHYS),
  130. 0,0,0,0,0,1,0,1,0,1)
  131. /*
  132. * TLB 2: 256M Non-cacheable, guarded
  133. */
  134. .long TLB1_MAS0(1, 2, 0)
  135. .long TLB1_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_256M)
  136. .long TLB1_MAS2(E500_TLB_EPN(CFG_PCI_PHYS),
  137. 0,0,0,0,1,0,1,0)
  138. .long TLB1_MAS3(E500_TLB_RPN(CFG_PCI_PHYS), 0,0,0,0,0,1,0,1,0,1)
  139. /*
  140. * TLB 3: 256M Non-cacheable, guarded
  141. */
  142. .long TLB1_MAS0(1, 3, 0)
  143. .long TLB1_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_256M)
  144. .long TLB1_MAS2(E500_TLB_EPN(CFG_PCI_PHYS + 0x10000000),
  145. 0,0,0,0,1,0,1,0)
  146. .long TLB1_MAS3(E500_TLB_RPN(CFG_PCI_PHYS + 0x10000000),
  147. 0,0,0,0,0,1,0,1,0,1)
  148. /*
  149. * TLB 4: 64M Non-cacheable, guarded
  150. * 0xe000_0000 1M CCSRBAR
  151. * 0xe100_0000 255M PCI IO range
  152. */
  153. .long TLB1_MAS0(1, 4, 0)
  154. .long TLB1_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_64M)
  155. .long TLB1_MAS2(E500_TLB_EPN(CFG_CCSRBAR), 0,0,0,0,1,0,1,0)
  156. .long TLB1_MAS3(E500_TLB_RPN(CFG_CCSRBAR), 0,0,0,0,0,1,0,1,0,1)
  157. #ifdef CFG_LBC_CACHE_BASE
  158. /*
  159. * TLB 5: 64M Cacheable, non-guarded
  160. */
  161. .long TLB1_MAS0(1, 5, 0)
  162. .long TLB1_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_64M)
  163. .long TLB1_MAS2(E500_TLB_EPN(CFG_LBC_CACHE_BASE), 0,0,0,0,0,0,0,0)
  164. .long TLB1_MAS3(E500_TLB_RPN(CFG_LBC_CACHE_BASE), 0,0,0,0,0,1,0,1,0,1)
  165. #endif
  166. /*
  167. * TLB 6: 64M Non-cacheable, guarded
  168. * 0xf8000000 64M PIXIS 0xF8000000 - 0xFBFFFFFF
  169. */
  170. .long TLB1_MAS0(1, 6, 0)
  171. .long TLB1_MAS1(1, 1, 0, 0, BOOKE_PAGESZ_64M)
  172. .long TLB1_MAS2(E500_TLB_EPN(CFG_LBC_NONCACHE_BASE), 0,0,0,0,1,0,1,0)
  173. .long TLB1_MAS3(E500_TLB_RPN(CFG_LBC_NONCACHE_BASE), 0,0,0,0,0,1,0,1,0,1)
  174. 2:
  175. entry_end
  176. /*
  177. * LAW(Local Access Window) configuration:
  178. *
  179. *
  180. * Notes:
  181. * CCSRBAR and L2-as-SRAM don't need a configured Local Access Window.
  182. * If flash is 8M at default position (last 8M), no LAW needed.
  183. *
  184. * LAW 0 is reserved for boot mapping
  185. */
  186. .section .bootpg, "ax"
  187. .globl law_entry
  188. law_entry:
  189. entry_start
  190. .long (4f-3f)/8
  191. 3:
  192. .long 0
  193. .long (LAWAR_TRGT_DDR | (LAWAR_SIZE & LAWAR_SIZE_128M)) & ~LAWAR_EN
  194. .long (CFG_PCI1_MEM_BASE>>12) & 0xfffff
  195. .long LAWAR_EN | LAWAR_TRGT_PCI1 | (LAWAR_SIZE & LAWAR_SIZE_512M)
  196. .long (CFG_PCI1_IO_PHYS>>12) & 0xfffff
  197. .long LAWAR_EN | LAWAR_TRGT_PCI1 | (LAWAR_SIZE & LAWAR_SIZE_16M)
  198. .long (CFG_LBC_CACHE_BASE>>12) & 0xfffff
  199. .long LAWAR_EN | LAWAR_TRGT_LBC | (LAWAR_SIZE & LAWAR_SIZE_256M)
  200. .long (CFG_PCIE1_MEM_PHYS>>12) & 0xfffff
  201. .long LAWAR_EN | LAWAR_TRGT_PCIE1 | (LAWAR_SIZE & LAWAR_SIZE_256M)
  202. /* To keep to 10 LAWs, PCIE1_IO_PHYS must use top of mem region */
  203. .long (CFG_PCIE2_MEM_PHYS>>12) & 0xfffff
  204. .long LAWAR_EN | LAWAR_TRGT_PCIE2 | (LAWAR_SIZE & LAWAR_SIZE_512M)
  205. .long (CFG_PCIE2_IO_PHYS>>12) & 0xfffff
  206. .long LAWAR_EN | LAWAR_TRGT_PCIE2 | (LAWAR_SIZE & LAWAR_SIZE_16M)
  207. .long (CFG_PCIE3_MEM_PHYS>>12) & 0xfffff
  208. .long LAWAR_EN | LAWAR_TRGT_PCIE3 | (LAWAR_SIZE & LAWAR_SIZE_256M)
  209. .long (CFG_PCIE3_IO_PHYS>>12) & 0xfffff
  210. .long LAWAR_EN | LAWAR_TRGT_PCIE3 | (LAWAR_SIZE & LAWAR_SIZE_16M)
  211. 4:
  212. entry_end