start.S 61 KB

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