start.S 59 KB

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