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>
9 * SPDX-License-Identifier: GPL-2.0 ibm-pibs
13 * Startup code for IBM/AMCC PowerPC 4xx (PPC4xx) based boards
15 * The following description only applies to the NOR flash style booting.
16 * NAND booting is different. For more details about NAND booting on 4xx
17 * take a look at doc/README.nand-boot-ppc440.
19 * The CPU starts at address 0xfffffffc (last word in the address space).
20 * The U-Boot image therefore has to be located in the "upper" area of the
21 * flash (e.g. 512MiB - 0xfff80000 ... 0xffffffff). The default value for
22 * the boot chip-select (CS0) is quite big and covers this area. On the
23 * 405EX this is for example 0xffe00000 ... 0xffffffff. U-Boot will
24 * reconfigure this CS0 (and other chip-selects as well when configured
25 * this way) in the boot process to the "correct" values matching the
29 #include <asm-offsets.h>
31 #include <asm/ppc4xx.h>
34 #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
36 #include <ppc_asm.tmpl>
39 #include <asm/cache.h>
41 #include <asm/ppc4xx-isram.h>
43 #ifdef CONFIG_SYS_INIT_DCACHE_CS
44 # if (CONFIG_SYS_INIT_DCACHE_CS == 0)
47 # if (defined(CONFIG_SYS_EBC_PB0AP) && defined(CONFIG_SYS_EBC_PB0CR))
48 # define PBxAP_VAL CONFIG_SYS_EBC_PB0AP
49 # define PBxCR_VAL CONFIG_SYS_EBC_PB0CR
52 # if (CONFIG_SYS_INIT_DCACHE_CS == 1)
55 # if (defined(CONFIG_SYS_EBC_PB1AP) && defined(CONFIG_SYS_EBC_PB1CR))
56 # define PBxAP_VAL CONFIG_SYS_EBC_PB1AP
57 # define PBxCR_VAL CONFIG_SYS_EBC_PB1CR
60 # if (CONFIG_SYS_INIT_DCACHE_CS == 2)
63 # if (defined(CONFIG_SYS_EBC_PB2AP) && defined(CONFIG_SYS_EBC_PB2CR))
64 # define PBxAP_VAL CONFIG_SYS_EBC_PB2AP
65 # define PBxCR_VAL CONFIG_SYS_EBC_PB2CR
68 # if (CONFIG_SYS_INIT_DCACHE_CS == 3)
71 # if (defined(CONFIG_SYS_EBC_PB3AP) && defined(CONFIG_SYS_EBC_PB3CR))
72 # define PBxAP_VAL CONFIG_SYS_EBC_PB3AP
73 # define PBxCR_VAL CONFIG_SYS_EBC_PB3CR
76 # if (CONFIG_SYS_INIT_DCACHE_CS == 4)
79 # if (defined(CONFIG_SYS_EBC_PB4AP) && defined(CONFIG_SYS_EBC_PB4CR))
80 # define PBxAP_VAL CONFIG_SYS_EBC_PB4AP
81 # define PBxCR_VAL CONFIG_SYS_EBC_PB4CR
84 # if (CONFIG_SYS_INIT_DCACHE_CS == 5)
87 # if (defined(CONFIG_SYS_EBC_PB5AP) && defined(CONFIG_SYS_EBC_PB5CR))
88 # define PBxAP_VAL CONFIG_SYS_EBC_PB5AP
89 # define PBxCR_VAL CONFIG_SYS_EBC_PB5CR
92 # if (CONFIG_SYS_INIT_DCACHE_CS == 6)
95 # if (defined(CONFIG_SYS_EBC_PB6AP) && defined(CONFIG_SYS_EBC_PB6CR))
96 # define PBxAP_VAL CONFIG_SYS_EBC_PB6AP
97 # define PBxCR_VAL CONFIG_SYS_EBC_PB6CR
100 # if (CONFIG_SYS_INIT_DCACHE_CS == 7)
103 # if (defined(CONFIG_SYS_EBC_PB7AP) && defined(CONFIG_SYS_EBC_PB7CR))
104 # define PBxAP_VAL CONFIG_SYS_EBC_PB7AP
105 # define PBxCR_VAL CONFIG_SYS_EBC_PB7CR
115 * Memory Bank x (nothingness) initialization CONFIG_SYS_INIT_RAM_ADDR + 64 MiB
116 * used as temporary stack pointer for the primordial stack
118 # ifndef CONFIG_SYS_INIT_DCACHE_PBxAR
119 # define CONFIG_SYS_INIT_DCACHE_PBxAR (EBC_BXAP_BME_DISABLED | \
120 EBC_BXAP_TWT_ENCODE(7) | \
121 EBC_BXAP_BCE_DISABLE | \
122 EBC_BXAP_BCT_2TRANS | \
123 EBC_BXAP_CSN_ENCODE(0) | \
124 EBC_BXAP_OEN_ENCODE(0) | \
125 EBC_BXAP_WBN_ENCODE(0) | \
126 EBC_BXAP_WBF_ENCODE(0) | \
127 EBC_BXAP_TH_ENCODE(2) | \
128 EBC_BXAP_RE_DISABLED | \
129 EBC_BXAP_SOR_NONDELAYED | \
130 EBC_BXAP_BEM_WRITEONLY | \
131 EBC_BXAP_PEN_DISABLED)
132 # endif /* CONFIG_SYS_INIT_DCACHE_PBxAR */
133 # ifndef CONFIG_SYS_INIT_DCACHE_PBxCR
134 # define CONFIG_SYS_INIT_DCACHE_PBxCR (EBC_BXCR_BAS_ENCODE(CONFIG_SYS_INIT_RAM_ADDR) | \
138 # endif /* CONFIG_SYS_INIT_DCACHE_PBxCR */
139 # ifndef CONFIG_SYS_INIT_RAM_PATTERN
140 # define CONFIG_SYS_INIT_RAM_PATTERN 0xDEADDEAD
142 #endif /* CONFIG_SYS_INIT_DCACHE_CS */
144 #if (defined(CONFIG_SYS_INIT_RAM_DCACHE) && (CONFIG_SYS_INIT_RAM_SIZE > (4 << 10)))
145 #error Only 4k of init-ram is supported - please adjust CONFIG_SYS_INIT_RAM_SIZE!
149 * Unless otherwise overriden, enable two 128MB cachable instruction regions
150 * at CONFIG_SYS_SDRAM_BASE and another 128MB cacheable instruction region covering
151 * NOR flash at CONFIG_SYS_FLASH_BASE. Disable all cacheable data regions.
153 #if !defined(CONFIG_SYS_FLASH_BASE)
154 /* If not already defined, set it to the "last" 128MByte region */
155 # define CONFIG_SYS_FLASH_BASE 0xf8000000
157 #if !defined(CONFIG_SYS_ICACHE_SACR_VALUE)
158 # define CONFIG_SYS_ICACHE_SACR_VALUE \
159 (PPC_128MB_SACR_VALUE(CONFIG_SYS_SDRAM_BASE + ( 0 << 20)) | \
160 PPC_128MB_SACR_VALUE(CONFIG_SYS_SDRAM_BASE + (128 << 20)) | \
161 PPC_128MB_SACR_VALUE(CONFIG_SYS_FLASH_BASE))
162 #endif /* !defined(CONFIG_SYS_ICACHE_SACR_VALUE) */
164 #if !defined(CONFIG_SYS_DCACHE_SACR_VALUE)
165 # define CONFIG_SYS_DCACHE_SACR_VALUE \
167 #endif /* !defined(CONFIG_SYS_DCACHE_SACR_VALUE) */
169 #if !defined(CONFIG_SYS_TLB_FOR_BOOT_FLASH)
170 #define CONFIG_SYS_TLB_FOR_BOOT_FLASH 0 /* use TLB 0 as default */
173 #define function_prolog(func_name) .text; \
177 #define function_epilog(func_name) .type func_name,@function; \
178 .size func_name,.-func_name
180 /* We don't want the MMU yet.
183 #define MSR_KERNEL ( MSR_ME ) /* Machine Check */
186 .extern ext_bus_cntlr_init
187 #ifdef CONFIG_NAND_U_BOOT
188 .extern reconfig_tlb0
192 * Set up GOT: Global Offset Table
194 * Use r12 to access the GOT
196 #if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD)
198 GOT_ENTRY(_GOT2_TABLE_)
199 GOT_ENTRY(_FIXUP_TABLE_)
202 GOT_ENTRY(_start_of_vectors)
203 GOT_ENTRY(_end_of_vectors)
204 GOT_ENTRY(transfer_to_handler)
206 GOT_ENTRY(__init_end)
208 GOT_ENTRY(__bss_start)
210 #endif /* CONFIG_NAND_SPL */
212 #if defined(CONFIG_NAND_U_BOOT) && !defined(CONFIG_NAND_SPL) && \
213 !defined(CONFIG_SPL_BUILD)
215 * NAND U-Boot image is started from offset 0
218 #if defined(CONFIG_440)
222 bl cpu_init_f /* run low-level CPU init code (from Flash) */
224 /* NOTREACHED - board_init_f() does not return */
227 #if defined(CONFIG_SYS_RAMBOOT) || defined(CONFIG_BOOT_FROM_XMD)
229 * 4xx RAM-booting U-Boot image is started from offset 0
235 #if defined(CONFIG_SPL) && !defined(CONFIG_SPL_BUILD)
237 * This is the entry of the real U-Boot from a board port
238 * that supports SPL booting on the PPC4xx. We only need
239 * to call board_init_f() here. Everything else has already
240 * been done in the SPL u-boot version.
242 GET_GOT /* initialize GOT access */
243 bl board_init_f /* run 1st part of board init code (in Flash)*/
244 /* NOTREACHED - board_init_f() does not return */
248 * 440 Startup -- on reset only the top 4k of the effective
249 * address space is mapped in by an entry in the instruction
250 * and data shadow TLB. The .bootpg section is located in the
251 * top 4k & does only what's necessary to map in the the rest
252 * of the boot rom. Once the boot rom is mapped in we can
253 * proceed with normal startup.
255 * NOTE: CS0 only covers the top 2MB of the effective address
259 #if defined(CONFIG_440)
260 #if !defined(CONFIG_NAND_SPL)
261 .section .bootpg,"ax"
265 /**************************************************************************/
267 /*--------------------------------------------------------------------+
268 | 440EPX BUP Change - Hardware team request
269 +--------------------------------------------------------------------*/
270 #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
275 /*----------------------------------------------------------------+
276 | Core bug fix. Clear the esr
277 +-----------------------------------------------------------------*/
280 /*----------------------------------------------------------------*/
281 /* Clear and set up some registers. */
282 /*----------------------------------------------------------------*/
283 iccci r0,r0 /* NOTE: operands not used for 440 */
284 dccci r0,r0 /* NOTE: operands not used for 440 */
291 /* NOTE: 440GX adds machine check status regs */
292 #if defined(CONFIG_440) && !defined(CONFIG_440GP)
299 /*----------------------------------------------------------------*/
301 /*----------------------------------------------------------------*/
302 /* Disable store gathering & broadcast, guarantee inst/data
303 * cache block touch, force load/store alignment
304 * (see errata 1.12: 440_33)
306 lis r1,0x0030 /* store gathering & broadcast disable */
307 ori r1,r1,0x6000 /* cache touch */
310 /*----------------------------------------------------------------*/
311 /* Initialize debug */
312 /*----------------------------------------------------------------*/
314 andis. r1, r1, 0x8000 /* test DBCR0[EDM] bit */
315 bne skip_debug_init /* if set, don't clear debug register */
317 ori r1,r1,CCR0_DTB@l /* Disable Trace Broadcast */
331 mtspr SPRN_DBSR,r1 /* Clear all valid bits */
334 #if defined (CONFIG_440SPE)
335 /*----------------------------------------------------------------+
336 | Initialize Core Configuration Reg1.
337 | a. ICDPEI: Record even parity. Normal operation.
338 | b. ICTPEI: Record even parity. Normal operation.
339 | c. DCTPEI: Record even parity. Normal operation.
340 | d. DCDPEI: Record even parity. Normal operation.
341 | e. DCUPEI: Record even parity. Normal operation.
342 | f. DCMPEI: Record even parity. Normal operation.
343 | g. FCOM: Normal operation
344 | h. MMUPEI: Record even parity. Normal operation.
345 | i. FFF: Flush only as much data as necessary.
346 | j. TCS: Timebase increments from CPU clock.
347 +-----------------------------------------------------------------*/
351 /*----------------------------------------------------------------+
352 | Reset the timebase.
353 | The previous write to CCR1 sets the timebase source.
354 +-----------------------------------------------------------------*/
359 /*----------------------------------------------------------------*/
360 /* Setup interrupt vectors */
361 /*----------------------------------------------------------------*/
362 mtspr SPRN_IVPR,r0 /* Vectors start at 0x0000_0000 */
364 mtspr SPRN_IVOR0,r1 /* Critical input */
366 mtspr SPRN_IVOR1,r1 /* Machine check */
368 mtspr SPRN_IVOR2,r1 /* Data storage */
370 mtspr SPRN_IVOR3,r1 /* Instruction storage */
372 mtspr SPRN_IVOR4,r1 /* External interrupt */
374 mtspr SPRN_IVOR5,r1 /* Alignment */
376 mtspr SPRN_IVOR6,r1 /* Program check */
378 mtspr SPRN_IVOR7,r1 /* Floating point unavailable */
380 mtspr SPRN_IVOR8,r1 /* System call */
382 mtspr SPRN_IVOR9,r1 /* Auxiliary Processor unavailable */
384 mtspr SPRN_IVOR10,r1 /* Decrementer */
386 mtspr SPRN_IVOR13,r1 /* Data TLB error */
388 mtspr SPRN_IVOR14,r1 /* Instr TLB error */
390 mtspr SPRN_IVOR15,r1 /* Debug */
392 /*----------------------------------------------------------------*/
393 /* Configure cache regions */
394 /*----------------------------------------------------------------*/
412 /*----------------------------------------------------------------*/
413 /* Cache victim limits */
414 /*----------------------------------------------------------------*/
415 /* floors 0, ceiling max to use the entire cache -- nothing locked
422 /*----------------------------------------------------------------+
423 |Initialize MMUCR[STID] = 0.
424 +-----------------------------------------------------------------*/
431 /*----------------------------------------------------------------*/
432 /* Clear all TLB entries -- TID = 0, TS = 0 */
433 /*----------------------------------------------------------------*/
435 #ifdef CONFIG_SYS_RAMBOOT
436 li r4,0 /* Start with TLB #0 */
438 li r4,1 /* Start with TLB #1 */
440 li r1,64 /* 64 TLB entries */
441 sub r1,r1,r4 /* calculate last TLB # */
444 #ifdef CONFIG_SYS_RAMBOOT
445 tlbre r3,r4,0 /* Read contents from TLB word #0 to get EPN */
446 rlwinm. r3,r3,0,0xfffffc00 /* Mask EPN */
447 beq tlbnxt /* Skip EPN=0 TLB, this is the SDRAM TLB */
449 tlbwe r0,r4,0 /* Invalidate all entries (V=0)*/
452 tlbnxt: addi r4,r4,1 /* Next TLB */
455 /*----------------------------------------------------------------*/
456 /* TLB entry setup -- step thru tlbtab */
457 /*----------------------------------------------------------------*/
458 #if defined(CONFIG_440SPE_REVA)
459 /*----------------------------------------------------------------*/
460 /* We have different TLB tables for revA and rev B of 440SPe */
461 /*----------------------------------------------------------------*/
473 bl tlbtab /* Get tlbtab pointer */
476 li r1,0x003f /* 64 TLB entries max */
482 #ifdef CONFIG_SYS_RAMBOOT
483 tlbre r3,r4,0 /* Read contents from TLB word #0 */
484 rlwinm. r3,r3,0,0x00000200 /* Mask V (valid) bit */
485 bne tlbnx2 /* Skip V=1 TLB, this is the SDRAM TLB */
489 beq 2f /* 0 marks end */
492 tlbwe r0,r4,0 /* TLB Word 0 */
493 tlbwe r1,r4,1 /* TLB Word 1 */
494 tlbwe r2,r4,2 /* TLB Word 2 */
495 tlbnx2: addi r4,r4,1 /* Next TLB */
498 /*----------------------------------------------------------------*/
499 /* Continue from 'normal' start */
500 /*----------------------------------------------------------------*/
506 mtspr SPRN_SRR1,r0 /* Keep things disabled for now */
510 #endif /* CONFIG_440 */
513 * r3 - 1st arg to board_init(): IMMP pointer
514 * r4 - 2nd arg to board_init(): boot flag
516 #if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD)
518 .long 0x27051956 /* U-Boot Magic Number */
519 .globl version_string
521 .ascii U_BOOT_VERSION_STRING, "\0"
523 . = EXC_OFF_SYS_RESET
524 .globl _start_of_vectors
527 /* Critical input. */
528 CRIT_EXCEPTION(0x100, CritcalInput, UnknownException)
532 MCK_EXCEPTION(0x200, MachineCheck, MachineCheckException)
534 CRIT_EXCEPTION(0x200, MachineCheck, MachineCheckException)
535 #endif /* CONFIG_440 */
537 /* Data Storage exception. */
538 STD_EXCEPTION(0x300, DataStorage, UnknownException)
540 /* Instruction Storage exception. */
541 STD_EXCEPTION(0x400, InstStorage, UnknownException)
543 /* External Interrupt exception. */
544 STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
546 /* Alignment exception. */
549 EXCEPTION_PROLOG(SRR0, SRR1)
554 addi r3,r1,STACK_FRAME_OVERHEAD
555 EXC_XFER_TEMPLATE(Alignment, AlignmentException, MSR_KERNEL, COPY_EE)
557 /* Program check exception */
560 EXCEPTION_PROLOG(SRR0, SRR1)
561 addi r3,r1,STACK_FRAME_OVERHEAD
562 EXC_XFER_TEMPLATE(ProgramCheck, ProgramCheckException,
566 STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
567 STD_EXCEPTION(0x900, Decrementer, DecrementerPITException)
568 STD_EXCEPTION(0xa00, APU, UnknownException)
570 STD_EXCEPTION(0xc00, SystemCall, UnknownException)
573 STD_EXCEPTION(0x1300, DataTLBError, UnknownException)
574 STD_EXCEPTION(0x1400, InstructionTLBError, UnknownException)
576 STD_EXCEPTION(0x1000, PIT, DecrementerPITException)
577 STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException)
578 STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException)
580 CRIT_EXCEPTION(0x2000, DebugBreakpoint, DebugException )
582 .globl _end_of_vectors
589 #if defined(CONFIG_SPL) && !defined(CONFIG_SPL_BUILD)
591 * This is the entry of the real U-Boot from a board port
592 * that supports SPL booting on the PPC4xx. We only need
593 * to call board_init_f() here. Everything else has already
594 * been done in the SPL u-boot version.
596 GET_GOT /* initialize GOT access */
597 bl board_init_f /* run 1st part of board init code (in Flash)*/
598 /* NOTREACHED - board_init_f() does not return */
601 /*****************************************************************************/
602 #if defined(CONFIG_440)
604 /*----------------------------------------------------------------*/
605 /* Clear and set up some registers. */
606 /*----------------------------------------------------------------*/
609 mtspr SPRN_DEC,r0 /* prevent dec exceptions */
610 mtspr SPRN_TBWL,r0 /* prevent fit & wdt exceptions */
612 mtspr SPRN_TSR,r1 /* clear all timer exception status */
613 mtspr SPRN_TCR,r0 /* disable all */
614 mtspr SPRN_ESR,r0 /* clear exception syndrome register */
615 mtxer r0 /* clear integer exception register */
617 /*----------------------------------------------------------------*/
618 /* Debug setup -- some (not very good) ice's need an event*/
619 /* to establish control :-( Define CONFIG_SYS_INIT_DBCR to the dbsr */
620 /* value you need in this case 0x8cff 0000 should do the trick */
621 /*----------------------------------------------------------------*/
622 #if defined(CONFIG_SYS_INIT_DBCR)
625 mtspr SPRN_DBSR,r1 /* Clear all status bits */
626 lis r0,CONFIG_SYS_INIT_DBCR@h
627 ori r0,r0,CONFIG_SYS_INIT_DBCR@l
632 /*----------------------------------------------------------------*/
633 /* Setup the internal SRAM */
634 /*----------------------------------------------------------------*/
637 #ifdef CONFIG_SYS_INIT_RAM_DCACHE
638 /* Clear Dcache to use as RAM */
639 addis r3,r0,CONFIG_SYS_INIT_RAM_ADDR@h
640 ori r3,r3,CONFIG_SYS_INIT_RAM_ADDR@l
641 addis r4,r0,CONFIG_SYS_INIT_RAM_SIZE@h
642 ori r4,r4,CONFIG_SYS_INIT_RAM_SIZE@l
643 rlwinm. r5,r4,0,27,31
655 * Lock the init-ram/stack in d-cache, so that other regions
656 * may use d-cache as well
657 * Note, that this current implementation locks exactly 4k
658 * of d-cache, so please make sure that you don't define a
659 * bigger init-ram area. Take a look at the lwmon5 440EPx
660 * implementation as a reference.
664 /* 8. set TFLOOR/NFLOOR to 8 (-> 8*16*32 bytes locked -> 4k) */
680 #endif /* CONFIG_SYS_INIT_RAM_DCACHE */
682 /* 440EP & 440GR are only 440er PPC's without internal SRAM */
683 #if !defined(CONFIG_440EP) && !defined(CONFIG_440GR)
684 /* not all PPC's have internal SRAM usable as L2-cache */
685 #if defined(CONFIG_440GX) || \
686 defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
687 defined(CONFIG_460SX)
688 mtdcr L2_CACHE_CFG,r0 /* Ensure L2 Cache is off */
689 #elif defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
690 defined(CONFIG_APM821XX)
692 ori r1,r1,0x0008 /* Set L2_CACHE_CFG[RDBW]=1 */
693 mtdcr L2_CACHE_CFG,r1
699 and r1,r1,r2 /* Disable parity check */
702 and r1,r1,r2 /* Disable pwr mgmt */
705 lis r1,0x8000 /* BAS = 8000_0000 */
706 #if defined(CONFIG_440GX) || defined(CONFIG_440SP)
707 ori r1,r1,0x0980 /* first 64k */
708 mtdcr ISRAM0_SB0CR,r1
710 ori r1,r1,0x0980 /* second 64k */
711 mtdcr ISRAM0_SB1CR,r1
713 ori r1,r1, 0x0980 /* third 64k */
714 mtdcr ISRAM0_SB2CR,r1
716 ori r1,r1, 0x0980 /* fourth 64k */
717 mtdcr ISRAM0_SB3CR,r1
718 #elif defined(CONFIG_440SPE) || defined(CONFIG_460EX) || \
719 defined(CONFIG_460GT) || defined(CONFIG_APM821XX)
720 lis r1,0x0000 /* BAS = X_0000_0000 */
721 ori r1,r1,0x0984 /* first 64k */
722 mtdcr ISRAM0_SB0CR,r1
724 ori r1,r1,0x0984 /* second 64k */
725 mtdcr ISRAM0_SB1CR,r1
727 ori r1,r1, 0x0984 /* third 64k */
728 mtdcr ISRAM0_SB2CR,r1
730 ori r1,r1, 0x0984 /* fourth 64k */
731 mtdcr ISRAM0_SB3CR,r1
732 #if defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
733 defined(CONFIG_APM821XX)
737 and r1,r1,r2 /* Disable parity check */
740 and r1,r1,r2 /* Disable pwr mgmt */
743 lis r1,0x0004 /* BAS = 4_0004_0000 */
744 ori r1,r1,ISRAM1_SIZE /* ocm size */
745 mtdcr ISRAM1_SB0CR,r1
747 #elif defined(CONFIG_460SX)
748 lis r1,0x0000 /* BAS = 0000_0000 */
749 ori r1,r1,0x0B84 /* first 128k */
750 mtdcr ISRAM0_SB0CR,r1
752 ori r1,r1,0x0B84 /* second 128k */
753 mtdcr ISRAM0_SB1CR,r1
755 ori r1,r1, 0x0B84 /* third 128k */
756 mtdcr ISRAM0_SB2CR,r1
758 ori r1,r1, 0x0B84 /* fourth 128k */
759 mtdcr ISRAM0_SB3CR,r1
760 #elif defined(CONFIG_440GP)
761 ori r1,r1,0x0380 /* 8k rw */
762 mtdcr ISRAM0_SB0CR,r1
763 mtdcr ISRAM0_SB1CR,r0 /* Disable bank 1 */
765 #endif /* #if !defined(CONFIG_440EP) && !defined(CONFIG_440GR) */
767 /*----------------------------------------------------------------*/
768 /* Setup the stack in internal SRAM */
769 /*----------------------------------------------------------------*/
770 lis r1,CONFIG_SYS_INIT_RAM_ADDR@h
771 ori r1,r1,CONFIG_SYS_INIT_SP_OFFSET@l
774 stwu r0,-4(r1) /* Terminate call chain */
776 stwu r1,-8(r1) /* Save back chain and move SP */
777 lis r0,RESET_VECTOR@h /* Address of reset vector */
778 ori r0,r0, RESET_VECTOR@l
779 stwu r1,-8(r1) /* Save back chain and move SP */
780 stw r0,+12(r1) /* Save return addr (underflow vect) */
782 #ifdef CONFIG_NAND_SPL
783 bl nand_boot_common /* will not return */
785 #ifndef CONFIG_SPL_BUILD
789 bl cpu_init_f /* run low-level CPU init code (from Flash) */
791 /* NOTREACHED - board_init_f() does not return */
794 #endif /* CONFIG_440 */
796 /*****************************************************************************/
797 #if defined(CONFIG_405GP) || \
798 defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \
799 defined(CONFIG_405EX) || defined(CONFIG_405)
800 /*----------------------------------------------------------------------- */
801 /* Clear and set up some registers. */
802 /*----------------------------------------------------------------------- */
804 #if !defined(CONFIG_405EX)
808 * On 405EX, completely clearing the SGR leads to PPC hangup
809 * upon PCIe configuration access. The PCIe memory regions
810 * need to be guarded!
817 mtesr r4 /* clear Exception Syndrome Reg */
818 mttcr r4 /* clear Timer Control Reg */
819 mtxer r4 /* clear Fixed-Point Exception Reg */
820 mtevpr r4 /* clear Exception Vector Prefix Reg */
821 addi r4,r0,(0xFFFF-0x10000) /* set r4 to 0xFFFFFFFF (status in the */
822 /* dbsr is cleared by setting bits to 1) */
823 mtdbsr r4 /* clear/reset the dbsr */
825 /* Invalidate the i- and d-caches. */
829 /* Set-up icache cacheability. */
830 lis r4, CONFIG_SYS_ICACHE_SACR_VALUE@h
831 ori r4, r4, CONFIG_SYS_ICACHE_SACR_VALUE@l
835 /* Set-up dcache cacheability. */
836 lis r4, CONFIG_SYS_DCACHE_SACR_VALUE@h
837 ori r4, r4, CONFIG_SYS_DCACHE_SACR_VALUE@l
840 #if !(defined(CONFIG_SYS_EBC_PB0AP) && defined(CONFIG_SYS_EBC_PB0CR))\
841 && !defined (CONFIG_XILINX_405)
842 /*----------------------------------------------------------------------- */
843 /* Tune the speed and size for flash CS0 */
844 /*----------------------------------------------------------------------- */
845 bl ext_bus_cntlr_init
848 #if !(defined(CONFIG_SYS_INIT_DCACHE_CS) || defined(CONFIG_SYS_TEMP_STACK_OCM))
850 * For boards that don't have OCM and can't use the data cache
851 * for their primordial stack, setup stack here directly after the
852 * SDRAM is initialized in ext_bus_cntlr_init.
854 lis r1, CONFIG_SYS_INIT_RAM_ADDR@h
855 ori r1,r1,CONFIG_SYS_INIT_SP_OFFSET /* set up the stack in SDRAM */
857 li r0, 0 /* Make room for stack frame header and */
858 stwu r0, -4(r1) /* clear final stack frame so that */
859 stwu r0, -4(r1) /* stack backtraces terminate cleanly */
861 * Set up a dummy frame to store reset vector as return address.
862 * this causes stack underflow to reset board.
864 stwu r1, -8(r1) /* Save back chain and move SP */
865 lis r0, RESET_VECTOR@h /* Address of reset vector */
866 ori r0, r0, RESET_VECTOR@l
867 stwu r1, -8(r1) /* Save back chain and move SP */
868 stw r0, +12(r1) /* Save return addr (underflow vect) */
869 #endif /* !(CONFIG_SYS_INIT_DCACHE_CS || !CONFIG_SYS_TEM_STACK_OCM) */
871 #if defined(CONFIG_405EP)
872 /*----------------------------------------------------------------------- */
873 /* DMA Status, clear to come up clean */
874 /*----------------------------------------------------------------------- */
875 addis r3,r0, 0xFFFF /* Clear all existing DMA status */
879 bl ppc405ep_init /* do ppc405ep specific init */
880 #endif /* CONFIG_405EP */
882 #if defined(CONFIG_SYS_OCM_DATA_ADDR) && defined(CONFIG_SYS_OCM_DATA_SIZE)
883 #if defined(CONFIG_405EZ)
884 /********************************************************************
885 * Setup OCM - On Chip Memory - PPC405EZ uses OCM Controller V2
886 *******************************************************************/
888 * We can map the OCM on the PLB3, so map it at
889 * CONFIG_SYS_OCM_DATA_ADDR + 0x8000
891 lis r3,CONFIG_SYS_OCM_DATA_ADDR@h /* OCM location */
892 ori r3,r3,CONFIG_SYS_OCM_DATA_ADDR@l
893 ori r3,r3,0x0270 /* 16K for Bank 1, R/W/Enable */
894 mtdcr OCM0_PLBCR1,r3 /* Set PLB Access */
895 ori r3,r3,0x4000 /* Add 0x4000 for bank 2 */
896 mtdcr OCM0_PLBCR2,r3 /* Set PLB Access */
899 lis r3,CONFIG_SYS_OCM_DATA_ADDR@h /* OCM location */
900 ori r3,r3,CONFIG_SYS_OCM_DATA_ADDR@l
901 ori r3,r3,0x0270 /* 16K for Bank 1, R/W/Enable */
902 mtdcr OCM0_DSRC1, r3 /* Set Data Side */
903 mtdcr OCM0_ISRC1, r3 /* Set Instruction Side */
904 ori r3,r3,0x4000 /* Add 0x4000 for bank 2 */
905 mtdcr OCM0_DSRC2, r3 /* Set Data Side */
906 mtdcr OCM0_ISRC2, r3 /* Set Instruction Side */
907 addis r3,0,0x0800 /* OCM Data Parity Disable - 1 Wait State */
911 #else /* CONFIG_405EZ */
912 /********************************************************************
913 * Setup OCM - On Chip Memory
914 *******************************************************************/
918 mfdcr r3, OCM0_ISCNTL /* get instr-side IRAM config */
919 mfdcr r4, OCM0_DSCNTL /* get data-side IRAM config */
920 and r3, r3, r0 /* disable data-side IRAM */
921 and r4, r4, r0 /* disable data-side IRAM */
922 mtdcr OCM0_ISCNTL, r3 /* set instr-side IRAM config */
923 mtdcr OCM0_DSCNTL, r4 /* set data-side IRAM config */
926 lis r3,CONFIG_SYS_OCM_DATA_ADDR@h /* OCM location */
927 ori r3,r3,CONFIG_SYS_OCM_DATA_ADDR@l
929 addis r4, 0, 0xC000 /* OCM data area enabled */
930 mtdcr OCM0_DSCNTL, r4
932 #endif /* CONFIG_405EZ */
935 /*----------------------------------------------------------------------- */
936 /* Setup temporary stack in DCACHE or OCM if needed for SDRAM SPD. */
937 /*----------------------------------------------------------------------- */
938 #ifdef CONFIG_SYS_INIT_DCACHE_CS
940 mtdcr EBC0_CFGADDR, r4
941 lis r4, CONFIG_SYS_INIT_DCACHE_PBxAR@h
942 ori r4, r4, CONFIG_SYS_INIT_DCACHE_PBxAR@l
943 mtdcr EBC0_CFGDATA, r4
946 mtdcr EBC0_CFGADDR, r4
947 lis r4, CONFIG_SYS_INIT_DCACHE_PBxCR@h
948 ori r4, r4, CONFIG_SYS_INIT_DCACHE_PBxCR@l
949 mtdcr EBC0_CFGDATA, r4
952 * Enable the data cache for the 128MB storage access control region
953 * at CONFIG_SYS_INIT_RAM_ADDR.
956 oris r4, r4, PPC_128MB_SACR_VALUE(CONFIG_SYS_INIT_RAM_ADDR)@h
957 ori r4, r4, PPC_128MB_SACR_VALUE(CONFIG_SYS_INIT_RAM_ADDR)@l
961 * Preallocate data cache lines to be used to avoid a subsequent
962 * cache miss and an ensuing machine check exception when exceptions
967 lis r3, CONFIG_SYS_INIT_RAM_ADDR@h
968 ori r3, r3, CONFIG_SYS_INIT_RAM_ADDR@l
970 lis r4, CONFIG_SYS_INIT_RAM_SIZE@h
971 ori r4, r4, CONFIG_SYS_INIT_RAM_SIZE@l
974 * Convert the size, in bytes, to the number of cache lines/blocks
977 clrlwi. r5, r4, (32 - L1_CACHE_SHIFT)
978 srwi r5, r4, L1_CACHE_SHIFT
984 /* Preallocate the computed number of cache blocks. */
985 ..alloc_dcache_block:
987 addi r3, r3, L1_CACHE_BYTES
988 bdnz ..alloc_dcache_block
992 * Load the initial stack pointer and data area and convert the size,
993 * in bytes, to the number of words to initialize to a known value.
995 lis r1, CONFIG_SYS_INIT_RAM_ADDR@h
996 ori r1, r1, CONFIG_SYS_INIT_SP_OFFSET@l
998 lis r4, (CONFIG_SYS_INIT_RAM_SIZE >> 2)@h
999 ori r4, r4, (CONFIG_SYS_INIT_RAM_SIZE >> 2)@l
1002 lis r2, CONFIG_SYS_INIT_RAM_ADDR@h
1003 ori r2, r2, CONFIG_SYS_INIT_RAM_SIZE@l
1005 lis r4, CONFIG_SYS_INIT_RAM_PATTERN@h
1006 ori r4, r4, CONFIG_SYS_INIT_RAM_PATTERN@l
1013 * Make room for stack frame header and clear final stack frame so
1014 * that stack backtraces terminate cleanly.
1020 * Set up a dummy frame to store reset vector as return address.
1021 * this causes stack underflow to reset board.
1023 stwu r1, -8(r1) /* Save back chain and move SP */
1024 addis r0, 0, RESET_VECTOR@h /* Address of reset vector */
1025 ori r0, r0, RESET_VECTOR@l
1026 stwu r1, -8(r1) /* Save back chain and move SP */
1027 stw r0, +12(r1) /* Save return addr (underflow vect) */
1029 #elif defined(CONFIG_SYS_TEMP_STACK_OCM) && \
1030 (defined(CONFIG_SYS_OCM_DATA_ADDR) && defined(CONFIG_SYS_OCM_DATA_SIZE))
1035 /* Set up Stack at top of OCM */
1036 lis r1, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)@h
1037 ori r1, r1, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)@l
1039 /* Set up a zeroized stack frame so that backtrace works right */
1045 * Set up a dummy frame to store reset vector as return address.
1046 * this causes stack underflow to reset board.
1048 stwu r1, -8(r1) /* Save back chain and move SP */
1049 lis r0, RESET_VECTOR@h /* Address of reset vector */
1050 ori r0, r0, RESET_VECTOR@l
1051 stwu r1, -8(r1) /* Save back chain and move SP */
1052 stw r0, +12(r1) /* Save return addr (underflow vect) */
1053 #endif /* CONFIG_SYS_INIT_DCACHE_CS */
1055 #ifdef CONFIG_NAND_SPL
1056 bl nand_boot_common /* will not return */
1058 GET_GOT /* initialize GOT access */
1060 bl cpu_init_f /* run low-level CPU init code (from Flash) */
1062 bl board_init_f /* run first part of init code (from Flash) */
1063 /* NOTREACHED - board_init_f() does not return */
1065 #endif /* CONFIG_NAND_SPL */
1067 #endif /* CONFIG_405GP || CONFIG_405 || CONFIG_405EP */
1068 /*----------------------------------------------------------------------- */
1071 #if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD)
1073 * This code finishes saving the registers to the exception frame
1074 * and jumps to the appropriate handler for the exception.
1075 * Register r21 is pointer into trap frame, r1 has new stack pointer.
1077 .globl transfer_to_handler
1078 transfer_to_handler:
1088 andi. r24,r23,0x3f00 /* get vector offset */
1092 mtspr SPRG2,r22 /* r1 is now kernel sp */
1093 lwz r24,0(r23) /* virtual address of handler */
1094 lwz r23,4(r23) /* where to go when done */
1099 rfi /* jump to handler, enable MMU */
1102 mfmsr r28 /* Disable interrupts */
1106 SYNC /* Some chip revs need this... */
1121 lwz r2,_NIP(r1) /* Restore environment */
1132 mfmsr r28 /* Disable interrupts */
1136 SYNC /* Some chip revs need this... */
1151 lwz r2,_NIP(r1) /* Restore environment */
1163 mfmsr r28 /* Disable interrupts */
1167 SYNC /* Some chip revs need this... */
1182 lwz r2,_NIP(r1) /* Restore environment */
1184 mtspr SPRN_MCSRR0,r2
1185 mtspr SPRN_MCSRR1,r0
1191 #endif /* CONFIG_440 */
1199 /*------------------------------------------------------------------------------- */
1200 /* Function: out16 */
1201 /* Description: Output 16 bits */
1202 /*------------------------------------------------------------------------------- */
1208 /*------------------------------------------------------------------------------- */
1209 /* Function: out16r */
1210 /* Description: Byte reverse and output 16 bits */
1211 /*------------------------------------------------------------------------------- */
1217 /*------------------------------------------------------------------------------- */
1218 /* Function: out32r */
1219 /* Description: Byte reverse and output 32 bits */
1220 /*------------------------------------------------------------------------------- */
1226 /*------------------------------------------------------------------------------- */
1227 /* Function: in16 */
1228 /* Description: Input 16 bits */
1229 /*------------------------------------------------------------------------------- */
1235 /*------------------------------------------------------------------------------- */
1236 /* Function: in16r */
1237 /* Description: Input 16 bits and byte reverse */
1238 /*------------------------------------------------------------------------------- */
1244 /*------------------------------------------------------------------------------- */
1245 /* Function: in32r */
1246 /* Description: Input 32 bits and byte reverse */
1247 /*------------------------------------------------------------------------------- */
1253 #if !defined(CONFIG_SPL_BUILD)
1255 * void relocate_code (addr_sp, gd, addr_moni)
1257 * This "function" does not return, instead it continues in RAM
1258 * after relocating the monitor code.
1260 * r3 = Relocated stack pointer
1261 * r4 = Relocated global data pointer
1262 * r5 = Relocated text pointer
1264 .globl relocate_code
1266 #if defined(CONFIG_4xx_DCACHE) || defined(CONFIG_SYS_INIT_DCACHE_CS)
1268 * We need to flush the initial global data (gd_t) and bd_info
1269 * before the dcache will be invalidated.
1272 /* Save registers */
1278 * Flush complete dcache, this is faster than flushing the
1279 * ranges for global_data and bd_info instead.
1283 #if defined(CONFIG_SYS_INIT_DCACHE_CS)
1285 * Undo the earlier data cache set-up for the primordial stack and
1286 * data area. First, invalidate the data cache and then disable data
1287 * cacheability for that area. Finally, restore the EBC values, if
1291 /* Invalidate the primordial stack and data area in cache */
1292 lis r3, CONFIG_SYS_INIT_RAM_ADDR@h
1293 ori r3, r3, CONFIG_SYS_INIT_RAM_ADDR@l
1295 lis r4, CONFIG_SYS_INIT_RAM_SIZE@h
1296 ori r4, r4, CONFIG_SYS_INIT_RAM_SIZE@l
1299 bl invalidate_dcache_range
1301 /* Disable cacheability for the region */
1303 lis r4, ~PPC_128MB_SACR_VALUE(CONFIG_SYS_INIT_RAM_ADDR)@h
1304 ori r4, r4, ~PPC_128MB_SACR_VALUE(CONFIG_SYS_INIT_RAM_ADDR)@l
1308 /* Restore the EBC parameters */
1310 mtdcr EBC0_CFGADDR, r3
1312 ori r3, r3, PBxAP_VAL@l
1313 mtdcr EBC0_CFGDATA, r3
1316 mtdcr EBC0_CFGADDR, r3
1318 ori r3, r3, PBxCR_VAL@l
1319 mtdcr EBC0_CFGDATA, r3
1320 #endif /* defined(CONFIG_SYS_INIT_DCACHE_CS) */
1322 /* Restore registers */
1326 #endif /* defined(CONFIG_4xx_DCACHE) || defined(CONFIG_SYS_INIT_DCACHE_CS) */
1328 #ifdef CONFIG_SYS_INIT_RAM_DCACHE
1330 * Unlock the previously locked d-cache
1334 /* set TFLOOR/NFLOOR to 0 again */
1351 /* Invalidate data cache, now no longer our stack */
1355 #endif /* CONFIG_SYS_INIT_RAM_DCACHE */
1358 * On some 440er platforms the cache is enabled in the first TLB (Boot-CS)
1359 * to speed up the boot process. Now this cache needs to be disabled.
1361 #if defined(CONFIG_440)
1362 /* Clear all potential pending exceptions */
1365 addi r1,r0,CONFIG_SYS_TLB_FOR_BOOT_FLASH /* Use defined TLB */
1366 tlbre r0,r1,0x0002 /* Read contents */
1367 ori r0,r0,0x0c00 /* Or in the inhibit, write through bit */
1368 tlbwe r0,r1,0x0002 /* Save it out */
1371 #endif /* defined(CONFIG_440) */
1372 mr r1, r3 /* Set new stack pointer */
1373 mr r9, r4 /* Save copy of Init Data pointer */
1374 mr r10, r5 /* Save copy of Destination Address */
1377 mr r3, r5 /* Destination Address */
1378 lis r4, CONFIG_SYS_MONITOR_BASE@h /* Source Address */
1379 ori r4, r4, CONFIG_SYS_MONITOR_BASE@l
1380 lwz r5, GOT(__init_end)
1382 li r6, L1_CACHE_BYTES /* Cache Line Size */
1387 * New GOT-PTR = (old GOT-PTR - CONFIG_SYS_MONITOR_BASE) + Destination Address
1393 /* First our own GOT */
1395 /* then the one used by the C code */
1405 beq cr1,4f /* In place copy is not necessary */
1406 beq 7f /* Protect against 0 count */
1425 * Now flush the cache: note that we must start from a cache aligned
1426 * address. Otherwise we might miss one cache line.
1430 beq 7f /* Always flush prefetch queue in any case */
1438 sync /* Wait for all dcbst to complete on bus */
1444 7: sync /* Wait for all icbi to complete on bus */
1448 * We are done. Do not return, instead branch to second part of board
1449 * initialization, now running from RAM.
1452 addi r0, r10, in_ram - _start + _START_OFFSET
1454 blr /* NEVER RETURNS! */
1459 * Relocation Function, r12 point to got2+0x8000
1461 * Adjust got2 pointers, no need to check for 0, this code
1462 * already puts a few entries in the table.
1464 li r0,__got2_entries@sectoff@l
1465 la r3,GOT(_GOT2_TABLE_)
1466 lwz r11,GOT(_GOT2_TABLE_)
1478 * Now adjust the fixups and the pointers to the fixups
1479 * in case we need to move ourselves again.
1481 li r0,__fixup_entries@sectoff@l
1482 lwz r3,GOT(_FIXUP_TABLE_)
1498 * Now clear BSS segment
1500 lwz r3,GOT(__bss_start)
1501 lwz r4,GOT(__bss_end)
1523 mr r3, r9 /* Init Data pointer */
1524 mr r4, r10 /* Destination Address */
1528 * Copy exception vector code to low memory
1531 * r7: source address, r8: end address, r9: target address
1535 mflr r4 /* save link register */
1537 lwz r7, GOT(_start_of_vectors)
1538 lwz r8, GOT(_end_of_vectors)
1540 li r9, 0x100 /* reset vector always at 0x100 */
1543 bgelr /* return if r7>=r8 - just in case */
1553 * relocate `hdlr' and `int_return' entries
1555 li r7, .L_MachineCheck - _start + _START_OFFSET
1556 li r8, Alignment - _start + _START_OFFSET
1559 addi r7, r7, 0x100 /* next exception vector */
1563 li r7, .L_Alignment - _start + _START_OFFSET
1566 li r7, .L_ProgramCheck - _start + _START_OFFSET
1570 li r7, .L_FPUnavailable - _start + _START_OFFSET
1573 li r7, .L_Decrementer - _start + _START_OFFSET
1576 li r7, .L_APU - _start + _START_OFFSET
1579 li r7, .L_InstructionTLBError - _start + _START_OFFSET
1582 li r7, .L_DataTLBError - _start + _START_OFFSET
1584 #else /* CONFIG_440 */
1585 li r7, .L_PIT - _start + _START_OFFSET
1588 li r7, .L_InstructionTLBMiss - _start + _START_OFFSET
1591 li r7, .L_DataTLBMiss - _start + _START_OFFSET
1593 #endif /* CONFIG_440 */
1595 li r7, .L_DebugBreakpoint - _start + _START_OFFSET
1598 #if !defined(CONFIG_440)
1599 addi r7,r0,0x1000 /* set ME bit (Machine Exceptions) */
1600 oris r7,r7,0x0002 /* set CE bit (Critical Exceptions) */
1601 mtmsr r7 /* change MSR */
1604 b __440_msr_continue
1607 addi r7,r0,0x1000 /* set ME bit (Machine Exceptions) */
1608 oris r7,r7,0x0002 /* set CE bit (Critical Exceptions) */
1616 mtlr r4 /* restore link register */
1618 #endif /* CONFIG_SPL_BUILD */
1620 #if defined(CONFIG_440)
1621 /*----------------------------------------------------------------------------+
1623 +----------------------------------------------------------------------------*/
1624 function_prolog(dcbz_area)
1625 rlwinm. r5,r4,0,27,31
1626 rlwinm r5,r4,27,5,31
1635 function_epilog(dcbz_area)
1636 #endif /* CONFIG_440 */
1637 #endif /* CONFIG_NAND_SPL */
1639 /*------------------------------------------------------------------------------- */
1641 /* Description: Input 8 bits */
1642 /*------------------------------------------------------------------------------- */
1648 /*------------------------------------------------------------------------------- */
1649 /* Function: out8 */
1650 /* Description: Output 8 bits */
1651 /*------------------------------------------------------------------------------- */
1657 /*------------------------------------------------------------------------------- */
1658 /* Function: out32 */
1659 /* Description: Output 32 bits */
1660 /*------------------------------------------------------------------------------- */
1666 /*------------------------------------------------------------------------------- */
1667 /* Function: in32 */
1668 /* Description: Input 32 bits */
1669 /*------------------------------------------------------------------------------- */
1675 /**************************************************************************/
1676 /* PPC405EP specific stuff */
1677 /**************************************************************************/
1681 #ifdef CONFIG_BUBINGA
1683 * Initialize EBC chip selects 1 & 4 and GPIO pins (for alternate
1684 * function) to support FPGA and NVRAM accesses below.
1687 lis r3,GPIO0_OSRH@h /* config GPIO output select */
1688 ori r3,r3,GPIO0_OSRH@l
1689 lis r4,CONFIG_SYS_GPIO0_OSRH@h
1690 ori r4,r4,CONFIG_SYS_GPIO0_OSRH@l
1693 ori r3,r3,GPIO0_OSRL@l
1694 lis r4,CONFIG_SYS_GPIO0_OSRL@h
1695 ori r4,r4,CONFIG_SYS_GPIO0_OSRL@l
1698 lis r3,GPIO0_ISR1H@h /* config GPIO input select */
1699 ori r3,r3,GPIO0_ISR1H@l
1700 lis r4,CONFIG_SYS_GPIO0_ISR1H@h
1701 ori r4,r4,CONFIG_SYS_GPIO0_ISR1H@l
1703 lis r3,GPIO0_ISR1L@h
1704 ori r3,r3,GPIO0_ISR1L@l
1705 lis r4,CONFIG_SYS_GPIO0_ISR1L@h
1706 ori r4,r4,CONFIG_SYS_GPIO0_ISR1L@l
1709 lis r3,GPIO0_TSRH@h /* config GPIO three-state select */
1710 ori r3,r3,GPIO0_TSRH@l
1711 lis r4,CONFIG_SYS_GPIO0_TSRH@h
1712 ori r4,r4,CONFIG_SYS_GPIO0_TSRH@l
1715 ori r3,r3,GPIO0_TSRL@l
1716 lis r4,CONFIG_SYS_GPIO0_TSRL@h
1717 ori r4,r4,CONFIG_SYS_GPIO0_TSRL@l
1720 lis r3,GPIO0_TCR@h /* config GPIO driver output enables */
1721 ori r3,r3,GPIO0_TCR@l
1722 lis r4,CONFIG_SYS_GPIO0_TCR@h
1723 ori r4,r4,CONFIG_SYS_GPIO0_TCR@l
1726 li r3,PB1AP /* program EBC bank 1 for RTC access */
1727 mtdcr EBC0_CFGADDR,r3
1728 lis r3,CONFIG_SYS_EBC_PB1AP@h
1729 ori r3,r3,CONFIG_SYS_EBC_PB1AP@l
1730 mtdcr EBC0_CFGDATA,r3
1732 mtdcr EBC0_CFGADDR,r3
1733 lis r3,CONFIG_SYS_EBC_PB1CR@h
1734 ori r3,r3,CONFIG_SYS_EBC_PB1CR@l
1735 mtdcr EBC0_CFGDATA,r3
1737 li r3,PB1AP /* program EBC bank 1 for RTC access */
1738 mtdcr EBC0_CFGADDR,r3
1739 lis r3,CONFIG_SYS_EBC_PB1AP@h
1740 ori r3,r3,CONFIG_SYS_EBC_PB1AP@l
1741 mtdcr EBC0_CFGDATA,r3
1743 mtdcr EBC0_CFGADDR,r3
1744 lis r3,CONFIG_SYS_EBC_PB1CR@h
1745 ori r3,r3,CONFIG_SYS_EBC_PB1CR@l
1746 mtdcr EBC0_CFGDATA,r3
1748 li r3,PB4AP /* program EBC bank 4 for FPGA access */
1749 mtdcr EBC0_CFGADDR,r3
1750 lis r3,CONFIG_SYS_EBC_PB4AP@h
1751 ori r3,r3,CONFIG_SYS_EBC_PB4AP@l
1752 mtdcr EBC0_CFGDATA,r3
1754 mtdcr EBC0_CFGADDR,r3
1755 lis r3,CONFIG_SYS_EBC_PB4CR@h
1756 ori r3,r3,CONFIG_SYS_EBC_PB4CR@l
1757 mtdcr EBC0_CFGDATA,r3
1761 !-----------------------------------------------------------------------
1762 ! Check to see if chip is in bypass mode.
1763 ! If so, write stored CPC0_PLLMR0 and CPC0_PLLMR1 values and perform a
1764 ! CPU reset Otherwise, skip this step and keep going.
1765 ! Note: Running BIOS in bypass mode is not supported since PLB speed
1766 ! will not be fast enough for the SDRAM (min 66MHz)
1767 !-----------------------------------------------------------------------
1769 mfdcr r5, CPC0_PLLMR1
1770 rlwinm r4,r5,1,0x1 /* get system clock source (SSCS) */
1773 beq pll_done /* if SSCS =b'1' then PLL has */
1774 /* already been set */
1775 /* and CPU has been reset */
1776 /* so skip to next section */
1778 #ifdef CONFIG_BUBINGA
1780 !-----------------------------------------------------------------------
1781 ! Read NVRAM to get value to write in PLLMR.
1782 ! If value has not been correctly saved, write default value
1783 ! Default config values (assuming on-board 33MHz SYS_CLK) are above.
1784 ! See CPU_DEFAULT_200 and CPU_DEFAULT_266 above.
1786 ! WARNING: This code assumes the first three words in the nvram_t
1787 ! structure in openbios.h. Changing the beginning of
1788 ! the structure will break this code.
1790 !-----------------------------------------------------------------------
1792 addis r3,0,NVRAM_BASE@h
1793 addi r3,r3,NVRAM_BASE@l
1796 addis r5,0,NVRVFY1@h
1797 addi r5,r5,NVRVFY1@l
1798 cmp cr0,0,r4,r5 /* Compare 1st NVRAM Magic number*/
1802 addis r5,0,NVRVFY2@h
1803 addi r5,r5,NVRVFY2@l
1804 cmp cr0,0,r4,r5 /* Compare 2 NVRAM Magic number */
1806 addi r3,r3,8 /* Skip over conf_size */
1807 lwz r4, 4(r3) /* Load PLLMR1 value from NVRAM */
1808 lwz r3, 0(r3) /* Load PLLMR0 value from NVRAM */
1809 rlwinm r5,r4,1,0x1 /* get system clock source (SSCS) */
1810 cmpi cr0,0,r5,1 /* See if PLL is locked */
1813 #endif /* CONFIG_BUBINGA */
1817 andi. r5, r4, CPC0_BOOT_SEP@l
1818 bne strap_1 /* serial eeprom present */
1819 addis r5,0,CPLD_REG0_ADDR@h
1820 ori r5,r5,CPLD_REG0_ADDR@l
1823 #endif /* CONFIG_TAIHU */
1825 #if defined(CONFIG_ZEUS)
1827 andi. r5, r4, CPC0_BOOT_SEP@l
1828 bne strap_1 /* serial eeprom present */
1835 mfdcr r3, CPC0_PLLMR0
1836 mfdcr r4, CPC0_PLLMR1
1840 addis r3,0,PLLMR0_DEFAULT@h /* PLLMR0 default value */
1841 ori r3,r3,PLLMR0_DEFAULT@l /* */
1842 addis r4,0,PLLMR1_DEFAULT@h /* PLLMR1 default value */
1843 ori r4,r4,PLLMR1_DEFAULT@l /* */
1848 addis r3,0,PLLMR0_DEFAULT_PCI66@h
1849 ori r3,r3,PLLMR0_DEFAULT_PCI66@l
1850 addis r4,0,PLLMR1_DEFAULT_PCI66@h
1851 ori r4,r4,PLLMR1_DEFAULT_PCI66@l
1854 mfdcr r3, CPC0_PLLMR0
1855 mfdcr r4, CPC0_PLLMR1
1856 #endif /* CONFIG_TAIHU */
1859 b pll_write /* Write the CPC0_PLLMR with new value */
1863 !-----------------------------------------------------------------------
1864 ! Clear Soft Reset Register
1865 ! This is needed to enable PCI if not booting from serial EPROM
1866 !-----------------------------------------------------------------------
1876 blr /* return to main code */
1879 !-----------------------------------------------------------------------------
1880 ! Function: pll_write
1881 ! Description: Updates the value of the CPC0_PLLMR according to CMOS27E documentation
1883 ! 1. Pll is first disabled (de-activated by putting in bypass mode)
1885 ! 3. Clock dividers are set while PLL is held in reset and bypassed
1886 ! 4. PLL Reset is cleared
1887 ! 5. Wait 100us for PLL to lock
1888 ! 6. A core reset is performed
1889 ! Input: r3 = Value to write to CPC0_PLLMR0
1890 ! Input: r4 = Value to write to CPC0_PLLMR1
1892 !-----------------------------------------------------------------------------
1898 ori r5,r5,0x0101 /* Stop the UART clocks */
1899 mtdcr CPC0_UCR,r5 /* Before changing PLL */
1901 mfdcr r5, CPC0_PLLMR1
1902 rlwinm r5,r5,0,0x7FFFFFFF /* Disable PLL */
1903 mtdcr CPC0_PLLMR1,r5
1904 oris r5,r5,0x4000 /* Set PLL Reset */
1905 mtdcr CPC0_PLLMR1,r5
1907 mtdcr CPC0_PLLMR0,r3 /* Set clock dividers */
1908 rlwinm r5,r4,0,0x3FFFFFFF /* Reset & Bypass new PLL dividers */
1909 oris r5,r5,0x4000 /* Set PLL Reset */
1910 mtdcr CPC0_PLLMR1,r5 /* Set clock dividers */
1911 rlwinm r5,r5,0,0xBFFFFFFF /* Clear PLL Reset */
1912 mtdcr CPC0_PLLMR1,r5
1915 ! Wait min of 100us for PLL to lock.
1916 ! See CMOS 27E databook for more info.
1917 ! At 200MHz, that means waiting 20,000 instructions
1919 addi r3,0,20000 /* 2000 = 0x4e20 */
1924 oris r5,r5,0x8000 /* Enable PLL */
1925 mtdcr CPC0_PLLMR1,r5 /* Engage */
1928 * Reset CPU to guarantee timings are OK
1929 * Not sure if this is needed...
1932 mtspr SPRN_DBCR0,r3 /* This will cause a CPU core reset, and */
1933 /* execution will continue from the poweron */
1934 /* vector of 0xfffffffc */
1935 #endif /* CONFIG_405EP */
1937 #if defined(CONFIG_440)
1938 /*----------------------------------------------------------------------------+
1940 +----------------------------------------------------------------------------*/
1941 function_prolog(mttlb3)
1944 function_epilog(mttlb3)
1946 /*----------------------------------------------------------------------------+
1948 +----------------------------------------------------------------------------*/
1949 function_prolog(mftlb3)
1952 function_epilog(mftlb3)
1954 /*----------------------------------------------------------------------------+
1956 +----------------------------------------------------------------------------*/
1957 function_prolog(mttlb2)
1960 function_epilog(mttlb2)
1962 /*----------------------------------------------------------------------------+
1964 +----------------------------------------------------------------------------*/
1965 function_prolog(mftlb2)
1968 function_epilog(mftlb2)
1970 /*----------------------------------------------------------------------------+
1972 +----------------------------------------------------------------------------*/
1973 function_prolog(mttlb1)
1976 function_epilog(mttlb1)
1978 /*----------------------------------------------------------------------------+
1980 +----------------------------------------------------------------------------*/
1981 function_prolog(mftlb1)
1984 function_epilog(mftlb1)
1985 #endif /* CONFIG_440 */
1987 #if defined(CONFIG_NAND_SPL)
1989 * void nand_boot_relocate(dst, src, bytes)
1991 * r3 = Destination address to copy code to (in SDRAM)
1992 * r4 = Source address to copy code from
1993 * r5 = size to copy in bytes
2001 * Copy SPL from icache into SDRAM
2013 * Calculate "corrected" link register, so that we "continue"
2014 * in execution in destination range
2016 sub r3,r7,r6 /* r3 = src - dst */
2017 sub r8,r8,r3 /* r8 = link-reg - (src - dst) */
2023 * First initialize SDRAM. It has to be available *before* calling
2026 lis r3,CONFIG_SYS_SDRAM_BASE@h
2027 ori r3,r3,CONFIG_SYS_SDRAM_BASE@l
2031 * Now copy the 4k SPL code into SDRAM and continue execution
2034 lis r3,CONFIG_SYS_NAND_BOOT_SPL_DST@h
2035 ori r3,r3,CONFIG_SYS_NAND_BOOT_SPL_DST@l
2036 lis r4,CONFIG_SYS_NAND_BOOT_SPL_SRC@h
2037 ori r4,r4,CONFIG_SYS_NAND_BOOT_SPL_SRC@l
2038 lis r5,CONFIG_SYS_NAND_BOOT_SPL_SIZE@h
2039 ori r5,r5,CONFIG_SYS_NAND_BOOT_SPL_SIZE@l
2040 bl nand_boot_relocate
2043 * We're running from SDRAM now!!!
2045 * It is necessary for 4xx systems to relocate from running at
2046 * the original location (0xfffffxxx) to somewhere else (SDRAM
2047 * preferably). This is because CS0 needs to be reconfigured for
2048 * NAND access. And we can't reconfigure this CS when currently
2049 * "running" from it.
2053 * Finally call nand_boot() to load main NAND U-Boot image from
2054 * NAND and jump to it.
2056 bl nand_boot /* will not return */
2057 #endif /* CONFIG_NAND_SPL */