start.S 47 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695
  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 AMCC 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_440GX) /* 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_440GX)
  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_440EP) && !defined(CONFIG_440GR)
  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_440EP) || defined(CONFIG_440GR)
  349. /* Clear Dcache to use as RAM */
  350. addis r3,r0,CFG_INIT_RAM_ADDR@h
  351. ori r3,r3,CFG_INIT_RAM_ADDR@l
  352. addis r4,r0,CFG_INIT_RAM_END@h
  353. ori r4,r4,CFG_INIT_RAM_END@l
  354. rlwinm. r5,r4,0,27,31
  355. rlwinm r5,r4,27,5,31
  356. beq ..d_ran
  357. addi r5,r5,0x0001
  358. ..d_ran:
  359. mtctr r5
  360. ..d_ag:
  361. dcbz r0,r3
  362. addi r3,r3,32
  363. bdnz ..d_ag
  364. #else
  365. #if defined (CONFIG_440GX)
  366. mtdcr l2_cache_cfg,r0 /* Ensure L2 Cache is off */
  367. #endif
  368. mtdcr isram0_sb1cr,r0 /* Disable bank 1 */
  369. li r2,0x7fff
  370. ori r2,r2,0xffff
  371. mfdcr r1,isram0_dpc
  372. and r1,r1,r2 /* Disable parity check */
  373. mtdcr isram0_dpc,r1
  374. mfdcr r1,isram0_pmeg
  375. andis. r1,r1,r2 /* Disable pwr mgmt */
  376. mtdcr isram0_pmeg,r1
  377. lis r1,0x8000 /* BAS = 8000_0000 */
  378. #if defined(CONFIG_440GX)
  379. ori r1,r1,0x0980 /* first 64k */
  380. mtdcr isram0_sb0cr,r1
  381. lis r1,0x8001
  382. ori r1,r1,0x0980 /* second 64k */
  383. mtdcr isram0_sb1cr,r1
  384. lis r1, 0x8002
  385. ori r1,r1, 0x0980 /* third 64k */
  386. mtdcr isram0_sb2cr,r1
  387. lis r1, 0x8003
  388. ori r1,r1, 0x0980 /* fourth 64k */
  389. mtdcr isram0_sb3cr,r1
  390. #else
  391. ori r1,r1,0x0380 /* 8k rw */
  392. mtdcr isram0_sb0cr,r1
  393. #endif
  394. #endif
  395. /*----------------------------------------------------------------*/
  396. /* Setup the stack in internal SRAM */
  397. /*----------------------------------------------------------------*/
  398. lis r1,CFG_INIT_RAM_ADDR@h
  399. ori r1,r1,CFG_INIT_SP_OFFSET@l
  400. li r0,0
  401. stwu r0,-4(r1)
  402. stwu r0,-4(r1) /* Terminate call chain */
  403. stwu r1,-8(r1) /* Save back chain and move SP */
  404. lis r0,RESET_VECTOR@h /* Address of reset vector */
  405. ori r0,r0, RESET_VECTOR@l
  406. stwu r1,-8(r1) /* Save back chain and move SP */
  407. stw r0,+12(r1) /* Save return addr (underflow vect) */
  408. GET_GOT
  409. bl board_init_f
  410. #endif /* CONFIG_440 */
  411. /*****************************************************************************/
  412. #ifdef CONFIG_IOP480
  413. /*----------------------------------------------------------------------- */
  414. /* Set up some machine state registers. */
  415. /*----------------------------------------------------------------------- */
  416. addi r0,r0,0x0000 /* initialize r0 to zero */
  417. mtspr esr,r0 /* clear Exception Syndrome Reg */
  418. mttcr r0 /* timer control register */
  419. mtexier r0 /* disable all interrupts */
  420. addi r4,r0,0x1000 /* set ME bit (Machine Exceptions) */
  421. oris r4,r4,0x2 /* set CE bit (Critical Exceptions) */
  422. mtmsr r4 /* change MSR */
  423. addis r4,r0,0xFFFF /* set r4 to 0xFFFFFFFF (status in the */
  424. ori r4,r4,0xFFFF /* dbsr is cleared by setting bits to 1) */
  425. mtdbsr r4 /* clear/reset the dbsr */
  426. mtexisr r4 /* clear all pending interrupts */
  427. addis r4,r0,0x8000
  428. mtexier r4 /* enable critical exceptions */
  429. addis r4,r0,0x0000 /* assume 403GCX - enable core clk */
  430. ori r4,r4,0x4020 /* dbling (no harm done on GA and GC */
  431. mtiocr r4 /* since bit not used) & DRC to latch */
  432. /* data bus on rising edge of CAS */
  433. /*----------------------------------------------------------------------- */
  434. /* Clear XER. */
  435. /*----------------------------------------------------------------------- */
  436. mtxer r0
  437. /*----------------------------------------------------------------------- */
  438. /* Invalidate i-cache and d-cache TAG arrays. */
  439. /*----------------------------------------------------------------------- */
  440. addi r3,0,1024 /* 1/4 of I-cache size, half of D-cache */
  441. addi r4,0,1024 /* 1/4 of I-cache */
  442. ..cloop:
  443. iccci 0,r3
  444. iccci r4,r3
  445. dccci 0,r3
  446. addic. r3,r3,-16 /* move back one cache line */
  447. bne ..cloop /* loop back to do rest until r3 = 0 */
  448. /* */
  449. /* initialize IOP480 so it can read 1 MB code area for SRAM spaces */
  450. /* this requires enabling MA[17..0], by default only MA[12..0] are enabled. */
  451. /* */
  452. /* first copy IOP480 register base address into r3 */
  453. addis r3,0,0x5000 /* IOP480 register base address hi */
  454. /* ori r3,r3,0x0000 / IOP480 register base address lo */
  455. #ifdef CONFIG_ADCIOP
  456. /* use r4 as the working variable */
  457. /* turn on CS3 (LOCCTL.7) */
  458. lwz r4,0x84(r3) /* LOCTL is at offset 0x84 */
  459. andi. r4,r4,0xff7f /* make bit 7 = 0 -- CS3 mode */
  460. stw r4,0x84(r3) /* LOCTL is at offset 0x84 */
  461. #endif
  462. #ifdef CONFIG_DASA_SIM
  463. /* use r4 as the working variable */
  464. /* turn on MA17 (LOCCTL.7) */
  465. lwz r4,0x84(r3) /* LOCTL is at offset 0x84 */
  466. ori r4,r4,0x80 /* make bit 7 = 1 -- MA17 mode */
  467. stw r4,0x84(r3) /* LOCTL is at offset 0x84 */
  468. #endif
  469. /* turn on MA16..13 (LCS0BRD.12 = 0) */
  470. lwz r4,0x100(r3) /* LCS0BRD is at offset 0x100 */
  471. andi. r4,r4,0xefff /* make bit 12 = 0 */
  472. stw r4,0x100(r3) /* LCS0BRD is at offset 0x100 */
  473. /* make sure above stores all comlete before going on */
  474. sync
  475. /* last thing, set local init status done bit (DEVINIT.31) */
  476. lwz r4,0x80(r3) /* DEVINIT is at offset 0x80 */
  477. oris r4,r4,0x8000 /* make bit 31 = 1 */
  478. stw r4,0x80(r3) /* DEVINIT is at offset 0x80 */
  479. /* clear all pending interrupts and disable all interrupts */
  480. li r4,-1 /* set p1 to 0xffffffff */
  481. stw r4,0x1b0(r3) /* clear all pending interrupts */
  482. stw r4,0x1b8(r3) /* clear all pending interrupts */
  483. li r4,0 /* set r4 to 0 */
  484. stw r4,0x1b4(r3) /* disable all interrupts */
  485. stw r4,0x1bc(r3) /* disable all interrupts */
  486. /* make sure above stores all comlete before going on */
  487. sync
  488. /*----------------------------------------------------------------------- */
  489. /* Enable two 128MB cachable regions. */
  490. /*----------------------------------------------------------------------- */
  491. addis r1,r0,0x8000
  492. addi r1,r1,0x0001
  493. mticcr r1 /* instruction cache */
  494. addis r1,r0,0x0000
  495. addi r1,r1,0x0000
  496. mtdccr r1 /* data cache */
  497. addis r1,r0,CFG_INIT_RAM_ADDR@h
  498. ori r1,r1,CFG_INIT_SP_OFFSET /* set up the stack to SDRAM */
  499. li r0, 0 /* Make room for stack frame header and */
  500. stwu r0, -4(r1) /* clear final stack frame so that */
  501. stwu r0, -4(r1) /* stack backtraces terminate cleanly */
  502. GET_GOT /* initialize GOT access */
  503. bl board_init_f /* run first part of init code (from Flash) */
  504. #endif /* CONFIG_IOP480 */
  505. /*****************************************************************************/
  506. #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || defined(CONFIG_405) || defined(CONFIG_405EP)
  507. /*----------------------------------------------------------------------- */
  508. /* Clear and set up some registers. */
  509. /*----------------------------------------------------------------------- */
  510. addi r4,r0,0x0000
  511. mtspr sgr,r4
  512. mtspr dcwr,r4
  513. mtesr r4 /* clear Exception Syndrome Reg */
  514. mttcr r4 /* clear Timer Control Reg */
  515. mtxer r4 /* clear Fixed-Point Exception Reg */
  516. mtevpr r4 /* clear Exception Vector Prefix Reg */
  517. addi r4,r0,0x1000 /* set ME bit (Machine Exceptions) */
  518. oris r4,r4,0x0002 /* set CE bit (Critical Exceptions) */
  519. mtmsr r4 /* change MSR */
  520. addi r4,r0,(0xFFFF-0x10000) /* set r4 to 0xFFFFFFFF (status in the */
  521. /* dbsr is cleared by setting bits to 1) */
  522. mtdbsr r4 /* clear/reset the dbsr */
  523. /*----------------------------------------------------------------------- */
  524. /* Invalidate I and D caches. Enable I cache for defined memory regions */
  525. /* to speed things up. Leave the D cache disabled for now. It will be */
  526. /* enabled/left disabled later based on user selected menu options. */
  527. /* Be aware that the I cache may be disabled later based on the menu */
  528. /* options as well. See miscLib/main.c. */
  529. /*----------------------------------------------------------------------- */
  530. bl invalidate_icache
  531. bl invalidate_dcache
  532. /*----------------------------------------------------------------------- */
  533. /* Enable two 128MB cachable regions. */
  534. /*----------------------------------------------------------------------- */
  535. addis r4,r0,0x8000
  536. addi r4,r4,0x0001
  537. mticcr r4 /* instruction cache */
  538. isync
  539. addis r4,r0,0x0000
  540. addi r4,r4,0x0000
  541. mtdccr r4 /* data cache */
  542. #if !(defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR))
  543. /*----------------------------------------------------------------------- */
  544. /* Tune the speed and size for flash CS0 */
  545. /*----------------------------------------------------------------------- */
  546. bl ext_bus_cntlr_init
  547. #endif
  548. #if defined(CONFIG_405EP)
  549. /*----------------------------------------------------------------------- */
  550. /* DMA Status, clear to come up clean */
  551. /*----------------------------------------------------------------------- */
  552. addis r3,r0, 0xFFFF /* Clear all existing DMA status */
  553. ori r3,r3, 0xFFFF
  554. mtdcr dmasr, r3
  555. bl ppc405ep_init /* do ppc405ep specific init */
  556. #endif /* CONFIG_405EP */
  557. #if defined(CFG_OCM_DATA_ADDR) && defined(CFG_OCM_DATA_SIZE)
  558. /********************************************************************
  559. * Setup OCM - On Chip Memory
  560. *******************************************************************/
  561. /* Setup OCM */
  562. lis r0, 0x7FFF
  563. ori r0, r0, 0xFFFF
  564. mfdcr r3, ocmiscntl /* get instr-side IRAM config */
  565. mfdcr r4, ocmdscntl /* get data-side IRAM config */
  566. and r3, r3, r0 /* disable data-side IRAM */
  567. and r4, r4, r0 /* disable data-side IRAM */
  568. mtdcr ocmiscntl, r3 /* set instr-side IRAM config */
  569. mtdcr ocmdscntl, r4 /* set data-side IRAM config */
  570. isync
  571. addis r3, 0, CFG_OCM_DATA_ADDR@h /* OCM location */
  572. mtdcr ocmdsarc, r3
  573. addis r4, 0, 0xC000 /* OCM data area enabled */
  574. mtdcr ocmdscntl, r4
  575. isync
  576. #endif
  577. /*----------------------------------------------------------------------- */
  578. /* Setup temporary stack in DCACHE or OCM if needed for SDRAM SPD. */
  579. /*----------------------------------------------------------------------- */
  580. #ifdef CFG_INIT_DCACHE_CS
  581. /*----------------------------------------------------------------------- */
  582. /* Memory Bank x (nothingness) initialization 1GB+64MEG */
  583. /* used as temporary stack pointer for stage0 */
  584. /*----------------------------------------------------------------------- */
  585. li r4,PBxAP
  586. mtdcr ebccfga,r4
  587. lis r4,0x0380
  588. ori r4,r4,0x0480
  589. mtdcr ebccfgd,r4
  590. addi r4,0,PBxCR
  591. mtdcr ebccfga,r4
  592. lis r4,0x400D
  593. ori r4,r4,0xa000
  594. mtdcr ebccfgd,r4
  595. /* turn on data chache for this region */
  596. lis r4,0x0080
  597. mtdccr r4
  598. /* set stack pointer and clear stack to known value */
  599. lis r1,CFG_INIT_RAM_ADDR@h
  600. ori r1,r1,CFG_INIT_SP_OFFSET@l
  601. li r4,2048 /* we store 2048 words to stack */
  602. mtctr r4
  603. lis r2,CFG_INIT_RAM_ADDR@h /* we also clear data area */
  604. ori r2,r2,CFG_INIT_RAM_END@l /* so cant copy value from r1 */
  605. lis r4,0xdead /* we store 0xdeaddead in the stack */
  606. ori r4,r4,0xdead
  607. ..stackloop:
  608. stwu r4,-4(r2)
  609. bdnz ..stackloop
  610. li r0, 0 /* Make room for stack frame header and */
  611. stwu r0, -4(r1) /* clear final stack frame so that */
  612. stwu r0, -4(r1) /* stack backtraces terminate cleanly */
  613. /*
  614. * Set up a dummy frame to store reset vector as return address.
  615. * this causes stack underflow to reset board.
  616. */
  617. stwu r1, -8(r1) /* Save back chain and move SP */
  618. addis r0, 0, RESET_VECTOR@h /* Address of reset vector */
  619. ori r0, r0, RESET_VECTOR@l
  620. stwu r1, -8(r1) /* Save back chain and move SP */
  621. stw r0, +12(r1) /* Save return addr (underflow vect) */
  622. #elif defined(CFG_TEMP_STACK_OCM) && \
  623. (defined(CFG_OCM_DATA_ADDR) && defined(CFG_OCM_DATA_SIZE))
  624. /*
  625. * Stack in OCM.
  626. */
  627. /* Set up Stack at top of OCM */
  628. lis r1, (CFG_INIT_RAM_ADDR + CFG_INIT_SP_OFFSET)@h
  629. ori r1, r1, (CFG_INIT_RAM_ADDR + CFG_INIT_SP_OFFSET)@l
  630. /* Set up a zeroized stack frame so that backtrace works right */
  631. li r0, 0
  632. stwu r0, -4(r1)
  633. stwu r0, -4(r1)
  634. /*
  635. * Set up a dummy frame to store reset vector as return address.
  636. * this causes stack underflow to reset board.
  637. */
  638. stwu r1, -8(r1) /* Save back chain and move SP */
  639. lis r0, RESET_VECTOR@h /* Address of reset vector */
  640. ori r0, r0, RESET_VECTOR@l
  641. stwu r1, -8(r1) /* Save back chain and move SP */
  642. stw r0, +12(r1) /* Save return addr (underflow vect) */
  643. #endif /* CFG_INIT_DCACHE_CS */
  644. /*----------------------------------------------------------------------- */
  645. /* Initialize SDRAM Controller */
  646. /*----------------------------------------------------------------------- */
  647. bl sdram_init
  648. /*
  649. * Setup temporary stack pointer only for boards
  650. * that do not use SDRAM SPD I2C stuff since it
  651. * is already initialized to use DCACHE or OCM
  652. * stacks.
  653. */
  654. #if !(defined(CFG_INIT_DCACHE_CS) || defined(CFG_TEMP_STACK_OCM))
  655. lis r1, CFG_INIT_RAM_ADDR@h
  656. ori r1,r1,CFG_INIT_SP_OFFSET /* set up the stack in SDRAM */
  657. li r0, 0 /* Make room for stack frame header and */
  658. stwu r0, -4(r1) /* clear final stack frame so that */
  659. stwu r0, -4(r1) /* stack backtraces terminate cleanly */
  660. /*
  661. * Set up a dummy frame to store reset vector as return address.
  662. * this causes stack underflow to reset board.
  663. */
  664. stwu r1, -8(r1) /* Save back chain and move SP */
  665. lis r0, RESET_VECTOR@h /* Address of reset vector */
  666. ori r0, r0, RESET_VECTOR@l
  667. stwu r1, -8(r1) /* Save back chain and move SP */
  668. stw r0, +12(r1) /* Save return addr (underflow vect) */
  669. #endif /* !(CFG_INIT_DCACHE_CS || !CFG_TEM_STACK_OCM) */
  670. GET_GOT /* initialize GOT access */
  671. bl cpu_init_f /* run low-level CPU init code (from Flash) */
  672. /* NEVER RETURNS! */
  673. bl board_init_f /* run first part of init code (from Flash) */
  674. #endif /* CONFIG_405GP || CONFIG_405CR || CONFIG_405 || CONFIG_405EP */
  675. /*----------------------------------------------------------------------- */
  676. /*****************************************************************************/
  677. .globl _start_of_vectors
  678. _start_of_vectors:
  679. #if 0
  680. /*TODO Fixup _start above so we can do this*/
  681. /* Critical input. */
  682. CRIT_EXCEPTION(0x100, CritcalInput, CritcalInputException)
  683. #endif
  684. /* Machine check */
  685. CRIT_EXCEPTION(0x200, MachineCheck, MachineCheckException)
  686. /* Data Storage exception. */
  687. STD_EXCEPTION(0x300, DataStorage, UnknownException)
  688. /* Instruction Storage exception. */
  689. STD_EXCEPTION(0x400, InstStorage, UnknownException)
  690. /* External Interrupt exception. */
  691. STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
  692. /* Alignment exception. */
  693. . = 0x600
  694. Alignment:
  695. EXCEPTION_PROLOG
  696. mfspr r4,DAR
  697. stw r4,_DAR(r21)
  698. mfspr r5,DSISR
  699. stw r5,_DSISR(r21)
  700. addi r3,r1,STACK_FRAME_OVERHEAD
  701. li r20,MSR_KERNEL
  702. rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
  703. lwz r6,GOT(transfer_to_handler)
  704. mtlr r6
  705. blrl
  706. .L_Alignment:
  707. .long AlignmentException - _start + EXC_OFF_SYS_RESET
  708. .long int_return - _start + EXC_OFF_SYS_RESET
  709. /* Program check exception */
  710. . = 0x700
  711. ProgramCheck:
  712. EXCEPTION_PROLOG
  713. addi r3,r1,STACK_FRAME_OVERHEAD
  714. li r20,MSR_KERNEL
  715. rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
  716. lwz r6,GOT(transfer_to_handler)
  717. mtlr r6
  718. blrl
  719. .L_ProgramCheck:
  720. .long ProgramCheckException - _start + EXC_OFF_SYS_RESET
  721. .long int_return - _start + EXC_OFF_SYS_RESET
  722. /* No FPU on MPC8xx. This exception is not supposed to happen.
  723. */
  724. STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
  725. /* I guess we could implement decrementer, and may have
  726. * to someday for timekeeping.
  727. */
  728. STD_EXCEPTION(0x900, Decrementer, timer_interrupt)
  729. STD_EXCEPTION(0xa00, Trap_0a, UnknownException)
  730. STD_EXCEPTION(0xb00, Trap_0b, UnknownException)
  731. STD_EXCEPTION(0xc00, SystemCall, UnknownException)
  732. STD_EXCEPTION(0xd00, SingleStep, UnknownException)
  733. STD_EXCEPTION(0xe00, Trap_0e, UnknownException)
  734. STD_EXCEPTION(0xf00, Trap_0f, UnknownException)
  735. /* On the MPC8xx, this is a software emulation interrupt. It occurs
  736. * for all unimplemented and illegal instructions.
  737. */
  738. STD_EXCEPTION(0x1000, PIT, PITException)
  739. STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException)
  740. STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException)
  741. STD_EXCEPTION(0x1300, InstructionTLBError, UnknownException)
  742. STD_EXCEPTION(0x1400, DataTLBError, UnknownException)
  743. STD_EXCEPTION(0x1500, Reserved5, UnknownException)
  744. STD_EXCEPTION(0x1600, Reserved6, UnknownException)
  745. STD_EXCEPTION(0x1700, Reserved7, UnknownException)
  746. STD_EXCEPTION(0x1800, Reserved8, UnknownException)
  747. STD_EXCEPTION(0x1900, Reserved9, UnknownException)
  748. STD_EXCEPTION(0x1a00, ReservedA, UnknownException)
  749. STD_EXCEPTION(0x1b00, ReservedB, UnknownException)
  750. STD_EXCEPTION(0x1c00, DataBreakpoint, UnknownException)
  751. STD_EXCEPTION(0x1d00, InstructionBreakpoint, UnknownException)
  752. STD_EXCEPTION(0x1e00, PeripheralBreakpoint, UnknownException)
  753. STD_EXCEPTION(0x1f00, DevPortBreakpoint, UnknownException)
  754. CRIT_EXCEPTION(0x2000, DebugBreakpoint, DebugException )
  755. .globl _end_of_vectors
  756. _end_of_vectors:
  757. . = 0x2100
  758. /*
  759. * This code finishes saving the registers to the exception frame
  760. * and jumps to the appropriate handler for the exception.
  761. * Register r21 is pointer into trap frame, r1 has new stack pointer.
  762. */
  763. .globl transfer_to_handler
  764. transfer_to_handler:
  765. stw r22,_NIP(r21)
  766. lis r22,MSR_POW@h
  767. andc r23,r23,r22
  768. stw r23,_MSR(r21)
  769. SAVE_GPR(7, r21)
  770. SAVE_4GPRS(8, r21)
  771. SAVE_8GPRS(12, r21)
  772. SAVE_8GPRS(24, r21)
  773. #if 0
  774. andi. r23,r23,MSR_PR
  775. mfspr r23,SPRG3 /* if from user, fix up tss.regs */
  776. beq 2f
  777. addi r24,r1,STACK_FRAME_OVERHEAD
  778. stw r24,PT_REGS(r23)
  779. 2: addi r2,r23,-TSS /* set r2 to current */
  780. tovirt(r2,r2,r23)
  781. #endif
  782. mflr r23
  783. andi. r24,r23,0x3f00 /* get vector offset */
  784. stw r24,TRAP(r21)
  785. li r22,0
  786. stw r22,RESULT(r21)
  787. mtspr SPRG2,r22 /* r1 is now kernel sp */
  788. #if 0
  789. addi r24,r2,TASK_STRUCT_SIZE /* check for kernel stack overflow */
  790. cmplw 0,r1,r2
  791. cmplw 1,r1,r24
  792. crand 1,1,4
  793. bgt stack_ovf /* if r2 < r1 < r2+TASK_STRUCT_SIZE */
  794. #endif
  795. lwz r24,0(r23) /* virtual address of handler */
  796. lwz r23,4(r23) /* where to go when done */
  797. mtspr SRR0,r24
  798. mtspr SRR1,r20
  799. mtlr r23
  800. SYNC
  801. rfi /* jump to handler, enable MMU */
  802. int_return:
  803. mfmsr r28 /* Disable interrupts */
  804. li r4,0
  805. ori r4,r4,MSR_EE
  806. andc r28,r28,r4
  807. SYNC /* Some chip revs need this... */
  808. mtmsr r28
  809. SYNC
  810. lwz r2,_CTR(r1)
  811. lwz r0,_LINK(r1)
  812. mtctr r2
  813. mtlr r0
  814. lwz r2,_XER(r1)
  815. lwz r0,_CCR(r1)
  816. mtspr XER,r2
  817. mtcrf 0xFF,r0
  818. REST_10GPRS(3, r1)
  819. REST_10GPRS(13, r1)
  820. REST_8GPRS(23, r1)
  821. REST_GPR(31, r1)
  822. lwz r2,_NIP(r1) /* Restore environment */
  823. lwz r0,_MSR(r1)
  824. mtspr SRR0,r2
  825. mtspr SRR1,r0
  826. lwz r0,GPR0(r1)
  827. lwz r2,GPR2(r1)
  828. lwz r1,GPR1(r1)
  829. SYNC
  830. rfi
  831. crit_return:
  832. mfmsr r28 /* Disable interrupts */
  833. li r4,0
  834. ori r4,r4,MSR_EE
  835. andc r28,r28,r4
  836. SYNC /* Some chip revs need this... */
  837. mtmsr r28
  838. SYNC
  839. lwz r2,_CTR(r1)
  840. lwz r0,_LINK(r1)
  841. mtctr r2
  842. mtlr r0
  843. lwz r2,_XER(r1)
  844. lwz r0,_CCR(r1)
  845. mtspr XER,r2
  846. mtcrf 0xFF,r0
  847. REST_10GPRS(3, r1)
  848. REST_10GPRS(13, r1)
  849. REST_8GPRS(23, r1)
  850. REST_GPR(31, r1)
  851. lwz r2,_NIP(r1) /* Restore environment */
  852. lwz r0,_MSR(r1)
  853. mtspr 990,r2 /* SRR2 */
  854. mtspr 991,r0 /* SRR3 */
  855. lwz r0,GPR0(r1)
  856. lwz r2,GPR2(r1)
  857. lwz r1,GPR1(r1)
  858. SYNC
  859. rfci
  860. /* Cache functions.
  861. */
  862. invalidate_icache:
  863. iccci r0,r0 /* for 405, iccci invalidates the */
  864. blr /* entire I cache */
  865. invalidate_dcache:
  866. addi r6,0,0x0000 /* clear GPR 6 */
  867. /* Do loop for # of dcache congruence classes. */
  868. #if defined(CONFIG_440GX) || defined(CONFIG_440EP) || defined(CONFIG_440GR)
  869. lis r7, (CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)@ha /* TBS for large sized cache */
  870. ori r7, r7, (CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)@l
  871. #else
  872. addi r7,r0, (CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)
  873. #endif
  874. /* NOTE: dccci invalidates both */
  875. mtctr r7 /* ways in the D cache */
  876. ..dcloop:
  877. dccci 0,r6 /* invalidate line */
  878. addi r6,r6, CFG_CACHELINE_SIZE /* bump to next line */
  879. bdnz ..dcloop
  880. blr
  881. flush_dcache:
  882. addis r9,r0,0x0002 /* set mask for EE and CE msr bits */
  883. ori r9,r9,0x8000
  884. mfmsr r12 /* save msr */
  885. andc r9,r12,r9
  886. mtmsr r9 /* disable EE and CE */
  887. addi r10,r0,0x0001 /* enable data cache for unused memory */
  888. mfdccr r9 /* region 0xF8000000-0xFFFFFFFF via */
  889. or r10,r10,r9 /* bit 31 in dccr */
  890. mtdccr r10
  891. /* do loop for # of congruence classes. */
  892. #if defined(CONFIG_440GX) || defined(CONFIG_440EP) || defined(CONFIG_440GR)
  893. lis r10,(CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)@ha /* TBS: for large cache sizes */
  894. ori r10,r10,(CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)@l
  895. lis r11,(CFG_DCACHE_SIZE / 2)@ha /* D cache set size - 2 way sets */
  896. ori r11,r11,(CFG_DCACHE_SIZE / 2)@l /* D cache set size - 2 way sets */
  897. #else
  898. addi r10,r0,(CFG_DCACHE_SIZE / CFG_CACHELINE_SIZE / 2)
  899. addi r11,r0,(CFG_DCACHE_SIZE / 2) /* D cache set size - 2 way sets */
  900. #endif
  901. mtctr r10
  902. addi r10,r0,(0xE000-0x10000) /* start at 0xFFFFE000 */
  903. add r11,r10,r11 /* add to get to other side of cache line */
  904. ..flush_dcache_loop:
  905. lwz r3,0(r10) /* least recently used side */
  906. lwz r3,0(r11) /* the other side */
  907. dccci r0,r11 /* invalidate both sides */
  908. addi r10,r10,CFG_CACHELINE_SIZE /* bump to next line */
  909. addi r11,r11,CFG_CACHELINE_SIZE /* bump to next line */
  910. bdnz ..flush_dcache_loop
  911. sync /* allow memory access to complete */
  912. mtdccr r9 /* restore dccr */
  913. mtmsr r12 /* restore msr */
  914. blr
  915. .globl icache_enable
  916. icache_enable:
  917. mflr r8
  918. bl invalidate_icache
  919. mtlr r8
  920. isync
  921. addis r3,r0, 0x8000 /* set bit 0 */
  922. mticcr r3
  923. blr
  924. .globl icache_disable
  925. icache_disable:
  926. addis r3,r0, 0x0000 /* clear bit 0 */
  927. mticcr r3
  928. isync
  929. blr
  930. .globl icache_status
  931. icache_status:
  932. mficcr r3
  933. srwi r3, r3, 31 /* >>31 => select bit 0 */
  934. blr
  935. .globl dcache_enable
  936. dcache_enable:
  937. mflr r8
  938. bl invalidate_dcache
  939. mtlr r8
  940. isync
  941. addis r3,r0, 0x8000 /* set bit 0 */
  942. mtdccr r3
  943. blr
  944. .globl dcache_disable
  945. dcache_disable:
  946. mflr r8
  947. bl flush_dcache
  948. mtlr r8
  949. addis r3,r0, 0x0000 /* clear bit 0 */
  950. mtdccr r3
  951. blr
  952. .globl dcache_status
  953. dcache_status:
  954. mfdccr r3
  955. srwi r3, r3, 31 /* >>31 => select bit 0 */
  956. blr
  957. .globl get_pvr
  958. get_pvr:
  959. mfspr r3, PVR
  960. blr
  961. #if !defined(CONFIG_440)
  962. .globl wr_pit
  963. wr_pit:
  964. mtspr pit, r3
  965. blr
  966. #endif
  967. .globl wr_tcr
  968. wr_tcr:
  969. mtspr tcr, r3
  970. blr
  971. /*------------------------------------------------------------------------------- */
  972. /* Function: in8 */
  973. /* Description: Input 8 bits */
  974. /*------------------------------------------------------------------------------- */
  975. .globl in8
  976. in8:
  977. lbz r3,0x0000(r3)
  978. blr
  979. /*------------------------------------------------------------------------------- */
  980. /* Function: out8 */
  981. /* Description: Output 8 bits */
  982. /*------------------------------------------------------------------------------- */
  983. .globl out8
  984. out8:
  985. stb r4,0x0000(r3)
  986. blr
  987. /*------------------------------------------------------------------------------- */
  988. /* Function: out16 */
  989. /* Description: Output 16 bits */
  990. /*------------------------------------------------------------------------------- */
  991. .globl out16
  992. out16:
  993. sth r4,0x0000(r3)
  994. blr
  995. /*------------------------------------------------------------------------------- */
  996. /* Function: out16r */
  997. /* Description: Byte reverse and output 16 bits */
  998. /*------------------------------------------------------------------------------- */
  999. .globl out16r
  1000. out16r:
  1001. sthbrx r4,r0,r3
  1002. blr
  1003. /*------------------------------------------------------------------------------- */
  1004. /* Function: out32 */
  1005. /* Description: Output 32 bits */
  1006. /*------------------------------------------------------------------------------- */
  1007. .globl out32
  1008. out32:
  1009. stw r4,0x0000(r3)
  1010. blr
  1011. /*------------------------------------------------------------------------------- */
  1012. /* Function: out32r */
  1013. /* Description: Byte reverse and output 32 bits */
  1014. /*------------------------------------------------------------------------------- */
  1015. .globl out32r
  1016. out32r:
  1017. stwbrx r4,r0,r3
  1018. blr
  1019. /*------------------------------------------------------------------------------- */
  1020. /* Function: in16 */
  1021. /* Description: Input 16 bits */
  1022. /*------------------------------------------------------------------------------- */
  1023. .globl in16
  1024. in16:
  1025. lhz r3,0x0000(r3)
  1026. blr
  1027. /*------------------------------------------------------------------------------- */
  1028. /* Function: in16r */
  1029. /* Description: Input 16 bits and byte reverse */
  1030. /*------------------------------------------------------------------------------- */
  1031. .globl in16r
  1032. in16r:
  1033. lhbrx r3,r0,r3
  1034. blr
  1035. /*------------------------------------------------------------------------------- */
  1036. /* Function: in32 */
  1037. /* Description: Input 32 bits */
  1038. /*------------------------------------------------------------------------------- */
  1039. .globl in32
  1040. in32:
  1041. lwz 3,0x0000(3)
  1042. blr
  1043. /*------------------------------------------------------------------------------- */
  1044. /* Function: in32r */
  1045. /* Description: Input 32 bits and byte reverse */
  1046. /*------------------------------------------------------------------------------- */
  1047. .globl in32r
  1048. in32r:
  1049. lwbrx r3,r0,r3
  1050. blr
  1051. /*------------------------------------------------------------------------------- */
  1052. /* Function: ppcDcbf */
  1053. /* Description: Data Cache block flush */
  1054. /* Input: r3 = effective address */
  1055. /* Output: none. */
  1056. /*------------------------------------------------------------------------------- */
  1057. .globl ppcDcbf
  1058. ppcDcbf:
  1059. dcbf r0,r3
  1060. blr
  1061. /*------------------------------------------------------------------------------- */
  1062. /* Function: ppcDcbi */
  1063. /* Description: Data Cache block Invalidate */
  1064. /* Input: r3 = effective address */
  1065. /* Output: none. */
  1066. /*------------------------------------------------------------------------------- */
  1067. .globl ppcDcbi
  1068. ppcDcbi:
  1069. dcbi r0,r3
  1070. blr
  1071. /*------------------------------------------------------------------------------- */
  1072. /* Function: ppcSync */
  1073. /* Description: Processor Synchronize */
  1074. /* Input: none. */
  1075. /* Output: none. */
  1076. /*------------------------------------------------------------------------------- */
  1077. .globl ppcSync
  1078. ppcSync:
  1079. sync
  1080. blr
  1081. /*------------------------------------------------------------------------------*/
  1082. /*
  1083. * void relocate_code (addr_sp, gd, addr_moni)
  1084. *
  1085. * This "function" does not return, instead it continues in RAM
  1086. * after relocating the monitor code.
  1087. *
  1088. * r3 = dest
  1089. * r4 = src
  1090. * r5 = length in bytes
  1091. * r6 = cachelinesize
  1092. */
  1093. .globl relocate_code
  1094. relocate_code:
  1095. #if defined(CONFIG_440EP) || defined(CONFIG_440GR)
  1096. dccci 0,0 /* Invalidate data cache, now no longer our stack */
  1097. sync
  1098. addi r1,r0,0x0000 /* Tlb entry #0 */
  1099. tlbre r0,r1,0x0002 /* Read contents */
  1100. ori r0,r0,0x0c00 /* Or in the inhibit, write through bit */
  1101. tlbwe r0,r1,0x0002 /* Save it out */
  1102. isync
  1103. #endif
  1104. mr r1, r3 /* Set new stack pointer */
  1105. mr r9, r4 /* Save copy of Init Data pointer */
  1106. mr r10, r5 /* Save copy of Destination Address */
  1107. mr r3, r5 /* Destination Address */
  1108. lis r4, CFG_MONITOR_BASE@h /* Source Address */
  1109. ori r4, r4, CFG_MONITOR_BASE@l
  1110. lwz r5, GOT(__init_end)
  1111. sub r5, r5, r4
  1112. li r6, CFG_CACHELINE_SIZE /* Cache Line Size */
  1113. /*
  1114. * Fix GOT pointer:
  1115. *
  1116. * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
  1117. *
  1118. * Offset:
  1119. */
  1120. sub r15, r10, r4
  1121. /* First our own GOT */
  1122. add r14, r14, r15
  1123. /* the the one used by the C code */
  1124. add r30, r30, r15
  1125. /*
  1126. * Now relocate code
  1127. */
  1128. cmplw cr1,r3,r4
  1129. addi r0,r5,3
  1130. srwi. r0,r0,2
  1131. beq cr1,4f /* In place copy is not necessary */
  1132. beq 7f /* Protect against 0 count */
  1133. mtctr r0
  1134. bge cr1,2f
  1135. la r8,-4(r4)
  1136. la r7,-4(r3)
  1137. 1: lwzu r0,4(r8)
  1138. stwu r0,4(r7)
  1139. bdnz 1b
  1140. b 4f
  1141. 2: slwi r0,r0,2
  1142. add r8,r4,r0
  1143. add r7,r3,r0
  1144. 3: lwzu r0,-4(r8)
  1145. stwu r0,-4(r7)
  1146. bdnz 3b
  1147. /*
  1148. * Now flush the cache: note that we must start from a cache aligned
  1149. * address. Otherwise we might miss one cache line.
  1150. */
  1151. 4: cmpwi r6,0
  1152. add r5,r3,r5
  1153. beq 7f /* Always flush prefetch queue in any case */
  1154. subi r0,r6,1
  1155. andc r3,r3,r0
  1156. mr r4,r3
  1157. 5: dcbst 0,r4
  1158. add r4,r4,r6
  1159. cmplw r4,r5
  1160. blt 5b
  1161. sync /* Wait for all dcbst to complete on bus */
  1162. mr r4,r3
  1163. 6: icbi 0,r4
  1164. add r4,r4,r6
  1165. cmplw r4,r5
  1166. blt 6b
  1167. 7: sync /* Wait for all icbi to complete on bus */
  1168. isync
  1169. /*
  1170. * We are done. Do not return, instead branch to second part of board
  1171. * initialization, now running from RAM.
  1172. */
  1173. addi r0, r10, in_ram - _start + EXC_OFF_SYS_RESET
  1174. mtlr r0
  1175. blr /* NEVER RETURNS! */
  1176. in_ram:
  1177. /*
  1178. * Relocation Function, r14 point to got2+0x8000
  1179. *
  1180. * Adjust got2 pointers, no need to check for 0, this code
  1181. * already puts a few entries in the table.
  1182. */
  1183. li r0,__got2_entries@sectoff@l
  1184. la r3,GOT(_GOT2_TABLE_)
  1185. lwz r11,GOT(_GOT2_TABLE_)
  1186. mtctr r0
  1187. sub r11,r3,r11
  1188. addi r3,r3,-4
  1189. 1: lwzu r0,4(r3)
  1190. add r0,r0,r11
  1191. stw r0,0(r3)
  1192. bdnz 1b
  1193. /*
  1194. * Now adjust the fixups and the pointers to the fixups
  1195. * in case we need to move ourselves again.
  1196. */
  1197. 2: li r0,__fixup_entries@sectoff@l
  1198. lwz r3,GOT(_FIXUP_TABLE_)
  1199. cmpwi r0,0
  1200. mtctr r0
  1201. addi r3,r3,-4
  1202. beq 4f
  1203. 3: lwzu r4,4(r3)
  1204. lwzux r0,r4,r11
  1205. add r0,r0,r11
  1206. stw r10,0(r3)
  1207. stw r0,0(r4)
  1208. bdnz 3b
  1209. 4:
  1210. clear_bss:
  1211. /*
  1212. * Now clear BSS segment
  1213. */
  1214. lwz r3,GOT(__bss_start)
  1215. lwz r4,GOT(_end)
  1216. cmplw 0, r3, r4
  1217. beq 6f
  1218. li r0, 0
  1219. 5:
  1220. stw r0, 0(r3)
  1221. addi r3, r3, 4
  1222. cmplw 0, r3, r4
  1223. bne 5b
  1224. 6:
  1225. mr r3, r9 /* Init Data pointer */
  1226. mr r4, r10 /* Destination Address */
  1227. bl board_init_r
  1228. /*
  1229. * Copy exception vector code to low memory
  1230. *
  1231. * r3: dest_addr
  1232. * r7: source address, r8: end address, r9: target address
  1233. */
  1234. .globl trap_init
  1235. trap_init:
  1236. lwz r7, GOT(_start)
  1237. lwz r8, GOT(_end_of_vectors)
  1238. li r9, 0x100 /* reset vector always at 0x100 */
  1239. cmplw 0, r7, r8
  1240. bgelr /* return if r7>=r8 - just in case */
  1241. mflr r4 /* save link register */
  1242. 1:
  1243. lwz r0, 0(r7)
  1244. stw r0, 0(r9)
  1245. addi r7, r7, 4
  1246. addi r9, r9, 4
  1247. cmplw 0, r7, r8
  1248. bne 1b
  1249. /*
  1250. * relocate `hdlr' and `int_return' entries
  1251. */
  1252. li r7, .L_MachineCheck - _start + EXC_OFF_SYS_RESET
  1253. li r8, Alignment - _start + EXC_OFF_SYS_RESET
  1254. 2:
  1255. bl trap_reloc
  1256. addi r7, r7, 0x100 /* next exception vector */
  1257. cmplw 0, r7, r8
  1258. blt 2b
  1259. li r7, .L_Alignment - _start + EXC_OFF_SYS_RESET
  1260. bl trap_reloc
  1261. li r7, .L_ProgramCheck - _start + EXC_OFF_SYS_RESET
  1262. bl trap_reloc
  1263. li r7, .L_FPUnavailable - _start + EXC_OFF_SYS_RESET
  1264. li r8, SystemCall - _start + EXC_OFF_SYS_RESET
  1265. 3:
  1266. bl trap_reloc
  1267. addi r7, r7, 0x100 /* next exception vector */
  1268. cmplw 0, r7, r8
  1269. blt 3b
  1270. li r7, .L_SingleStep - _start + EXC_OFF_SYS_RESET
  1271. li r8, _end_of_vectors - _start + EXC_OFF_SYS_RESET
  1272. 4:
  1273. bl trap_reloc
  1274. addi r7, r7, 0x100 /* next exception vector */
  1275. cmplw 0, r7, r8
  1276. blt 4b
  1277. mtlr r4 /* restore link register */
  1278. blr
  1279. /*
  1280. * Function: relocate entries for one exception vector
  1281. */
  1282. trap_reloc:
  1283. lwz r0, 0(r7) /* hdlr ... */
  1284. add r0, r0, r3 /* ... += dest_addr */
  1285. stw r0, 0(r7)
  1286. lwz r0, 4(r7) /* int_return ... */
  1287. add r0, r0, r3 /* ... += dest_addr */
  1288. stw r0, 4(r7)
  1289. blr
  1290. /**************************************************************************/
  1291. /* PPC405EP specific stuff */
  1292. /**************************************************************************/
  1293. #ifdef CONFIG_405EP
  1294. ppc405ep_init:
  1295. #ifdef CONFIG_BUBINGA
  1296. /*
  1297. * Initialize EBC chip selects 1 & 4 and GPIO pins (for alternate
  1298. * function) to support FPGA and NVRAM accesses below.
  1299. */
  1300. lis r3,GPIO0_OSRH@h /* config GPIO output select */
  1301. ori r3,r3,GPIO0_OSRH@l
  1302. lis r4,CFG_GPIO0_OSRH@h
  1303. ori r4,r4,CFG_GPIO0_OSRH@l
  1304. stw r4,0(r3)
  1305. lis r3,GPIO0_OSRL@h
  1306. ori r3,r3,GPIO0_OSRL@l
  1307. lis r4,CFG_GPIO0_OSRL@h
  1308. ori r4,r4,CFG_GPIO0_OSRL@l
  1309. stw r4,0(r3)
  1310. lis r3,GPIO0_ISR1H@h /* config GPIO input select */
  1311. ori r3,r3,GPIO0_ISR1H@l
  1312. lis r4,CFG_GPIO0_ISR1H@h
  1313. ori r4,r4,CFG_GPIO0_ISR1H@l
  1314. stw r4,0(r3)
  1315. lis r3,GPIO0_ISR1L@h
  1316. ori r3,r3,GPIO0_ISR1L@l
  1317. lis r4,CFG_GPIO0_ISR1L@h
  1318. ori r4,r4,CFG_GPIO0_ISR1L@l
  1319. stw r4,0(r3)
  1320. lis r3,GPIO0_TSRH@h /* config GPIO three-state select */
  1321. ori r3,r3,GPIO0_TSRH@l
  1322. lis r4,CFG_GPIO0_TSRH@h
  1323. ori r4,r4,CFG_GPIO0_TSRH@l
  1324. stw r4,0(r3)
  1325. lis r3,GPIO0_TSRL@h
  1326. ori r3,r3,GPIO0_TSRL@l
  1327. lis r4,CFG_GPIO0_TSRL@h
  1328. ori r4,r4,CFG_GPIO0_TSRL@l
  1329. stw r4,0(r3)
  1330. lis r3,GPIO0_TCR@h /* config GPIO driver output enables */
  1331. ori r3,r3,GPIO0_TCR@l
  1332. lis r4,CFG_GPIO0_TCR@h
  1333. ori r4,r4,CFG_GPIO0_TCR@l
  1334. stw r4,0(r3)
  1335. li r3,pb1ap /* program EBC bank 1 for RTC access */
  1336. mtdcr ebccfga,r3
  1337. lis r3,CFG_EBC_PB1AP@h
  1338. ori r3,r3,CFG_EBC_PB1AP@l
  1339. mtdcr ebccfgd,r3
  1340. li r3,pb1cr
  1341. mtdcr ebccfga,r3
  1342. lis r3,CFG_EBC_PB1CR@h
  1343. ori r3,r3,CFG_EBC_PB1CR@l
  1344. mtdcr ebccfgd,r3
  1345. li r3,pb1ap /* program EBC bank 1 for RTC access */
  1346. mtdcr ebccfga,r3
  1347. lis r3,CFG_EBC_PB1AP@h
  1348. ori r3,r3,CFG_EBC_PB1AP@l
  1349. mtdcr ebccfgd,r3
  1350. li r3,pb1cr
  1351. mtdcr ebccfga,r3
  1352. lis r3,CFG_EBC_PB1CR@h
  1353. ori r3,r3,CFG_EBC_PB1CR@l
  1354. mtdcr ebccfgd,r3
  1355. li r3,pb4ap /* program EBC bank 4 for FPGA access */
  1356. mtdcr ebccfga,r3
  1357. lis r3,CFG_EBC_PB4AP@h
  1358. ori r3,r3,CFG_EBC_PB4AP@l
  1359. mtdcr ebccfgd,r3
  1360. li r3,pb4cr
  1361. mtdcr ebccfga,r3
  1362. lis r3,CFG_EBC_PB4CR@h
  1363. ori r3,r3,CFG_EBC_PB4CR@l
  1364. mtdcr ebccfgd,r3
  1365. #endif
  1366. addi r3,0,CPC0_PCI_HOST_CFG_EN
  1367. #ifdef CONFIG_BUBINGA
  1368. /*
  1369. !-----------------------------------------------------------------------
  1370. ! Check FPGA for PCI internal/external arbitration
  1371. ! If board is set to internal arbitration, update cpc0_pci
  1372. !-----------------------------------------------------------------------
  1373. */
  1374. addis r5,r0,FPGA_REG1@h /* set offset for FPGA_REG1 */
  1375. ori r5,r5,FPGA_REG1@l
  1376. lbz r5,0x0(r5) /* read to get PCI arb selection */
  1377. andi. r6,r5,FPGA_REG1_PCI_INT_ARB /* using internal arbiter ?*/
  1378. beq ..pci_cfg_set /* if not set, then bypass reg write*/
  1379. #endif
  1380. ori r3,r3,CPC0_PCI_ARBIT_EN
  1381. ..pci_cfg_set:
  1382. mtdcr CPC0_PCI, r3 /* Enable internal arbiter*/
  1383. /*
  1384. !-----------------------------------------------------------------------
  1385. ! Check to see if chip is in bypass mode.
  1386. ! If so, write stored CPC0_PLLMR0 and CPC0_PLLMR1 values and perform a
  1387. ! CPU reset Otherwise, skip this step and keep going.
  1388. ! Note: Running BIOS in bypass mode is not supported since PLB speed
  1389. ! will not be fast enough for the SDRAM (min 66MHz)
  1390. !-----------------------------------------------------------------------
  1391. */
  1392. mfdcr r5, CPC0_PLLMR1
  1393. rlwinm r4,r5,1,0x1 /* get system clock source (SSCS) */
  1394. cmpi cr0,0,r4,0x1
  1395. beq pll_done /* if SSCS =b'1' then PLL has */
  1396. /* already been set */
  1397. /* and CPU has been reset */
  1398. /* so skip to next section */
  1399. #ifdef CONFIG_BUBINGA
  1400. /*
  1401. !-----------------------------------------------------------------------
  1402. ! Read NVRAM to get value to write in PLLMR.
  1403. ! If value has not been correctly saved, write default value
  1404. ! Default config values (assuming on-board 33MHz SYS_CLK) are above.
  1405. ! See CPU_DEFAULT_200 and CPU_DEFAULT_266 above.
  1406. !
  1407. ! WARNING: This code assumes the first three words in the nvram_t
  1408. ! structure in openbios.h. Changing the beginning of
  1409. ! the structure will break this code.
  1410. !
  1411. !-----------------------------------------------------------------------
  1412. */
  1413. addis r3,0,NVRAM_BASE@h
  1414. addi r3,r3,NVRAM_BASE@l
  1415. lwz r4, 0(r3)
  1416. addis r5,0,NVRVFY1@h
  1417. addi r5,r5,NVRVFY1@l
  1418. cmp cr0,0,r4,r5 /* Compare 1st NVRAM Magic number*/
  1419. bne ..no_pllset
  1420. addi r3,r3,4
  1421. lwz r4, 0(r3)
  1422. addis r5,0,NVRVFY2@h
  1423. addi r5,r5,NVRVFY2@l
  1424. cmp cr0,0,r4,r5 /* Compare 2 NVRAM Magic number */
  1425. bne ..no_pllset
  1426. addi r3,r3,8 /* Skip over conf_size */
  1427. lwz r4, 4(r3) /* Load PLLMR1 value from NVRAM */
  1428. lwz r3, 0(r3) /* Load PLLMR0 value from NVRAM */
  1429. rlwinm r5,r4,1,0x1 /* get system clock source (SSCS) */
  1430. cmpi cr0,0,r5,1 /* See if PLL is locked */
  1431. beq pll_write
  1432. ..no_pllset:
  1433. #endif /* CONFIG_BUBINGA */
  1434. addis r3,0,PLLMR0_DEFAULT@h /* PLLMR0 default value */
  1435. ori r3,r3,PLLMR0_DEFAULT@l /* */
  1436. addis r4,0,PLLMR1_DEFAULT@h /* PLLMR1 default value */
  1437. ori r4,r4,PLLMR1_DEFAULT@l /* */
  1438. b pll_write /* Write the CPC0_PLLMR with new value */
  1439. pll_done:
  1440. /*
  1441. !-----------------------------------------------------------------------
  1442. ! Clear Soft Reset Register
  1443. ! This is needed to enable PCI if not booting from serial EPROM
  1444. !-----------------------------------------------------------------------
  1445. */
  1446. addi r3, 0, 0x0
  1447. mtdcr CPC0_SRR, r3
  1448. addis r3,0,0x0010
  1449. mtctr r3
  1450. pci_wait:
  1451. bdnz pci_wait
  1452. blr /* return to main code */
  1453. /*
  1454. !-----------------------------------------------------------------------------
  1455. ! Function: pll_write
  1456. ! Description: Updates the value of the CPC0_PLLMR according to CMOS27E documentation
  1457. ! That is:
  1458. ! 1. Pll is first disabled (de-activated by putting in bypass mode)
  1459. ! 2. PLL is reset
  1460. ! 3. Clock dividers are set while PLL is held in reset and bypassed
  1461. ! 4. PLL Reset is cleared
  1462. ! 5. Wait 100us for PLL to lock
  1463. ! 6. A core reset is performed
  1464. ! Input: r3 = Value to write to CPC0_PLLMR0
  1465. ! Input: r4 = Value to write to CPC0_PLLMR1
  1466. ! Output r3 = none
  1467. !-----------------------------------------------------------------------------
  1468. */
  1469. pll_write:
  1470. mfdcr r5, CPC0_UCR
  1471. andis. r5,r5,0xFFFF
  1472. ori r5,r5,0x0101 /* Stop the UART clocks */
  1473. mtdcr CPC0_UCR,r5 /* Before changing PLL */
  1474. mfdcr r5, CPC0_PLLMR1
  1475. rlwinm r5,r5,0,0x7FFFFFFF /* Disable PLL */
  1476. mtdcr CPC0_PLLMR1,r5
  1477. oris r5,r5,0x4000 /* Set PLL Reset */
  1478. mtdcr CPC0_PLLMR1,r5
  1479. mtdcr CPC0_PLLMR0,r3 /* Set clock dividers */
  1480. rlwinm r5,r4,0,0x3FFFFFFF /* Reset & Bypass new PLL dividers */
  1481. oris r5,r5,0x4000 /* Set PLL Reset */
  1482. mtdcr CPC0_PLLMR1,r5 /* Set clock dividers */
  1483. rlwinm r5,r5,0,0xBFFFFFFF /* Clear PLL Reset */
  1484. mtdcr CPC0_PLLMR1,r5
  1485. /*
  1486. ! Wait min of 100us for PLL to lock.
  1487. ! See CMOS 27E databook for more info.
  1488. ! At 200MHz, that means waiting 20,000 instructions
  1489. */
  1490. addi r3,0,20000 /* 2000 = 0x4e20 */
  1491. mtctr r3
  1492. pll_wait:
  1493. bdnz pll_wait
  1494. oris r5,r5,0x8000 /* Enable PLL */
  1495. mtdcr CPC0_PLLMR1,r5 /* Engage */
  1496. /*
  1497. * Reset CPU to guarantee timings are OK
  1498. * Not sure if this is needed...
  1499. */
  1500. addis r3,0,0x1000
  1501. mtspr dbcr0,r3 /* This will cause a CPU core reset, and */
  1502. /* execution will continue from the poweron */
  1503. /* vector of 0xfffffffc */
  1504. #endif /* CONFIG_405EP */