start.S 61 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175
  1. /*
  2. * Copyright (C) 1998 Dan Malek <dmalek@jlc.net>
  3. * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se>
  4. * Copyright (C) 2000,2001,2002 Wolfgang Denk <wd@denx.de>
  5. * Copyright (C) 2007 Stefan Roese <sr@denx.de>, DENX Software Engineering
  6. * Copyright (c) 2008 Nuovation System Designs, LLC
  7. * Grant Erickson <gerickson@nuovations.com>
  8. *
  9. * See file CREDITS for list of people who contributed to this
  10. * project.
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License as
  14. * published by the Free Software Foundation; either version 2 of
  15. * the License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  25. * MA 02111-1307 USA
  26. */
  27. /*------------------------------------------------------------------------------+
  28. * This source code is dual-licensed. You may use it under the terms of the
  29. * GNU General Public License version 2, or under the license below.
  30. *
  31. * This source code has been made available to you by IBM on an AS-IS
  32. * basis. Anyone receiving this source is licensed under IBM
  33. * copyrights to use it in any way he or she deems fit, including
  34. * copying it, modifying it, compiling it, and redistributing it either
  35. * with or without modifications. No license under IBM patents or
  36. * patent applications is to be implied by the copyright license.
  37. *
  38. * Any user of this software should understand that IBM cannot provide
  39. * technical support for this software and will not be responsible for
  40. * any consequences resulting from the use of this software.
  41. *
  42. * Any person who transfers this source code or any derivative work
  43. * must include the IBM copyright notice, this paragraph, and the
  44. * preceding two paragraphs in the transferred software.
  45. *
  46. * COPYRIGHT I B M CORPORATION 1995
  47. * LICENSED MATERIAL - PROGRAM PROPERTY OF I B M
  48. *-------------------------------------------------------------------------------
  49. */
  50. /*
  51. * Startup code for IBM/AMCC PowerPC 4xx (PPC4xx) based boards
  52. *
  53. * The following description only applies to the NOR flash style booting.
  54. * NAND booting is different. For more details about NAND booting on 4xx
  55. * take a look at doc/README.nand-boot-ppc440.
  56. *
  57. * The CPU starts at address 0xfffffffc (last word in the address space).
  58. * The U-Boot image therefore has to be located in the "upper" area of the
  59. * flash (e.g. 512MiB - 0xfff80000 ... 0xffffffff). The default value for
  60. * the boot chip-select (CS0) is quite big and covers this area. On the
  61. * 405EX this is for example 0xffe00000 ... 0xffffffff. U-Boot will
  62. * reconfigure this CS0 (and other chip-selects as well when configured
  63. * this way) in the boot process to the "correct" values matching the
  64. * board layout.
  65. */
  66. #include <asm-offsets.h>
  67. #include <config.h>
  68. #include <asm/ppc4xx.h>
  69. #include <version.h>
  70. #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
  71. #include <ppc_asm.tmpl>
  72. #include <ppc_defs.h>
  73. #include <asm/cache.h>
  74. #include <asm/mmu.h>
  75. #include <asm/ppc4xx-isram.h>
  76. #ifdef CONFIG_SYS_INIT_DCACHE_CS
  77. # if (CONFIG_SYS_INIT_DCACHE_CS == 0)
  78. # define PBxAP PB1AP
  79. # define PBxCR PB0CR
  80. # if (defined(CONFIG_SYS_EBC_PB0AP) && defined(CONFIG_SYS_EBC_PB0CR))
  81. # define PBxAP_VAL CONFIG_SYS_EBC_PB0AP
  82. # define PBxCR_VAL CONFIG_SYS_EBC_PB0CR
  83. # endif
  84. # endif
  85. # if (CONFIG_SYS_INIT_DCACHE_CS == 1)
  86. # define PBxAP PB1AP
  87. # define PBxCR PB1CR
  88. # if (defined(CONFIG_SYS_EBC_PB1AP) && defined(CONFIG_SYS_EBC_PB1CR))
  89. # define PBxAP_VAL CONFIG_SYS_EBC_PB1AP
  90. # define PBxCR_VAL CONFIG_SYS_EBC_PB1CR
  91. # endif
  92. # endif
  93. # if (CONFIG_SYS_INIT_DCACHE_CS == 2)
  94. # define PBxAP PB2AP
  95. # define PBxCR PB2CR
  96. # if (defined(CONFIG_SYS_EBC_PB2AP) && defined(CONFIG_SYS_EBC_PB2CR))
  97. # define PBxAP_VAL CONFIG_SYS_EBC_PB2AP
  98. # define PBxCR_VAL CONFIG_SYS_EBC_PB2CR
  99. # endif
  100. # endif
  101. # if (CONFIG_SYS_INIT_DCACHE_CS == 3)
  102. # define PBxAP PB3AP
  103. # define PBxCR PB3CR
  104. # if (defined(CONFIG_SYS_EBC_PB3AP) && defined(CONFIG_SYS_EBC_PB3CR))
  105. # define PBxAP_VAL CONFIG_SYS_EBC_PB3AP
  106. # define PBxCR_VAL CONFIG_SYS_EBC_PB3CR
  107. # endif
  108. # endif
  109. # if (CONFIG_SYS_INIT_DCACHE_CS == 4)
  110. # define PBxAP PB4AP
  111. # define PBxCR PB4CR
  112. # if (defined(CONFIG_SYS_EBC_PB4AP) && defined(CONFIG_SYS_EBC_PB4CR))
  113. # define PBxAP_VAL CONFIG_SYS_EBC_PB4AP
  114. # define PBxCR_VAL CONFIG_SYS_EBC_PB4CR
  115. # endif
  116. # endif
  117. # if (CONFIG_SYS_INIT_DCACHE_CS == 5)
  118. # define PBxAP PB5AP
  119. # define PBxCR PB5CR
  120. # if (defined(CONFIG_SYS_EBC_PB5AP) && defined(CONFIG_SYS_EBC_PB5CR))
  121. # define PBxAP_VAL CONFIG_SYS_EBC_PB5AP
  122. # define PBxCR_VAL CONFIG_SYS_EBC_PB5CR
  123. # endif
  124. # endif
  125. # if (CONFIG_SYS_INIT_DCACHE_CS == 6)
  126. # define PBxAP PB6AP
  127. # define PBxCR PB6CR
  128. # if (defined(CONFIG_SYS_EBC_PB6AP) && defined(CONFIG_SYS_EBC_PB6CR))
  129. # define PBxAP_VAL CONFIG_SYS_EBC_PB6AP
  130. # define PBxCR_VAL CONFIG_SYS_EBC_PB6CR
  131. # endif
  132. # endif
  133. # if (CONFIG_SYS_INIT_DCACHE_CS == 7)
  134. # define PBxAP PB7AP
  135. # define PBxCR PB7CR
  136. # if (defined(CONFIG_SYS_EBC_PB7AP) && defined(CONFIG_SYS_EBC_PB7CR))
  137. # define PBxAP_VAL CONFIG_SYS_EBC_PB7AP
  138. # define PBxCR_VAL CONFIG_SYS_EBC_PB7CR
  139. # endif
  140. # endif
  141. # ifndef PBxAP_VAL
  142. # define PBxAP_VAL 0
  143. # endif
  144. # ifndef PBxCR_VAL
  145. # define PBxCR_VAL 0
  146. # endif
  147. /*
  148. * Memory Bank x (nothingness) initialization CONFIG_SYS_INIT_RAM_ADDR + 64 MiB
  149. * used as temporary stack pointer for the primordial stack
  150. */
  151. # ifndef CONFIG_SYS_INIT_DCACHE_PBxAR
  152. # define CONFIG_SYS_INIT_DCACHE_PBxAR (EBC_BXAP_BME_DISABLED | \
  153. EBC_BXAP_TWT_ENCODE(7) | \
  154. EBC_BXAP_BCE_DISABLE | \
  155. EBC_BXAP_BCT_2TRANS | \
  156. EBC_BXAP_CSN_ENCODE(0) | \
  157. EBC_BXAP_OEN_ENCODE(0) | \
  158. EBC_BXAP_WBN_ENCODE(0) | \
  159. EBC_BXAP_WBF_ENCODE(0) | \
  160. EBC_BXAP_TH_ENCODE(2) | \
  161. EBC_BXAP_RE_DISABLED | \
  162. EBC_BXAP_SOR_NONDELAYED | \
  163. EBC_BXAP_BEM_WRITEONLY | \
  164. EBC_BXAP_PEN_DISABLED)
  165. # endif /* CONFIG_SYS_INIT_DCACHE_PBxAR */
  166. # ifndef CONFIG_SYS_INIT_DCACHE_PBxCR
  167. # define CONFIG_SYS_INIT_DCACHE_PBxCR (EBC_BXCR_BAS_ENCODE(CONFIG_SYS_INIT_RAM_ADDR) | \
  168. EBC_BXCR_BS_64MB | \
  169. EBC_BXCR_BU_RW | \
  170. EBC_BXCR_BW_16BIT)
  171. # endif /* CONFIG_SYS_INIT_DCACHE_PBxCR */
  172. # ifndef CONFIG_SYS_INIT_RAM_PATTERN
  173. # define CONFIG_SYS_INIT_RAM_PATTERN 0xDEADDEAD
  174. # endif
  175. #endif /* CONFIG_SYS_INIT_DCACHE_CS */
  176. #if (defined(CONFIG_SYS_INIT_RAM_DCACHE) && (CONFIG_SYS_INIT_RAM_SIZE > (4 << 10)))
  177. #error Only 4k of init-ram is supported - please adjust CONFIG_SYS_INIT_RAM_SIZE!
  178. #endif
  179. /*
  180. * Unless otherwise overriden, enable two 128MB cachable instruction regions
  181. * at CONFIG_SYS_SDRAM_BASE and another 128MB cacheable instruction region covering
  182. * NOR flash at CONFIG_SYS_FLASH_BASE. Disable all cacheable data regions.
  183. */
  184. #if !defined(CONFIG_SYS_FLASH_BASE)
  185. /* If not already defined, set it to the "last" 128MByte region */
  186. # define CONFIG_SYS_FLASH_BASE 0xf8000000
  187. #endif
  188. #if !defined(CONFIG_SYS_ICACHE_SACR_VALUE)
  189. # define CONFIG_SYS_ICACHE_SACR_VALUE \
  190. (PPC_128MB_SACR_VALUE(CONFIG_SYS_SDRAM_BASE + ( 0 << 20)) | \
  191. PPC_128MB_SACR_VALUE(CONFIG_SYS_SDRAM_BASE + (128 << 20)) | \
  192. PPC_128MB_SACR_VALUE(CONFIG_SYS_FLASH_BASE))
  193. #endif /* !defined(CONFIG_SYS_ICACHE_SACR_VALUE) */
  194. #if !defined(CONFIG_SYS_DCACHE_SACR_VALUE)
  195. # define CONFIG_SYS_DCACHE_SACR_VALUE \
  196. (0x00000000)
  197. #endif /* !defined(CONFIG_SYS_DCACHE_SACR_VALUE) */
  198. #if !defined(CONFIG_SYS_TLB_FOR_BOOT_FLASH)
  199. #define CONFIG_SYS_TLB_FOR_BOOT_FLASH 0 /* use TLB 0 as default */
  200. #endif
  201. #define function_prolog(func_name) .text; \
  202. .align 2; \
  203. .globl func_name; \
  204. func_name:
  205. #define function_epilog(func_name) .type func_name,@function; \
  206. .size func_name,.-func_name
  207. /* We don't want the MMU yet.
  208. */
  209. #undef MSR_KERNEL
  210. #define MSR_KERNEL ( MSR_ME ) /* Machine Check */
  211. .extern ext_bus_cntlr_init
  212. #ifdef CONFIG_NAND_U_BOOT
  213. .extern reconfig_tlb0
  214. #endif
  215. /*
  216. * Set up GOT: Global Offset Table
  217. *
  218. * Use r12 to access the GOT
  219. */
  220. #if !defined(CONFIG_NAND_SPL)
  221. START_GOT
  222. GOT_ENTRY(_GOT2_TABLE_)
  223. GOT_ENTRY(_FIXUP_TABLE_)
  224. GOT_ENTRY(_start)
  225. GOT_ENTRY(_start_of_vectors)
  226. GOT_ENTRY(_end_of_vectors)
  227. GOT_ENTRY(transfer_to_handler)
  228. GOT_ENTRY(__init_end)
  229. GOT_ENTRY(__bss_end__)
  230. GOT_ENTRY(__bss_start)
  231. END_GOT
  232. #endif /* CONFIG_NAND_SPL */
  233. #if defined(CONFIG_NAND_U_BOOT) && !defined(CONFIG_NAND_SPL)
  234. /*
  235. * NAND U-Boot image is started from offset 0
  236. */
  237. .text
  238. #if defined(CONFIG_440)
  239. bl reconfig_tlb0
  240. #endif
  241. GET_GOT
  242. bl cpu_init_f /* run low-level CPU init code (from Flash) */
  243. bl board_init_f
  244. /* NOTREACHED - board_init_f() does not return */
  245. #endif
  246. #if defined(CONFIG_SYS_RAMBOOT) || defined(CONFIG_BOOT_FROM_XMD)
  247. /*
  248. * 4xx RAM-booting U-Boot image is started from offset 0
  249. */
  250. .text
  251. bl _start_440
  252. #endif
  253. /*
  254. * 440 Startup -- on reset only the top 4k of the effective
  255. * address space is mapped in by an entry in the instruction
  256. * and data shadow TLB. The .bootpg section is located in the
  257. * top 4k & does only what's necessary to map in the the rest
  258. * of the boot rom. Once the boot rom is mapped in we can
  259. * proceed with normal startup.
  260. *
  261. * NOTE: CS0 only covers the top 2MB of the effective address
  262. * space after reset.
  263. */
  264. #if defined(CONFIG_440)
  265. #if !defined(CONFIG_NAND_SPL)
  266. .section .bootpg,"ax"
  267. #endif
  268. .globl _start_440
  269. /**************************************************************************/
  270. _start_440:
  271. /*--------------------------------------------------------------------+
  272. | 440EPX BUP Change - Hardware team request
  273. +--------------------------------------------------------------------*/
  274. #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
  275. sync
  276. nop
  277. nop
  278. #endif
  279. /*----------------------------------------------------------------+
  280. | Core bug fix. Clear the esr
  281. +-----------------------------------------------------------------*/
  282. li r0,0
  283. mtspr SPRN_ESR,r0
  284. /*----------------------------------------------------------------*/
  285. /* Clear and set up some registers. */
  286. /*----------------------------------------------------------------*/
  287. iccci r0,r0 /* NOTE: operands not used for 440 */
  288. dccci r0,r0 /* NOTE: operands not used for 440 */
  289. sync
  290. li r0,0
  291. mtspr SPRN_SRR0,r0
  292. mtspr SPRN_SRR1,r0
  293. mtspr SPRN_CSRR0,r0
  294. mtspr SPRN_CSRR1,r0
  295. /* NOTE: 440GX adds machine check status regs */
  296. #if defined(CONFIG_440) && !defined(CONFIG_440GP)
  297. mtspr SPRN_MCSRR0,r0
  298. mtspr SPRN_MCSRR1,r0
  299. mfspr r1,SPRN_MCSR
  300. mtspr SPRN_MCSR,r1
  301. #endif
  302. /*----------------------------------------------------------------*/
  303. /* CCR0 init */
  304. /*----------------------------------------------------------------*/
  305. /* Disable store gathering & broadcast, guarantee inst/data
  306. * cache block touch, force load/store alignment
  307. * (see errata 1.12: 440_33)
  308. */
  309. lis r1,0x0030 /* store gathering & broadcast disable */
  310. ori r1,r1,0x6000 /* cache touch */
  311. mtspr SPRN_CCR0,r1
  312. /*----------------------------------------------------------------*/
  313. /* Initialize debug */
  314. /*----------------------------------------------------------------*/
  315. mfspr r1,SPRN_DBCR0
  316. andis. r1, r1, 0x8000 /* test DBCR0[EDM] bit */
  317. bne skip_debug_init /* if set, don't clear debug register */
  318. mfspr r1,SPRN_CCR0
  319. ori r1,r1,CCR0_DTB@l /* Disable Trace Broadcast */
  320. mtspr SPRN_CCR0,r1
  321. mtspr SPRN_DBCR0,r0
  322. mtspr SPRN_DBCR1,r0
  323. mtspr SPRN_DBCR2,r0
  324. mtspr SPRN_IAC1,r0
  325. mtspr SPRN_IAC2,r0
  326. mtspr SPRN_IAC3,r0
  327. mtspr SPRN_DAC1,r0
  328. mtspr SPRN_DAC2,r0
  329. mtspr SPRN_DVC1,r0
  330. mtspr SPRN_DVC2,r0
  331. mfspr r1,SPRN_DBSR
  332. mtspr SPRN_DBSR,r1 /* Clear all valid bits */
  333. skip_debug_init:
  334. #if defined (CONFIG_440SPE)
  335. /*----------------------------------------------------------------+
  336. | Initialize Core Configuration Reg1.
  337. | a. ICDPEI: Record even parity. Normal operation.
  338. | b. ICTPEI: Record even parity. Normal operation.
  339. | c. DCTPEI: Record even parity. Normal operation.
  340. | d. DCDPEI: Record even parity. Normal operation.
  341. | e. DCUPEI: Record even parity. Normal operation.
  342. | f. DCMPEI: Record even parity. Normal operation.
  343. | g. FCOM: Normal operation
  344. | h. MMUPEI: Record even parity. Normal operation.
  345. | i. FFF: Flush only as much data as necessary.
  346. | j. TCS: Timebase increments from CPU clock.
  347. +-----------------------------------------------------------------*/
  348. li r0,0
  349. mtspr SPRN_CCR1, r0
  350. /*----------------------------------------------------------------+
  351. | Reset the timebase.
  352. | The previous write to CCR1 sets the timebase source.
  353. +-----------------------------------------------------------------*/
  354. mtspr SPRN_TBWL, r0
  355. mtspr SPRN_TBWU, r0
  356. #endif
  357. /*----------------------------------------------------------------*/
  358. /* Setup interrupt vectors */
  359. /*----------------------------------------------------------------*/
  360. mtspr SPRN_IVPR,r0 /* Vectors start at 0x0000_0000 */
  361. li r1,0x0100
  362. mtspr SPRN_IVOR0,r1 /* Critical input */
  363. li r1,0x0200
  364. mtspr SPRN_IVOR1,r1 /* Machine check */
  365. li r1,0x0300
  366. mtspr SPRN_IVOR2,r1 /* Data storage */
  367. li r1,0x0400
  368. mtspr SPRN_IVOR3,r1 /* Instruction storage */
  369. li r1,0x0500
  370. mtspr SPRN_IVOR4,r1 /* External interrupt */
  371. li r1,0x0600
  372. mtspr SPRN_IVOR5,r1 /* Alignment */
  373. li r1,0x0700
  374. mtspr SPRN_IVOR6,r1 /* Program check */
  375. li r1,0x0800
  376. mtspr SPRN_IVOR7,r1 /* Floating point unavailable */
  377. li r1,0x0c00
  378. mtspr SPRN_IVOR8,r1 /* System call */
  379. li r1,0x0a00
  380. mtspr SPRN_IVOR9,r1 /* Auxiliary Processor unavailable */
  381. li r1,0x0900
  382. mtspr SPRN_IVOR10,r1 /* Decrementer */
  383. li r1,0x1300
  384. mtspr SPRN_IVOR13,r1 /* Data TLB error */
  385. li r1,0x1400
  386. mtspr SPRN_IVOR14,r1 /* Instr TLB error */
  387. li r1,0x2000
  388. mtspr SPRN_IVOR15,r1 /* Debug */
  389. /*----------------------------------------------------------------*/
  390. /* Configure cache regions */
  391. /*----------------------------------------------------------------*/
  392. mtspr SPRN_INV0,r0
  393. mtspr SPRN_INV1,r0
  394. mtspr SPRN_INV2,r0
  395. mtspr SPRN_INV3,r0
  396. mtspr SPRN_DNV0,r0
  397. mtspr SPRN_DNV1,r0
  398. mtspr SPRN_DNV2,r0
  399. mtspr SPRN_DNV3,r0
  400. mtspr SPRN_ITV0,r0
  401. mtspr SPRN_ITV1,r0
  402. mtspr SPRN_ITV2,r0
  403. mtspr SPRN_ITV3,r0
  404. mtspr SPRN_DTV0,r0
  405. mtspr SPRN_DTV1,r0
  406. mtspr SPRN_DTV2,r0
  407. mtspr SPRN_DTV3,r0
  408. /*----------------------------------------------------------------*/
  409. /* Cache victim limits */
  410. /*----------------------------------------------------------------*/
  411. /* floors 0, ceiling max to use the entire cache -- nothing locked
  412. */
  413. lis r1,0x0001
  414. ori r1,r1,0xf800
  415. mtspr SPRN_IVLIM,r1
  416. mtspr SPRN_DVLIM,r1
  417. /*----------------------------------------------------------------+
  418. |Initialize MMUCR[STID] = 0.
  419. +-----------------------------------------------------------------*/
  420. mfspr r0,SPRN_MMUCR
  421. addis r1,0,0xFFFF
  422. ori r1,r1,0xFF00
  423. and r0,r0,r1
  424. mtspr SPRN_MMUCR,r0
  425. /*----------------------------------------------------------------*/
  426. /* Clear all TLB entries -- TID = 0, TS = 0 */
  427. /*----------------------------------------------------------------*/
  428. addis r0,0,0x0000
  429. #ifdef CONFIG_SYS_RAMBOOT
  430. li r4,0 /* Start with TLB #0 */
  431. #else
  432. li r4,1 /* Start with TLB #1 */
  433. #endif
  434. li r1,64 /* 64 TLB entries */
  435. sub r1,r1,r4 /* calculate last TLB # */
  436. mtctr r1
  437. rsttlb:
  438. #ifdef CONFIG_SYS_RAMBOOT
  439. tlbre r3,r4,0 /* Read contents from TLB word #0 to get EPN */
  440. rlwinm. r3,r3,0,0xfffffc00 /* Mask EPN */
  441. beq tlbnxt /* Skip EPN=0 TLB, this is the SDRAM TLB */
  442. #endif
  443. tlbwe r0,r4,0 /* Invalidate all entries (V=0)*/
  444. tlbwe r0,r4,1
  445. tlbwe r0,r4,2
  446. tlbnxt: addi r4,r4,1 /* Next TLB */
  447. bdnz rsttlb
  448. /*----------------------------------------------------------------*/
  449. /* TLB entry setup -- step thru tlbtab */
  450. /*----------------------------------------------------------------*/
  451. #if defined(CONFIG_440SPE_REVA)
  452. /*----------------------------------------------------------------*/
  453. /* We have different TLB tables for revA and rev B of 440SPe */
  454. /*----------------------------------------------------------------*/
  455. mfspr r1, PVR
  456. lis r0,0x5342
  457. ori r0,r0,0x1891
  458. cmpw r7,r1,r0
  459. bne r7,..revA
  460. bl tlbtabB
  461. b ..goon
  462. ..revA:
  463. bl tlbtabA
  464. ..goon:
  465. #else
  466. bl tlbtab /* Get tlbtab pointer */
  467. #endif
  468. mr r5,r0
  469. li r1,0x003f /* 64 TLB entries max */
  470. mtctr r1
  471. li r4,0 /* TLB # */
  472. addi r5,r5,-4
  473. 1:
  474. #ifdef CONFIG_SYS_RAMBOOT
  475. tlbre r3,r4,0 /* Read contents from TLB word #0 */
  476. rlwinm. r3,r3,0,0x00000200 /* Mask V (valid) bit */
  477. bne tlbnx2 /* Skip V=1 TLB, this is the SDRAM TLB */
  478. #endif
  479. lwzu r0,4(r5)
  480. cmpwi r0,0
  481. beq 2f /* 0 marks end */
  482. lwzu r1,4(r5)
  483. lwzu r2,4(r5)
  484. tlbwe r0,r4,0 /* TLB Word 0 */
  485. tlbwe r1,r4,1 /* TLB Word 1 */
  486. tlbwe r2,r4,2 /* TLB Word 2 */
  487. tlbnx2: addi r4,r4,1 /* Next TLB */
  488. bdnz 1b
  489. /*----------------------------------------------------------------*/
  490. /* Continue from 'normal' start */
  491. /*----------------------------------------------------------------*/
  492. 2:
  493. bl 3f
  494. b _start
  495. 3: li r0,0
  496. mtspr SPRN_SRR1,r0 /* Keep things disabled for now */
  497. mflr r1
  498. mtspr SPRN_SRR0,r1
  499. rfi
  500. #endif /* CONFIG_440 */
  501. /*
  502. * r3 - 1st arg to board_init(): IMMP pointer
  503. * r4 - 2nd arg to board_init(): boot flag
  504. */
  505. #ifndef CONFIG_NAND_SPL
  506. .text
  507. .long 0x27051956 /* U-Boot Magic Number */
  508. .globl version_string
  509. version_string:
  510. .ascii U_BOOT_VERSION_STRING, "\0"
  511. . = EXC_OFF_SYS_RESET
  512. .globl _start_of_vectors
  513. _start_of_vectors:
  514. /* Critical input. */
  515. CRIT_EXCEPTION(0x100, CritcalInput, UnknownException)
  516. #ifdef CONFIG_440
  517. /* Machine check */
  518. MCK_EXCEPTION(0x200, MachineCheck, MachineCheckException)
  519. #else
  520. CRIT_EXCEPTION(0x200, MachineCheck, MachineCheckException)
  521. #endif /* CONFIG_440 */
  522. /* Data Storage exception. */
  523. STD_EXCEPTION(0x300, DataStorage, UnknownException)
  524. /* Instruction Storage exception. */
  525. STD_EXCEPTION(0x400, InstStorage, UnknownException)
  526. /* External Interrupt exception. */
  527. STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
  528. /* Alignment exception. */
  529. . = 0x600
  530. Alignment:
  531. EXCEPTION_PROLOG(SRR0, SRR1)
  532. mfspr r4,DAR
  533. stw r4,_DAR(r21)
  534. mfspr r5,DSISR
  535. stw r5,_DSISR(r21)
  536. addi r3,r1,STACK_FRAME_OVERHEAD
  537. EXC_XFER_TEMPLATE(Alignment, AlignmentException, MSR_KERNEL, COPY_EE)
  538. /* Program check exception */
  539. . = 0x700
  540. ProgramCheck:
  541. EXCEPTION_PROLOG(SRR0, SRR1)
  542. addi r3,r1,STACK_FRAME_OVERHEAD
  543. EXC_XFER_TEMPLATE(ProgramCheck, ProgramCheckException,
  544. MSR_KERNEL, COPY_EE)
  545. #ifdef CONFIG_440
  546. STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
  547. STD_EXCEPTION(0x900, Decrementer, DecrementerPITException)
  548. STD_EXCEPTION(0xa00, APU, UnknownException)
  549. #endif
  550. STD_EXCEPTION(0xc00, SystemCall, UnknownException)
  551. #ifdef CONFIG_440
  552. STD_EXCEPTION(0x1300, DataTLBError, UnknownException)
  553. STD_EXCEPTION(0x1400, InstructionTLBError, UnknownException)
  554. #else
  555. STD_EXCEPTION(0x1000, PIT, DecrementerPITException)
  556. STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException)
  557. STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException)
  558. #endif
  559. CRIT_EXCEPTION(0x2000, DebugBreakpoint, DebugException )
  560. .globl _end_of_vectors
  561. _end_of_vectors:
  562. . = _START_OFFSET
  563. #endif
  564. .globl _start
  565. _start:
  566. /*****************************************************************************/
  567. #if defined(CONFIG_440)
  568. /*----------------------------------------------------------------*/
  569. /* Clear and set up some registers. */
  570. /*----------------------------------------------------------------*/
  571. li r0,0x0000
  572. lis r1,0xffff
  573. mtspr SPRN_DEC,r0 /* prevent dec exceptions */
  574. mtspr SPRN_TBWL,r0 /* prevent fit & wdt exceptions */
  575. mtspr SPRN_TBWU,r0
  576. mtspr SPRN_TSR,r1 /* clear all timer exception status */
  577. mtspr SPRN_TCR,r0 /* disable all */
  578. mtspr SPRN_ESR,r0 /* clear exception syndrome register */
  579. mtxer r0 /* clear integer exception register */
  580. /*----------------------------------------------------------------*/
  581. /* Debug setup -- some (not very good) ice's need an event*/
  582. /* to establish control :-( Define CONFIG_SYS_INIT_DBCR to the dbsr */
  583. /* value you need in this case 0x8cff 0000 should do the trick */
  584. /*----------------------------------------------------------------*/
  585. #if defined(CONFIG_SYS_INIT_DBCR)
  586. lis r1,0xffff
  587. ori r1,r1,0xffff
  588. mtspr SPRN_DBSR,r1 /* Clear all status bits */
  589. lis r0,CONFIG_SYS_INIT_DBCR@h
  590. ori r0,r0,CONFIG_SYS_INIT_DBCR@l
  591. mtspr SPRN_DBCR0,r0
  592. isync
  593. #endif
  594. /*----------------------------------------------------------------*/
  595. /* Setup the internal SRAM */
  596. /*----------------------------------------------------------------*/
  597. li r0,0
  598. #ifdef CONFIG_SYS_INIT_RAM_DCACHE
  599. /* Clear Dcache to use as RAM */
  600. addis r3,r0,CONFIG_SYS_INIT_RAM_ADDR@h
  601. ori r3,r3,CONFIG_SYS_INIT_RAM_ADDR@l
  602. addis r4,r0,CONFIG_SYS_INIT_RAM_SIZE@h
  603. ori r4,r4,CONFIG_SYS_INIT_RAM_SIZE@l
  604. rlwinm. r5,r4,0,27,31
  605. rlwinm r5,r4,27,5,31
  606. beq ..d_ran
  607. addi r5,r5,0x0001
  608. ..d_ran:
  609. mtctr r5
  610. ..d_ag:
  611. dcbz r0,r3
  612. addi r3,r3,32
  613. bdnz ..d_ag
  614. /*
  615. * Lock the init-ram/stack in d-cache, so that other regions
  616. * may use d-cache as well
  617. * Note, that this current implementation locks exactly 4k
  618. * of d-cache, so please make sure that you don't define a
  619. * bigger init-ram area. Take a look at the lwmon5 440EPx
  620. * implementation as a reference.
  621. */
  622. msync
  623. isync
  624. /* 8. set TFLOOR/NFLOOR to 8 (-> 8*16*32 bytes locked -> 4k) */
  625. lis r1,0x0201
  626. ori r1,r1,0xf808
  627. mtspr SPRN_DVLIM,r1
  628. lis r1,0x0808
  629. ori r1,r1,0x0808
  630. mtspr SPRN_DNV0,r1
  631. mtspr SPRN_DNV1,r1
  632. mtspr SPRN_DNV2,r1
  633. mtspr SPRN_DNV3,r1
  634. mtspr SPRN_DTV0,r1
  635. mtspr SPRN_DTV1,r1
  636. mtspr SPRN_DTV2,r1
  637. mtspr SPRN_DTV3,r1
  638. msync
  639. isync
  640. #endif /* CONFIG_SYS_INIT_RAM_DCACHE */
  641. /* 440EP & 440GR are only 440er PPC's without internal SRAM */
  642. #if !defined(CONFIG_440EP) && !defined(CONFIG_440GR)
  643. /* not all PPC's have internal SRAM usable as L2-cache */
  644. #if defined(CONFIG_440GX) || \
  645. defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
  646. defined(CONFIG_460SX)
  647. mtdcr L2_CACHE_CFG,r0 /* Ensure L2 Cache is off */
  648. #elif defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
  649. defined(CONFIG_APM821XX)
  650. lis r1, 0x0000
  651. ori r1,r1,0x0008 /* Set L2_CACHE_CFG[RDBW]=1 */
  652. mtdcr L2_CACHE_CFG,r1
  653. #endif
  654. lis r2,0x7fff
  655. ori r2,r2,0xffff
  656. mfdcr r1,ISRAM0_DPC
  657. and r1,r1,r2 /* Disable parity check */
  658. mtdcr ISRAM0_DPC,r1
  659. mfdcr r1,ISRAM0_PMEG
  660. and r1,r1,r2 /* Disable pwr mgmt */
  661. mtdcr ISRAM0_PMEG,r1
  662. lis r1,0x8000 /* BAS = 8000_0000 */
  663. #if defined(CONFIG_440GX) || defined(CONFIG_440SP)
  664. ori r1,r1,0x0980 /* first 64k */
  665. mtdcr ISRAM0_SB0CR,r1
  666. lis r1,0x8001
  667. ori r1,r1,0x0980 /* second 64k */
  668. mtdcr ISRAM0_SB1CR,r1
  669. lis r1, 0x8002
  670. ori r1,r1, 0x0980 /* third 64k */
  671. mtdcr ISRAM0_SB2CR,r1
  672. lis r1, 0x8003
  673. ori r1,r1, 0x0980 /* fourth 64k */
  674. mtdcr ISRAM0_SB3CR,r1
  675. #elif defined(CONFIG_440SPE) || defined(CONFIG_460EX) || \
  676. defined(CONFIG_460GT) || defined(CONFIG_APM821XX)
  677. lis r1,0x0000 /* BAS = X_0000_0000 */
  678. ori r1,r1,0x0984 /* first 64k */
  679. mtdcr ISRAM0_SB0CR,r1
  680. lis r1,0x0001
  681. ori r1,r1,0x0984 /* second 64k */
  682. mtdcr ISRAM0_SB1CR,r1
  683. lis r1, 0x0002
  684. ori r1,r1, 0x0984 /* third 64k */
  685. mtdcr ISRAM0_SB2CR,r1
  686. lis r1, 0x0003
  687. ori r1,r1, 0x0984 /* fourth 64k */
  688. mtdcr ISRAM0_SB3CR,r1
  689. #if defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
  690. defined(CONFIG_APM821XX)
  691. lis r2,0x7fff
  692. ori r2,r2,0xffff
  693. mfdcr r1,ISRAM1_DPC
  694. and r1,r1,r2 /* Disable parity check */
  695. mtdcr ISRAM1_DPC,r1
  696. mfdcr r1,ISRAM1_PMEG
  697. and r1,r1,r2 /* Disable pwr mgmt */
  698. mtdcr ISRAM1_PMEG,r1
  699. lis r1,0x0004 /* BAS = 4_0004_0000 */
  700. ori r1,r1,ISRAM1_SIZE /* ocm size */
  701. mtdcr ISRAM1_SB0CR,r1
  702. #endif
  703. #elif defined(CONFIG_460SX)
  704. lis r1,0x0000 /* BAS = 0000_0000 */
  705. ori r1,r1,0x0B84 /* first 128k */
  706. mtdcr ISRAM0_SB0CR,r1
  707. lis r1,0x0001
  708. ori r1,r1,0x0B84 /* second 128k */
  709. mtdcr ISRAM0_SB1CR,r1
  710. lis r1, 0x0002
  711. ori r1,r1, 0x0B84 /* third 128k */
  712. mtdcr ISRAM0_SB2CR,r1
  713. lis r1, 0x0003
  714. ori r1,r1, 0x0B84 /* fourth 128k */
  715. mtdcr ISRAM0_SB3CR,r1
  716. #elif defined(CONFIG_440GP)
  717. ori r1,r1,0x0380 /* 8k rw */
  718. mtdcr ISRAM0_SB0CR,r1
  719. mtdcr ISRAM0_SB1CR,r0 /* Disable bank 1 */
  720. #endif
  721. #endif /* #if !defined(CONFIG_440EP) && !defined(CONFIG_440GR) */
  722. /*----------------------------------------------------------------*/
  723. /* Setup the stack in internal SRAM */
  724. /*----------------------------------------------------------------*/
  725. lis r1,CONFIG_SYS_INIT_RAM_ADDR@h
  726. ori r1,r1,CONFIG_SYS_INIT_SP_OFFSET@l
  727. li r0,0
  728. stwu r0,-4(r1)
  729. stwu r0,-4(r1) /* Terminate call chain */
  730. stwu r1,-8(r1) /* Save back chain and move SP */
  731. lis r0,RESET_VECTOR@h /* Address of reset vector */
  732. ori r0,r0, RESET_VECTOR@l
  733. stwu r1,-8(r1) /* Save back chain and move SP */
  734. stw r0,+12(r1) /* Save return addr (underflow vect) */
  735. #ifdef CONFIG_NAND_SPL
  736. bl nand_boot_common /* will not return */
  737. #else
  738. GET_GOT
  739. bl cpu_init_f /* run low-level CPU init code (from Flash) */
  740. bl board_init_f
  741. /* NOTREACHED - board_init_f() does not return */
  742. #endif
  743. #endif /* CONFIG_440 */
  744. /*****************************************************************************/
  745. #ifdef CONFIG_IOP480
  746. /*----------------------------------------------------------------------- */
  747. /* Set up some machine state registers. */
  748. /*----------------------------------------------------------------------- */
  749. addi r0,r0,0x0000 /* initialize r0 to zero */
  750. mtspr SPRN_ESR,r0 /* clear Exception Syndrome Reg */
  751. mttcr r0 /* timer control register */
  752. mtexier r0 /* disable all interrupts */
  753. addis r4,r0,0xFFFF /* set r4 to 0xFFFFFFFF (status in the */
  754. ori r4,r4,0xFFFF /* dbsr is cleared by setting bits to 1) */
  755. mtdbsr r4 /* clear/reset the dbsr */
  756. mtexisr r4 /* clear all pending interrupts */
  757. addis r4,r0,0x8000
  758. mtexier r4 /* enable critical exceptions */
  759. addis r4,r0,0x0000 /* assume 403GCX - enable core clk */
  760. ori r4,r4,0x4020 /* dbling (no harm done on GA and GC */
  761. mtiocr r4 /* since bit not used) & DRC to latch */
  762. /* data bus on rising edge of CAS */
  763. /*----------------------------------------------------------------------- */
  764. /* Clear XER. */
  765. /*----------------------------------------------------------------------- */
  766. mtxer r0
  767. /*----------------------------------------------------------------------- */
  768. /* Invalidate i-cache and d-cache TAG arrays. */
  769. /*----------------------------------------------------------------------- */
  770. addi r3,0,1024 /* 1/4 of I-cache size, half of D-cache */
  771. addi r4,0,1024 /* 1/4 of I-cache */
  772. ..cloop:
  773. iccci 0,r3
  774. iccci r4,r3
  775. dccci 0,r3
  776. addic. r3,r3,-16 /* move back one cache line */
  777. bne ..cloop /* loop back to do rest until r3 = 0 */
  778. /* */
  779. /* initialize IOP480 so it can read 1 MB code area for SRAM spaces */
  780. /* this requires enabling MA[17..0], by default only MA[12..0] are enabled. */
  781. /* */
  782. /* first copy IOP480 register base address into r3 */
  783. addis r3,0,0x5000 /* IOP480 register base address hi */
  784. /* ori r3,r3,0x0000 / IOP480 register base address lo */
  785. #ifdef CONFIG_ADCIOP
  786. /* use r4 as the working variable */
  787. /* turn on CS3 (LOCCTL.7) */
  788. lwz r4,0x84(r3) /* LOCTL is at offset 0x84 */
  789. andi. r4,r4,0xff7f /* make bit 7 = 0 -- CS3 mode */
  790. stw r4,0x84(r3) /* LOCTL is at offset 0x84 */
  791. #endif
  792. #ifdef CONFIG_DASA_SIM
  793. /* use r4 as the working variable */
  794. /* turn on MA17 (LOCCTL.7) */
  795. lwz r4,0x84(r3) /* LOCTL is at offset 0x84 */
  796. ori r4,r4,0x80 /* make bit 7 = 1 -- MA17 mode */
  797. stw r4,0x84(r3) /* LOCTL is at offset 0x84 */
  798. #endif
  799. /* turn on MA16..13 (LCS0BRD.12 = 0) */
  800. lwz r4,0x100(r3) /* LCS0BRD is at offset 0x100 */
  801. andi. r4,r4,0xefff /* make bit 12 = 0 */
  802. stw r4,0x100(r3) /* LCS0BRD is at offset 0x100 */
  803. /* make sure above stores all comlete before going on */
  804. sync
  805. /* last thing, set local init status done bit (DEVINIT.31) */
  806. lwz r4,0x80(r3) /* DEVINIT is at offset 0x80 */
  807. oris r4,r4,0x8000 /* make bit 31 = 1 */
  808. stw r4,0x80(r3) /* DEVINIT is at offset 0x80 */
  809. /* clear all pending interrupts and disable all interrupts */
  810. li r4,-1 /* set p1 to 0xffffffff */
  811. stw r4,0x1b0(r3) /* clear all pending interrupts */
  812. stw r4,0x1b8(r3) /* clear all pending interrupts */
  813. li r4,0 /* set r4 to 0 */
  814. stw r4,0x1b4(r3) /* disable all interrupts */
  815. stw r4,0x1bc(r3) /* disable all interrupts */
  816. /* make sure above stores all comlete before going on */
  817. sync
  818. /* Set-up icache cacheability. */
  819. lis r1, CONFIG_SYS_ICACHE_SACR_VALUE@h
  820. ori r1, r1, CONFIG_SYS_ICACHE_SACR_VALUE@l
  821. mticcr r1
  822. isync
  823. /* Set-up dcache cacheability. */
  824. lis r1, CONFIG_SYS_DCACHE_SACR_VALUE@h
  825. ori r1, r1, CONFIG_SYS_DCACHE_SACR_VALUE@l
  826. mtdccr r1
  827. addis r1,r0,CONFIG_SYS_INIT_RAM_ADDR@h
  828. ori r1,r1,CONFIG_SYS_INIT_SP_OFFSET /* set up the stack to SDRAM */
  829. li r0, 0 /* Make room for stack frame header and */
  830. stwu r0, -4(r1) /* clear final stack frame so that */
  831. stwu r0, -4(r1) /* stack backtraces terminate cleanly */
  832. GET_GOT /* initialize GOT access */
  833. bl board_init_f /* run first part of init code (from Flash) */
  834. /* NOTREACHED - board_init_f() does not return */
  835. #endif /* CONFIG_IOP480 */
  836. /*****************************************************************************/
  837. #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
  838. defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \
  839. defined(CONFIG_405EX) || defined(CONFIG_405)
  840. /*----------------------------------------------------------------------- */
  841. /* Clear and set up some registers. */
  842. /*----------------------------------------------------------------------- */
  843. addi r4,r0,0x0000
  844. #if !defined(CONFIG_405EX)
  845. mtspr SPRN_SGR,r4
  846. #else
  847. /*
  848. * On 405EX, completely clearing the SGR leads to PPC hangup
  849. * upon PCIe configuration access. The PCIe memory regions
  850. * need to be guarded!
  851. */
  852. lis r3,0x0000
  853. ori r3,r3,0x7FFC
  854. mtspr SPRN_SGR,r3
  855. #endif
  856. mtspr SPRN_DCWR,r4
  857. mtesr r4 /* clear Exception Syndrome Reg */
  858. mttcr r4 /* clear Timer Control Reg */
  859. mtxer r4 /* clear Fixed-Point Exception Reg */
  860. mtevpr r4 /* clear Exception Vector Prefix Reg */
  861. addi r4,r0,(0xFFFF-0x10000) /* set r4 to 0xFFFFFFFF (status in the */
  862. /* dbsr is cleared by setting bits to 1) */
  863. mtdbsr r4 /* clear/reset the dbsr */
  864. /* Invalidate the i- and d-caches. */
  865. bl invalidate_icache
  866. bl invalidate_dcache
  867. /* Set-up icache cacheability. */
  868. lis r4, CONFIG_SYS_ICACHE_SACR_VALUE@h
  869. ori r4, r4, CONFIG_SYS_ICACHE_SACR_VALUE@l
  870. mticcr r4
  871. isync
  872. /* Set-up dcache cacheability. */
  873. lis r4, CONFIG_SYS_DCACHE_SACR_VALUE@h
  874. ori r4, r4, CONFIG_SYS_DCACHE_SACR_VALUE@l
  875. mtdccr r4
  876. #if !(defined(CONFIG_SYS_EBC_PB0AP) && defined(CONFIG_SYS_EBC_PB0CR))\
  877. && !defined (CONFIG_XILINX_405)
  878. /*----------------------------------------------------------------------- */
  879. /* Tune the speed and size for flash CS0 */
  880. /*----------------------------------------------------------------------- */
  881. bl ext_bus_cntlr_init
  882. #endif
  883. #if !(defined(CONFIG_SYS_INIT_DCACHE_CS) || defined(CONFIG_SYS_TEMP_STACK_OCM))
  884. /*
  885. * For boards that don't have OCM and can't use the data cache
  886. * for their primordial stack, setup stack here directly after the
  887. * SDRAM is initialized in ext_bus_cntlr_init.
  888. */
  889. lis r1, CONFIG_SYS_INIT_RAM_ADDR@h
  890. ori r1,r1,CONFIG_SYS_INIT_SP_OFFSET /* set up the stack in SDRAM */
  891. li r0, 0 /* Make room for stack frame header and */
  892. stwu r0, -4(r1) /* clear final stack frame so that */
  893. stwu r0, -4(r1) /* stack backtraces terminate cleanly */
  894. /*
  895. * Set up a dummy frame to store reset vector as return address.
  896. * this causes stack underflow to reset board.
  897. */
  898. stwu r1, -8(r1) /* Save back chain and move SP */
  899. lis r0, RESET_VECTOR@h /* Address of reset vector */
  900. ori r0, r0, RESET_VECTOR@l
  901. stwu r1, -8(r1) /* Save back chain and move SP */
  902. stw r0, +12(r1) /* Save return addr (underflow vect) */
  903. #endif /* !(CONFIG_SYS_INIT_DCACHE_CS || !CONFIG_SYS_TEM_STACK_OCM) */
  904. #if defined(CONFIG_405EP)
  905. /*----------------------------------------------------------------------- */
  906. /* DMA Status, clear to come up clean */
  907. /*----------------------------------------------------------------------- */
  908. addis r3,r0, 0xFFFF /* Clear all existing DMA status */
  909. ori r3,r3, 0xFFFF
  910. mtdcr DMASR, r3
  911. bl ppc405ep_init /* do ppc405ep specific init */
  912. #endif /* CONFIG_405EP */
  913. #if defined(CONFIG_SYS_OCM_DATA_ADDR) && defined(CONFIG_SYS_OCM_DATA_SIZE)
  914. #if defined(CONFIG_405EZ)
  915. /********************************************************************
  916. * Setup OCM - On Chip Memory - PPC405EZ uses OCM Controller V2
  917. *******************************************************************/
  918. /*
  919. * We can map the OCM on the PLB3, so map it at
  920. * CONFIG_SYS_OCM_DATA_ADDR + 0x8000
  921. */
  922. lis r3,CONFIG_SYS_OCM_DATA_ADDR@h /* OCM location */
  923. ori r3,r3,CONFIG_SYS_OCM_DATA_ADDR@l
  924. ori r3,r3,0x0270 /* 16K for Bank 1, R/W/Enable */
  925. mtdcr OCM0_PLBCR1,r3 /* Set PLB Access */
  926. ori r3,r3,0x4000 /* Add 0x4000 for bank 2 */
  927. mtdcr OCM0_PLBCR2,r3 /* Set PLB Access */
  928. isync
  929. lis r3,CONFIG_SYS_OCM_DATA_ADDR@h /* OCM location */
  930. ori r3,r3,CONFIG_SYS_OCM_DATA_ADDR@l
  931. ori r3,r3,0x0270 /* 16K for Bank 1, R/W/Enable */
  932. mtdcr OCM0_DSRC1, r3 /* Set Data Side */
  933. mtdcr OCM0_ISRC1, r3 /* Set Instruction Side */
  934. ori r3,r3,0x4000 /* Add 0x4000 for bank 2 */
  935. mtdcr OCM0_DSRC2, r3 /* Set Data Side */
  936. mtdcr OCM0_ISRC2, r3 /* Set Instruction Side */
  937. addis r3,0,0x0800 /* OCM Data Parity Disable - 1 Wait State */
  938. mtdcr OCM0_DISDPC,r3
  939. isync
  940. #else /* CONFIG_405EZ */
  941. /********************************************************************
  942. * Setup OCM - On Chip Memory
  943. *******************************************************************/
  944. /* Setup OCM */
  945. lis r0, 0x7FFF
  946. ori r0, r0, 0xFFFF
  947. mfdcr r3, OCM0_ISCNTL /* get instr-side IRAM config */
  948. mfdcr r4, OCM0_DSCNTL /* get data-side IRAM config */
  949. and r3, r3, r0 /* disable data-side IRAM */
  950. and r4, r4, r0 /* disable data-side IRAM */
  951. mtdcr OCM0_ISCNTL, r3 /* set instr-side IRAM config */
  952. mtdcr OCM0_DSCNTL, r4 /* set data-side IRAM config */
  953. isync
  954. lis r3,CONFIG_SYS_OCM_DATA_ADDR@h /* OCM location */
  955. ori r3,r3,CONFIG_SYS_OCM_DATA_ADDR@l
  956. mtdcr OCM0_DSARC, r3
  957. addis r4, 0, 0xC000 /* OCM data area enabled */
  958. mtdcr OCM0_DSCNTL, r4
  959. isync
  960. #endif /* CONFIG_405EZ */
  961. #endif
  962. /*----------------------------------------------------------------------- */
  963. /* Setup temporary stack in DCACHE or OCM if needed for SDRAM SPD. */
  964. /*----------------------------------------------------------------------- */
  965. #ifdef CONFIG_SYS_INIT_DCACHE_CS
  966. li r4, PBxAP
  967. mtdcr EBC0_CFGADDR, r4
  968. lis r4, CONFIG_SYS_INIT_DCACHE_PBxAR@h
  969. ori r4, r4, CONFIG_SYS_INIT_DCACHE_PBxAR@l
  970. mtdcr EBC0_CFGDATA, r4
  971. addi r4, 0, PBxCR
  972. mtdcr EBC0_CFGADDR, r4
  973. lis r4, CONFIG_SYS_INIT_DCACHE_PBxCR@h
  974. ori r4, r4, CONFIG_SYS_INIT_DCACHE_PBxCR@l
  975. mtdcr EBC0_CFGDATA, r4
  976. /*
  977. * Enable the data cache for the 128MB storage access control region
  978. * at CONFIG_SYS_INIT_RAM_ADDR.
  979. */
  980. mfdccr r4
  981. oris r4, r4, PPC_128MB_SACR_VALUE(CONFIG_SYS_INIT_RAM_ADDR)@h
  982. ori r4, r4, PPC_128MB_SACR_VALUE(CONFIG_SYS_INIT_RAM_ADDR)@l
  983. mtdccr r4
  984. /*
  985. * Preallocate data cache lines to be used to avoid a subsequent
  986. * cache miss and an ensuing machine check exception when exceptions
  987. * are enabled.
  988. */
  989. li r0, 0
  990. lis r3, CONFIG_SYS_INIT_RAM_ADDR@h
  991. ori r3, r3, CONFIG_SYS_INIT_RAM_ADDR@l
  992. lis r4, CONFIG_SYS_INIT_RAM_SIZE@h
  993. ori r4, r4, CONFIG_SYS_INIT_RAM_SIZE@l
  994. /*
  995. * Convert the size, in bytes, to the number of cache lines/blocks
  996. * to preallocate.
  997. */
  998. clrlwi. r5, r4, (32 - L1_CACHE_SHIFT)
  999. srwi r5, r4, L1_CACHE_SHIFT
  1000. beq ..load_counter
  1001. addi r5, r5, 0x0001
  1002. ..load_counter:
  1003. mtctr r5
  1004. /* Preallocate the computed number of cache blocks. */
  1005. ..alloc_dcache_block:
  1006. dcba r0, r3
  1007. addi r3, r3, L1_CACHE_BYTES
  1008. bdnz ..alloc_dcache_block
  1009. sync
  1010. /*
  1011. * Load the initial stack pointer and data area and convert the size,
  1012. * in bytes, to the number of words to initialize to a known value.
  1013. */
  1014. lis r1, CONFIG_SYS_INIT_RAM_ADDR@h
  1015. ori r1, r1, CONFIG_SYS_INIT_SP_OFFSET@l
  1016. lis r4, (CONFIG_SYS_INIT_RAM_SIZE >> 2)@h
  1017. ori r4, r4, (CONFIG_SYS_INIT_RAM_SIZE >> 2)@l
  1018. mtctr r4
  1019. lis r2, CONFIG_SYS_INIT_RAM_ADDR@h
  1020. ori r2, r2, CONFIG_SYS_INIT_RAM_SIZE@l
  1021. lis r4, CONFIG_SYS_INIT_RAM_PATTERN@h
  1022. ori r4, r4, CONFIG_SYS_INIT_RAM_PATTERN@l
  1023. ..stackloop:
  1024. stwu r4, -4(r2)
  1025. bdnz ..stackloop
  1026. /*
  1027. * Make room for stack frame header and clear final stack frame so
  1028. * that stack backtraces terminate cleanly.
  1029. */
  1030. stwu r0, -4(r1)
  1031. stwu r0, -4(r1)
  1032. /*
  1033. * Set up a dummy frame to store reset vector as return address.
  1034. * this causes stack underflow to reset board.
  1035. */
  1036. stwu r1, -8(r1) /* Save back chain and move SP */
  1037. addis r0, 0, RESET_VECTOR@h /* Address of reset vector */
  1038. ori r0, r0, RESET_VECTOR@l
  1039. stwu r1, -8(r1) /* Save back chain and move SP */
  1040. stw r0, +12(r1) /* Save return addr (underflow vect) */
  1041. #elif defined(CONFIG_SYS_TEMP_STACK_OCM) && \
  1042. (defined(CONFIG_SYS_OCM_DATA_ADDR) && defined(CONFIG_SYS_OCM_DATA_SIZE))
  1043. /*
  1044. * Stack in OCM.
  1045. */
  1046. /* Set up Stack at top of OCM */
  1047. lis r1, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)@h
  1048. ori r1, r1, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)@l
  1049. /* Set up a zeroized stack frame so that backtrace works right */
  1050. li r0, 0
  1051. stwu r0, -4(r1)
  1052. stwu r0, -4(r1)
  1053. /*
  1054. * Set up a dummy frame to store reset vector as return address.
  1055. * this causes stack underflow to reset board.
  1056. */
  1057. stwu r1, -8(r1) /* Save back chain and move SP */
  1058. lis r0, RESET_VECTOR@h /* Address of reset vector */
  1059. ori r0, r0, RESET_VECTOR@l
  1060. stwu r1, -8(r1) /* Save back chain and move SP */
  1061. stw r0, +12(r1) /* Save return addr (underflow vect) */
  1062. #endif /* CONFIG_SYS_INIT_DCACHE_CS */
  1063. #ifdef CONFIG_NAND_SPL
  1064. bl nand_boot_common /* will not return */
  1065. #else
  1066. GET_GOT /* initialize GOT access */
  1067. bl cpu_init_f /* run low-level CPU init code (from Flash) */
  1068. bl board_init_f /* run first part of init code (from Flash) */
  1069. /* NOTREACHED - board_init_f() does not return */
  1070. #endif /* CONFIG_NAND_SPL */
  1071. #endif /* CONFIG_405GP || CONFIG_405CR || CONFIG_405 || CONFIG_405EP */
  1072. /*----------------------------------------------------------------------- */
  1073. #ifndef CONFIG_NAND_SPL
  1074. /*
  1075. * This code finishes saving the registers to the exception frame
  1076. * and jumps to the appropriate handler for the exception.
  1077. * Register r21 is pointer into trap frame, r1 has new stack pointer.
  1078. */
  1079. .globl transfer_to_handler
  1080. transfer_to_handler:
  1081. stw r22,_NIP(r21)
  1082. lis r22,MSR_POW@h
  1083. andc r23,r23,r22
  1084. stw r23,_MSR(r21)
  1085. SAVE_GPR(7, r21)
  1086. SAVE_4GPRS(8, r21)
  1087. SAVE_8GPRS(12, r21)
  1088. SAVE_8GPRS(24, r21)
  1089. mflr r23
  1090. andi. r24,r23,0x3f00 /* get vector offset */
  1091. stw r24,TRAP(r21)
  1092. li r22,0
  1093. stw r22,RESULT(r21)
  1094. mtspr SPRG2,r22 /* r1 is now kernel sp */
  1095. lwz r24,0(r23) /* virtual address of handler */
  1096. lwz r23,4(r23) /* where to go when done */
  1097. mtspr SRR0,r24
  1098. mtspr SRR1,r20
  1099. mtlr r23
  1100. SYNC
  1101. rfi /* jump to handler, enable MMU */
  1102. int_return:
  1103. mfmsr r28 /* Disable interrupts */
  1104. li r4,0
  1105. ori r4,r4,MSR_EE
  1106. andc r28,r28,r4
  1107. SYNC /* Some chip revs need this... */
  1108. mtmsr r28
  1109. SYNC
  1110. lwz r2,_CTR(r1)
  1111. lwz r0,_LINK(r1)
  1112. mtctr r2
  1113. mtlr r0
  1114. lwz r2,_XER(r1)
  1115. lwz r0,_CCR(r1)
  1116. mtspr XER,r2
  1117. mtcrf 0xFF,r0
  1118. REST_10GPRS(3, r1)
  1119. REST_10GPRS(13, r1)
  1120. REST_8GPRS(23, r1)
  1121. REST_GPR(31, r1)
  1122. lwz r2,_NIP(r1) /* Restore environment */
  1123. lwz r0,_MSR(r1)
  1124. mtspr SRR0,r2
  1125. mtspr SRR1,r0
  1126. lwz r0,GPR0(r1)
  1127. lwz r2,GPR2(r1)
  1128. lwz r1,GPR1(r1)
  1129. SYNC
  1130. rfi
  1131. crit_return:
  1132. mfmsr r28 /* Disable interrupts */
  1133. li r4,0
  1134. ori r4,r4,MSR_EE
  1135. andc r28,r28,r4
  1136. SYNC /* Some chip revs need this... */
  1137. mtmsr r28
  1138. SYNC
  1139. lwz r2,_CTR(r1)
  1140. lwz r0,_LINK(r1)
  1141. mtctr r2
  1142. mtlr r0
  1143. lwz r2,_XER(r1)
  1144. lwz r0,_CCR(r1)
  1145. mtspr XER,r2
  1146. mtcrf 0xFF,r0
  1147. REST_10GPRS(3, r1)
  1148. REST_10GPRS(13, r1)
  1149. REST_8GPRS(23, r1)
  1150. REST_GPR(31, r1)
  1151. lwz r2,_NIP(r1) /* Restore environment */
  1152. lwz r0,_MSR(r1)
  1153. mtspr SPRN_CSRR0,r2
  1154. mtspr SPRN_CSRR1,r0
  1155. lwz r0,GPR0(r1)
  1156. lwz r2,GPR2(r1)
  1157. lwz r1,GPR1(r1)
  1158. SYNC
  1159. rfci
  1160. #ifdef CONFIG_440
  1161. mck_return:
  1162. mfmsr r28 /* Disable interrupts */
  1163. li r4,0
  1164. ori r4,r4,MSR_EE
  1165. andc r28,r28,r4
  1166. SYNC /* Some chip revs need this... */
  1167. mtmsr r28
  1168. SYNC
  1169. lwz r2,_CTR(r1)
  1170. lwz r0,_LINK(r1)
  1171. mtctr r2
  1172. mtlr r0
  1173. lwz r2,_XER(r1)
  1174. lwz r0,_CCR(r1)
  1175. mtspr XER,r2
  1176. mtcrf 0xFF,r0
  1177. REST_10GPRS(3, r1)
  1178. REST_10GPRS(13, r1)
  1179. REST_8GPRS(23, r1)
  1180. REST_GPR(31, r1)
  1181. lwz r2,_NIP(r1) /* Restore environment */
  1182. lwz r0,_MSR(r1)
  1183. mtspr SPRN_MCSRR0,r2
  1184. mtspr SPRN_MCSRR1,r0
  1185. lwz r0,GPR0(r1)
  1186. lwz r2,GPR2(r1)
  1187. lwz r1,GPR1(r1)
  1188. SYNC
  1189. rfmci
  1190. #endif /* CONFIG_440 */
  1191. .globl get_pvr
  1192. get_pvr:
  1193. mfspr r3, PVR
  1194. blr
  1195. /*------------------------------------------------------------------------------- */
  1196. /* Function: out16 */
  1197. /* Description: Output 16 bits */
  1198. /*------------------------------------------------------------------------------- */
  1199. .globl out16
  1200. out16:
  1201. sth r4,0x0000(r3)
  1202. blr
  1203. /*------------------------------------------------------------------------------- */
  1204. /* Function: out16r */
  1205. /* Description: Byte reverse and output 16 bits */
  1206. /*------------------------------------------------------------------------------- */
  1207. .globl out16r
  1208. out16r:
  1209. sthbrx r4,r0,r3
  1210. blr
  1211. /*------------------------------------------------------------------------------- */
  1212. /* Function: out32r */
  1213. /* Description: Byte reverse and output 32 bits */
  1214. /*------------------------------------------------------------------------------- */
  1215. .globl out32r
  1216. out32r:
  1217. stwbrx r4,r0,r3
  1218. blr
  1219. /*------------------------------------------------------------------------------- */
  1220. /* Function: in16 */
  1221. /* Description: Input 16 bits */
  1222. /*------------------------------------------------------------------------------- */
  1223. .globl in16
  1224. in16:
  1225. lhz r3,0x0000(r3)
  1226. blr
  1227. /*------------------------------------------------------------------------------- */
  1228. /* Function: in16r */
  1229. /* Description: Input 16 bits and byte reverse */
  1230. /*------------------------------------------------------------------------------- */
  1231. .globl in16r
  1232. in16r:
  1233. lhbrx r3,r0,r3
  1234. blr
  1235. /*------------------------------------------------------------------------------- */
  1236. /* Function: in32r */
  1237. /* Description: Input 32 bits and byte reverse */
  1238. /*------------------------------------------------------------------------------- */
  1239. .globl in32r
  1240. in32r:
  1241. lwbrx r3,r0,r3
  1242. blr
  1243. /*
  1244. * void relocate_code (addr_sp, gd, addr_moni)
  1245. *
  1246. * This "function" does not return, instead it continues in RAM
  1247. * after relocating the monitor code.
  1248. *
  1249. * r3 = Relocated stack pointer
  1250. * r4 = Relocated global data pointer
  1251. * r5 = Relocated text pointer
  1252. */
  1253. .globl relocate_code
  1254. relocate_code:
  1255. #if defined(CONFIG_4xx_DCACHE) || defined(CONFIG_SYS_INIT_DCACHE_CS)
  1256. /*
  1257. * We need to flush the initial global data (gd_t) and bd_info
  1258. * before the dcache will be invalidated.
  1259. */
  1260. /* Save registers */
  1261. mr r9, r3
  1262. mr r10, r4
  1263. mr r11, r5
  1264. /*
  1265. * Flush complete dcache, this is faster than flushing the
  1266. * ranges for global_data and bd_info instead.
  1267. */
  1268. bl flush_dcache
  1269. #if defined(CONFIG_SYS_INIT_DCACHE_CS)
  1270. /*
  1271. * Undo the earlier data cache set-up for the primordial stack and
  1272. * data area. First, invalidate the data cache and then disable data
  1273. * cacheability for that area. Finally, restore the EBC values, if
  1274. * any.
  1275. */
  1276. /* Invalidate the primordial stack and data area in cache */
  1277. lis r3, CONFIG_SYS_INIT_RAM_ADDR@h
  1278. ori r3, r3, CONFIG_SYS_INIT_RAM_ADDR@l
  1279. lis r4, CONFIG_SYS_INIT_RAM_SIZE@h
  1280. ori r4, r4, CONFIG_SYS_INIT_RAM_SIZE@l
  1281. add r4, r4, r3
  1282. bl invalidate_dcache_range
  1283. /* Disable cacheability for the region */
  1284. mfdccr r3
  1285. lis r4, ~PPC_128MB_SACR_VALUE(CONFIG_SYS_INIT_RAM_ADDR)@h
  1286. ori r4, r4, ~PPC_128MB_SACR_VALUE(CONFIG_SYS_INIT_RAM_ADDR)@l
  1287. and r3, r3, r4
  1288. mtdccr r3
  1289. /* Restore the EBC parameters */
  1290. li r3, PBxAP
  1291. mtdcr EBC0_CFGADDR, r3
  1292. lis r3, PBxAP_VAL@h
  1293. ori r3, r3, PBxAP_VAL@l
  1294. mtdcr EBC0_CFGDATA, r3
  1295. li r3, PBxCR
  1296. mtdcr EBC0_CFGADDR, r3
  1297. lis r3, PBxCR_VAL@h
  1298. ori r3, r3, PBxCR_VAL@l
  1299. mtdcr EBC0_CFGDATA, r3
  1300. #endif /* defined(CONFIG_SYS_INIT_DCACHE_CS) */
  1301. /* Restore registers */
  1302. mr r3, r9
  1303. mr r4, r10
  1304. mr r5, r11
  1305. #endif /* defined(CONFIG_4xx_DCACHE) || defined(CONFIG_SYS_INIT_DCACHE_CS) */
  1306. #ifdef CONFIG_SYS_INIT_RAM_DCACHE
  1307. /*
  1308. * Unlock the previously locked d-cache
  1309. */
  1310. msync
  1311. isync
  1312. /* set TFLOOR/NFLOOR to 0 again */
  1313. lis r6,0x0001
  1314. ori r6,r6,0xf800
  1315. mtspr SPRN_DVLIM,r6
  1316. lis r6,0x0000
  1317. ori r6,r6,0x0000
  1318. mtspr SPRN_DNV0,r6
  1319. mtspr SPRN_DNV1,r6
  1320. mtspr SPRN_DNV2,r6
  1321. mtspr SPRN_DNV3,r6
  1322. mtspr SPRN_DTV0,r6
  1323. mtspr SPRN_DTV1,r6
  1324. mtspr SPRN_DTV2,r6
  1325. mtspr SPRN_DTV3,r6
  1326. msync
  1327. isync
  1328. /* Invalidate data cache, now no longer our stack */
  1329. dccci 0,0
  1330. sync
  1331. isync
  1332. #endif /* CONFIG_SYS_INIT_RAM_DCACHE */
  1333. /*
  1334. * On some 440er platforms the cache is enabled in the first TLB (Boot-CS)
  1335. * to speed up the boot process. Now this cache needs to be disabled.
  1336. */
  1337. #if defined(CONFIG_440)
  1338. /* Clear all potential pending exceptions */
  1339. mfspr r1,SPRN_MCSR
  1340. mtspr SPRN_MCSR,r1
  1341. addi r1,r0,CONFIG_SYS_TLB_FOR_BOOT_FLASH /* Use defined TLB */
  1342. tlbre r0,r1,0x0002 /* Read contents */
  1343. ori r0,r0,0x0c00 /* Or in the inhibit, write through bit */
  1344. tlbwe r0,r1,0x0002 /* Save it out */
  1345. sync
  1346. isync
  1347. #endif /* defined(CONFIG_440) */
  1348. mr r1, r3 /* Set new stack pointer */
  1349. mr r9, r4 /* Save copy of Init Data pointer */
  1350. mr r10, r5 /* Save copy of Destination Address */
  1351. GET_GOT
  1352. mr r3, r5 /* Destination Address */
  1353. lis r4, CONFIG_SYS_MONITOR_BASE@h /* Source Address */
  1354. ori r4, r4, CONFIG_SYS_MONITOR_BASE@l
  1355. lwz r5, GOT(__init_end)
  1356. sub r5, r5, r4
  1357. li r6, L1_CACHE_BYTES /* Cache Line Size */
  1358. /*
  1359. * Fix GOT pointer:
  1360. *
  1361. * New GOT-PTR = (old GOT-PTR - CONFIG_SYS_MONITOR_BASE) + Destination Address
  1362. *
  1363. * Offset:
  1364. */
  1365. sub r15, r10, r4
  1366. /* First our own GOT */
  1367. add r12, r12, r15
  1368. /* then the one used by the C code */
  1369. add r30, r30, r15
  1370. /*
  1371. * Now relocate code
  1372. */
  1373. cmplw cr1,r3,r4
  1374. addi r0,r5,3
  1375. srwi. r0,r0,2
  1376. beq cr1,4f /* In place copy is not necessary */
  1377. beq 7f /* Protect against 0 count */
  1378. mtctr r0
  1379. bge cr1,2f
  1380. la r8,-4(r4)
  1381. la r7,-4(r3)
  1382. 1: lwzu r0,4(r8)
  1383. stwu r0,4(r7)
  1384. bdnz 1b
  1385. b 4f
  1386. 2: slwi r0,r0,2
  1387. add r8,r4,r0
  1388. add r7,r3,r0
  1389. 3: lwzu r0,-4(r8)
  1390. stwu r0,-4(r7)
  1391. bdnz 3b
  1392. /*
  1393. * Now flush the cache: note that we must start from a cache aligned
  1394. * address. Otherwise we might miss one cache line.
  1395. */
  1396. 4: cmpwi r6,0
  1397. add r5,r3,r5
  1398. beq 7f /* Always flush prefetch queue in any case */
  1399. subi r0,r6,1
  1400. andc r3,r3,r0
  1401. mr r4,r3
  1402. 5: dcbst 0,r4
  1403. add r4,r4,r6
  1404. cmplw r4,r5
  1405. blt 5b
  1406. sync /* Wait for all dcbst to complete on bus */
  1407. mr r4,r3
  1408. 6: icbi 0,r4
  1409. add r4,r4,r6
  1410. cmplw r4,r5
  1411. blt 6b
  1412. 7: sync /* Wait for all icbi to complete on bus */
  1413. isync
  1414. /*
  1415. * We are done. Do not return, instead branch to second part of board
  1416. * initialization, now running from RAM.
  1417. */
  1418. addi r0, r10, in_ram - _start + _START_OFFSET
  1419. mtlr r0
  1420. blr /* NEVER RETURNS! */
  1421. in_ram:
  1422. /*
  1423. * Relocation Function, r12 point to got2+0x8000
  1424. *
  1425. * Adjust got2 pointers, no need to check for 0, this code
  1426. * already puts a few entries in the table.
  1427. */
  1428. li r0,__got2_entries@sectoff@l
  1429. la r3,GOT(_GOT2_TABLE_)
  1430. lwz r11,GOT(_GOT2_TABLE_)
  1431. mtctr r0
  1432. sub r11,r3,r11
  1433. addi r3,r3,-4
  1434. 1: lwzu r0,4(r3)
  1435. cmpwi r0,0
  1436. beq- 2f
  1437. add r0,r0,r11
  1438. stw r0,0(r3)
  1439. 2: bdnz 1b
  1440. /*
  1441. * Now adjust the fixups and the pointers to the fixups
  1442. * in case we need to move ourselves again.
  1443. */
  1444. li r0,__fixup_entries@sectoff@l
  1445. lwz r3,GOT(_FIXUP_TABLE_)
  1446. cmpwi r0,0
  1447. mtctr r0
  1448. addi r3,r3,-4
  1449. beq 4f
  1450. 3: lwzu r4,4(r3)
  1451. lwzux r0,r4,r11
  1452. cmpwi r0,0
  1453. add r0,r0,r11
  1454. stw r4,0(r3)
  1455. beq- 5f
  1456. stw r0,0(r4)
  1457. 5: bdnz 3b
  1458. 4:
  1459. clear_bss:
  1460. /*
  1461. * Now clear BSS segment
  1462. */
  1463. lwz r3,GOT(__bss_start)
  1464. lwz r4,GOT(__bss_end__)
  1465. cmplw 0, r3, r4
  1466. beq 7f
  1467. li r0, 0
  1468. andi. r5, r4, 3
  1469. beq 6f
  1470. sub r4, r4, r5
  1471. mtctr r5
  1472. mr r5, r4
  1473. 5: stb r0, 0(r5)
  1474. addi r5, r5, 1
  1475. bdnz 5b
  1476. 6:
  1477. stw r0, 0(r3)
  1478. addi r3, r3, 4
  1479. cmplw 0, r3, r4
  1480. bne 6b
  1481. 7:
  1482. mr r3, r9 /* Init Data pointer */
  1483. mr r4, r10 /* Destination Address */
  1484. bl board_init_r
  1485. /*
  1486. * Copy exception vector code to low memory
  1487. *
  1488. * r3: dest_addr
  1489. * r7: source address, r8: end address, r9: target address
  1490. */
  1491. .globl trap_init
  1492. trap_init:
  1493. mflr r4 /* save link register */
  1494. GET_GOT
  1495. lwz r7, GOT(_start_of_vectors)
  1496. lwz r8, GOT(_end_of_vectors)
  1497. li r9, 0x100 /* reset vector always at 0x100 */
  1498. cmplw 0, r7, r8
  1499. bgelr /* return if r7>=r8 - just in case */
  1500. 1:
  1501. lwz r0, 0(r7)
  1502. stw r0, 0(r9)
  1503. addi r7, r7, 4
  1504. addi r9, r9, 4
  1505. cmplw 0, r7, r8
  1506. bne 1b
  1507. /*
  1508. * relocate `hdlr' and `int_return' entries
  1509. */
  1510. li r7, .L_MachineCheck - _start + _START_OFFSET
  1511. li r8, Alignment - _start + _START_OFFSET
  1512. 2:
  1513. bl trap_reloc
  1514. addi r7, r7, 0x100 /* next exception vector */
  1515. cmplw 0, r7, r8
  1516. blt 2b
  1517. li r7, .L_Alignment - _start + _START_OFFSET
  1518. bl trap_reloc
  1519. li r7, .L_ProgramCheck - _start + _START_OFFSET
  1520. bl trap_reloc
  1521. #ifdef CONFIG_440
  1522. li r7, .L_FPUnavailable - _start + _START_OFFSET
  1523. bl trap_reloc
  1524. li r7, .L_Decrementer - _start + _START_OFFSET
  1525. bl trap_reloc
  1526. li r7, .L_APU - _start + _START_OFFSET
  1527. bl trap_reloc
  1528. li r7, .L_InstructionTLBError - _start + _START_OFFSET
  1529. bl trap_reloc
  1530. li r7, .L_DataTLBError - _start + _START_OFFSET
  1531. bl trap_reloc
  1532. #else /* CONFIG_440 */
  1533. li r7, .L_PIT - _start + _START_OFFSET
  1534. bl trap_reloc
  1535. li r7, .L_InstructionTLBMiss - _start + _START_OFFSET
  1536. bl trap_reloc
  1537. li r7, .L_DataTLBMiss - _start + _START_OFFSET
  1538. bl trap_reloc
  1539. #endif /* CONFIG_440 */
  1540. li r7, .L_DebugBreakpoint - _start + _START_OFFSET
  1541. bl trap_reloc
  1542. #if !defined(CONFIG_440)
  1543. addi r7,r0,0x1000 /* set ME bit (Machine Exceptions) */
  1544. oris r7,r7,0x0002 /* set CE bit (Critical Exceptions) */
  1545. mtmsr r7 /* change MSR */
  1546. #else
  1547. bl __440_msr_set
  1548. b __440_msr_continue
  1549. __440_msr_set:
  1550. addi r7,r0,0x1000 /* set ME bit (Machine Exceptions) */
  1551. oris r7,r7,0x0002 /* set CE bit (Critical Exceptions) */
  1552. mtspr SPRN_SRR1,r7
  1553. mflr r7
  1554. mtspr SPRN_SRR0,r7
  1555. rfi
  1556. __440_msr_continue:
  1557. #endif
  1558. mtlr r4 /* restore link register */
  1559. blr
  1560. #if defined(CONFIG_440)
  1561. /*----------------------------------------------------------------------------+
  1562. | dcbz_area.
  1563. +----------------------------------------------------------------------------*/
  1564. function_prolog(dcbz_area)
  1565. rlwinm. r5,r4,0,27,31
  1566. rlwinm r5,r4,27,5,31
  1567. beq ..d_ra2
  1568. addi r5,r5,0x0001
  1569. ..d_ra2:mtctr r5
  1570. ..d_ag2:dcbz r0,r3
  1571. addi r3,r3,32
  1572. bdnz ..d_ag2
  1573. sync
  1574. blr
  1575. function_epilog(dcbz_area)
  1576. #endif /* CONFIG_440 */
  1577. #endif /* CONFIG_NAND_SPL */
  1578. /*------------------------------------------------------------------------------- */
  1579. /* Function: in8 */
  1580. /* Description: Input 8 bits */
  1581. /*------------------------------------------------------------------------------- */
  1582. .globl in8
  1583. in8:
  1584. lbz r3,0x0000(r3)
  1585. blr
  1586. /*------------------------------------------------------------------------------- */
  1587. /* Function: out8 */
  1588. /* Description: Output 8 bits */
  1589. /*------------------------------------------------------------------------------- */
  1590. .globl out8
  1591. out8:
  1592. stb r4,0x0000(r3)
  1593. blr
  1594. /*------------------------------------------------------------------------------- */
  1595. /* Function: out32 */
  1596. /* Description: Output 32 bits */
  1597. /*------------------------------------------------------------------------------- */
  1598. .globl out32
  1599. out32:
  1600. stw r4,0x0000(r3)
  1601. blr
  1602. /*------------------------------------------------------------------------------- */
  1603. /* Function: in32 */
  1604. /* Description: Input 32 bits */
  1605. /*------------------------------------------------------------------------------- */
  1606. .globl in32
  1607. in32:
  1608. lwz 3,0x0000(3)
  1609. blr
  1610. /**************************************************************************/
  1611. /* PPC405EP specific stuff */
  1612. /**************************************************************************/
  1613. #ifdef CONFIG_405EP
  1614. ppc405ep_init:
  1615. #ifdef CONFIG_BUBINGA
  1616. /*
  1617. * Initialize EBC chip selects 1 & 4 and GPIO pins (for alternate
  1618. * function) to support FPGA and NVRAM accesses below.
  1619. */
  1620. lis r3,GPIO0_OSRH@h /* config GPIO output select */
  1621. ori r3,r3,GPIO0_OSRH@l
  1622. lis r4,CONFIG_SYS_GPIO0_OSRH@h
  1623. ori r4,r4,CONFIG_SYS_GPIO0_OSRH@l
  1624. stw r4,0(r3)
  1625. lis r3,GPIO0_OSRL@h
  1626. ori r3,r3,GPIO0_OSRL@l
  1627. lis r4,CONFIG_SYS_GPIO0_OSRL@h
  1628. ori r4,r4,CONFIG_SYS_GPIO0_OSRL@l
  1629. stw r4,0(r3)
  1630. lis r3,GPIO0_ISR1H@h /* config GPIO input select */
  1631. ori r3,r3,GPIO0_ISR1H@l
  1632. lis r4,CONFIG_SYS_GPIO0_ISR1H@h
  1633. ori r4,r4,CONFIG_SYS_GPIO0_ISR1H@l
  1634. stw r4,0(r3)
  1635. lis r3,GPIO0_ISR1L@h
  1636. ori r3,r3,GPIO0_ISR1L@l
  1637. lis r4,CONFIG_SYS_GPIO0_ISR1L@h
  1638. ori r4,r4,CONFIG_SYS_GPIO0_ISR1L@l
  1639. stw r4,0(r3)
  1640. lis r3,GPIO0_TSRH@h /* config GPIO three-state select */
  1641. ori r3,r3,GPIO0_TSRH@l
  1642. lis r4,CONFIG_SYS_GPIO0_TSRH@h
  1643. ori r4,r4,CONFIG_SYS_GPIO0_TSRH@l
  1644. stw r4,0(r3)
  1645. lis r3,GPIO0_TSRL@h
  1646. ori r3,r3,GPIO0_TSRL@l
  1647. lis r4,CONFIG_SYS_GPIO0_TSRL@h
  1648. ori r4,r4,CONFIG_SYS_GPIO0_TSRL@l
  1649. stw r4,0(r3)
  1650. lis r3,GPIO0_TCR@h /* config GPIO driver output enables */
  1651. ori r3,r3,GPIO0_TCR@l
  1652. lis r4,CONFIG_SYS_GPIO0_TCR@h
  1653. ori r4,r4,CONFIG_SYS_GPIO0_TCR@l
  1654. stw r4,0(r3)
  1655. li r3,PB1AP /* program EBC bank 1 for RTC access */
  1656. mtdcr EBC0_CFGADDR,r3
  1657. lis r3,CONFIG_SYS_EBC_PB1AP@h
  1658. ori r3,r3,CONFIG_SYS_EBC_PB1AP@l
  1659. mtdcr EBC0_CFGDATA,r3
  1660. li r3,PB1CR
  1661. mtdcr EBC0_CFGADDR,r3
  1662. lis r3,CONFIG_SYS_EBC_PB1CR@h
  1663. ori r3,r3,CONFIG_SYS_EBC_PB1CR@l
  1664. mtdcr EBC0_CFGDATA,r3
  1665. li r3,PB1AP /* program EBC bank 1 for RTC access */
  1666. mtdcr EBC0_CFGADDR,r3
  1667. lis r3,CONFIG_SYS_EBC_PB1AP@h
  1668. ori r3,r3,CONFIG_SYS_EBC_PB1AP@l
  1669. mtdcr EBC0_CFGDATA,r3
  1670. li r3,PB1CR
  1671. mtdcr EBC0_CFGADDR,r3
  1672. lis r3,CONFIG_SYS_EBC_PB1CR@h
  1673. ori r3,r3,CONFIG_SYS_EBC_PB1CR@l
  1674. mtdcr EBC0_CFGDATA,r3
  1675. li r3,PB4AP /* program EBC bank 4 for FPGA access */
  1676. mtdcr EBC0_CFGADDR,r3
  1677. lis r3,CONFIG_SYS_EBC_PB4AP@h
  1678. ori r3,r3,CONFIG_SYS_EBC_PB4AP@l
  1679. mtdcr EBC0_CFGDATA,r3
  1680. li r3,PB4CR
  1681. mtdcr EBC0_CFGADDR,r3
  1682. lis r3,CONFIG_SYS_EBC_PB4CR@h
  1683. ori r3,r3,CONFIG_SYS_EBC_PB4CR@l
  1684. mtdcr EBC0_CFGDATA,r3
  1685. #endif
  1686. /*
  1687. !-----------------------------------------------------------------------
  1688. ! Check to see if chip is in bypass mode.
  1689. ! If so, write stored CPC0_PLLMR0 and CPC0_PLLMR1 values and perform a
  1690. ! CPU reset Otherwise, skip this step and keep going.
  1691. ! Note: Running BIOS in bypass mode is not supported since PLB speed
  1692. ! will not be fast enough for the SDRAM (min 66MHz)
  1693. !-----------------------------------------------------------------------
  1694. */
  1695. mfdcr r5, CPC0_PLLMR1
  1696. rlwinm r4,r5,1,0x1 /* get system clock source (SSCS) */
  1697. cmpi cr0,0,r4,0x1
  1698. beq pll_done /* if SSCS =b'1' then PLL has */
  1699. /* already been set */
  1700. /* and CPU has been reset */
  1701. /* so skip to next section */
  1702. #ifdef CONFIG_BUBINGA
  1703. /*
  1704. !-----------------------------------------------------------------------
  1705. ! Read NVRAM to get value to write in PLLMR.
  1706. ! If value has not been correctly saved, write default value
  1707. ! Default config values (assuming on-board 33MHz SYS_CLK) are above.
  1708. ! See CPU_DEFAULT_200 and CPU_DEFAULT_266 above.
  1709. !
  1710. ! WARNING: This code assumes the first three words in the nvram_t
  1711. ! structure in openbios.h. Changing the beginning of
  1712. ! the structure will break this code.
  1713. !
  1714. !-----------------------------------------------------------------------
  1715. */
  1716. addis r3,0,NVRAM_BASE@h
  1717. addi r3,r3,NVRAM_BASE@l
  1718. lwz r4, 0(r3)
  1719. addis r5,0,NVRVFY1@h
  1720. addi r5,r5,NVRVFY1@l
  1721. cmp cr0,0,r4,r5 /* Compare 1st NVRAM Magic number*/
  1722. bne ..no_pllset
  1723. addi r3,r3,4
  1724. lwz r4, 0(r3)
  1725. addis r5,0,NVRVFY2@h
  1726. addi r5,r5,NVRVFY2@l
  1727. cmp cr0,0,r4,r5 /* Compare 2 NVRAM Magic number */
  1728. bne ..no_pllset
  1729. addi r3,r3,8 /* Skip over conf_size */
  1730. lwz r4, 4(r3) /* Load PLLMR1 value from NVRAM */
  1731. lwz r3, 0(r3) /* Load PLLMR0 value from NVRAM */
  1732. rlwinm r5,r4,1,0x1 /* get system clock source (SSCS) */
  1733. cmpi cr0,0,r5,1 /* See if PLL is locked */
  1734. beq pll_write
  1735. ..no_pllset:
  1736. #endif /* CONFIG_BUBINGA */
  1737. #ifdef CONFIG_TAIHU
  1738. mfdcr r4, CPC0_BOOT
  1739. andi. r5, r4, CPC0_BOOT_SEP@l
  1740. bne strap_1 /* serial eeprom present */
  1741. addis r5,0,CPLD_REG0_ADDR@h
  1742. ori r5,r5,CPLD_REG0_ADDR@l
  1743. andi. r5, r5, 0x10
  1744. bne _pci_66mhz
  1745. #endif /* CONFIG_TAIHU */
  1746. #if defined(CONFIG_ZEUS)
  1747. mfdcr r4, CPC0_BOOT
  1748. andi. r5, r4, CPC0_BOOT_SEP@l
  1749. bne strap_1 /* serial eeprom present */
  1750. lis r3,0x0000
  1751. addi r3,r3,0x3030
  1752. lis r4,0x8042
  1753. addi r4,r4,0x223e
  1754. b 1f
  1755. strap_1:
  1756. mfdcr r3, CPC0_PLLMR0
  1757. mfdcr r4, CPC0_PLLMR1
  1758. b 1f
  1759. #endif
  1760. addis r3,0,PLLMR0_DEFAULT@h /* PLLMR0 default value */
  1761. ori r3,r3,PLLMR0_DEFAULT@l /* */
  1762. addis r4,0,PLLMR1_DEFAULT@h /* PLLMR1 default value */
  1763. ori r4,r4,PLLMR1_DEFAULT@l /* */
  1764. #ifdef CONFIG_TAIHU
  1765. b 1f
  1766. _pci_66mhz:
  1767. addis r3,0,PLLMR0_DEFAULT_PCI66@h
  1768. ori r3,r3,PLLMR0_DEFAULT_PCI66@l
  1769. addis r4,0,PLLMR1_DEFAULT_PCI66@h
  1770. ori r4,r4,PLLMR1_DEFAULT_PCI66@l
  1771. b 1f
  1772. strap_1:
  1773. mfdcr r3, CPC0_PLLMR0
  1774. mfdcr r4, CPC0_PLLMR1
  1775. #endif /* CONFIG_TAIHU */
  1776. 1:
  1777. b pll_write /* Write the CPC0_PLLMR with new value */
  1778. pll_done:
  1779. /*
  1780. !-----------------------------------------------------------------------
  1781. ! Clear Soft Reset Register
  1782. ! This is needed to enable PCI if not booting from serial EPROM
  1783. !-----------------------------------------------------------------------
  1784. */
  1785. addi r3, 0, 0x0
  1786. mtdcr CPC0_SRR, r3
  1787. addis r3,0,0x0010
  1788. mtctr r3
  1789. pci_wait:
  1790. bdnz pci_wait
  1791. blr /* return to main code */
  1792. /*
  1793. !-----------------------------------------------------------------------------
  1794. ! Function: pll_write
  1795. ! Description: Updates the value of the CPC0_PLLMR according to CMOS27E documentation
  1796. ! That is:
  1797. ! 1. Pll is first disabled (de-activated by putting in bypass mode)
  1798. ! 2. PLL is reset
  1799. ! 3. Clock dividers are set while PLL is held in reset and bypassed
  1800. ! 4. PLL Reset is cleared
  1801. ! 5. Wait 100us for PLL to lock
  1802. ! 6. A core reset is performed
  1803. ! Input: r3 = Value to write to CPC0_PLLMR0
  1804. ! Input: r4 = Value to write to CPC0_PLLMR1
  1805. ! Output r3 = none
  1806. !-----------------------------------------------------------------------------
  1807. */
  1808. .globl pll_write
  1809. pll_write:
  1810. mfdcr r5, CPC0_UCR
  1811. andis. r5,r5,0xFFFF
  1812. ori r5,r5,0x0101 /* Stop the UART clocks */
  1813. mtdcr CPC0_UCR,r5 /* Before changing PLL */
  1814. mfdcr r5, CPC0_PLLMR1
  1815. rlwinm r5,r5,0,0x7FFFFFFF /* Disable PLL */
  1816. mtdcr CPC0_PLLMR1,r5
  1817. oris r5,r5,0x4000 /* Set PLL Reset */
  1818. mtdcr CPC0_PLLMR1,r5
  1819. mtdcr CPC0_PLLMR0,r3 /* Set clock dividers */
  1820. rlwinm r5,r4,0,0x3FFFFFFF /* Reset & Bypass new PLL dividers */
  1821. oris r5,r5,0x4000 /* Set PLL Reset */
  1822. mtdcr CPC0_PLLMR1,r5 /* Set clock dividers */
  1823. rlwinm r5,r5,0,0xBFFFFFFF /* Clear PLL Reset */
  1824. mtdcr CPC0_PLLMR1,r5
  1825. /*
  1826. ! Wait min of 100us for PLL to lock.
  1827. ! See CMOS 27E databook for more info.
  1828. ! At 200MHz, that means waiting 20,000 instructions
  1829. */
  1830. addi r3,0,20000 /* 2000 = 0x4e20 */
  1831. mtctr r3
  1832. pll_wait:
  1833. bdnz pll_wait
  1834. oris r5,r5,0x8000 /* Enable PLL */
  1835. mtdcr CPC0_PLLMR1,r5 /* Engage */
  1836. /*
  1837. * Reset CPU to guarantee timings are OK
  1838. * Not sure if this is needed...
  1839. */
  1840. addis r3,0,0x1000
  1841. mtspr SPRN_DBCR0,r3 /* This will cause a CPU core reset, and */
  1842. /* execution will continue from the poweron */
  1843. /* vector of 0xfffffffc */
  1844. #endif /* CONFIG_405EP */
  1845. #if defined(CONFIG_440)
  1846. /*----------------------------------------------------------------------------+
  1847. | mttlb3.
  1848. +----------------------------------------------------------------------------*/
  1849. function_prolog(mttlb3)
  1850. TLBWE(4,3,2)
  1851. blr
  1852. function_epilog(mttlb3)
  1853. /*----------------------------------------------------------------------------+
  1854. | mftlb3.
  1855. +----------------------------------------------------------------------------*/
  1856. function_prolog(mftlb3)
  1857. TLBRE(3,3,2)
  1858. blr
  1859. function_epilog(mftlb3)
  1860. /*----------------------------------------------------------------------------+
  1861. | mttlb2.
  1862. +----------------------------------------------------------------------------*/
  1863. function_prolog(mttlb2)
  1864. TLBWE(4,3,1)
  1865. blr
  1866. function_epilog(mttlb2)
  1867. /*----------------------------------------------------------------------------+
  1868. | mftlb2.
  1869. +----------------------------------------------------------------------------*/
  1870. function_prolog(mftlb2)
  1871. TLBRE(3,3,1)
  1872. blr
  1873. function_epilog(mftlb2)
  1874. /*----------------------------------------------------------------------------+
  1875. | mttlb1.
  1876. +----------------------------------------------------------------------------*/
  1877. function_prolog(mttlb1)
  1878. TLBWE(4,3,0)
  1879. blr
  1880. function_epilog(mttlb1)
  1881. /*----------------------------------------------------------------------------+
  1882. | mftlb1.
  1883. +----------------------------------------------------------------------------*/
  1884. function_prolog(mftlb1)
  1885. TLBRE(3,3,0)
  1886. blr
  1887. function_epilog(mftlb1)
  1888. #endif /* CONFIG_440 */
  1889. #if defined(CONFIG_NAND_SPL)
  1890. /*
  1891. * void nand_boot_relocate(dst, src, bytes)
  1892. *
  1893. * r3 = Destination address to copy code to (in SDRAM)
  1894. * r4 = Source address to copy code from
  1895. * r5 = size to copy in bytes
  1896. */
  1897. nand_boot_relocate:
  1898. mr r6,r3
  1899. mr r7,r4
  1900. mflr r8
  1901. /*
  1902. * Copy SPL from icache into SDRAM
  1903. */
  1904. subi r3,r3,4
  1905. subi r4,r4,4
  1906. srwi r5,r5,2
  1907. mtctr r5
  1908. ..spl_loop:
  1909. lwzu r0,4(r4)
  1910. stwu r0,4(r3)
  1911. bdnz ..spl_loop
  1912. /*
  1913. * Calculate "corrected" link register, so that we "continue"
  1914. * in execution in destination range
  1915. */
  1916. sub r3,r7,r6 /* r3 = src - dst */
  1917. sub r8,r8,r3 /* r8 = link-reg - (src - dst) */
  1918. mtlr r8
  1919. blr
  1920. nand_boot_common:
  1921. /*
  1922. * First initialize SDRAM. It has to be available *before* calling
  1923. * nand_boot().
  1924. */
  1925. lis r3,CONFIG_SYS_SDRAM_BASE@h
  1926. ori r3,r3,CONFIG_SYS_SDRAM_BASE@l
  1927. bl initdram
  1928. /*
  1929. * Now copy the 4k SPL code into SDRAM and continue execution
  1930. * from there.
  1931. */
  1932. lis r3,CONFIG_SYS_NAND_BOOT_SPL_DST@h
  1933. ori r3,r3,CONFIG_SYS_NAND_BOOT_SPL_DST@l
  1934. lis r4,CONFIG_SYS_NAND_BOOT_SPL_SRC@h
  1935. ori r4,r4,CONFIG_SYS_NAND_BOOT_SPL_SRC@l
  1936. lis r5,CONFIG_SYS_NAND_BOOT_SPL_SIZE@h
  1937. ori r5,r5,CONFIG_SYS_NAND_BOOT_SPL_SIZE@l
  1938. bl nand_boot_relocate
  1939. /*
  1940. * We're running from SDRAM now!!!
  1941. *
  1942. * It is necessary for 4xx systems to relocate from running at
  1943. * the original location (0xfffffxxx) to somewhere else (SDRAM
  1944. * preferably). This is because CS0 needs to be reconfigured for
  1945. * NAND access. And we can't reconfigure this CS when currently
  1946. * "running" from it.
  1947. */
  1948. /*
  1949. * Finally call nand_boot() to load main NAND U-Boot image from
  1950. * NAND and jump to it.
  1951. */
  1952. bl nand_boot /* will not return */
  1953. #endif /* CONFIG_NAND_SPL */