start.S 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232
  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 Freescale Semiconductor, Inc. 2004, 2006, 2008.
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. /*
  26. * U-Boot - Startup Code for MPC83xx PowerPC based Embedded Boards
  27. */
  28. #include <config.h>
  29. #include <mpc83xx.h>
  30. #include <timestamp.h>
  31. #include <version.h>
  32. #define CONFIG_83XX 1 /* needed for Linux kernel header files*/
  33. #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
  34. #include <ppc_asm.tmpl>
  35. #include <ppc_defs.h>
  36. #include <asm/cache.h>
  37. #include <asm/mmu.h>
  38. #ifndef CONFIG_IDENT_STRING
  39. #define CONFIG_IDENT_STRING "MPC83XX"
  40. #endif
  41. /* We don't want the MMU yet.
  42. */
  43. #undef MSR_KERNEL
  44. /*
  45. * Floating Point enable, Machine Check and Recoverable Interr.
  46. */
  47. #ifdef DEBUG
  48. #define MSR_KERNEL (MSR_FP|MSR_RI)
  49. #else
  50. #define MSR_KERNEL (MSR_FP|MSR_ME|MSR_RI)
  51. #endif
  52. #if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SYS_RAMBOOT)
  53. #define CONFIG_SYS_FLASHBOOT
  54. #endif
  55. /*
  56. * Set up GOT: Global Offset Table
  57. *
  58. * Use r14 to access the GOT
  59. */
  60. START_GOT
  61. GOT_ENTRY(_GOT2_TABLE_)
  62. GOT_ENTRY(__bss_start)
  63. GOT_ENTRY(_end)
  64. #ifndef CONFIG_NAND_SPL
  65. GOT_ENTRY(_FIXUP_TABLE_)
  66. GOT_ENTRY(_start)
  67. GOT_ENTRY(_start_of_vectors)
  68. GOT_ENTRY(_end_of_vectors)
  69. GOT_ENTRY(transfer_to_handler)
  70. #endif
  71. END_GOT
  72. /*
  73. * The Hard Reset Configuration Word (HRCW) table is in the first 64
  74. * (0x40) bytes of flash. It has 8 bytes, but each byte is repeated 8
  75. * times so the processor can fetch it out of flash whether the flash
  76. * is 8, 16, 32, or 64 bits wide (hardware trickery).
  77. */
  78. .text
  79. #define _HRCW_TABLE_ENTRY(w) \
  80. .fill 8,1,(((w)>>24)&0xff); \
  81. .fill 8,1,(((w)>>16)&0xff); \
  82. .fill 8,1,(((w)>> 8)&0xff); \
  83. .fill 8,1,(((w) )&0xff)
  84. _HRCW_TABLE_ENTRY(CONFIG_SYS_HRCW_LOW)
  85. _HRCW_TABLE_ENTRY(CONFIG_SYS_HRCW_HIGH)
  86. /*
  87. * Magic number and version string - put it after the HRCW since it
  88. * cannot be first in flash like it is in many other processors.
  89. */
  90. .long 0x27051956 /* U-Boot Magic Number */
  91. .globl version_string
  92. version_string:
  93. .ascii U_BOOT_VERSION
  94. .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
  95. .ascii " ", CONFIG_IDENT_STRING, "\0"
  96. .align 2
  97. .globl enable_addr_trans
  98. enable_addr_trans:
  99. /* enable address translation */
  100. mfmsr r5
  101. ori r5, r5, (MSR_IR | MSR_DR)
  102. mtmsr r5
  103. isync
  104. blr
  105. .globl disable_addr_trans
  106. disable_addr_trans:
  107. /* disable address translation */
  108. mflr r4
  109. mfmsr r3
  110. andi. r0, r3, (MSR_IR | MSR_DR)
  111. beqlr
  112. andc r3, r3, r0
  113. mtspr SRR0, r4
  114. mtspr SRR1, r3
  115. rfi
  116. .globl get_pvr
  117. get_pvr:
  118. mfspr r3, PVR
  119. blr
  120. .globl ppcDWstore
  121. ppcDWstore:
  122. lfd 1, 0(r4)
  123. stfd 1, 0(r3)
  124. blr
  125. .globl ppcDWload
  126. ppcDWload:
  127. lfd 1, 0(r3)
  128. stfd 1, 0(r4)
  129. blr
  130. #ifndef CONFIG_DEFAULT_IMMR
  131. #error CONFIG_DEFAULT_IMMR must be defined
  132. #endif /* CONFIG_SYS_DEFAULT_IMMR */
  133. #ifndef CONFIG_SYS_IMMR
  134. #define CONFIG_SYS_IMMR CONFIG_DEFAULT_IMMR
  135. #endif /* CONFIG_SYS_IMMR */
  136. /*
  137. * After configuration, a system reset exception is executed using the
  138. * vector at offset 0x100 relative to the base set by MSR[IP]. If
  139. * MSR[IP] is 0, the base address is 0x00000000. If MSR[IP] is 1, the
  140. * base address is 0xfff00000. In the case of a Power On Reset or Hard
  141. * Reset, the value of MSR[IP] is determined by the CIP field in the
  142. * HRCW.
  143. *
  144. * Other bits in the HRCW set up the Base Address and Port Size in BR0.
  145. * This determines the location of the boot ROM (flash or EPROM) in the
  146. * processor's address space at boot time. As long as the HRCW is set up
  147. * so that we eventually end up executing the code below when the
  148. * processor executes the reset exception, the actual values used should
  149. * not matter.
  150. *
  151. * Once we have got here, the address mask in OR0 is cleared so that the
  152. * bottom 32K of the boot ROM is effectively repeated all throughout the
  153. * processor's address space, after which we can jump to the absolute
  154. * address at which the boot ROM was linked at compile time, and proceed
  155. * to initialise the memory controller without worrying if the rug will
  156. * be pulled out from under us, so to speak (it will be fine as long as
  157. * we configure BR0 with the same boot ROM link address).
  158. */
  159. . = EXC_OFF_SYS_RESET
  160. .globl _start
  161. _start: /* time t 0 */
  162. li r21, BOOTFLAG_COLD /* Normal Power-On: Boot from FLASH*/
  163. nop
  164. b boot_cold
  165. . = EXC_OFF_SYS_RESET + 0x10
  166. .globl _start_warm
  167. _start_warm:
  168. li r21, BOOTFLAG_WARM /* Software reboot */
  169. b boot_warm
  170. boot_cold: /* time t 3 */
  171. lis r4, CONFIG_DEFAULT_IMMR@h
  172. nop
  173. boot_warm: /* time t 5 */
  174. mfmsr r5 /* save msr contents */
  175. /* 83xx manuals prescribe a specific sequence for updating IMMRBAR. */
  176. bl 1f
  177. 1: mflr r7
  178. lis r3, CONFIG_SYS_IMMR@h
  179. ori r3, r3, CONFIG_SYS_IMMR@l
  180. lwz r6, IMMRBAR(r4)
  181. isync
  182. stw r3, IMMRBAR(r4)
  183. lwz r6, 0(r7) /* Arbitrary external load */
  184. isync
  185. lwz r6, IMMRBAR(r3)
  186. isync
  187. /* Initialise the E300 processor core */
  188. /*------------------------------------------*/
  189. #ifdef CONFIG_NAND_SPL
  190. /* The FCM begins execution after only the first page
  191. * is loaded. Wait for the rest before branching
  192. * to another flash page.
  193. */
  194. 1: lwz r6, 0x50b0(r3)
  195. andi. r6, r6, 1
  196. beq 1b
  197. #endif
  198. bl init_e300_core
  199. #ifdef CONFIG_SYS_FLASHBOOT
  200. /* Inflate flash location so it appears everywhere, calculate */
  201. /* the absolute address in final location of the FLASH, jump */
  202. /* there and deflate the flash size back to minimal size */
  203. /*------------------------------------------------------------*/
  204. bl map_flash_by_law1
  205. lis r4, (CONFIG_SYS_MONITOR_BASE)@h
  206. ori r4, r4, (CONFIG_SYS_MONITOR_BASE)@l
  207. addi r5, r4, in_flash - _start + EXC_OFF_SYS_RESET
  208. mtlr r5
  209. blr
  210. in_flash:
  211. #if 1 /* Remapping flash with LAW0. */
  212. bl remap_flash_by_law0
  213. #endif
  214. #endif /* CONFIG_SYS_FLASHBOOT */
  215. /* setup the bats */
  216. bl setup_bats
  217. sync
  218. /*
  219. * Cache must be enabled here for stack-in-cache trick.
  220. * This means we need to enable the BATS.
  221. * This means:
  222. * 1) for the EVB, original gt regs need to be mapped
  223. * 2) need to have an IBAT for the 0xf region,
  224. * we are running there!
  225. * Cache should be turned on after BATs, since by default
  226. * everything is write-through.
  227. * The init-mem BAT can be reused after reloc. The old
  228. * gt-regs BAT can be reused after board_init_f calls
  229. * board_early_init_f (EVB only).
  230. */
  231. /* enable address translation */
  232. bl enable_addr_trans
  233. sync
  234. /* enable the data cache */
  235. bl dcache_enable
  236. sync
  237. #ifdef CONFIG_SYS_INIT_RAM_LOCK
  238. bl lock_ram_in_cache
  239. sync
  240. #endif
  241. /* set up the stack pointer in our newly created
  242. * cache-ram (r1) */
  243. lis r1, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET)@h
  244. ori r1, r1, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET)@l
  245. li r0, 0 /* Make room for stack frame header and */
  246. stwu r0, -4(r1) /* clear final stack frame so that */
  247. stwu r0, -4(r1) /* stack backtraces terminate cleanly */
  248. /* let the C-code set up the rest */
  249. /* */
  250. /* Be careful to keep code relocatable & stack humble */
  251. /*------------------------------------------------------*/
  252. GET_GOT /* initialize GOT access */
  253. /* r3: IMMR */
  254. lis r3, CONFIG_SYS_IMMR@h
  255. /* run low-level CPU init code (in Flash)*/
  256. bl cpu_init_f
  257. /* r3: BOOTFLAG */
  258. mr r3, r21
  259. /* run 1st part of board init code (in Flash)*/
  260. bl board_init_f
  261. #ifndef CONFIG_NAND_SPL
  262. /*
  263. * Vector Table
  264. */
  265. .globl _start_of_vectors
  266. _start_of_vectors:
  267. /* Machine check */
  268. STD_EXCEPTION(0x200, MachineCheck, MachineCheckException)
  269. /* Data Storage exception. */
  270. STD_EXCEPTION(0x300, DataStorage, UnknownException)
  271. /* Instruction Storage exception. */
  272. STD_EXCEPTION(0x400, InstStorage, UnknownException)
  273. /* External Interrupt exception. */
  274. #ifndef FIXME
  275. STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
  276. #endif
  277. /* Alignment exception. */
  278. . = 0x600
  279. Alignment:
  280. EXCEPTION_PROLOG(SRR0, SRR1)
  281. mfspr r4,DAR
  282. stw r4,_DAR(r21)
  283. mfspr r5,DSISR
  284. stw r5,_DSISR(r21)
  285. addi r3,r1,STACK_FRAME_OVERHEAD
  286. li r20,MSR_KERNEL
  287. rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
  288. rlwimi r20,r23,0,25,25 /* copy IP bit from saved MSR */
  289. lwz r6,GOT(transfer_to_handler)
  290. mtlr r6
  291. blrl
  292. .L_Alignment:
  293. .long AlignmentException - _start + EXC_OFF_SYS_RESET
  294. .long int_return - _start + EXC_OFF_SYS_RESET
  295. /* Program check exception */
  296. . = 0x700
  297. ProgramCheck:
  298. EXCEPTION_PROLOG(SRR0, SRR1)
  299. addi r3,r1,STACK_FRAME_OVERHEAD
  300. li r20,MSR_KERNEL
  301. rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
  302. rlwimi r20,r23,0,25,25 /* copy IP bit from saved MSR */
  303. lwz r6,GOT(transfer_to_handler)
  304. mtlr r6
  305. blrl
  306. .L_ProgramCheck:
  307. .long ProgramCheckException - _start + EXC_OFF_SYS_RESET
  308. .long int_return - _start + EXC_OFF_SYS_RESET
  309. STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
  310. /* I guess we could implement decrementer, and may have
  311. * to someday for timekeeping.
  312. */
  313. STD_EXCEPTION(0x900, Decrementer, timer_interrupt)
  314. STD_EXCEPTION(0xa00, Trap_0a, UnknownException)
  315. STD_EXCEPTION(0xb00, Trap_0b, UnknownException)
  316. STD_EXCEPTION(0xc00, SystemCall, UnknownException)
  317. STD_EXCEPTION(0xd00, SingleStep, UnknownException)
  318. STD_EXCEPTION(0xe00, Trap_0e, UnknownException)
  319. STD_EXCEPTION(0xf00, Trap_0f, UnknownException)
  320. STD_EXCEPTION(0x1000, InstructionTLBMiss, UnknownException)
  321. STD_EXCEPTION(0x1100, DataLoadTLBMiss, UnknownException)
  322. STD_EXCEPTION(0x1200, DataStoreTLBMiss, UnknownException)
  323. #ifdef DEBUG
  324. . = 0x1300
  325. /*
  326. * This exception occurs when the program counter matches the
  327. * Instruction Address Breakpoint Register (IABR).
  328. *
  329. * I want the cpu to halt if this occurs so I can hunt around
  330. * with the debugger and look at things.
  331. *
  332. * When DEBUG is defined, both machine check enable (in the MSR)
  333. * and checkstop reset enable (in the reset mode register) are
  334. * turned off and so a checkstop condition will result in the cpu
  335. * halting.
  336. *
  337. * I force the cpu into a checkstop condition by putting an illegal
  338. * instruction here (at least this is the theory).
  339. *
  340. * well - that didnt work, so just do an infinite loop!
  341. */
  342. 1: b 1b
  343. #else
  344. STD_EXCEPTION(0x1300, InstructionBreakpoint, DebugException)
  345. #endif
  346. STD_EXCEPTION(0x1400, SMI, UnknownException)
  347. STD_EXCEPTION(0x1500, Trap_15, UnknownException)
  348. STD_EXCEPTION(0x1600, Trap_16, UnknownException)
  349. STD_EXCEPTION(0x1700, Trap_17, UnknownException)
  350. STD_EXCEPTION(0x1800, Trap_18, UnknownException)
  351. STD_EXCEPTION(0x1900, Trap_19, UnknownException)
  352. STD_EXCEPTION(0x1a00, Trap_1a, UnknownException)
  353. STD_EXCEPTION(0x1b00, Trap_1b, UnknownException)
  354. STD_EXCEPTION(0x1c00, Trap_1c, UnknownException)
  355. STD_EXCEPTION(0x1d00, Trap_1d, UnknownException)
  356. STD_EXCEPTION(0x1e00, Trap_1e, UnknownException)
  357. STD_EXCEPTION(0x1f00, Trap_1f, UnknownException)
  358. STD_EXCEPTION(0x2000, Trap_20, UnknownException)
  359. STD_EXCEPTION(0x2100, Trap_21, UnknownException)
  360. STD_EXCEPTION(0x2200, Trap_22, UnknownException)
  361. STD_EXCEPTION(0x2300, Trap_23, UnknownException)
  362. STD_EXCEPTION(0x2400, Trap_24, UnknownException)
  363. STD_EXCEPTION(0x2500, Trap_25, UnknownException)
  364. STD_EXCEPTION(0x2600, Trap_26, UnknownException)
  365. STD_EXCEPTION(0x2700, Trap_27, UnknownException)
  366. STD_EXCEPTION(0x2800, Trap_28, UnknownException)
  367. STD_EXCEPTION(0x2900, Trap_29, UnknownException)
  368. STD_EXCEPTION(0x2a00, Trap_2a, UnknownException)
  369. STD_EXCEPTION(0x2b00, Trap_2b, UnknownException)
  370. STD_EXCEPTION(0x2c00, Trap_2c, UnknownException)
  371. STD_EXCEPTION(0x2d00, Trap_2d, UnknownException)
  372. STD_EXCEPTION(0x2e00, Trap_2e, UnknownException)
  373. STD_EXCEPTION(0x2f00, Trap_2f, UnknownException)
  374. .globl _end_of_vectors
  375. _end_of_vectors:
  376. . = 0x3000
  377. /*
  378. * This code finishes saving the registers to the exception frame
  379. * and jumps to the appropriate handler for the exception.
  380. * Register r21 is pointer into trap frame, r1 has new stack pointer.
  381. */
  382. .globl transfer_to_handler
  383. transfer_to_handler:
  384. stw r22,_NIP(r21)
  385. lis r22,MSR_POW@h
  386. andc r23,r23,r22
  387. stw r23,_MSR(r21)
  388. SAVE_GPR(7, r21)
  389. SAVE_4GPRS(8, r21)
  390. SAVE_8GPRS(12, r21)
  391. SAVE_8GPRS(24, r21)
  392. mflr r23
  393. andi. r24,r23,0x3f00 /* get vector offset */
  394. stw r24,TRAP(r21)
  395. li r22,0
  396. stw r22,RESULT(r21)
  397. lwz r24,0(r23) /* virtual address of handler */
  398. lwz r23,4(r23) /* where to go when done */
  399. mtspr SRR0,r24
  400. mtspr SRR1,r20
  401. mtlr r23
  402. SYNC
  403. rfi /* jump to handler, enable MMU */
  404. int_return:
  405. mfmsr r28 /* Disable interrupts */
  406. li r4,0
  407. ori r4,r4,MSR_EE
  408. andc r28,r28,r4
  409. SYNC /* Some chip revs need this... */
  410. mtmsr r28
  411. SYNC
  412. lwz r2,_CTR(r1)
  413. lwz r0,_LINK(r1)
  414. mtctr r2
  415. mtlr r0
  416. lwz r2,_XER(r1)
  417. lwz r0,_CCR(r1)
  418. mtspr XER,r2
  419. mtcrf 0xFF,r0
  420. REST_10GPRS(3, r1)
  421. REST_10GPRS(13, r1)
  422. REST_8GPRS(23, r1)
  423. REST_GPR(31, r1)
  424. lwz r2,_NIP(r1) /* Restore environment */
  425. lwz r0,_MSR(r1)
  426. mtspr SRR0,r2
  427. mtspr SRR1,r0
  428. lwz r0,GPR0(r1)
  429. lwz r2,GPR2(r1)
  430. lwz r1,GPR1(r1)
  431. SYNC
  432. rfi
  433. #endif /* !CONFIG_NAND_SPL */
  434. /*
  435. * This code initialises the E300 processor core
  436. * (conforms to PowerPC 603e spec)
  437. * Note: expects original MSR contents to be in r5.
  438. */
  439. .globl init_e300_core
  440. init_e300_core: /* time t 10 */
  441. /* Initialize machine status; enable machine check interrupt */
  442. /*-----------------------------------------------------------*/
  443. li r3, MSR_KERNEL /* Set ME and RI flags */
  444. rlwimi r3, r5, 0, 25, 25 /* preserve IP bit set by HRCW */
  445. #ifdef DEBUG
  446. rlwimi r3, r5, 0, 21, 22 /* debugger might set SE & BE bits */
  447. #endif
  448. SYNC /* Some chip revs need this... */
  449. mtmsr r3
  450. SYNC
  451. mtspr SRR1, r3 /* Make SRR1 match MSR */
  452. lis r3, CONFIG_SYS_IMMR@h
  453. #if defined(CONFIG_WATCHDOG)
  454. /* Initialise the Wathcdog values and reset it (if req) */
  455. /*------------------------------------------------------*/
  456. lis r4, CONFIG_SYS_WATCHDOG_VALUE
  457. ori r4, r4, (SWCRR_SWEN | SWCRR_SWRI | SWCRR_SWPR)
  458. stw r4, SWCRR(r3)
  459. /* and reset it */
  460. li r4, 0x556C
  461. sth r4, SWSRR@l(r3)
  462. li r4, -0x55C7
  463. sth r4, SWSRR@l(r3)
  464. #else
  465. /* Disable Wathcdog */
  466. /*-------------------*/
  467. lwz r4, SWCRR(r3)
  468. /* Check to see if its enabled for disabling
  469. once disabled by SW you can't re-enable */
  470. andi. r4, r4, 0x4
  471. beq 1f
  472. xor r4, r4, r4
  473. stw r4, SWCRR(r3)
  474. 1:
  475. #endif /* CONFIG_WATCHDOG */
  476. #if defined(CONFIG_MASK_AER_AO)
  477. /* Write the Arbiter Event Enable to mask Address Only traps. */
  478. /* This prevents the dcbz instruction from being trapped when */
  479. /* HID0_ABE Address Broadcast Enable is set and the MEMORY */
  480. /* COHERENCY bit is set in the WIMG bits, which is often */
  481. /* needed for PCI operation. */
  482. lwz r4, 0x0808(r3)
  483. rlwinm r0, r4, 0, ~AER_AO
  484. stw r0, 0x0808(r3)
  485. #endif /* CONFIG_MASK_AER_AO */
  486. /* Initialize the Hardware Implementation-dependent Registers */
  487. /* HID0 also contains cache control */
  488. /* - force invalidation of data and instruction caches */
  489. /*------------------------------------------------------*/
  490. lis r3, CONFIG_SYS_HID0_INIT@h
  491. ori r3, r3, (CONFIG_SYS_HID0_INIT | HID0_ICFI | HID0_DCFI)@l
  492. SYNC
  493. mtspr HID0, r3
  494. lis r3, CONFIG_SYS_HID0_FINAL@h
  495. ori r3, r3, (CONFIG_SYS_HID0_FINAL & ~(HID0_ICFI | HID0_DCFI))@l
  496. SYNC
  497. mtspr HID0, r3
  498. lis r3, CONFIG_SYS_HID2@h
  499. ori r3, r3, CONFIG_SYS_HID2@l
  500. SYNC
  501. mtspr HID2, r3
  502. /* Done! */
  503. /*------------------------------*/
  504. blr
  505. /* setup_bats - set them up to some initial state */
  506. .globl setup_bats
  507. setup_bats:
  508. addis r0, r0, 0x0000
  509. /* IBAT 0 */
  510. addis r4, r0, CONFIG_SYS_IBAT0L@h
  511. ori r4, r4, CONFIG_SYS_IBAT0L@l
  512. addis r3, r0, CONFIG_SYS_IBAT0U@h
  513. ori r3, r3, CONFIG_SYS_IBAT0U@l
  514. mtspr IBAT0L, r4
  515. mtspr IBAT0U, r3
  516. /* DBAT 0 */
  517. addis r4, r0, CONFIG_SYS_DBAT0L@h
  518. ori r4, r4, CONFIG_SYS_DBAT0L@l
  519. addis r3, r0, CONFIG_SYS_DBAT0U@h
  520. ori r3, r3, CONFIG_SYS_DBAT0U@l
  521. mtspr DBAT0L, r4
  522. mtspr DBAT0U, r3
  523. /* IBAT 1 */
  524. addis r4, r0, CONFIG_SYS_IBAT1L@h
  525. ori r4, r4, CONFIG_SYS_IBAT1L@l
  526. addis r3, r0, CONFIG_SYS_IBAT1U@h
  527. ori r3, r3, CONFIG_SYS_IBAT1U@l
  528. mtspr IBAT1L, r4
  529. mtspr IBAT1U, r3
  530. /* DBAT 1 */
  531. addis r4, r0, CONFIG_SYS_DBAT1L@h
  532. ori r4, r4, CONFIG_SYS_DBAT1L@l
  533. addis r3, r0, CONFIG_SYS_DBAT1U@h
  534. ori r3, r3, CONFIG_SYS_DBAT1U@l
  535. mtspr DBAT1L, r4
  536. mtspr DBAT1U, r3
  537. /* IBAT 2 */
  538. addis r4, r0, CONFIG_SYS_IBAT2L@h
  539. ori r4, r4, CONFIG_SYS_IBAT2L@l
  540. addis r3, r0, CONFIG_SYS_IBAT2U@h
  541. ori r3, r3, CONFIG_SYS_IBAT2U@l
  542. mtspr IBAT2L, r4
  543. mtspr IBAT2U, r3
  544. /* DBAT 2 */
  545. addis r4, r0, CONFIG_SYS_DBAT2L@h
  546. ori r4, r4, CONFIG_SYS_DBAT2L@l
  547. addis r3, r0, CONFIG_SYS_DBAT2U@h
  548. ori r3, r3, CONFIG_SYS_DBAT2U@l
  549. mtspr DBAT2L, r4
  550. mtspr DBAT2U, r3
  551. /* IBAT 3 */
  552. addis r4, r0, CONFIG_SYS_IBAT3L@h
  553. ori r4, r4, CONFIG_SYS_IBAT3L@l
  554. addis r3, r0, CONFIG_SYS_IBAT3U@h
  555. ori r3, r3, CONFIG_SYS_IBAT3U@l
  556. mtspr IBAT3L, r4
  557. mtspr IBAT3U, r3
  558. /* DBAT 3 */
  559. addis r4, r0, CONFIG_SYS_DBAT3L@h
  560. ori r4, r4, CONFIG_SYS_DBAT3L@l
  561. addis r3, r0, CONFIG_SYS_DBAT3U@h
  562. ori r3, r3, CONFIG_SYS_DBAT3U@l
  563. mtspr DBAT3L, r4
  564. mtspr DBAT3U, r3
  565. #ifdef CONFIG_HIGH_BATS
  566. /* IBAT 4 */
  567. addis r4, r0, CONFIG_SYS_IBAT4L@h
  568. ori r4, r4, CONFIG_SYS_IBAT4L@l
  569. addis r3, r0, CONFIG_SYS_IBAT4U@h
  570. ori r3, r3, CONFIG_SYS_IBAT4U@l
  571. mtspr IBAT4L, r4
  572. mtspr IBAT4U, r3
  573. /* DBAT 4 */
  574. addis r4, r0, CONFIG_SYS_DBAT4L@h
  575. ori r4, r4, CONFIG_SYS_DBAT4L@l
  576. addis r3, r0, CONFIG_SYS_DBAT4U@h
  577. ori r3, r3, CONFIG_SYS_DBAT4U@l
  578. mtspr DBAT4L, r4
  579. mtspr DBAT4U, r3
  580. /* IBAT 5 */
  581. addis r4, r0, CONFIG_SYS_IBAT5L@h
  582. ori r4, r4, CONFIG_SYS_IBAT5L@l
  583. addis r3, r0, CONFIG_SYS_IBAT5U@h
  584. ori r3, r3, CONFIG_SYS_IBAT5U@l
  585. mtspr IBAT5L, r4
  586. mtspr IBAT5U, r3
  587. /* DBAT 5 */
  588. addis r4, r0, CONFIG_SYS_DBAT5L@h
  589. ori r4, r4, CONFIG_SYS_DBAT5L@l
  590. addis r3, r0, CONFIG_SYS_DBAT5U@h
  591. ori r3, r3, CONFIG_SYS_DBAT5U@l
  592. mtspr DBAT5L, r4
  593. mtspr DBAT5U, r3
  594. /* IBAT 6 */
  595. addis r4, r0, CONFIG_SYS_IBAT6L@h
  596. ori r4, r4, CONFIG_SYS_IBAT6L@l
  597. addis r3, r0, CONFIG_SYS_IBAT6U@h
  598. ori r3, r3, CONFIG_SYS_IBAT6U@l
  599. mtspr IBAT6L, r4
  600. mtspr IBAT6U, r3
  601. /* DBAT 6 */
  602. addis r4, r0, CONFIG_SYS_DBAT6L@h
  603. ori r4, r4, CONFIG_SYS_DBAT6L@l
  604. addis r3, r0, CONFIG_SYS_DBAT6U@h
  605. ori r3, r3, CONFIG_SYS_DBAT6U@l
  606. mtspr DBAT6L, r4
  607. mtspr DBAT6U, r3
  608. /* IBAT 7 */
  609. addis r4, r0, CONFIG_SYS_IBAT7L@h
  610. ori r4, r4, CONFIG_SYS_IBAT7L@l
  611. addis r3, r0, CONFIG_SYS_IBAT7U@h
  612. ori r3, r3, CONFIG_SYS_IBAT7U@l
  613. mtspr IBAT7L, r4
  614. mtspr IBAT7U, r3
  615. /* DBAT 7 */
  616. addis r4, r0, CONFIG_SYS_DBAT7L@h
  617. ori r4, r4, CONFIG_SYS_DBAT7L@l
  618. addis r3, r0, CONFIG_SYS_DBAT7U@h
  619. ori r3, r3, CONFIG_SYS_DBAT7U@l
  620. mtspr DBAT7L, r4
  621. mtspr DBAT7U, r3
  622. #endif
  623. isync
  624. /* invalidate all tlb's
  625. *
  626. * From the 603e User Manual: "The 603e provides the ability to
  627. * invalidate a TLB entry. The TLB Invalidate Entry (tlbie)
  628. * instruction invalidates the TLB entry indexed by the EA, and
  629. * operates on both the instruction and data TLBs simultaneously
  630. * invalidating four TLB entries (both sets in each TLB). The
  631. * index corresponds to bits 15-19 of the EA. To invalidate all
  632. * entries within both TLBs, 32 tlbie instructions should be
  633. * issued, incrementing this field by one each time."
  634. *
  635. * "Note that the tlbia instruction is not implemented on the
  636. * 603e."
  637. *
  638. * bits 15-19 correspond to addresses 0x00000000 to 0x0001F000
  639. * incrementing by 0x1000 each time. The code below is sort of
  640. * based on code in "flush_tlbs" from arch/ppc/kernel/head.S
  641. *
  642. */
  643. lis r3, 0
  644. lis r5, 2
  645. 1:
  646. tlbie r3
  647. addi r3, r3, 0x1000
  648. cmp 0, 0, r3, r5
  649. blt 1b
  650. blr
  651. /* Cache functions.
  652. *
  653. * Note: requires that all cache bits in
  654. * HID0 are in the low half word.
  655. */
  656. .globl icache_enable
  657. icache_enable:
  658. mfspr r3, HID0
  659. ori r3, r3, HID0_ICE
  660. li r4, HID0_ICFI|HID0_ILOCK
  661. andc r3, r3, r4
  662. ori r4, r3, HID0_ICFI
  663. isync
  664. mtspr HID0, r4 /* sets enable and invalidate, clears lock */
  665. isync
  666. mtspr HID0, r3 /* clears invalidate */
  667. blr
  668. .globl icache_disable
  669. icache_disable:
  670. mfspr r3, HID0
  671. lis r4, 0
  672. ori r4, r4, HID0_ICE|HID0_ICFI|HID0_ILOCK
  673. andc r3, r3, r4
  674. isync
  675. mtspr HID0, r3 /* clears invalidate, enable and lock */
  676. blr
  677. .globl icache_status
  678. icache_status:
  679. mfspr r3, HID0
  680. rlwinm r3, r3, (31 - HID0_ICE_SHIFT + 1), 31, 31
  681. blr
  682. .globl dcache_enable
  683. dcache_enable:
  684. mfspr r3, HID0
  685. li r5, HID0_DCFI|HID0_DLOCK
  686. andc r3, r3, r5
  687. ori r3, r3, HID0_DCE
  688. sync
  689. mtspr HID0, r3 /* enable, no invalidate */
  690. blr
  691. .globl dcache_disable
  692. dcache_disable:
  693. mflr r4
  694. bl flush_dcache /* uses r3 and r5 */
  695. mfspr r3, HID0
  696. li r5, HID0_DCE|HID0_DLOCK
  697. andc r3, r3, r5
  698. ori r5, r3, HID0_DCFI
  699. sync
  700. mtspr HID0, r5 /* sets invalidate, clears enable and lock */
  701. sync
  702. mtspr HID0, r3 /* clears invalidate */
  703. mtlr r4
  704. blr
  705. .globl dcache_status
  706. dcache_status:
  707. mfspr r3, HID0
  708. rlwinm r3, r3, (31 - HID0_DCE_SHIFT + 1), 31, 31
  709. blr
  710. .globl flush_dcache
  711. flush_dcache:
  712. lis r3, 0
  713. lis r5, CONFIG_SYS_CACHELINE_SIZE
  714. 1: cmp 0, 1, r3, r5
  715. bge 2f
  716. lwz r5, 0(r3)
  717. lis r5, CONFIG_SYS_CACHELINE_SIZE
  718. addi r3, r3, 0x4
  719. b 1b
  720. 2: blr
  721. /*-------------------------------------------------------------------*/
  722. /*
  723. * void relocate_code (addr_sp, gd, addr_moni)
  724. *
  725. * This "function" does not return, instead it continues in RAM
  726. * after relocating the monitor code.
  727. *
  728. * r3 = dest
  729. * r4 = src
  730. * r5 = length in bytes
  731. * r6 = cachelinesize
  732. */
  733. .globl relocate_code
  734. relocate_code:
  735. mr r1, r3 /* Set new stack pointer */
  736. mr r9, r4 /* Save copy of Global Data pointer */
  737. mr r10, r5 /* Save copy of Destination Address */
  738. mr r3, r5 /* Destination Address */
  739. lis r4, CONFIG_SYS_MONITOR_BASE@h /* Source Address */
  740. ori r4, r4, CONFIG_SYS_MONITOR_BASE@l
  741. lwz r5, GOT(__bss_start)
  742. sub r5, r5, r4
  743. li r6, CONFIG_SYS_CACHELINE_SIZE /* Cache Line Size */
  744. /*
  745. * Fix GOT pointer:
  746. *
  747. * New GOT-PTR = (old GOT-PTR - CONFIG_SYS_MONITOR_BASE)
  748. * + Destination Address
  749. *
  750. * Offset:
  751. */
  752. sub r15, r10, r4
  753. /* First our own GOT */
  754. add r14, r14, r15
  755. /* then the one used by the C code */
  756. add r30, r30, r15
  757. /*
  758. * Now relocate code
  759. */
  760. cmplw cr1,r3,r4
  761. addi r0,r5,3
  762. srwi. r0,r0,2
  763. beq cr1,4f /* In place copy is not necessary */
  764. beq 7f /* Protect against 0 count */
  765. mtctr r0
  766. bge cr1,2f
  767. la r8,-4(r4)
  768. la r7,-4(r3)
  769. /* copy */
  770. 1: lwzu r0,4(r8)
  771. stwu r0,4(r7)
  772. bdnz 1b
  773. addi r0,r5,3
  774. srwi. r0,r0,2
  775. mtctr r0
  776. la r8,-4(r4)
  777. la r7,-4(r3)
  778. /* and compare */
  779. 20: lwzu r20,4(r8)
  780. lwzu r21,4(r7)
  781. xor. r22, r20, r21
  782. bne 30f
  783. bdnz 20b
  784. b 4f
  785. /* compare failed */
  786. 30: li r3, 0
  787. blr
  788. 2: slwi r0,r0,2 /* re copy in reverse order ... y do we needed it? */
  789. add r8,r4,r0
  790. add r7,r3,r0
  791. 3: lwzu r0,-4(r8)
  792. stwu r0,-4(r7)
  793. bdnz 3b
  794. /*
  795. * Now flush the cache: note that we must start from a cache aligned
  796. * address. Otherwise we might miss one cache line.
  797. */
  798. 4: cmpwi r6,0
  799. add r5,r3,r5
  800. beq 7f /* Always flush prefetch queue in any case */
  801. subi r0,r6,1
  802. andc r3,r3,r0
  803. mr r4,r3
  804. 5: dcbst 0,r4
  805. add r4,r4,r6
  806. cmplw r4,r5
  807. blt 5b
  808. sync /* Wait for all dcbst to complete on bus */
  809. mr r4,r3
  810. 6: icbi 0,r4
  811. add r4,r4,r6
  812. cmplw r4,r5
  813. blt 6b
  814. 7: sync /* Wait for all icbi to complete on bus */
  815. isync
  816. /*
  817. * We are done. Do not return, instead branch to second part of board
  818. * initialization, now running from RAM.
  819. */
  820. addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET
  821. mtlr r0
  822. blr
  823. in_ram:
  824. /*
  825. * Relocation Function, r14 point to got2+0x8000
  826. *
  827. * Adjust got2 pointers, no need to check for 0, this code
  828. * already puts a few entries in the table.
  829. */
  830. li r0,__got2_entries@sectoff@l
  831. la r3,GOT(_GOT2_TABLE_)
  832. lwz r11,GOT(_GOT2_TABLE_)
  833. mtctr r0
  834. sub r11,r3,r11
  835. addi r3,r3,-4
  836. 1: lwzu r0,4(r3)
  837. add r0,r0,r11
  838. stw r0,0(r3)
  839. bdnz 1b
  840. #ifndef CONFIG_NAND_SPL
  841. /*
  842. * Now adjust the fixups and the pointers to the fixups
  843. * in case we need to move ourselves again.
  844. */
  845. 2: li r0,__fixup_entries@sectoff@l
  846. lwz r3,GOT(_FIXUP_TABLE_)
  847. cmpwi r0,0
  848. mtctr r0
  849. addi r3,r3,-4
  850. beq 4f
  851. 3: lwzu r4,4(r3)
  852. lwzux r0,r4,r11
  853. add r0,r0,r11
  854. stw r10,0(r3)
  855. stw r0,0(r4)
  856. bdnz 3b
  857. 4:
  858. #endif
  859. clear_bss:
  860. /*
  861. * Now clear BSS segment
  862. */
  863. lwz r3,GOT(__bss_start)
  864. #if defined(CONFIG_HYMOD)
  865. /*
  866. * For HYMOD - the environment is the very last item in flash.
  867. * The real .bss stops just before environment starts, so only
  868. * clear up to that point.
  869. *
  870. * taken from mods for FADS board
  871. */
  872. lwz r4,GOT(environment)
  873. #else
  874. lwz r4,GOT(_end)
  875. #endif
  876. cmplw 0, r3, r4
  877. beq 6f
  878. li r0, 0
  879. 5:
  880. stw r0, 0(r3)
  881. addi r3, r3, 4
  882. cmplw 0, r3, r4
  883. bne 5b
  884. 6:
  885. mr r3, r9 /* Global Data pointer */
  886. mr r4, r10 /* Destination Address */
  887. bl board_init_r
  888. #ifndef CONFIG_NAND_SPL
  889. /*
  890. * Copy exception vector code to low memory
  891. *
  892. * r3: dest_addr
  893. * r7: source address, r8: end address, r9: target address
  894. */
  895. .globl trap_init
  896. trap_init:
  897. lwz r7, GOT(_start)
  898. lwz r8, GOT(_end_of_vectors)
  899. li r9, 0x100 /* reset vector always at 0x100 */
  900. cmplw 0, r7, r8
  901. bgelr /* return if r7>=r8 - just in case */
  902. mflr r4 /* save link register */
  903. 1:
  904. lwz r0, 0(r7)
  905. stw r0, 0(r9)
  906. addi r7, r7, 4
  907. addi r9, r9, 4
  908. cmplw 0, r7, r8
  909. bne 1b
  910. /*
  911. * relocate `hdlr' and `int_return' entries
  912. */
  913. li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET
  914. li r8, Alignment - _start + EXC_OFF_SYS_RESET
  915. 2:
  916. bl trap_reloc
  917. addi r7, r7, 0x100 /* next exception vector */
  918. cmplw 0, r7, r8
  919. blt 2b
  920. li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET
  921. bl trap_reloc
  922. li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET
  923. bl trap_reloc
  924. li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET
  925. li r8, SystemCall - _start + EXC_OFF_SYS_RESET
  926. 3:
  927. bl trap_reloc
  928. addi r7, r7, 0x100 /* next exception vector */
  929. cmplw 0, r7, r8
  930. blt 3b
  931. li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET
  932. li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET
  933. 4:
  934. bl trap_reloc
  935. addi r7, r7, 0x100 /* next exception vector */
  936. cmplw 0, r7, r8
  937. blt 4b
  938. mfmsr r3 /* now that the vectors have */
  939. lis r7, MSR_IP@h /* relocated into low memory */
  940. ori r7, r7, MSR_IP@l /* MSR[IP] can be turned off */
  941. andc r3, r3, r7 /* (if it was on) */
  942. SYNC /* Some chip revs need this... */
  943. mtmsr r3
  944. SYNC
  945. mtlr r4 /* restore link register */
  946. blr
  947. /*
  948. * Function: relocate entries for one exception vector
  949. */
  950. trap_reloc:
  951. lwz r0, 0(r7) /* hdlr ... */
  952. add r0, r0, r3 /* ... += dest_addr */
  953. stw r0, 0(r7)
  954. lwz r0, 4(r7) /* int_return ... */
  955. add r0, r0, r3 /* ... += dest_addr */
  956. stw r0, 4(r7)
  957. blr
  958. #endif /* !CONFIG_NAND_SPL */
  959. #ifdef CONFIG_SYS_INIT_RAM_LOCK
  960. lock_ram_in_cache:
  961. /* Allocate Initial RAM in data cache.
  962. */
  963. lis r3, (CONFIG_SYS_INIT_RAM_ADDR & ~31)@h
  964. ori r3, r3, (CONFIG_SYS_INIT_RAM_ADDR & ~31)@l
  965. li r4, ((CONFIG_SYS_INIT_RAM_END & ~31) + \
  966. (CONFIG_SYS_INIT_RAM_ADDR & 31) + 31) / 32
  967. mtctr r4
  968. 1:
  969. dcbz r0, r3
  970. addi r3, r3, 32
  971. bdnz 1b
  972. /* Lock the data cache */
  973. mfspr r0, HID0
  974. ori r0, r0, HID0_DLOCK
  975. sync
  976. mtspr HID0, r0
  977. sync
  978. blr
  979. #ifndef CONFIG_NAND_SPL
  980. .globl unlock_ram_in_cache
  981. unlock_ram_in_cache:
  982. /* invalidate the INIT_RAM section */
  983. lis r3, (CONFIG_SYS_INIT_RAM_ADDR & ~31)@h
  984. ori r3, r3, (CONFIG_SYS_INIT_RAM_ADDR & ~31)@l
  985. li r4, ((CONFIG_SYS_INIT_RAM_END & ~31) + \
  986. (CONFIG_SYS_INIT_RAM_ADDR & 31) + 31) / 32
  987. mtctr r4
  988. 1: icbi r0, r3
  989. dcbi r0, r3
  990. addi r3, r3, 32
  991. bdnz 1b
  992. sync /* Wait for all icbi to complete on bus */
  993. isync
  994. /* Unlock the data cache and invalidate it */
  995. mfspr r3, HID0
  996. li r5, HID0_DLOCK|HID0_DCFI
  997. andc r3, r3, r5 /* no invalidate, unlock */
  998. ori r5, r3, HID0_DCFI /* invalidate, unlock */
  999. sync
  1000. mtspr HID0, r5 /* invalidate, unlock */
  1001. sync
  1002. mtspr HID0, r3 /* no invalidate, unlock */
  1003. blr
  1004. #endif /* !CONFIG_NAND_SPL */
  1005. #endif /* CONFIG_SYS_INIT_RAM_LOCK */
  1006. #ifdef CONFIG_SYS_FLASHBOOT
  1007. map_flash_by_law1:
  1008. /* When booting from ROM (Flash or EPROM), clear the */
  1009. /* Address Mask in OR0 so ROM appears everywhere */
  1010. /*----------------------------------------------------*/
  1011. lis r3, (CONFIG_SYS_IMMR)@h /* r3 <= CONFIG_SYS_IMMR */
  1012. lwz r4, OR0@l(r3)
  1013. li r5, 0x7fff /* r5 <= 0x00007FFFF */
  1014. and r4, r4, r5
  1015. stw r4, OR0@l(r3) /* OR0 <= OR0 & 0x00007FFFF */
  1016. /* As MPC8349E User's Manual presented, when RCW[BMS] is set to 0,
  1017. * system will boot from 0x0000_0100, and the LBLAWBAR0[BASE_ADDR]
  1018. * reset value is 0x00000; when RCW[BMS] is set to 1, system will boot
  1019. * from 0xFFF0_0100, and the LBLAWBAR0[BASE_ADDR] reset value is
  1020. * 0xFF800. From the hard resetting to here, the processor fetched and
  1021. * executed the instructions one by one. There is not absolutely
  1022. * jumping happened. Laterly, the u-boot code has to do an absolutely
  1023. * jumping to tell the CPU instruction fetching component what the
  1024. * u-boot TEXT base address is. Because the TEXT base resides in the
  1025. * boot ROM memory space, to garantee the code can run smoothly after
  1026. * that jumping, we must map in the entire boot ROM by Local Access
  1027. * Window. Sometimes, we desire an non-0x00000 or non-0xFF800 starting
  1028. * address for boot ROM, such as 0xFE000000. In this case, the default
  1029. * LBIU Local Access Widow 0 will not cover this memory space. So, we
  1030. * need another window to map in it.
  1031. */
  1032. lis r4, (CONFIG_SYS_FLASH_BASE)@h
  1033. ori r4, r4, (CONFIG_SYS_FLASH_BASE)@l
  1034. stw r4, LBLAWBAR1(r3) /* LBLAWBAR1 <= CONFIG_SYS_FLASH_BASE */
  1035. /* Store 0x80000012 + log2(CONFIG_SYS_FLASH_SIZE) into LBLAWAR1 */
  1036. lis r4, (0x80000012)@h
  1037. ori r4, r4, (0x80000012)@l
  1038. li r5, CONFIG_SYS_FLASH_SIZE
  1039. 1: srawi. r5, r5, 1 /* r5 = r5 >> 1 */
  1040. addi r4, r4, 1
  1041. bne 1b
  1042. stw r4, LBLAWAR1(r3) /* LBLAWAR1 <= 8MB Flash Size */
  1043. blr
  1044. /* Though all the LBIU Local Access Windows and LBC Banks will be
  1045. * initialized in the C code, we'd better configure boot ROM's
  1046. * window 0 and bank 0 correctly at here.
  1047. */
  1048. remap_flash_by_law0:
  1049. /* Initialize the BR0 with the boot ROM starting address. */
  1050. lwz r4, BR0(r3)
  1051. li r5, 0x7FFF
  1052. and r4, r4, r5
  1053. lis r5, (CONFIG_SYS_FLASH_BASE & 0xFFFF8000)@h
  1054. ori r5, r5, (CONFIG_SYS_FLASH_BASE & 0xFFFF8000)@l
  1055. or r5, r5, r4
  1056. stw r5, BR0(r3) /* r5 <= (CONFIG_SYS_FLASH_BASE & 0xFFFF8000) | (BR0 & 0x00007FFF) */
  1057. lwz r4, OR0(r3)
  1058. lis r5, ~((CONFIG_SYS_FLASH_SIZE << 4) - 1)
  1059. or r4, r4, r5
  1060. stw r4, OR0(r3)
  1061. lis r4, (CONFIG_SYS_FLASH_BASE)@h
  1062. ori r4, r4, (CONFIG_SYS_FLASH_BASE)@l
  1063. stw r4, LBLAWBAR0(r3) /* LBLAWBAR0 <= CONFIG_SYS_FLASH_BASE */
  1064. /* Store 0x80000012 + log2(CONFIG_SYS_FLASH_SIZE) into LBLAWAR0 */
  1065. lis r4, (0x80000012)@h
  1066. ori r4, r4, (0x80000012)@l
  1067. li r5, CONFIG_SYS_FLASH_SIZE
  1068. 1: srawi. r5, r5, 1 /* r5 = r5 >> 1 */
  1069. addi r4, r4, 1
  1070. bne 1b
  1071. stw r4, LBLAWAR0(r3) /* LBLAWAR0 <= Flash Size */
  1072. xor r4, r4, r4
  1073. stw r4, LBLAWBAR1(r3)
  1074. stw r4, LBLAWAR1(r3) /* Off LBIU LAW1 */
  1075. blr
  1076. #endif /* CONFIG_SYS_FLASHBOOT */