start.S 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693
  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. *
  6. * See file CREDITS for list of people who contributed to this
  7. * project.
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation; either version 2 of
  12. * the License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this program; if not, write to the Free Software
  21. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  22. * MA 02111-1307 USA
  23. */
  24. /*------------------------------------------------------------------------------+ */
  25. /* */
  26. /* This source code has been made available to you by IBM on an AS-IS */
  27. /* basis. Anyone receiving this source is licensed under IBM */
  28. /* copyrights to use it in any way he or she deems fit, including */
  29. /* copying it, modifying it, compiling it, and redistributing it either */
  30. /* with or without modifications. No license under IBM patents or */
  31. /* patent applications is to be implied by the copyright license. */
  32. /* */
  33. /* Any user of this software should understand that IBM cannot provide */
  34. /* technical support for this software and will not be responsible for */
  35. /* any consequences resulting from the use of this software. */
  36. /* */
  37. /* Any person who transfers this source code or any derivative work */
  38. /* must include the IBM copyright notice, this paragraph, and the */
  39. /* preceding two paragraphs in the transferred software. */
  40. /* */
  41. /* COPYRIGHT I B M CORPORATION 1995 */
  42. /* LICENSED MATERIAL - PROGRAM PROPERTY OF I B M */
  43. /*------------------------------------------------------------------------------- */
  44. /* U-Boot - Startup Code for IBM 4xx PowerPC based Embedded Boards
  45. *
  46. *
  47. * The processor starts at 0xfffffffc and the code is executed
  48. * from flash/rom.
  49. * in memory, but as long we don't jump around before relocating.
  50. * board_init lies at a quite high address and when the cpu has
  51. * jumped there, everything is ok.
  52. * This works because the cpu gives the FLASH (CS0) the whole
  53. * address space at startup, and board_init lies as a echo of
  54. * the flash somewhere up there in the memorymap.
  55. *
  56. * board_init will change CS0 to be positioned at the correct
  57. * address and (s)dram will be positioned at address 0
  58. */
  59. #include <config.h>
  60. #include <mpc8xx.h>
  61. #include <ppc4xx.h>
  62. #include <version.h>
  63. #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
  64. #include <ppc_asm.tmpl>
  65. #include <ppc_defs.h>
  66. #include <asm/cache.h>
  67. #include <asm/mmu.h>
  68. #ifndef CONFIG_IDENT_STRING
  69. #define CONFIG_IDENT_STRING ""
  70. #endif
  71. #ifdef CFG_INIT_DCACHE_CS
  72. # if (CFG_INIT_DCACHE_CS == 0)
  73. # define PBxAP pb0ap
  74. # define PBxCR pb0cr
  75. # endif
  76. # if (CFG_INIT_DCACHE_CS == 1)
  77. # define PBxAP pb1ap
  78. # define PBxCR pb1cr
  79. # endif
  80. # if (CFG_INIT_DCACHE_CS == 2)
  81. # define PBxAP pb2ap
  82. # define PBxCR pb2cr
  83. # endif
  84. # if (CFG_INIT_DCACHE_CS == 3)
  85. # define PBxAP pb3ap
  86. # define PBxCR pb3cr
  87. # endif
  88. # if (CFG_INIT_DCACHE_CS == 4)
  89. # define PBxAP pb4ap
  90. # define PBxCR pb4cr
  91. # endif
  92. # if (CFG_INIT_DCACHE_CS == 5)
  93. # define PBxAP pb5ap
  94. # define PBxCR pb5cr
  95. # endif
  96. # if (CFG_INIT_DCACHE_CS == 6)
  97. # define PBxAP pb6ap
  98. # define PBxCR pb6cr
  99. # endif
  100. # if (CFG_INIT_DCACHE_CS == 7)
  101. # define PBxAP pb7ap
  102. # define PBxCR pb7cr
  103. # endif
  104. #endif /* CFG_INIT_DCACHE_CS */
  105. /* We don't want the MMU yet.
  106. */
  107. #undef MSR_KERNEL
  108. #define MSR_KERNEL ( MSR_ME ) /* Machine Check */
  109. .extern ext_bus_cntlr_init
  110. .extern sdram_init
  111. /*
  112. * Set up GOT: Global Offset Table
  113. *
  114. * Use r14 to access the GOT
  115. */
  116. START_GOT
  117. GOT_ENTRY(_GOT2_TABLE_)
  118. GOT_ENTRY(_FIXUP_TABLE_)
  119. GOT_ENTRY(_start)
  120. GOT_ENTRY(_start_of_vectors)
  121. GOT_ENTRY(_end_of_vectors)
  122. GOT_ENTRY(transfer_to_handler)
  123. GOT_ENTRY(__init_end)
  124. GOT_ENTRY(_end)
  125. GOT_ENTRY(__bss_start)
  126. END_GOT
  127. /*
  128. * 440 Startup -- on reset only the top 4k of the effective
  129. * address space is mapped in by an entry in the instruction
  130. * and data shadow TLB. The .bootpg section is located in the
  131. * top 4k & does only what's necessary to map in the the rest
  132. * of the boot rom. Once the boot rom is mapped in we can
  133. * proceed with normal startup.
  134. *
  135. * NOTE: CS0 only covers the top 2MB of the effective address
  136. * space after reset.
  137. */
  138. #if defined(CONFIG_440)
  139. .section .bootpg,"ax"
  140. .globl _start_440
  141. /**************************************************************************/
  142. _start_440:
  143. /*----------------------------------------------------------------*/
  144. /* Clear and set up some registers. */
  145. /*----------------------------------------------------------------*/
  146. iccci r0,r0 /* NOTE: operands not used for 440 */
  147. dccci r0,r0 /* NOTE: operands not used for 440 */
  148. sync
  149. li r0,0
  150. mtspr srr0,r0
  151. mtspr srr1,r0
  152. mtspr csrr0,r0
  153. mtspr csrr1,r0
  154. #if defined (CONFIG_440_GX) /* NOTE: 440GX adds machine check status regs */
  155. mtspr mcsrr0,r0
  156. mtspr mcsrr1,r0
  157. mfspr r1, mcsr
  158. mtspr mcsr,r1
  159. #endif
  160. /*----------------------------------------------------------------*/
  161. /* Initialize debug */
  162. /*----------------------------------------------------------------*/
  163. mtspr dbcr0,r0
  164. mtspr dbcr1,r0
  165. mtspr dbcr2,r0
  166. mtspr iac1,r0
  167. mtspr iac2,r0
  168. mtspr iac3,r0
  169. mtspr dac1,r0
  170. mtspr dac2,r0
  171. mtspr dvc1,r0
  172. mtspr dvc2,r0
  173. mfspr r1,dbsr
  174. mtspr dbsr,r1 /* Clear all valid bits */
  175. /*----------------------------------------------------------------*/
  176. /* CCR0 init */
  177. /*----------------------------------------------------------------*/
  178. /* Disable store gathering & broadcast, guarantee inst/data
  179. * cache block touch, force load/store alignment
  180. * (see errata 1.12: 440_33)
  181. */
  182. lis r1,0x0030 /* store gathering & broadcast disable */
  183. ori r1,r1,0x6000 /* cache touch */
  184. mtspr ccr0,r1
  185. /*----------------------------------------------------------------*/
  186. /* Setup interrupt vectors */
  187. /*----------------------------------------------------------------*/
  188. mtspr ivpr,r0 /* Vectors start at 0x0000_0000 */
  189. li r1,0x0100
  190. mtspr ivor0,r1 /* Critical input */
  191. li r1,0x0200
  192. mtspr ivor1,r1 /* Machine check */
  193. li r1,0x0300
  194. mtspr ivor2,r1 /* Data storage */
  195. li r1,0x0400
  196. mtspr ivor3,r1 /* Instruction storage */
  197. li r1,0x0500
  198. mtspr ivor4,r1 /* External interrupt */
  199. li r1,0x0600
  200. mtspr ivor5,r1 /* Alignment */
  201. li r1,0x0700
  202. mtspr ivor6,r1 /* Program check */
  203. li r1,0x0800
  204. mtspr ivor7,r1 /* Floating point unavailable */
  205. li r1,0x0c00
  206. mtspr ivor8,r1 /* System call */
  207. li r1,0x1000
  208. mtspr ivor10,r1 /* Decrementer (PIT for 440) */
  209. li r1,0x1400
  210. mtspr ivor13,r1 /* Data TLB error */
  211. li r1,0x1300
  212. mtspr ivor14,r1 /* Instr TLB error */
  213. li r1,0x2000
  214. mtspr ivor15,r1 /* Debug */
  215. /*----------------------------------------------------------------*/
  216. /* Configure cache regions */
  217. /*----------------------------------------------------------------*/
  218. mtspr inv0,r0
  219. mtspr inv1,r0
  220. mtspr inv2,r0
  221. mtspr inv3,r0
  222. mtspr dnv0,r0
  223. mtspr dnv1,r0
  224. mtspr dnv2,r0
  225. mtspr dnv3,r0
  226. mtspr itv0,r0
  227. mtspr itv1,r0
  228. mtspr itv2,r0
  229. mtspr itv3,r0
  230. mtspr dtv0,r0
  231. mtspr dtv1,r0
  232. mtspr dtv2,r0
  233. mtspr dtv3,r0
  234. /*----------------------------------------------------------------*/
  235. /* Cache victim limits */
  236. /*----------------------------------------------------------------*/
  237. /* floors 0, ceiling max to use the entire cache -- nothing locked
  238. */
  239. lis r1,0x0001
  240. ori r1,r1,0xf800
  241. mtspr ivlim,r1
  242. mtspr dvlim,r1
  243. /*----------------------------------------------------------------*/
  244. /* Clear all TLB entries -- TID = 0, TS = 0 */
  245. /*----------------------------------------------------------------*/
  246. mtspr mmucr,r0
  247. li r1,0x003f /* 64 TLB entries */
  248. mtctr r1
  249. 0: tlbwe r0,r1,0x0000 /* Invalidate all entries (V=0)*/
  250. subi r1,r1,0x0001
  251. bdnz 0b
  252. /*----------------------------------------------------------------*/
  253. /* TLB entry setup -- step thru tlbtab */
  254. /*----------------------------------------------------------------*/
  255. bl tlbtab /* Get tlbtab pointer */
  256. mr r5,r0
  257. li r1,0x003f /* 64 TLB entries max */
  258. mtctr r1
  259. li r4,0 /* TLB # */
  260. addi r5,r5,-4
  261. 1: lwzu r0,4(r5)
  262. cmpwi r0,0
  263. beq 2f /* 0 marks end */
  264. lwzu r1,4(r5)
  265. lwzu r2,4(r5)
  266. tlbwe r0,r4,0 /* TLB Word 0 */
  267. tlbwe r1,r4,1 /* TLB Word 1 */
  268. tlbwe r2,r4,2 /* TLB Word 2 */
  269. addi r4,r4,1 /* Next TLB */
  270. bdnz 1b
  271. /*----------------------------------------------------------------*/
  272. /* Continue from 'normal' start */
  273. /*----------------------------------------------------------------*/
  274. 2: bl 3f
  275. b _start
  276. 3: li r0,0
  277. mtspr srr1,r0 /* Keep things disabled for now */
  278. mflr r1
  279. mtspr srr0,r1
  280. rfi
  281. #endif /* CONFIG_440 */
  282. /*
  283. * r3 - 1st arg to board_init(): IMMP pointer
  284. * r4 - 2nd arg to board_init(): boot flag
  285. */
  286. .text
  287. .long 0x27051956 /* U-Boot Magic Number */
  288. .globl version_string
  289. version_string:
  290. .ascii U_BOOT_VERSION
  291. .ascii " (", __DATE__, " - ", __TIME__, ")"
  292. .ascii CONFIG_IDENT_STRING, "\0"
  293. /*
  294. * Maybe this should be moved somewhere else because the current
  295. * location (0x100) is where the CriticalInput Execption should be.
  296. */
  297. . = EXC_OFF_SYS_RESET
  298. .globl _start
  299. _start:
  300. /*****************************************************************************/
  301. #if defined(CONFIG_440)
  302. /*----------------------------------------------------------------*/
  303. /* Clear and set up some registers. */
  304. /*----------------------------------------------------------------*/
  305. li r0,0x0000
  306. lis r1,0xffff
  307. mtspr dec,r0 /* prevent dec exceptions */
  308. mtspr tbl,r0 /* prevent fit & wdt exceptions */
  309. mtspr tbu,r0
  310. mtspr tsr,r1 /* clear all timer exception status */
  311. mtspr tcr,r0 /* disable all */
  312. mtspr esr,r0 /* clear exception syndrome register */
  313. mtxer r0 /* clear integer exception register */
  314. #if !defined(CONFIG_440_GX)
  315. lis r1,0x0002 /* set CE bit (Critical Exceptions) */
  316. ori r1,r1,0x1000 /* set ME bit (Machine Exceptions) */
  317. mtmsr r1 /* change MSR */
  318. #elif !defined(CONFIG_440_EP) && !defined(CONFIG_440_GR)
  319. bl __440gx_msr_set
  320. b __440gx_msr_continue
  321. __440gx_msr_set:
  322. lis r1, 0x0002 /* set CE bit (Critical Exceptions) */
  323. ori r1,r1,0x1000 /* set ME bit (Machine Exceptions) */
  324. mtspr srr1,r1
  325. mflr r1
  326. mtspr srr0,r1
  327. rfi
  328. __440gx_msr_continue:
  329. #endif
  330. /*----------------------------------------------------------------*/
  331. /* Debug setup -- some (not very good) ice's need an event*/
  332. /* to establish control :-( Define CFG_INIT_DBCR to the dbsr */
  333. /* value you need in this case 0x8cff 0000 should do the trick */
  334. /*----------------------------------------------------------------*/
  335. #if defined(CFG_INIT_DBCR)
  336. lis r1,0xffff
  337. ori r1,r1,0xffff
  338. mtspr dbsr,r1 /* Clear all status bits */
  339. lis r0,CFG_INIT_DBCR@h
  340. ori r0,r0,CFG_INIT_DBCR@l
  341. mtspr dbcr0,r0
  342. isync
  343. #endif
  344. /*----------------------------------------------------------------*/
  345. /* Setup the internal SRAM */
  346. /*----------------------------------------------------------------*/
  347. li r0,0
  348. #if defined(CONFIG_440_EP) || defined(CONFIG_440_GR)
  349. /* Clear Dcache to use as RAM */
  350. lis r3,CFG_INIT_RAM_ADDR@h
  351. li r4,CFG_INIT_RAM_END@l
  352. rlwinm. r5,r4,0,27,31
  353. rlwinm r5,r4,27,5,31
  354. beq ..d_ran
  355. addi r5,r5,0x0001
  356. ..d_ran:
  357. mtctr r5
  358. ..d_ag:
  359. dcbz r0,r3
  360. addi r3,r3,32
  361. bdnz ..d_ag
  362. #else
  363. #if defined (CONFIG_440_GX)
  364. mtdcr l2_cache_cfg,r0 /* Ensure L2 Cache is off */
  365. #endif
  366. mtdcr isram0_sb1cr,r0 /* Disable bank 1 */
  367. li r2,0x7fff
  368. ori r2,r2,0xffff
  369. mfdcr r1,isram0_dpc
  370. and r1,r1,r2 /* Disable parity check */
  371. mtdcr isram0_dpc,r1
  372. mfdcr r1,isram0_pmeg
  373. andis. r1,r1,r2 /* Disable pwr mgmt */
  374. mtdcr isram0_pmeg,r1
  375. lis r1,0x8000 /* BAS = 8000_0000 */
  376. #if defined(CONFIG_440_GX)
  377. ori r1,r1,0x0980 /* first 64k */
  378. mtdcr isram0_sb0cr,r1
  379. lis r1,0x8001
  380. ori r1,r1,0x0980 /* second 64k */
  381. mtdcr isram0_sb1cr,r1
  382. lis r1, 0x8002
  383. ori r1,r1, 0x0980 /* third 64k */
  384. mtdcr isram0_sb2cr,r1
  385. lis r1, 0x8003
  386. ori r1,r1, 0x0980 /* fourth 64k */
  387. mtdcr isram0_sb3cr,r1
  388. #else
  389. ori r1,r1,0x0380 /* 8k rw */
  390. mtdcr isram0_sb0cr,r1
  391. #endif
  392. #endif
  393. /*----------------------------------------------------------------*/
  394. /* Setup the stack in internal SRAM */
  395. /*----------------------------------------------------------------*/
  396. lis r1,CFG_INIT_RAM_ADDR@h
  397. ori r1,r1,CFG_INIT_SP_OFFSET@l
  398. li r0,0
  399. stwu r0,-4(r1)
  400. stwu r0,-4(r1) /* Terminate call chain */
  401. stwu r1,-8(r1) /* Save back chain and move SP */
  402. lis r0,RESET_VECTOR@h /* Address of reset vector */
  403. ori r0,r0, RESET_VECTOR@l
  404. stwu r1,-8(r1) /* Save back chain and move SP */
  405. stw r0,+12(r1) /* Save return addr (underflow vect) */
  406. GET_GOT
  407. bl board_init_f
  408. #endif /* CONFIG_440 */
  409. /*****************************************************************************/
  410. #ifdef CONFIG_IOP480
  411. /*----------------------------------------------------------------------- */
  412. /* Set up some machine state registers. */
  413. /*----------------------------------------------------------------------- */
  414. addi r0,r0,0x0000 /* initialize r0 to zero */
  415. mtspr esr,r0 /* clear Exception Syndrome Reg */
  416. mttcr r0 /* timer control register */
  417. mtexier r0 /* disable all interrupts */
  418. addi r4,r0,0x1000 /* set ME bit (Machine Exceptions) */
  419. oris r4,r4,0x2 /* set CE bit (Critical Exceptions) */
  420. mtmsr r4 /* change MSR */
  421. addis r4,r0,0xFFFF /* set r4 to 0xFFFFFFFF (status in the */
  422. ori r4,r4,0xFFFF /* dbsr is cleared by setting bits to 1) */
  423. mtdbsr r4 /* clear/reset the dbsr */
  424. mtexisr r4 /* clear all pending interrupts */
  425. addis r4,r0,0x8000
  426. mtexier r4 /* enable critical exceptions */
  427. addis r4,r0,0x0000 /* assume 403GCX - enable core clk */
  428. ori r4,r4,0x4020 /* dbling (no harm done on GA and GC */
  429. mtiocr r4 /* since bit not used) & DRC to latch */
  430. /* data bus on rising edge of CAS */
  431. /*----------------------------------------------------------------------- */
  432. /* Clear XER. */
  433. /*----------------------------------------------------------------------- */
  434. mtxer r0
  435. /*----------------------------------------------------------------------- */
  436. /* Invalidate i-cache and d-cache TAG arrays. */
  437. /*----------------------------------------------------------------------- */
  438. addi r3,0,1024 /* 1/4 of I-cache size, half of D-cache */
  439. addi r4,0,1024 /* 1/4 of I-cache */
  440. ..cloop:
  441. iccci 0,r3
  442. iccci r4,r3
  443. dccci 0,r3
  444. addic. r3,r3,-16 /* move back one cache line */
  445. bne ..cloop /* loop back to do rest until r3 = 0 */
  446. /* */
  447. /* initialize IOP480 so it can read 1 MB code area for SRAM spaces */
  448. /* this requires enabling MA[17..0], by default only MA[12..0] are enabled. */
  449. /* */
  450. /* first copy IOP480 register base address into r3 */
  451. addis r3,0,0x5000 /* IOP480 register base address hi */
  452. /* ori r3,r3,0x0000 / IOP480 register base address lo */
  453. #ifdef CONFIG_ADCIOP
  454. /* use r4 as the working variable */
  455. /* turn on CS3 (LOCCTL.7) */
  456. lwz r4,0x84(r3) /* LOCTL is at offset 0x84 */
  457. andi. r4,r4,0xff7f /* make bit 7 = 0 -- CS3 mode */
  458. stw r4,0x84(r3) /* LOCTL is at offset 0x84 */
  459. #endif
  460. #ifdef CONFIG_DASA_SIM
  461. /* use r4 as the working variable */
  462. /* turn on MA17 (LOCCTL.7) */
  463. lwz r4,0x84(r3) /* LOCTL is at offset 0x84 */
  464. ori r4,r4,0x80 /* make bit 7 = 1 -- MA17 mode */
  465. stw r4,0x84(r3) /* LOCTL is at offset 0x84 */
  466. #endif
  467. /* turn on MA16..13 (LCS0BRD.12 = 0) */
  468. lwz r4,0x100(r3) /* LCS0BRD is at offset 0x100 */
  469. andi. r4,r4,0xefff /* make bit 12 = 0 */
  470. stw r4,0x100(r3) /* LCS0BRD is at offset 0x100 */
  471. /* make sure above stores all comlete before going on */
  472. sync
  473. /* last thing, set local init status done bit (DEVINIT.31) */
  474. lwz r4,0x80(r3) /* DEVINIT is at offset 0x80 */
  475. oris r4,r4,0x8000 /* make bit 31 = 1 */
  476. stw r4,0x80(r3) /* DEVINIT is at offset 0x80 */
  477. /* clear all pending interrupts and disable all interrupts */
  478. li r4,-1 /* set p1 to 0xffffffff */
  479. stw r4,0x1b0(r3) /* clear all pending interrupts */
  480. stw r4,0x1b8(r3) /* clear all pending interrupts */
  481. li r4,0 /* set r4 to 0 */
  482. stw r4,0x1b4(r3) /* disable all interrupts */
  483. stw r4,0x1bc(r3) /* disable all interrupts */
  484. /* make sure above stores all comlete before going on */
  485. sync
  486. /*----------------------------------------------------------------------- */
  487. /* Enable two 128MB cachable regions. */
  488. /*----------------------------------------------------------------------- */
  489. addis r1,r0,0x8000
  490. addi r1,r1,0x0001
  491. mticcr r1 /* instruction cache */
  492. addis r1,r0,0x0000
  493. addi r1,r1,0x0000
  494. mtdccr r1 /* data cache */
  495. addis r1,r0,CFG_INIT_RAM_ADDR@h
  496. ori r1,r1,CFG_INIT_SP_OFFSET /* set up the stack to SDRAM */
  497. li r0, 0 /* Make room for stack frame header and */
  498. stwu r0, -4(r1) /* clear final stack frame so that */
  499. stwu r0, -4(r1) /* stack backtraces terminate cleanly */
  500. GET_GOT /* initialize GOT access */
  501. bl board_init_f /* run first part of init code (from Flash) */
  502. #endif /* CONFIG_IOP480 */
  503. /*****************************************************************************/
  504. #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405) || defined(CONFIG_405EP)
  505. /*----------------------------------------------------------------------- */
  506. /* Clear and set up some registers. */
  507. /*----------------------------------------------------------------------- */
  508. addi r4,r0,0x0000
  509. mtspr sgr,r4
  510. mtspr dcwr,r4
  511. mtesr r4 /* clear Exception Syndrome Reg */
  512. mttcr r4 /* clear Timer Control Reg */
  513. mtxer r4 /* clear Fixed-Point Exception Reg */
  514. mtevpr r4 /* clear Exception Vector Prefix Reg */
  515. addi r4,r0,0x1000 /* set ME bit (Machine Exceptions) */
  516. oris r4,r4,0x0002 /* set CE bit (Critical Exceptions) */
  517. mtmsr r4 /* change MSR */
  518. addi r4,r0,(0xFFFF-0x10000) /* set r4 to 0xFFFFFFFF (status in the */
  519. /* dbsr is cleared by setting bits to 1) */
  520. mtdbsr r4 /* clear/reset the dbsr */
  521. /*----------------------------------------------------------------------- */
  522. /* Invalidate I and D caches. Enable I cache for defined memory regions */
  523. /* to speed things up. Leave the D cache disabled for now. It will be */
  524. /* enabled/left disabled later based on user selected menu options. */
  525. /* Be aware that the I cache may be disabled later based on the menu */
  526. /* options as well. See miscLib/main.c. */
  527. /*----------------------------------------------------------------------- */
  528. bl invalidate_icache
  529. bl invalidate_dcache
  530. /*----------------------------------------------------------------------- */
  531. /* Enable two 128MB cachable regions. */
  532. /*----------------------------------------------------------------------- */
  533. addis r4,r0,0x8000
  534. addi r4,r4,0x0001
  535. mticcr r4 /* instruction cache */
  536. isync
  537. addis r4,r0,0x0000
  538. addi r4,r4,0x0000
  539. mtdccr r4 /* data cache */
  540. #if !(defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR))
  541. /*----------------------------------------------------------------------- */
  542. /* Tune the speed and size for flash CS0 */
  543. /*----------------------------------------------------------------------- */
  544. bl ext_bus_cntlr_init
  545. #endif
  546. #if defined(CONFIG_405EP)
  547. /*----------------------------------------------------------------------- */
  548. /* DMA Status, clear to come up clean */
  549. /*----------------------------------------------------------------------- */
  550. addis r3,r0, 0xFFFF /* Clear all existing DMA status */
  551. ori r3,r3, 0xFFFF
  552. mtdcr dmasr, r3
  553. bl ppc405ep_init /* do ppc405ep specific init */
  554. #endif /* CONFIG_405EP */
  555. #if defined(CFG_OCM_DATA_ADDR) && defined(CFG_OCM_DATA_SIZE)
  556. /********************************************************************
  557. * Setup OCM - On Chip Memory
  558. *******************************************************************/
  559. /* Setup OCM */
  560. lis r0, 0x7FFF
  561. ori r0, r0, 0xFFFF
  562. mfdcr r3, ocmiscntl /* get instr-side IRAM config */
  563. mfdcr r4, ocmdscntl /* get data-side IRAM config */
  564. and r3, r3, r0 /* disable data-side IRAM */
  565. and r4, r4, r0 /* disable data-side IRAM */
  566. mtdcr ocmiscntl, r3 /* set instr-side IRAM config */
  567. mtdcr ocmdscntl, r4 /* set data-side IRAM config */
  568. isync
  569. addis r3, 0, CFG_OCM_DATA_ADDR@h /* OCM location */
  570. mtdcr ocmdsarc, r3
  571. addis r4, 0, 0xC000 /* OCM data area enabled */
  572. mtdcr ocmdscntl, r4
  573. isync
  574. #endif
  575. /*----------------------------------------------------------------------- */
  576. /* Setup temporary stack in DCACHE or OCM if needed for SDRAM SPD. */
  577. /*----------------------------------------------------------------------- */
  578. #ifdef CFG_INIT_DCACHE_CS
  579. /*----------------------------------------------------------------------- */
  580. /* Memory Bank x (nothingness) initialization 1GB+64MEG */
  581. /* used as temporary stack pointer for stage0 */
  582. /*----------------------------------------------------------------------- */
  583. li r4,PBxAP
  584. mtdcr ebccfga,r4
  585. lis r4,0x0380
  586. ori r4,r4,0x0480
  587. mtdcr ebccfgd,r4
  588. addi r4,0,PBxCR
  589. mtdcr ebccfga,r4
  590. lis r4,0x400D
  591. ori r4,r4,0xa000
  592. mtdcr ebccfgd,r4
  593. /* turn on data chache for this region */
  594. lis r4,0x0080
  595. mtdccr r4
  596. /* set stack pointer and clear stack to known value */
  597. lis r1,CFG_INIT_RAM_ADDR@h
  598. ori r1,r1,CFG_INIT_SP_OFFSET@l
  599. li r4,2048 /* we store 2048 words to stack */
  600. mtctr r4
  601. lis r2,CFG_INIT_RAM_ADDR@h /* we also clear data area */
  602. ori r2,r2,CFG_INIT_RAM_END@l /* so cant copy value from r1 */
  603. lis r4,0xdead /* we store 0xdeaddead in the stack */
  604. ori r4,r4,0xdead
  605. ..stackloop:
  606. stwu r4,-4(r2)
  607. bdnz ..stackloop
  608. li r0, 0 /* Make room for stack frame header and */
  609. stwu r0, -4(r1) /* clear final stack frame so that */
  610. stwu r0, -4(r1) /* stack backtraces terminate cleanly */
  611. /*
  612. * Set up a dummy frame to store reset vector as return address.
  613. * this causes stack underflow to reset board.
  614. */
  615. stwu r1, -8(r1) /* Save back chain and move SP */
  616. addis r0, 0, RESET_VECTOR@h /* Address of reset vector */
  617. ori r0, r0, RESET_VECTOR@l
  618. stwu r1, -8(r1) /* Save back chain and move SP */
  619. stw r0, +12(r1) /* Save return addr (underflow vect) */
  620. #elif defined(CFG_TEMP_STACK_OCM) && \
  621. (defined(CFG_OCM_DATA_ADDR) && defined(CFG_OCM_DATA_SIZE))
  622. /*
  623. * Stack in OCM.
  624. */
  625. /* Set up Stack at top of OCM */
  626. lis r1, (CFG_INIT_RAM_ADDR + CFG_INIT_SP_OFFSET)@h
  627. ori r1, r1, (CFG_INIT_RAM_ADDR + CFG_INIT_SP_OFFSET)@l
  628. /* Set up a zeroized stack frame so that backtrace works right */
  629. li r0, 0
  630. stwu r0, -4(r1)
  631. stwu r0, -4(r1)
  632. /*
  633. * Set up a dummy frame to store reset vector as return address.
  634. * this causes stack underflow to reset board.
  635. */
  636. stwu r1, -8(r1) /* Save back chain and move SP */
  637. lis r0, RESET_VECTOR@h /* Address of reset vector */
  638. ori r0, r0, RESET_VECTOR@l
  639. stwu r1, -8(r1) /* Save back chain and move SP */
  640. stw r0, +12(r1) /* Save return addr (underflow vect) */
  641. #endif /* CFG_INIT_DCACHE_CS */
  642. /*----------------------------------------------------------------------- */
  643. /* Initialize SDRAM Controller */
  644. /*----------------------------------------------------------------------- */
  645. bl sdram_init
  646. /*
  647. * Setup temporary stack pointer only for boards
  648. * that do not use SDRAM SPD I2C stuff since it
  649. * is already initialized to use DCACHE or OCM
  650. * stacks.
  651. */
  652. #if !(defined(CFG_INIT_DCACHE_CS) || defined(CFG_TEMP_STACK_OCM))
  653. lis r1, CFG_INIT_RAM_ADDR@h
  654. ori r1,r1,CFG_INIT_SP_OFFSET /* set up the stack in SDRAM */
  655. li r0, 0 /* Make room for stack frame header and */
  656. stwu r0, -4(r1) /* clear final stack frame so that */
  657. stwu r0, -4(r1) /* stack backtraces terminate cleanly */
  658. /*
  659. * Set up a dummy frame to store reset vector as return address.
  660. * this causes stack underflow to reset board.
  661. */
  662. stwu r1, -8(r1) /* Save back chain and move SP */
  663. lis r0, RESET_VECTOR@h /* Address of reset vector */
  664. ori r0, r0, RESET_VECTOR@l
  665. stwu r1, -8(r1) /* Save back chain and move SP */
  666. stw r0, +12(r1) /* Save return addr (underflow vect) */
  667. #endif /* !(CFG_INIT_DCACHE_CS || !CFG_TEM_STACK_OCM) */
  668. GET_GOT /* initialize GOT access */
  669. bl cpu_init_f /* run low-level CPU init code (from Flash) */
  670. /* NEVER RETURNS! */
  671. bl board_init_f /* run first part of init code (from Flash) */
  672. #endif /* CONFIG_405GP || CONFIG_405CR || CONFIG_405 || CONFIG_405EP */
  673. /*----------------------------------------------------------------------- */
  674. /*****************************************************************************/
  675. .globl _start_of_vectors
  676. _start_of_vectors:
  677. #if 0
  678. /*TODO Fixup _start above so we can do this*/
  679. /* Critical input. */
  680. CRIT_EXCEPTION(0x100, CritcalInput, CritcalInputException)
  681. #endif
  682. /* Machine check */
  683. CRIT_EXCEPTION(0x200, MachineCheck, MachineCheckException)
  684. /* Data Storage exception. */
  685. STD_EXCEPTION(0x300, DataStorage, UnknownException)
  686. /* Instruction Storage exception. */
  687. STD_EXCEPTION(0x400, InstStorage, UnknownException)
  688. /* External Interrupt exception. */
  689. STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
  690. /* Alignment exception. */
  691. . = 0x600
  692. Alignment:
  693. EXCEPTION_PROLOG
  694. mfspr r4,DAR
  695. stw r4,_DAR(r21)
  696. mfspr r5,DSISR
  697. stw r5,_DSISR(r21)
  698. addi r3,r1,STACK_FRAME_OVERHEAD
  699. li r20,MSR_KERNEL
  700. rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
  701. lwz r6,GOT(transfer_to_handler)
  702. mtlr r6
  703. blrl
  704. .L_Alignment:
  705. .long AlignmentException - _start + EXC_OFF_SYS_RESET
  706. .long int_return - _start + EXC_OFF_SYS_RESET
  707. /* Program check exception */
  708. . = 0x700
  709. ProgramCheck:
  710. EXCEPTION_PROLOG
  711. addi r3,r1,STACK_FRAME_OVERHEAD
  712. li r20,MSR_KERNEL
  713. rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
  714. lwz r6,GOT(transfer_to_handler)
  715. mtlr r6
  716. blrl
  717. .L_ProgramCheck:
  718. .long ProgramCheckException - _start + EXC_OFF_SYS_RESET
  719. .long int_return - _start + EXC_OFF_SYS_RESET
  720. /* No FPU on MPC8xx. This exception is not supposed to happen.
  721. */
  722. STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
  723. /* I guess we could implement decrementer, and may have
  724. * to someday for timekeeping.
  725. */
  726. STD_EXCEPTION(0x900, Decrementer, timer_interrupt)
  727. STD_EXCEPTION(0xa00, Trap_0a, UnknownException)
  728. STD_EXCEPTION(0xb00, Trap_0b, UnknownException)
  729. STD_EXCEPTION(0xc00, SystemCall, UnknownException)
  730. STD_EXCEPTION(0xd00, SingleStep, UnknownException)
  731. STD_EXCEPTION(0xe00, Trap_0e, UnknownException)
  732. STD_EXCEPTION(0xf00, Trap_0f, UnknownException)
  733. /* On the MPC8xx, this is a software emulation interrupt. It occurs
  734. * for all unimplemented and illegal instructions.
  735. */
  736. STD_EXCEPTION(0x1000, PIT, PITException)
  737. STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException)
  738. STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException)
  739. STD_EXCEPTION(0x1300, InstructionTLBError, UnknownException)
  740. STD_EXCEPTION(0x1400, DataTLBError, UnknownException)
  741. STD_EXCEPTION(0x1500, Reserved5, UnknownException)
  742. STD_EXCEPTION(0x1600, Reserved6, UnknownException)
  743. STD_EXCEPTION(0x1700, Reserved7, UnknownException)
  744. STD_EXCEPTION(0x1800, Reserved8, UnknownException)
  745. STD_EXCEPTION(0x1900, Reserved9, UnknownException)
  746. STD_EXCEPTION(0x1a00, ReservedA, UnknownException)
  747. STD_EXCEPTION(0x1b00, ReservedB, UnknownException)
  748. STD_EXCEPTION(0x1c00, DataBreakpoint, UnknownException)
  749. STD_EXCEPTION(0x1d00, InstructionBreakpoint, UnknownException)
  750. STD_EXCEPTION(0x1e00, PeripheralBreakpoint, UnknownException)
  751. STD_EXCEPTION(0x1f00, DevPortBreakpoint, UnknownException)
  752. CRIT_EXCEPTION(0x2000, DebugBreakpoint, DebugException )
  753. .globl _end_of_vectors
  754. _end_of_vectors:
  755. . = 0x2100
  756. /*
  757. * This code finishes saving the registers to the exception frame
  758. * and jumps to the appropriate handler for the exception.
  759. * Register r21 is pointer into trap frame, r1 has new stack pointer.
  760. */
  761. .globl transfer_to_handler
  762. transfer_to_handler:
  763. stw r22,_NIP(r21)
  764. lis r22,MSR_POW@h
  765. andc r23,r23,r22
  766. stw r23,_MSR(r21)
  767. SAVE_GPR(7, r21)
  768. SAVE_4GPRS(8, r21)
  769. SAVE_8GPRS(12, r21)
  770. SAVE_8GPRS(24, r21)
  771. #if 0
  772. andi. r23,r23,MSR_PR
  773. mfspr r23,SPRG3 /* if from user, fix up tss.regs */
  774. beq 2f
  775. addi r24,r1,STACK_FRAME_OVERHEAD
  776. stw r24,PT_REGS(r23)
  777. 2: addi r2,r23,-TSS /* set r2 to current */
  778. tovirt(r2,r2,r23)
  779. #endif
  780. mflr r23
  781. andi. r24,r23,0x3f00 /* get vector offset */
  782. stw r24,TRAP(r21)
  783. li r22,0
  784. stw r22,RESULT(r21)
  785. mtspr SPRG2,r22 /* r1 is now kernel sp */
  786. #if 0
  787. addi r24,r2,TASK_STRUCT_SIZE /* check for kernel stack overflow */
  788. cmplw 0,r1,r2
  789. cmplw 1,r1,r24
  790. crand 1,1,4
  791. bgt stack_ovf /* if r2 < r1 < r2+TASK_STRUCT_SIZE */
  792. #endif
  793. lwz r24,0(r23) /* virtual address of handler */
  794. lwz r23,4(r23) /* where to go when done */
  795. mtspr SRR0,r24
  796. mtspr SRR1,r20
  797. mtlr r23
  798. SYNC
  799. rfi /* jump to handler, enable MMU */
  800. int_return:
  801. mfmsr r28 /* Disable interrupts */
  802. li r4,0
  803. ori r4,r4,MSR_EE
  804. andc r28,r28,r4
  805. SYNC /* Some chip revs need this... */
  806. mtmsr r28
  807. SYNC
  808. lwz r2,_CTR(r1)
  809. lwz r0,_LINK(r1)
  810. mtctr r2
  811. mtlr r0
  812. lwz r2,_XER(r1)
  813. lwz r0,_CCR(r1)
  814. mtspr XER,r2
  815. mtcrf 0xFF,r0
  816. REST_10GPRS(3, r1)
  817. REST_10GPRS(13, r1)
  818. REST_8GPRS(23, r1)
  819. REST_GPR(31, r1)
  820. lwz r2,_NIP(r1) /* Restore environment */
  821. lwz r0,_MSR(r1)
  822. mtspr SRR0,r2
  823. mtspr SRR1,r0
  824. lwz r0,GPR0(r1)
  825. lwz r2,GPR2(r1)
  826. lwz r1,GPR1(r1)
  827. SYNC
  828. rfi
  829. crit_return:
  830. mfmsr r28 /* Disable interrupts */
  831. li r4,0
  832. ori r4,r4,MSR_EE
  833. andc r28,r28,r4
  834. SYNC /* Some chip revs need this... */
  835. mtmsr r28
  836. SYNC
  837. lwz r2,_CTR(r1)
  838. lwz r0,_LINK(r1)
  839. mtctr r2
  840. mtlr r0
  841. lwz r2,_XER(r1)
  842. lwz r0,_CCR(r1)
  843. mtspr XER,r2
  844. mtcrf 0xFF,r0
  845. REST_10GPRS(3, r1)
  846. REST_10GPRS(13, r1)
  847. REST_8GPRS(23, r1)
  848. REST_GPR(31, r1)
  849. lwz r2,_NIP(r1) /* Restore environment */
  850. lwz r0,_MSR(r1)
  851. mtspr 990,r2 /* SRR2 */
  852. mtspr 991,r0 /* SRR3 */
  853. lwz r0,GPR0(r1)
  854. lwz r2,GPR2(r1)
  855. lwz r1,GPR1(r1)
  856. SYNC
  857. rfci
  858. /* Cache functions.
  859. */
  860. invalidate_icache:
  861. iccci r0,r0 /* for 405, iccci invalidates the */
  862. blr /* entire I cache */
  863. invalidate_dcache:
  864. addi r6,0,0x0000 /* clear GPR 6 */
  865. /* Do loop for # of dcache congruence classes. */
  866. #if defined(CONFIG_440_GX) || defined(CONFIG_440_EP) || defined(CONFIG_440_GR)
  867. lis r7, (CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)@ha /* TBS for large sized cache */
  868. ori r7, r7, (CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)@l
  869. #else
  870. addi r7,r0, (CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)
  871. #endif
  872. /* NOTE: dccci invalidates both */
  873. mtctr r7 /* ways in the D cache */
  874. ..dcloop:
  875. dccci 0,r6 /* invalidate line */
  876. addi r6,r6, CFG_CACHELINE_SIZE /* bump to next line */
  877. bdnz ..dcloop
  878. blr
  879. flush_dcache:
  880. addis r9,r0,0x0002 /* set mask for EE and CE msr bits */
  881. ori r9,r9,0x8000
  882. mfmsr r12 /* save msr */
  883. andc r9,r12,r9
  884. mtmsr r9 /* disable EE and CE */
  885. addi r10,r0,0x0001 /* enable data cache for unused memory */
  886. mfdccr r9 /* region 0xF8000000-0xFFFFFFFF via */
  887. or r10,r10,r9 /* bit 31 in dccr */
  888. mtdccr r10
  889. /* do loop for # of congruence classes. */
  890. #if defined(CONFIG_440_GX) || defined(CONFIG_440_EP) || defined(CONFIG_440_GR)
  891. lis r10,(CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)@ha /* TBS: for large cache sizes */
  892. ori r10,r10,(CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)@l
  893. lis r11,(CFG_DCACHE_SIZE / 2)@ha /* D cache set size - 2 way sets */
  894. ori r11,r11,(CFG_DCACHE_SIZE / 2)@l /* D cache set size - 2 way sets */
  895. #else
  896. addi r10,r0,(CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)
  897. addi r11,r0,(CFG_DCACHE_SIZE / 2) /* D cache set size - 2 way sets */
  898. #endif
  899. mtctr r10
  900. addi r10,r0,(0xE000-0x10000) /* start at 0xFFFFE000 */
  901. add r11,r10,r11 /* add to get to other side of cache line */
  902. ..flush_dcache_loop:
  903. lwz r3,0(r10) /* least recently used side */
  904. lwz r3,0(r11) /* the other side */
  905. dccci r0,r11 /* invalidate both sides */
  906. addi r10,r10,CFG_CACHELINE_SIZE /* bump to next line */
  907. addi r11,r11,CFG_CACHELINE_SIZE /* bump to next line */
  908. bdnz ..flush_dcache_loop
  909. sync /* allow memory access to complete */
  910. mtdccr r9 /* restore dccr */
  911. mtmsr r12 /* restore msr */
  912. blr
  913. .globl icache_enable
  914. icache_enable:
  915. mflr r8
  916. bl invalidate_icache
  917. mtlr r8
  918. isync
  919. addis r3,r0, 0x8000 /* set bit 0 */
  920. mticcr r3
  921. blr
  922. .globl icache_disable
  923. icache_disable:
  924. addis r3,r0, 0x0000 /* clear bit 0 */
  925. mticcr r3
  926. isync
  927. blr
  928. .globl icache_status
  929. icache_status:
  930. mficcr r3
  931. srwi r3, r3, 31 /* >>31 => select bit 0 */
  932. blr
  933. .globl dcache_enable
  934. dcache_enable:
  935. mflr r8
  936. bl invalidate_dcache
  937. mtlr r8
  938. isync
  939. addis r3,r0, 0x8000 /* set bit 0 */
  940. mtdccr r3
  941. blr
  942. .globl dcache_disable
  943. dcache_disable:
  944. mflr r8
  945. bl flush_dcache
  946. mtlr r8
  947. addis r3,r0, 0x0000 /* clear bit 0 */
  948. mtdccr r3
  949. blr
  950. .globl dcache_status
  951. dcache_status:
  952. mfdccr r3
  953. srwi r3, r3, 31 /* >>31 => select bit 0 */
  954. blr
  955. .globl get_pvr
  956. get_pvr:
  957. mfspr r3, PVR
  958. blr
  959. #if !defined(CONFIG_440)
  960. .globl wr_pit
  961. wr_pit:
  962. mtspr pit, r3
  963. blr
  964. #endif
  965. .globl wr_tcr
  966. wr_tcr:
  967. mtspr tcr, r3
  968. blr
  969. /*------------------------------------------------------------------------------- */
  970. /* Function: in8 */
  971. /* Description: Input 8 bits */
  972. /*------------------------------------------------------------------------------- */
  973. .globl in8
  974. in8:
  975. lbz r3,0x0000(r3)
  976. blr
  977. /*------------------------------------------------------------------------------- */
  978. /* Function: out8 */
  979. /* Description: Output 8 bits */
  980. /*------------------------------------------------------------------------------- */
  981. .globl out8
  982. out8:
  983. stb r4,0x0000(r3)
  984. blr
  985. /*------------------------------------------------------------------------------- */
  986. /* Function: out16 */
  987. /* Description: Output 16 bits */
  988. /*------------------------------------------------------------------------------- */
  989. .globl out16
  990. out16:
  991. sth r4,0x0000(r3)
  992. blr
  993. /*------------------------------------------------------------------------------- */
  994. /* Function: out16r */
  995. /* Description: Byte reverse and output 16 bits */
  996. /*------------------------------------------------------------------------------- */
  997. .globl out16r
  998. out16r:
  999. sthbrx r4,r0,r3
  1000. blr
  1001. /*------------------------------------------------------------------------------- */
  1002. /* Function: out32 */
  1003. /* Description: Output 32 bits */
  1004. /*------------------------------------------------------------------------------- */
  1005. .globl out32
  1006. out32:
  1007. stw r4,0x0000(r3)
  1008. blr
  1009. /*------------------------------------------------------------------------------- */
  1010. /* Function: out32r */
  1011. /* Description: Byte reverse and output 32 bits */
  1012. /*------------------------------------------------------------------------------- */
  1013. .globl out32r
  1014. out32r:
  1015. stwbrx r4,r0,r3
  1016. blr
  1017. /*------------------------------------------------------------------------------- */
  1018. /* Function: in16 */
  1019. /* Description: Input 16 bits */
  1020. /*------------------------------------------------------------------------------- */
  1021. .globl in16
  1022. in16:
  1023. lhz r3,0x0000(r3)
  1024. blr
  1025. /*------------------------------------------------------------------------------- */
  1026. /* Function: in16r */
  1027. /* Description: Input 16 bits and byte reverse */
  1028. /*------------------------------------------------------------------------------- */
  1029. .globl in16r
  1030. in16r:
  1031. lhbrx r3,r0,r3
  1032. blr
  1033. /*------------------------------------------------------------------------------- */
  1034. /* Function: in32 */
  1035. /* Description: Input 32 bits */
  1036. /*------------------------------------------------------------------------------- */
  1037. .globl in32
  1038. in32:
  1039. lwz 3,0x0000(3)
  1040. blr
  1041. /*------------------------------------------------------------------------------- */
  1042. /* Function: in32r */
  1043. /* Description: Input 32 bits and byte reverse */
  1044. /*------------------------------------------------------------------------------- */
  1045. .globl in32r
  1046. in32r:
  1047. lwbrx r3,r0,r3
  1048. blr
  1049. /*------------------------------------------------------------------------------- */
  1050. /* Function: ppcDcbf */
  1051. /* Description: Data Cache block flush */
  1052. /* Input: r3 = effective address */
  1053. /* Output: none. */
  1054. /*------------------------------------------------------------------------------- */
  1055. .globl ppcDcbf
  1056. ppcDcbf:
  1057. dcbf r0,r3
  1058. blr
  1059. /*------------------------------------------------------------------------------- */
  1060. /* Function: ppcDcbi */
  1061. /* Description: Data Cache block Invalidate */
  1062. /* Input: r3 = effective address */
  1063. /* Output: none. */
  1064. /*------------------------------------------------------------------------------- */
  1065. .globl ppcDcbi
  1066. ppcDcbi:
  1067. dcbi r0,r3
  1068. blr
  1069. /*------------------------------------------------------------------------------- */
  1070. /* Function: ppcSync */
  1071. /* Description: Processor Synchronize */
  1072. /* Input: none. */
  1073. /* Output: none. */
  1074. /*------------------------------------------------------------------------------- */
  1075. .globl ppcSync
  1076. ppcSync:
  1077. sync
  1078. blr
  1079. /*------------------------------------------------------------------------------*/
  1080. /*
  1081. * void relocate_code (addr_sp, gd, addr_moni)
  1082. *
  1083. * This "function" does not return, instead it continues in RAM
  1084. * after relocating the monitor code.
  1085. *
  1086. * r3 = dest
  1087. * r4 = src
  1088. * r5 = length in bytes
  1089. * r6 = cachelinesize
  1090. */
  1091. .globl relocate_code
  1092. relocate_code:
  1093. #if defined(CONFIG_440_EP) || defined(CONFIG_440_GR)
  1094. dccci 0,0 /* Invalidate data cache, now no longer our stack */
  1095. sync
  1096. addi r1,r0,0x0000 /* Tlb entry #0 */
  1097. tlbre r0,r1,0x0002 /* Read contents */
  1098. ori r0,r0,0x0c00 /* Or in the inhibit, write through bit */
  1099. tlbwe r0,r1,0x0002 /* Save it out */
  1100. isync
  1101. #endif
  1102. mr r1, r3 /* Set new stack pointer */
  1103. mr r9, r4 /* Save copy of Init Data pointer */
  1104. mr r10, r5 /* Save copy of Destination Address */
  1105. mr r3, r5 /* Destination Address */
  1106. lis r4, CFG_MONITOR_BASE@h /* Source Address */
  1107. ori r4, r4, CFG_MONITOR_BASE@l
  1108. lwz r5, GOT(__init_end)
  1109. sub r5, r5, r4
  1110. li r6, CFG_CACHELINE_SIZE /* Cache Line Size */
  1111. /*
  1112. * Fix GOT pointer:
  1113. *
  1114. * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
  1115. *
  1116. * Offset:
  1117. */
  1118. sub r15, r10, r4
  1119. /* First our own GOT */
  1120. add r14, r14, r15
  1121. /* the the one used by the C code */
  1122. add r30, r30, r15
  1123. /*
  1124. * Now relocate code
  1125. */
  1126. cmplw cr1,r3,r4
  1127. addi r0,r5,3
  1128. srwi. r0,r0,2
  1129. beq cr1,4f /* In place copy is not necessary */
  1130. beq 7f /* Protect against 0 count */
  1131. mtctr r0
  1132. bge cr1,2f
  1133. la r8,-4(r4)
  1134. la r7,-4(r3)
  1135. 1: lwzu r0,4(r8)
  1136. stwu r0,4(r7)
  1137. bdnz 1b
  1138. b 4f
  1139. 2: slwi r0,r0,2
  1140. add r8,r4,r0
  1141. add r7,r3,r0
  1142. 3: lwzu r0,-4(r8)
  1143. stwu r0,-4(r7)
  1144. bdnz 3b
  1145. /*
  1146. * Now flush the cache: note that we must start from a cache aligned
  1147. * address. Otherwise we might miss one cache line.
  1148. */
  1149. 4: cmpwi r6,0
  1150. add r5,r3,r5
  1151. beq 7f /* Always flush prefetch queue in any case */
  1152. subi r0,r6,1
  1153. andc r3,r3,r0
  1154. mr r4,r3
  1155. 5: dcbst 0,r4
  1156. add r4,r4,r6
  1157. cmplw r4,r5
  1158. blt 5b
  1159. sync /* Wait for all dcbst to complete on bus */
  1160. mr r4,r3
  1161. 6: icbi 0,r4
  1162. add r4,r4,r6
  1163. cmplw r4,r5
  1164. blt 6b
  1165. 7: sync /* Wait for all icbi to complete on bus */
  1166. isync
  1167. /*
  1168. * We are done. Do not return, instead branch to second part of board
  1169. * initialization, now running from RAM.
  1170. */
  1171. addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET
  1172. mtlr r0
  1173. blr /* NEVER RETURNS! */
  1174. in_ram:
  1175. /*
  1176. * Relocation Function, r14 point to got2+0x8000
  1177. *
  1178. * Adjust got2 pointers, no need to check for 0, this code
  1179. * already puts a few entries in the table.
  1180. */
  1181. li r0,__got2_entries@sectoff@l
  1182. la r3,GOT(_GOT2_TABLE_)
  1183. lwz r11,GOT(_GOT2_TABLE_)
  1184. mtctr r0
  1185. sub r11,r3,r11
  1186. addi r3,r3,-4
  1187. 1: lwzu r0,4(r3)
  1188. add r0,r0,r11
  1189. stw r0,0(r3)
  1190. bdnz 1b
  1191. /*
  1192. * Now adjust the fixups and the pointers to the fixups
  1193. * in case we need to move ourselves again.
  1194. */
  1195. 2: li r0,__fixup_entries@sectoff@l
  1196. lwz r3,GOT(_FIXUP_TABLE_)
  1197. cmpwi r0,0
  1198. mtctr r0
  1199. addi r3,r3,-4
  1200. beq 4f
  1201. 3: lwzu r4,4(r3)
  1202. lwzux r0,r4,r11
  1203. add r0,r0,r11
  1204. stw r10,0(r3)
  1205. stw r0,0(r4)
  1206. bdnz 3b
  1207. 4:
  1208. clear_bss:
  1209. /*
  1210. * Now clear BSS segment
  1211. */
  1212. lwz r3,GOT(__bss_start)
  1213. lwz r4,GOT(_end)
  1214. cmplw 0, r3, r4
  1215. beq 6f
  1216. li r0, 0
  1217. 5:
  1218. stw r0, 0(r3)
  1219. addi r3, r3, 4
  1220. cmplw 0, r3, r4
  1221. bne 5b
  1222. 6:
  1223. mr r3, r9 /* Init Data pointer */
  1224. mr r4, r10 /* Destination Address */
  1225. bl board_init_r
  1226. /*
  1227. * Copy exception vector code to low memory
  1228. *
  1229. * r3: dest_addr
  1230. * r7: source address, r8: end address, r9: target address
  1231. */
  1232. .globl trap_init
  1233. trap_init:
  1234. lwz r7, GOT(_start)
  1235. lwz r8, GOT(_end_of_vectors)
  1236. li r9, 0x100 /* reset vector always at 0x100 */
  1237. cmplw 0, r7, r8
  1238. bgelr /* return if r7>=r8 - just in case */
  1239. mflr r4 /* save link register */
  1240. 1:
  1241. lwz r0, 0(r7)
  1242. stw r0, 0(r9)
  1243. addi r7, r7, 4
  1244. addi r9, r9, 4
  1245. cmplw 0, r7, r8
  1246. bne 1b
  1247. /*
  1248. * relocate `hdlr' and `int_return' entries
  1249. */
  1250. li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET
  1251. li r8, Alignment - _start + EXC_OFF_SYS_RESET
  1252. 2:
  1253. bl trap_reloc
  1254. addi r7, r7, 0x100 /* next exception vector */
  1255. cmplw 0, r7, r8
  1256. blt 2b
  1257. li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET
  1258. bl trap_reloc
  1259. li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET
  1260. bl trap_reloc
  1261. li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET
  1262. li r8, SystemCall - _start + EXC_OFF_SYS_RESET
  1263. 3:
  1264. bl trap_reloc
  1265. addi r7, r7, 0x100 /* next exception vector */
  1266. cmplw 0, r7, r8
  1267. blt 3b
  1268. li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET
  1269. li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET
  1270. 4:
  1271. bl trap_reloc
  1272. addi r7, r7, 0x100 /* next exception vector */
  1273. cmplw 0, r7, r8
  1274. blt 4b
  1275. mtlr r4 /* restore link register */
  1276. blr
  1277. /*
  1278. * Function: relocate entries for one exception vector
  1279. */
  1280. trap_reloc:
  1281. lwz r0, 0(r7) /* hdlr ... */
  1282. add r0, r0, r3 /* ... += dest_addr */
  1283. stw r0, 0(r7)
  1284. lwz r0, 4(r7) /* int_return ... */
  1285. add r0, r0, r3 /* ... += dest_addr */
  1286. stw r0, 4(r7)
  1287. blr
  1288. /**************************************************************************/
  1289. /* PPC405EP specific stuff */
  1290. /**************************************************************************/
  1291. #ifdef CONFIG_405EP
  1292. ppc405ep_init:
  1293. #ifdef CONFIG_BUBINGA
  1294. /*
  1295. * Initialize EBC chip selects 1 & 4 and GPIO pins (for alternate
  1296. * function) to support FPGA and NVRAM accesses below.
  1297. */
  1298. lis r3,GPIO0_OSRH@h /* config GPIO output select */
  1299. ori r3,r3,GPIO0_OSRH@l
  1300. lis r4,CFG_GPIO0_OSRH@h
  1301. ori r4,r4,CFG_GPIO0_OSRH@l
  1302. stw r4,0(r3)
  1303. lis r3,GPIO0_OSRL@h
  1304. ori r3,r3,GPIO0_OSRL@l
  1305. lis r4,CFG_GPIO0_OSRL@h
  1306. ori r4,r4,CFG_GPIO0_OSRL@l
  1307. stw r4,0(r3)
  1308. lis r3,GPIO0_ISR1H@h /* config GPIO input select */
  1309. ori r3,r3,GPIO0_ISR1H@l
  1310. lis r4,CFG_GPIO0_ISR1H@h
  1311. ori r4,r4,CFG_GPIO0_ISR1H@l
  1312. stw r4,0(r3)
  1313. lis r3,GPIO0_ISR1L@h
  1314. ori r3,r3,GPIO0_ISR1L@l
  1315. lis r4,CFG_GPIO0_ISR1L@h
  1316. ori r4,r4,CFG_GPIO0_ISR1L@l
  1317. stw r4,0(r3)
  1318. lis r3,GPIO0_TSRH@h /* config GPIO three-state select */
  1319. ori r3,r3,GPIO0_TSRH@l
  1320. lis r4,CFG_GPIO0_TSRH@h
  1321. ori r4,r4,CFG_GPIO0_TSRH@l
  1322. stw r4,0(r3)
  1323. lis r3,GPIO0_TSRL@h
  1324. ori r3,r3,GPIO0_TSRL@l
  1325. lis r4,CFG_GPIO0_TSRL@h
  1326. ori r4,r4,CFG_GPIO0_TSRL@l
  1327. stw r4,0(r3)
  1328. lis r3,GPIO0_TCR@h /* config GPIO driver output enables */
  1329. ori r3,r3,GPIO0_TCR@l
  1330. lis r4,CFG_GPIO0_TCR@h
  1331. ori r4,r4,CFG_GPIO0_TCR@l
  1332. stw r4,0(r3)
  1333. li r3,pb1ap /* program EBC bank 1 for RTC access */
  1334. mtdcr ebccfga,r3
  1335. lis r3,CFG_EBC_PB1AP@h
  1336. ori r3,r3,CFG_EBC_PB1AP@l
  1337. mtdcr ebccfgd,r3
  1338. li r3,pb1cr
  1339. mtdcr ebccfga,r3
  1340. lis r3,CFG_EBC_PB1CR@h
  1341. ori r3,r3,CFG_EBC_PB1CR@l
  1342. mtdcr ebccfgd,r3
  1343. li r3,pb1ap /* program EBC bank 1 for RTC access */
  1344. mtdcr ebccfga,r3
  1345. lis r3,CFG_EBC_PB1AP@h
  1346. ori r3,r3,CFG_EBC_PB1AP@l
  1347. mtdcr ebccfgd,r3
  1348. li r3,pb1cr
  1349. mtdcr ebccfga,r3
  1350. lis r3,CFG_EBC_PB1CR@h
  1351. ori r3,r3,CFG_EBC_PB1CR@l
  1352. mtdcr ebccfgd,r3
  1353. li r3,pb4ap /* program EBC bank 4 for FPGA access */
  1354. mtdcr ebccfga,r3
  1355. lis r3,CFG_EBC_PB4AP@h
  1356. ori r3,r3,CFG_EBC_PB4AP@l
  1357. mtdcr ebccfgd,r3
  1358. li r3,pb4cr
  1359. mtdcr ebccfga,r3
  1360. lis r3,CFG_EBC_PB4CR@h
  1361. ori r3,r3,CFG_EBC_PB4CR@l
  1362. mtdcr ebccfgd,r3
  1363. #endif
  1364. addi r3,0,CPC0_PCI_HOST_CFG_EN
  1365. #ifdef CONFIG_BUBINGA
  1366. /*
  1367. !-----------------------------------------------------------------------
  1368. ! Check FPGA for PCI internal/external arbitration
  1369. ! If board is set to internal arbitration, update cpc0_pci
  1370. !-----------------------------------------------------------------------
  1371. */
  1372. addis r5,r0,FPGA_REG1@h /* set offset for FPGA_REG1 */
  1373. ori r5,r5,FPGA_REG1@l
  1374. lbz r5,0x0(r5) /* read to get PCI arb selection */
  1375. andi. r6,r5,FPGA_REG1_PCI_INT_ARB /* using internal arbiter ?*/
  1376. beq ..pci_cfg_set /* if not set, then bypass reg write*/
  1377. #endif
  1378. ori r3,r3,CPC0_PCI_ARBIT_EN
  1379. ..pci_cfg_set:
  1380. mtdcr CPC0_PCI, r3 /* Enable internal arbiter*/
  1381. /*
  1382. !-----------------------------------------------------------------------
  1383. ! Check to see if chip is in bypass mode.
  1384. ! If so, write stored CPC0_PLLMR0 and CPC0_PLLMR1 values and perform a
  1385. ! CPU reset Otherwise, skip this step and keep going.
  1386. ! Note: Running BIOS in bypass mode is not supported since PLB speed
  1387. ! will not be fast enough for the SDRAM (min 66MHz)
  1388. !-----------------------------------------------------------------------
  1389. */
  1390. mfdcr r5, CPC0_PLLMR1
  1391. rlwinm r4,r5,1,0x1 /* get system clock source (SSCS) */
  1392. cmpi cr0,0,r4,0x1
  1393. beq pll_done /* if SSCS =b'1' then PLL has */
  1394. /* already been set */
  1395. /* and CPU has been reset */
  1396. /* so skip to next section */
  1397. #ifdef CONFIG_BUBINGA
  1398. /*
  1399. !-----------------------------------------------------------------------
  1400. ! Read NVRAM to get value to write in PLLMR.
  1401. ! If value has not been correctly saved, write default value
  1402. ! Default config values (assuming on-board 33MHz SYS_CLK) are above.
  1403. ! See CPU_DEFAULT_200 and CPU_DEFAULT_266 above.
  1404. !
  1405. ! WARNING: This code assumes the first three words in the nvram_t
  1406. ! structure in openbios.h. Changing the beginning of
  1407. ! the structure will break this code.
  1408. !
  1409. !-----------------------------------------------------------------------
  1410. */
  1411. addis r3,0,NVRAM_BASE@h
  1412. addi r3,r3,NVRAM_BASE@l
  1413. lwz r4, 0(r3)
  1414. addis r5,0,NVRVFY1@h
  1415. addi r5,r5,NVRVFY1@l
  1416. cmp cr0,0,r4,r5 /* Compare 1st NVRAM Magic number*/
  1417. bne ..no_pllset
  1418. addi r3,r3,4
  1419. lwz r4, 0(r3)
  1420. addis r5,0,NVRVFY2@h
  1421. addi r5,r5,NVRVFY2@l
  1422. cmp cr0,0,r4,r5 /* Compare 2 NVRAM Magic number */
  1423. bne ..no_pllset
  1424. addi r3,r3,8 /* Skip over conf_size */
  1425. lwz r4, 4(r3) /* Load PLLMR1 value from NVRAM */
  1426. lwz r3, 0(r3) /* Load PLLMR0 value from NVRAM */
  1427. rlwinm r5,r4,1,0x1 /* get system clock source (SSCS) */
  1428. cmpi cr0,0,r5,1 /* See if PLL is locked */
  1429. beq pll_write
  1430. ..no_pllset:
  1431. #endif /* CONFIG_BUBINGA */
  1432. addis r3,0,PLLMR0_DEFAULT@h /* PLLMR0 default value */
  1433. ori r3,r3,PLLMR0_DEFAULT@l /* */
  1434. addis r4,0,PLLMR1_DEFAULT@h /* PLLMR1 default value */
  1435. ori r4,r4,PLLMR1_DEFAULT@l /* */
  1436. b pll_write /* Write the CPC0_PLLMR with new value */
  1437. pll_done:
  1438. /*
  1439. !-----------------------------------------------------------------------
  1440. ! Clear Soft Reset Register
  1441. ! This is needed to enable PCI if not booting from serial EPROM
  1442. !-----------------------------------------------------------------------
  1443. */
  1444. addi r3, 0, 0x0
  1445. mtdcr CPC0_SRR, r3
  1446. addis r3,0,0x0010
  1447. mtctr r3
  1448. pci_wait:
  1449. bdnz pci_wait
  1450. blr /* return to main code */
  1451. /*
  1452. !-----------------------------------------------------------------------------
  1453. ! Function: pll_write
  1454. ! Description: Updates the value of the CPC0_PLLMR according to CMOS27E documentation
  1455. ! That is:
  1456. ! 1. Pll is first disabled (de-activated by putting in bypass mode)
  1457. ! 2. PLL is reset
  1458. ! 3. Clock dividers are set while PLL is held in reset and bypassed
  1459. ! 4. PLL Reset is cleared
  1460. ! 5. Wait 100us for PLL to lock
  1461. ! 6. A core reset is performed
  1462. ! Input: r3 = Value to write to CPC0_PLLMR0
  1463. ! Input: r4 = Value to write to CPC0_PLLMR1
  1464. ! Output r3 = none
  1465. !-----------------------------------------------------------------------------
  1466. */
  1467. pll_write:
  1468. mfdcr r5, CPC0_UCR
  1469. andis. r5,r5,0xFFFF
  1470. ori r5,r5,0x0101 /* Stop the UART clocks */
  1471. mtdcr CPC0_UCR,r5 /* Before changing PLL */
  1472. mfdcr r5, CPC0_PLLMR1
  1473. rlwinm r5,r5,0,0x7FFFFFFF /* Disable PLL */
  1474. mtdcr CPC0_PLLMR1,r5
  1475. oris r5,r5,0x4000 /* Set PLL Reset */
  1476. mtdcr CPC0_PLLMR1,r5
  1477. mtdcr CPC0_PLLMR0,r3 /* Set clock dividers */
  1478. rlwinm r5,r4,0,0x3FFFFFFF /* Reset & Bypass new PLL dividers */
  1479. oris r5,r5,0x4000 /* Set PLL Reset */
  1480. mtdcr CPC0_PLLMR1,r5 /* Set clock dividers */
  1481. rlwinm r5,r5,0,0xBFFFFFFF /* Clear PLL Reset */
  1482. mtdcr CPC0_PLLMR1,r5
  1483. /*
  1484. ! Wait min of 100us for PLL to lock.
  1485. ! See CMOS 27E databook for more info.
  1486. ! At 200MHz, that means waiting 20,000 instructions
  1487. */
  1488. addi r3,0,20000 /* 2000 = 0x4e20 */
  1489. mtctr r3
  1490. pll_wait:
  1491. bdnz pll_wait
  1492. oris r5,r5,0x8000 /* Enable PLL */
  1493. mtdcr CPC0_PLLMR1,r5 /* Engage */
  1494. /*
  1495. * Reset CPU to guarantee timings are OK
  1496. * Not sure if this is needed...
  1497. */
  1498. addis r3,0,0x1000
  1499. mtspr dbcr0,r3 /* This will cause a CPU core reset, and */
  1500. /* execution will continue from the poweron */
  1501. /* vector of 0xfffffffc */
  1502. #endif /* CONFIG_405EP */