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 #include <ppc_asm.tmpl>
37 #include <asm/cache.h>
39 #include <asm/ppc4xx-isram.h>
41 #ifdef CONFIG_SYS_INIT_DCACHE_CS
42 # if (CONFIG_SYS_INIT_DCACHE_CS == 0)
45 # if (defined(CONFIG_SYS_EBC_PB0AP) && defined(CONFIG_SYS_EBC_PB0CR))
46 # define PBxAP_VAL CONFIG_SYS_EBC_PB0AP
47 # define PBxCR_VAL CONFIG_SYS_EBC_PB0CR
50 # if (CONFIG_SYS_INIT_DCACHE_CS == 1)
53 # if (defined(CONFIG_SYS_EBC_PB1AP) && defined(CONFIG_SYS_EBC_PB1CR))
54 # define PBxAP_VAL CONFIG_SYS_EBC_PB1AP
55 # define PBxCR_VAL CONFIG_SYS_EBC_PB1CR
58 # if (CONFIG_SYS_INIT_DCACHE_CS == 2)
61 # if (defined(CONFIG_SYS_EBC_PB2AP) && defined(CONFIG_SYS_EBC_PB2CR))
62 # define PBxAP_VAL CONFIG_SYS_EBC_PB2AP
63 # define PBxCR_VAL CONFIG_SYS_EBC_PB2CR
66 # if (CONFIG_SYS_INIT_DCACHE_CS == 3)
69 # if (defined(CONFIG_SYS_EBC_PB3AP) && defined(CONFIG_SYS_EBC_PB3CR))
70 # define PBxAP_VAL CONFIG_SYS_EBC_PB3AP
71 # define PBxCR_VAL CONFIG_SYS_EBC_PB3CR
74 # if (CONFIG_SYS_INIT_DCACHE_CS == 4)
77 # if (defined(CONFIG_SYS_EBC_PB4AP) && defined(CONFIG_SYS_EBC_PB4CR))
78 # define PBxAP_VAL CONFIG_SYS_EBC_PB4AP
79 # define PBxCR_VAL CONFIG_SYS_EBC_PB4CR
82 # if (CONFIG_SYS_INIT_DCACHE_CS == 5)
85 # if (defined(CONFIG_SYS_EBC_PB5AP) && defined(CONFIG_SYS_EBC_PB5CR))
86 # define PBxAP_VAL CONFIG_SYS_EBC_PB5AP
87 # define PBxCR_VAL CONFIG_SYS_EBC_PB5CR
90 # if (CONFIG_SYS_INIT_DCACHE_CS == 6)
93 # if (defined(CONFIG_SYS_EBC_PB6AP) && defined(CONFIG_SYS_EBC_PB6CR))
94 # define PBxAP_VAL CONFIG_SYS_EBC_PB6AP
95 # define PBxCR_VAL CONFIG_SYS_EBC_PB6CR
98 # if (CONFIG_SYS_INIT_DCACHE_CS == 7)
101 # if (defined(CONFIG_SYS_EBC_PB7AP) && defined(CONFIG_SYS_EBC_PB7CR))
102 # define PBxAP_VAL CONFIG_SYS_EBC_PB7AP
103 # define PBxCR_VAL CONFIG_SYS_EBC_PB7CR
113 * Memory Bank x (nothingness) initialization CONFIG_SYS_INIT_RAM_ADDR + 64 MiB
114 * used as temporary stack pointer for the primordial stack
116 # ifndef CONFIG_SYS_INIT_DCACHE_PBxAR
117 # define CONFIG_SYS_INIT_DCACHE_PBxAR (EBC_BXAP_BME_DISABLED | \
118 EBC_BXAP_TWT_ENCODE(7) | \
119 EBC_BXAP_BCE_DISABLE | \
120 EBC_BXAP_BCT_2TRANS | \
121 EBC_BXAP_CSN_ENCODE(0) | \
122 EBC_BXAP_OEN_ENCODE(0) | \
123 EBC_BXAP_WBN_ENCODE(0) | \
124 EBC_BXAP_WBF_ENCODE(0) | \
125 EBC_BXAP_TH_ENCODE(2) | \
126 EBC_BXAP_RE_DISABLED | \
127 EBC_BXAP_SOR_NONDELAYED | \
128 EBC_BXAP_BEM_WRITEONLY | \
129 EBC_BXAP_PEN_DISABLED)
130 # endif /* CONFIG_SYS_INIT_DCACHE_PBxAR */
131 # ifndef CONFIG_SYS_INIT_DCACHE_PBxCR
132 # define CONFIG_SYS_INIT_DCACHE_PBxCR (EBC_BXCR_BAS_ENCODE(CONFIG_SYS_INIT_RAM_ADDR) | \
136 # endif /* CONFIG_SYS_INIT_DCACHE_PBxCR */
137 # ifndef CONFIG_SYS_INIT_RAM_PATTERN
138 # define CONFIG_SYS_INIT_RAM_PATTERN 0xDEADDEAD
140 #endif /* CONFIG_SYS_INIT_DCACHE_CS */
142 #if (defined(CONFIG_SYS_INIT_RAM_DCACHE) && (CONFIG_SYS_INIT_RAM_SIZE > (4 << 10)))
143 #error Only 4k of init-ram is supported - please adjust CONFIG_SYS_INIT_RAM_SIZE!
147 * Unless otherwise overriden, enable two 128MB cachable instruction regions
148 * at CONFIG_SYS_SDRAM_BASE and another 128MB cacheable instruction region covering
149 * NOR flash at CONFIG_SYS_FLASH_BASE. Disable all cacheable data regions.
151 #if !defined(CONFIG_SYS_FLASH_BASE)
152 /* If not already defined, set it to the "last" 128MByte region */
153 # define CONFIG_SYS_FLASH_BASE 0xf8000000
155 #if !defined(CONFIG_SYS_ICACHE_SACR_VALUE)
156 # define CONFIG_SYS_ICACHE_SACR_VALUE \
157 (PPC_128MB_SACR_VALUE(CONFIG_SYS_SDRAM_BASE + ( 0 << 20)) | \
158 PPC_128MB_SACR_VALUE(CONFIG_SYS_SDRAM_BASE + (128 << 20)) | \
159 PPC_128MB_SACR_VALUE(CONFIG_SYS_FLASH_BASE))
160 #endif /* !defined(CONFIG_SYS_ICACHE_SACR_VALUE) */
162 #if !defined(CONFIG_SYS_DCACHE_SACR_VALUE)
163 # define CONFIG_SYS_DCACHE_SACR_VALUE \
165 #endif /* !defined(CONFIG_SYS_DCACHE_SACR_VALUE) */
167 #if !defined(CONFIG_SYS_TLB_FOR_BOOT_FLASH)
168 #define CONFIG_SYS_TLB_FOR_BOOT_FLASH 0 /* use TLB 0 as default */
171 #define function_prolog(func_name) .text; \
175 #define function_epilog(func_name) .type func_name,@function; \
176 .size func_name,.-func_name
178 /* We don't want the MMU yet.
181 #define MSR_KERNEL ( MSR_ME ) /* Machine Check */
184 .extern ext_bus_cntlr_init
185 #ifdef CONFIG_NAND_U_BOOT
186 .extern reconfig_tlb0
190 * Set up GOT: Global Offset Table
192 * Use r12 to access the GOT
194 #if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD)
196 GOT_ENTRY(_GOT2_TABLE_)
197 GOT_ENTRY(_FIXUP_TABLE_)
200 GOT_ENTRY(_start_of_vectors)
201 GOT_ENTRY(_end_of_vectors)
202 GOT_ENTRY(transfer_to_handler)
204 GOT_ENTRY(__init_end)
206 GOT_ENTRY(__bss_start)
208 #endif /* CONFIG_NAND_SPL */
210 #if defined(CONFIG_NAND_U_BOOT) && !defined(CONFIG_NAND_SPL) && \
211 !defined(CONFIG_SPL_BUILD)
213 * NAND U-Boot image is started from offset 0
216 #if defined(CONFIG_440)
220 bl cpu_init_f /* run low-level CPU init code (from Flash) */
222 /* NOTREACHED - board_init_f() does not return */
225 #if defined(CONFIG_SYS_RAMBOOT) || defined(CONFIG_BOOT_FROM_XMD)
227 * 4xx RAM-booting U-Boot image is started from offset 0
233 #if defined(CONFIG_SPL) && !defined(CONFIG_SPL_BUILD)
235 * This is the entry of the real U-Boot from a board port
236 * that supports SPL booting on the PPC4xx. We only need
237 * to call board_init_f() here. Everything else has already
238 * been done in the SPL u-boot version.
240 GET_GOT /* initialize GOT access */
241 bl board_init_f /* run 1st part of board init code (in Flash)*/
242 /* NOTREACHED - board_init_f() does not return */
246 * 440 Startup -- on reset only the top 4k of the effective
247 * address space is mapped in by an entry in the instruction
248 * and data shadow TLB. The .bootpg section is located in the
249 * top 4k & does only what's necessary to map in the the rest
250 * of the boot rom. Once the boot rom is mapped in we can
251 * proceed with normal startup.
253 * NOTE: CS0 only covers the top 2MB of the effective address
257 #if defined(CONFIG_440)
258 #if !defined(CONFIG_NAND_SPL)
259 .section .bootpg,"ax"
263 /**************************************************************************/
265 /*--------------------------------------------------------------------+
266 | 440EPX BUP Change - Hardware team request
267 +--------------------------------------------------------------------*/
268 #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
273 /*----------------------------------------------------------------+
274 | Core bug fix. Clear the esr
275 +-----------------------------------------------------------------*/
278 /*----------------------------------------------------------------*/
279 /* Clear and set up some registers. */
280 /*----------------------------------------------------------------*/
281 iccci r0,r0 /* NOTE: operands not used for 440 */
282 dccci r0,r0 /* NOTE: operands not used for 440 */
289 /* NOTE: 440GX adds machine check status regs */
290 #if defined(CONFIG_440) && !defined(CONFIG_440GP)
297 /*----------------------------------------------------------------*/
299 /*----------------------------------------------------------------*/
300 /* Disable store gathering & broadcast, guarantee inst/data
301 * cache block touch, force load/store alignment
302 * (see errata 1.12: 440_33)
304 lis r1,0x0030 /* store gathering & broadcast disable */
305 ori r1,r1,0x6000 /* cache touch */
308 /*----------------------------------------------------------------*/
309 /* Initialize debug */
310 /*----------------------------------------------------------------*/
312 andis. r1, r1, 0x8000 /* test DBCR0[EDM] bit */
313 bne skip_debug_init /* if set, don't clear debug register */
315 ori r1,r1,CCR0_DTB@l /* Disable Trace Broadcast */
329 mtspr SPRN_DBSR,r1 /* Clear all valid bits */
332 #if defined (CONFIG_440SPE)
333 /*----------------------------------------------------------------+
334 | Initialize Core Configuration Reg1.
335 | a. ICDPEI: Record even parity. Normal operation.
336 | b. ICTPEI: Record even parity. Normal operation.
337 | c. DCTPEI: Record even parity. Normal operation.
338 | d. DCDPEI: Record even parity. Normal operation.
339 | e. DCUPEI: Record even parity. Normal operation.
340 | f. DCMPEI: Record even parity. Normal operation.
341 | g. FCOM: Normal operation
342 | h. MMUPEI: Record even parity. Normal operation.
343 | i. FFF: Flush only as much data as necessary.
344 | j. TCS: Timebase increments from CPU clock.
345 +-----------------------------------------------------------------*/
349 /*----------------------------------------------------------------+
350 | Reset the timebase.
351 | The previous write to CCR1 sets the timebase source.
352 +-----------------------------------------------------------------*/
357 /*----------------------------------------------------------------*/
358 /* Setup interrupt vectors */
359 /*----------------------------------------------------------------*/
360 mtspr SPRN_IVPR,r0 /* Vectors start at 0x0000_0000 */
362 mtspr SPRN_IVOR0,r1 /* Critical input */
364 mtspr SPRN_IVOR1,r1 /* Machine check */
366 mtspr SPRN_IVOR2,r1 /* Data storage */
368 mtspr SPRN_IVOR3,r1 /* Instruction storage */
370 mtspr SPRN_IVOR4,r1 /* External interrupt */
372 mtspr SPRN_IVOR5,r1 /* Alignment */
374 mtspr SPRN_IVOR6,r1 /* Program check */
376 mtspr SPRN_IVOR7,r1 /* Floating point unavailable */
378 mtspr SPRN_IVOR8,r1 /* System call */
380 mtspr SPRN_IVOR9,r1 /* Auxiliary Processor unavailable */
382 mtspr SPRN_IVOR10,r1 /* Decrementer */
384 mtspr SPRN_IVOR13,r1 /* Data TLB error */
386 mtspr SPRN_IVOR14,r1 /* Instr TLB error */
388 mtspr SPRN_IVOR15,r1 /* Debug */
390 /*----------------------------------------------------------------*/
391 /* Configure cache regions */
392 /*----------------------------------------------------------------*/
410 /*----------------------------------------------------------------*/
411 /* Cache victim limits */
412 /*----------------------------------------------------------------*/
413 /* floors 0, ceiling max to use the entire cache -- nothing locked
420 /*----------------------------------------------------------------+
421 |Initialize MMUCR[STID] = 0.
422 +-----------------------------------------------------------------*/
429 /*----------------------------------------------------------------*/
430 /* Clear all TLB entries -- TID = 0, TS = 0 */
431 /*----------------------------------------------------------------*/
433 #ifdef CONFIG_SYS_RAMBOOT
434 li r4,0 /* Start with TLB #0 */
436 li r4,1 /* Start with TLB #1 */
438 li r1,64 /* 64 TLB entries */
439 sub r1,r1,r4 /* calculate last TLB # */
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 */
447 tlbwe r0,r4,0 /* Invalidate all entries (V=0)*/
450 tlbnxt: addi r4,r4,1 /* Next TLB */
453 /*----------------------------------------------------------------*/
454 /* TLB entry setup -- step thru tlbtab */
455 /*----------------------------------------------------------------*/
456 #if defined(CONFIG_440SPE_REVA)
457 /*----------------------------------------------------------------*/
458 /* We have different TLB tables for revA and rev B of 440SPe */
459 /*----------------------------------------------------------------*/
471 bl tlbtab /* Get tlbtab pointer */
474 li r1,0x003f /* 64 TLB entries max */
480 #ifdef CONFIG_SYS_RAMBOOT
481 tlbre r3,r4,0 /* Read contents from TLB word #0 */
482 rlwinm. r3,r3,0,0x00000200 /* Mask V (valid) bit */
483 bne tlbnx2 /* Skip V=1 TLB, this is the SDRAM TLB */
487 beq 2f /* 0 marks end */
490 tlbwe r0,r4,0 /* TLB Word 0 */
491 tlbwe r1,r4,1 /* TLB Word 1 */
492 tlbwe r2,r4,2 /* TLB Word 2 */
493 tlbnx2: addi r4,r4,1 /* Next TLB */
496 /*----------------------------------------------------------------*/
497 /* Continue from 'normal' start */
498 /*----------------------------------------------------------------*/
504 mtspr SPRN_SRR1,r0 /* Keep things disabled for now */
508 #endif /* CONFIG_440 */
511 * r3 - 1st arg to board_init(): IMMP pointer
512 * r4 - 2nd arg to board_init(): boot flag
514 #if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD)
516 .long 0x27051956 /* U-Boot Magic Number */
517 .globl version_string
519 .ascii U_BOOT_VERSION_STRING, "\0"
521 . = EXC_OFF_SYS_RESET
522 .globl _start_of_vectors
525 /* Critical input. */
526 CRIT_EXCEPTION(0x100, CritcalInput, UnknownException)
530 MCK_EXCEPTION(0x200, MachineCheck, MachineCheckException)
532 CRIT_EXCEPTION(0x200, MachineCheck, MachineCheckException)
533 #endif /* CONFIG_440 */
535 /* Data Storage exception. */
536 STD_EXCEPTION(0x300, DataStorage, UnknownException)
538 /* Instruction Storage exception. */
539 STD_EXCEPTION(0x400, InstStorage, UnknownException)
541 /* External Interrupt exception. */
542 STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
544 /* Alignment exception. */
547 EXCEPTION_PROLOG(SRR0, SRR1)
552 addi r3,r1,STACK_FRAME_OVERHEAD
553 EXC_XFER_TEMPLATE(Alignment, AlignmentException, MSR_KERNEL, COPY_EE)
555 /* Program check exception */
558 EXCEPTION_PROLOG(SRR0, SRR1)
559 addi r3,r1,STACK_FRAME_OVERHEAD
560 EXC_XFER_TEMPLATE(ProgramCheck, ProgramCheckException,
564 STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
565 STD_EXCEPTION(0x900, Decrementer, DecrementerPITException)
566 STD_EXCEPTION(0xa00, APU, UnknownException)
568 STD_EXCEPTION(0xc00, SystemCall, UnknownException)
571 STD_EXCEPTION(0x1300, DataTLBError, UnknownException)
572 STD_EXCEPTION(0x1400, InstructionTLBError, UnknownException)
574 STD_EXCEPTION(0x1000, PIT, DecrementerPITException)
575 STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException)
576 STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException)
578 CRIT_EXCEPTION(0x2000, DebugBreakpoint, DebugException )
580 .globl _end_of_vectors
587 #if defined(CONFIG_SPL) && !defined(CONFIG_SPL_BUILD)
589 * This is the entry of the real U-Boot from a board port
590 * that supports SPL booting on the PPC4xx. We only need
591 * to call board_init_f() here. Everything else has already
592 * been done in the SPL u-boot version.
594 GET_GOT /* initialize GOT access */
595 bl board_init_f /* run 1st part of board init code (in Flash)*/
596 /* NOTREACHED - board_init_f() does not return */
599 /*****************************************************************************/
600 #if defined(CONFIG_440)
602 /*----------------------------------------------------------------*/
603 /* Clear and set up some registers. */
604 /*----------------------------------------------------------------*/
607 mtspr SPRN_DEC,r0 /* prevent dec exceptions */
608 mtspr SPRN_TBWL,r0 /* prevent fit & wdt exceptions */
610 mtspr SPRN_TSR,r1 /* clear all timer exception status */
611 mtspr SPRN_TCR,r0 /* disable all */
612 mtspr SPRN_ESR,r0 /* clear exception syndrome register */
613 mtxer r0 /* clear integer exception register */
615 /*----------------------------------------------------------------*/
616 /* Debug setup -- some (not very good) ice's need an event*/
617 /* to establish control :-( Define CONFIG_SYS_INIT_DBCR to the dbsr */
618 /* value you need in this case 0x8cff 0000 should do the trick */
619 /*----------------------------------------------------------------*/
620 #if defined(CONFIG_SYS_INIT_DBCR)
623 mtspr SPRN_DBSR,r1 /* Clear all status bits */
624 lis r0,CONFIG_SYS_INIT_DBCR@h
625 ori r0,r0,CONFIG_SYS_INIT_DBCR@l
630 /*----------------------------------------------------------------*/
631 /* Setup the internal SRAM */
632 /*----------------------------------------------------------------*/
635 #ifdef CONFIG_SYS_INIT_RAM_DCACHE
636 /* Clear Dcache to use as RAM */
637 addis r3,r0,CONFIG_SYS_INIT_RAM_ADDR@h
638 ori r3,r3,CONFIG_SYS_INIT_RAM_ADDR@l
639 addis r4,r0,CONFIG_SYS_INIT_RAM_SIZE@h
640 ori r4,r4,CONFIG_SYS_INIT_RAM_SIZE@l
641 rlwinm. r5,r4,0,27,31
653 * Lock the init-ram/stack in d-cache, so that other regions
654 * may use d-cache as well
655 * Note, that this current implementation locks exactly 4k
656 * of d-cache, so please make sure that you don't define a
657 * bigger init-ram area. Take a look at the lwmon5 440EPx
658 * implementation as a reference.
662 /* 8. set TFLOOR/NFLOOR to 8 (-> 8*16*32 bytes locked -> 4k) */
678 #endif /* CONFIG_SYS_INIT_RAM_DCACHE */
680 /* 440EP & 440GR are only 440er PPC's without internal SRAM */
681 #if !defined(CONFIG_440EP) && !defined(CONFIG_440GR)
682 /* not all PPC's have internal SRAM usable as L2-cache */
683 #if defined(CONFIG_440GX) || \
684 defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
685 defined(CONFIG_460SX)
686 mtdcr L2_CACHE_CFG,r0 /* Ensure L2 Cache is off */
687 #elif defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
688 defined(CONFIG_APM821XX)
690 ori r1,r1,0x0008 /* Set L2_CACHE_CFG[RDBW]=1 */
691 mtdcr L2_CACHE_CFG,r1
697 and r1,r1,r2 /* Disable parity check */
700 and r1,r1,r2 /* Disable pwr mgmt */
703 lis r1,0x8000 /* BAS = 8000_0000 */
704 #if defined(CONFIG_440GX) || defined(CONFIG_440SP)
705 ori r1,r1,0x0980 /* first 64k */
706 mtdcr ISRAM0_SB0CR,r1
708 ori r1,r1,0x0980 /* second 64k */
709 mtdcr ISRAM0_SB1CR,r1
711 ori r1,r1, 0x0980 /* third 64k */
712 mtdcr ISRAM0_SB2CR,r1
714 ori r1,r1, 0x0980 /* fourth 64k */
715 mtdcr ISRAM0_SB3CR,r1
716 #elif defined(CONFIG_440SPE) || defined(CONFIG_460EX) || \
717 defined(CONFIG_460GT) || defined(CONFIG_APM821XX)
718 lis r1,0x0000 /* BAS = X_0000_0000 */
719 ori r1,r1,0x0984 /* first 64k */
720 mtdcr ISRAM0_SB0CR,r1
722 ori r1,r1,0x0984 /* second 64k */
723 mtdcr ISRAM0_SB1CR,r1
725 ori r1,r1, 0x0984 /* third 64k */
726 mtdcr ISRAM0_SB2CR,r1
728 ori r1,r1, 0x0984 /* fourth 64k */
729 mtdcr ISRAM0_SB3CR,r1
730 #if defined(CONFIG_460EX) || defined(CONFIG_460GT) || \
731 defined(CONFIG_APM821XX)
735 and r1,r1,r2 /* Disable parity check */
738 and r1,r1,r2 /* Disable pwr mgmt */
741 lis r1,0x0004 /* BAS = 4_0004_0000 */
742 ori r1,r1,ISRAM1_SIZE /* ocm size */
743 mtdcr ISRAM1_SB0CR,r1
745 #elif defined(CONFIG_460SX)
746 lis r1,0x0000 /* BAS = 0000_0000 */
747 ori r1,r1,0x0B84 /* first 128k */
748 mtdcr ISRAM0_SB0CR,r1
750 ori r1,r1,0x0B84 /* second 128k */
751 mtdcr ISRAM0_SB1CR,r1
753 ori r1,r1, 0x0B84 /* third 128k */
754 mtdcr ISRAM0_SB2CR,r1
756 ori r1,r1, 0x0B84 /* fourth 128k */
757 mtdcr ISRAM0_SB3CR,r1
758 #elif defined(CONFIG_440GP)
759 ori r1,r1,0x0380 /* 8k rw */
760 mtdcr ISRAM0_SB0CR,r1
761 mtdcr ISRAM0_SB1CR,r0 /* Disable bank 1 */
763 #endif /* #if !defined(CONFIG_440EP) && !defined(CONFIG_440GR) */
765 /*----------------------------------------------------------------*/
766 /* Setup the stack in internal SRAM */
767 /*----------------------------------------------------------------*/
768 lis r1,CONFIG_SYS_INIT_RAM_ADDR@h
769 ori r1,r1,CONFIG_SYS_INIT_SP_OFFSET@l
772 stwu r0,-4(r1) /* Terminate call chain */
774 stwu r1,-8(r1) /* Save back chain and move SP */
775 lis r0,RESET_VECTOR@h /* Address of reset vector */
776 ori r0,r0, RESET_VECTOR@l
777 stwu r1,-8(r1) /* Save back chain and move SP */
778 stw r0,+12(r1) /* Save return addr (underflow vect) */
780 #ifdef CONFIG_NAND_SPL
781 bl nand_boot_common /* will not return */
783 #ifndef CONFIG_SPL_BUILD
787 bl cpu_init_f /* run low-level CPU init code (from Flash) */
789 /* NOTREACHED - board_init_f() does not return */
792 #endif /* CONFIG_440 */
794 /*****************************************************************************/
795 #if defined(CONFIG_405GP) || \
796 defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \
797 defined(CONFIG_405EX) || defined(CONFIG_405)
798 /*----------------------------------------------------------------------- */
799 /* Clear and set up some registers. */
800 /*----------------------------------------------------------------------- */
802 #if !defined(CONFIG_405EX)
806 * On 405EX, completely clearing the SGR leads to PPC hangup
807 * upon PCIe configuration access. The PCIe memory regions
808 * need to be guarded!
815 mtesr r4 /* clear Exception Syndrome Reg */
816 mttcr r4 /* clear Timer Control Reg */
817 mtxer r4 /* clear Fixed-Point Exception Reg */
818 mtevpr r4 /* clear Exception Vector Prefix Reg */
819 addi r4,r0,(0xFFFF-0x10000) /* set r4 to 0xFFFFFFFF (status in the */
820 /* dbsr is cleared by setting bits to 1) */
821 mtdbsr r4 /* clear/reset the dbsr */
823 /* Invalidate the i- and d-caches. */
827 /* Set-up icache cacheability. */
828 lis r4, CONFIG_SYS_ICACHE_SACR_VALUE@h
829 ori r4, r4, CONFIG_SYS_ICACHE_SACR_VALUE@l
833 /* Set-up dcache cacheability. */
834 lis r4, CONFIG_SYS_DCACHE_SACR_VALUE@h
835 ori r4, r4, CONFIG_SYS_DCACHE_SACR_VALUE@l
838 #if !(defined(CONFIG_SYS_EBC_PB0AP) && defined(CONFIG_SYS_EBC_PB0CR))\
839 && !defined (CONFIG_XILINX_405)
840 /*----------------------------------------------------------------------- */
841 /* Tune the speed and size for flash CS0 */
842 /*----------------------------------------------------------------------- */
843 bl ext_bus_cntlr_init
846 #if !(defined(CONFIG_SYS_INIT_DCACHE_CS) || defined(CONFIG_SYS_TEMP_STACK_OCM))
848 * For boards that don't have OCM and can't use the data cache
849 * for their primordial stack, setup stack here directly after the
850 * SDRAM is initialized in ext_bus_cntlr_init.
852 lis r1, CONFIG_SYS_INIT_RAM_ADDR@h
853 ori r1,r1,CONFIG_SYS_INIT_SP_OFFSET /* set up the stack in SDRAM */
855 li r0, 0 /* Make room for stack frame header and */
856 stwu r0, -4(r1) /* clear final stack frame so that */
857 stwu r0, -4(r1) /* stack backtraces terminate cleanly */
859 * Set up a dummy frame to store reset vector as return address.
860 * this causes stack underflow to reset board.
862 stwu r1, -8(r1) /* Save back chain and move SP */
863 lis r0, RESET_VECTOR@h /* Address of reset vector */
864 ori r0, r0, RESET_VECTOR@l
865 stwu r1, -8(r1) /* Save back chain and move SP */
866 stw r0, +12(r1) /* Save return addr (underflow vect) */
867 #endif /* !(CONFIG_SYS_INIT_DCACHE_CS || !CONFIG_SYS_TEM_STACK_OCM) */
869 #if defined(CONFIG_405EP)
870 /*----------------------------------------------------------------------- */
871 /* DMA Status, clear to come up clean */
872 /*----------------------------------------------------------------------- */
873 addis r3,r0, 0xFFFF /* Clear all existing DMA status */
877 bl ppc405ep_init /* do ppc405ep specific init */
878 #endif /* CONFIG_405EP */
880 #if defined(CONFIG_SYS_OCM_DATA_ADDR) && defined(CONFIG_SYS_OCM_DATA_SIZE)
881 #if defined(CONFIG_405EZ)
882 /********************************************************************
883 * Setup OCM - On Chip Memory - PPC405EZ uses OCM Controller V2
884 *******************************************************************/
886 * We can map the OCM on the PLB3, so map it at
887 * CONFIG_SYS_OCM_DATA_ADDR + 0x8000
889 lis r3,CONFIG_SYS_OCM_DATA_ADDR@h /* OCM location */
890 ori r3,r3,CONFIG_SYS_OCM_DATA_ADDR@l
891 ori r3,r3,0x0270 /* 16K for Bank 1, R/W/Enable */
892 mtdcr OCM0_PLBCR1,r3 /* Set PLB Access */
893 ori r3,r3,0x4000 /* Add 0x4000 for bank 2 */
894 mtdcr OCM0_PLBCR2,r3 /* Set PLB Access */
897 lis r3,CONFIG_SYS_OCM_DATA_ADDR@h /* OCM location */
898 ori r3,r3,CONFIG_SYS_OCM_DATA_ADDR@l
899 ori r3,r3,0x0270 /* 16K for Bank 1, R/W/Enable */
900 mtdcr OCM0_DSRC1, r3 /* Set Data Side */
901 mtdcr OCM0_ISRC1, r3 /* Set Instruction Side */
902 ori r3,r3,0x4000 /* Add 0x4000 for bank 2 */
903 mtdcr OCM0_DSRC2, r3 /* Set Data Side */
904 mtdcr OCM0_ISRC2, r3 /* Set Instruction Side */
905 addis r3,0,0x0800 /* OCM Data Parity Disable - 1 Wait State */
909 #else /* CONFIG_405EZ */
910 /********************************************************************
911 * Setup OCM - On Chip Memory
912 *******************************************************************/
916 mfdcr r3, OCM0_ISCNTL /* get instr-side IRAM config */
917 mfdcr r4, OCM0_DSCNTL /* get data-side IRAM config */
918 and r3, r3, r0 /* disable data-side IRAM */
919 and r4, r4, r0 /* disable data-side IRAM */
920 mtdcr OCM0_ISCNTL, r3 /* set instr-side IRAM config */
921 mtdcr OCM0_DSCNTL, r4 /* set data-side IRAM config */
924 lis r3,CONFIG_SYS_OCM_DATA_ADDR@h /* OCM location */
925 ori r3,r3,CONFIG_SYS_OCM_DATA_ADDR@l
927 addis r4, 0, 0xC000 /* OCM data area enabled */
928 mtdcr OCM0_DSCNTL, r4
930 #endif /* CONFIG_405EZ */
933 /*----------------------------------------------------------------------- */
934 /* Setup temporary stack in DCACHE or OCM if needed for SDRAM SPD. */
935 /*----------------------------------------------------------------------- */
936 #ifdef CONFIG_SYS_INIT_DCACHE_CS
938 mtdcr EBC0_CFGADDR, r4
939 lis r4, CONFIG_SYS_INIT_DCACHE_PBxAR@h
940 ori r4, r4, CONFIG_SYS_INIT_DCACHE_PBxAR@l
941 mtdcr EBC0_CFGDATA, r4
944 mtdcr EBC0_CFGADDR, r4
945 lis r4, CONFIG_SYS_INIT_DCACHE_PBxCR@h
946 ori r4, r4, CONFIG_SYS_INIT_DCACHE_PBxCR@l
947 mtdcr EBC0_CFGDATA, r4
950 * Enable the data cache for the 128MB storage access control region
951 * at CONFIG_SYS_INIT_RAM_ADDR.
954 oris r4, r4, PPC_128MB_SACR_VALUE(CONFIG_SYS_INIT_RAM_ADDR)@h
955 ori r4, r4, PPC_128MB_SACR_VALUE(CONFIG_SYS_INIT_RAM_ADDR)@l
959 * Preallocate data cache lines to be used to avoid a subsequent
960 * cache miss and an ensuing machine check exception when exceptions
965 lis r3, CONFIG_SYS_INIT_RAM_ADDR@h
966 ori r3, r3, CONFIG_SYS_INIT_RAM_ADDR@l
968 lis r4, CONFIG_SYS_INIT_RAM_SIZE@h
969 ori r4, r4, CONFIG_SYS_INIT_RAM_SIZE@l
972 * Convert the size, in bytes, to the number of cache lines/blocks
975 clrlwi. r5, r4, (32 - L1_CACHE_SHIFT)
976 srwi r5, r4, L1_CACHE_SHIFT
982 /* Preallocate the computed number of cache blocks. */
983 ..alloc_dcache_block:
985 addi r3, r3, L1_CACHE_BYTES
986 bdnz ..alloc_dcache_block
990 * Load the initial stack pointer and data area and convert the size,
991 * in bytes, to the number of words to initialize to a known value.
993 lis r1, CONFIG_SYS_INIT_RAM_ADDR@h
994 ori r1, r1, CONFIG_SYS_INIT_SP_OFFSET@l
996 lis r4, (CONFIG_SYS_INIT_RAM_SIZE >> 2)@h
997 ori r4, r4, (CONFIG_SYS_INIT_RAM_SIZE >> 2)@l
1000 lis r2, CONFIG_SYS_INIT_RAM_ADDR@h
1001 ori r2, r2, CONFIG_SYS_INIT_RAM_SIZE@l
1003 lis r4, CONFIG_SYS_INIT_RAM_PATTERN@h
1004 ori r4, r4, CONFIG_SYS_INIT_RAM_PATTERN@l
1011 * Make room for stack frame header and clear final stack frame so
1012 * that stack backtraces terminate cleanly.
1018 * Set up a dummy frame to store reset vector as return address.
1019 * this causes stack underflow to reset board.
1021 stwu r1, -8(r1) /* Save back chain and move SP */
1022 addis r0, 0, RESET_VECTOR@h /* Address of reset vector */
1023 ori r0, r0, RESET_VECTOR@l
1024 stwu r1, -8(r1) /* Save back chain and move SP */
1025 stw r0, +12(r1) /* Save return addr (underflow vect) */
1027 #elif defined(CONFIG_SYS_TEMP_STACK_OCM) && \
1028 (defined(CONFIG_SYS_OCM_DATA_ADDR) && defined(CONFIG_SYS_OCM_DATA_SIZE))
1033 /* Set up Stack at top of OCM */
1034 lis r1, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)@h
1035 ori r1, r1, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)@l
1037 /* Set up a zeroized stack frame so that backtrace works right */
1043 * Set up a dummy frame to store reset vector as return address.
1044 * this causes stack underflow to reset board.
1046 stwu r1, -8(r1) /* Save back chain and move SP */
1047 lis r0, RESET_VECTOR@h /* Address of reset vector */
1048 ori r0, r0, RESET_VECTOR@l
1049 stwu r1, -8(r1) /* Save back chain and move SP */
1050 stw r0, +12(r1) /* Save return addr (underflow vect) */
1051 #endif /* CONFIG_SYS_INIT_DCACHE_CS */
1053 #ifdef CONFIG_NAND_SPL
1054 bl nand_boot_common /* will not return */
1056 GET_GOT /* initialize GOT access */
1058 bl cpu_init_f /* run low-level CPU init code (from Flash) */
1060 bl board_init_f /* run first part of init code (from Flash) */
1061 /* NOTREACHED - board_init_f() does not return */
1063 #endif /* CONFIG_NAND_SPL */
1065 #endif /* CONFIG_405GP || CONFIG_405 || CONFIG_405EP */
1066 /*----------------------------------------------------------------------- */
1069 #if !defined(CONFIG_NAND_SPL) && !defined(CONFIG_SPL_BUILD)
1071 * This code finishes saving the registers to the exception frame
1072 * and jumps to the appropriate handler for the exception.
1073 * Register r21 is pointer into trap frame, r1 has new stack pointer.
1075 .globl transfer_to_handler
1076 transfer_to_handler:
1086 andi. r24,r23,0x3f00 /* get vector offset */
1090 mtspr SPRG2,r22 /* r1 is now kernel sp */
1091 lwz r24,0(r23) /* virtual address of handler */
1092 lwz r23,4(r23) /* where to go when done */
1097 rfi /* jump to handler, enable MMU */
1100 mfmsr r28 /* Disable interrupts */
1104 SYNC /* Some chip revs need this... */
1119 lwz r2,_NIP(r1) /* Restore environment */
1130 mfmsr r28 /* Disable interrupts */
1134 SYNC /* Some chip revs need this... */
1149 lwz r2,_NIP(r1) /* Restore environment */
1161 mfmsr r28 /* Disable interrupts */
1165 SYNC /* Some chip revs need this... */
1180 lwz r2,_NIP(r1) /* Restore environment */
1182 mtspr SPRN_MCSRR0,r2
1183 mtspr SPRN_MCSRR1,r0
1189 #endif /* CONFIG_440 */
1197 /*------------------------------------------------------------------------------- */
1198 /* Function: out16 */
1199 /* Description: Output 16 bits */
1200 /*------------------------------------------------------------------------------- */
1206 /*------------------------------------------------------------------------------- */
1207 /* Function: out16r */
1208 /* Description: Byte reverse and output 16 bits */
1209 /*------------------------------------------------------------------------------- */
1215 /*------------------------------------------------------------------------------- */
1216 /* Function: out32r */
1217 /* Description: Byte reverse and output 32 bits */
1218 /*------------------------------------------------------------------------------- */
1224 /*------------------------------------------------------------------------------- */
1225 /* Function: in16 */
1226 /* Description: Input 16 bits */
1227 /*------------------------------------------------------------------------------- */
1233 /*------------------------------------------------------------------------------- */
1234 /* Function: in16r */
1235 /* Description: Input 16 bits and byte reverse */
1236 /*------------------------------------------------------------------------------- */
1242 /*------------------------------------------------------------------------------- */
1243 /* Function: in32r */
1244 /* Description: Input 32 bits and byte reverse */
1245 /*------------------------------------------------------------------------------- */
1251 #if !defined(CONFIG_SPL_BUILD)
1253 * void relocate_code (addr_sp, gd, addr_moni)
1255 * This "function" does not return, instead it continues in RAM
1256 * after relocating the monitor code.
1258 * r3 = Relocated stack pointer
1259 * r4 = Relocated global data pointer
1260 * r5 = Relocated text pointer
1262 .globl relocate_code
1264 #if defined(CONFIG_4xx_DCACHE) || defined(CONFIG_SYS_INIT_DCACHE_CS)
1266 * We need to flush the initial global data (gd_t) and bd_info
1267 * before the dcache will be invalidated.
1270 /* Save registers */
1276 * Flush complete dcache, this is faster than flushing the
1277 * ranges for global_data and bd_info instead.
1281 #if defined(CONFIG_SYS_INIT_DCACHE_CS)
1283 * Undo the earlier data cache set-up for the primordial stack and
1284 * data area. First, invalidate the data cache and then disable data
1285 * cacheability for that area. Finally, restore the EBC values, if
1289 /* Invalidate the primordial stack and data area in cache */
1290 lis r3, CONFIG_SYS_INIT_RAM_ADDR@h
1291 ori r3, r3, CONFIG_SYS_INIT_RAM_ADDR@l
1293 lis r4, CONFIG_SYS_INIT_RAM_SIZE@h
1294 ori r4, r4, CONFIG_SYS_INIT_RAM_SIZE@l
1297 bl invalidate_dcache_range
1299 /* Disable cacheability for the region */
1301 lis r4, ~PPC_128MB_SACR_VALUE(CONFIG_SYS_INIT_RAM_ADDR)@h
1302 ori r4, r4, ~PPC_128MB_SACR_VALUE(CONFIG_SYS_INIT_RAM_ADDR)@l
1306 /* Restore the EBC parameters */
1308 mtdcr EBC0_CFGADDR, r3
1310 ori r3, r3, PBxAP_VAL@l
1311 mtdcr EBC0_CFGDATA, r3
1314 mtdcr EBC0_CFGADDR, r3
1316 ori r3, r3, PBxCR_VAL@l
1317 mtdcr EBC0_CFGDATA, r3
1318 #endif /* defined(CONFIG_SYS_INIT_DCACHE_CS) */
1320 /* Restore registers */
1324 #endif /* defined(CONFIG_4xx_DCACHE) || defined(CONFIG_SYS_INIT_DCACHE_CS) */
1326 #ifdef CONFIG_SYS_INIT_RAM_DCACHE
1328 * Unlock the previously locked d-cache
1332 /* set TFLOOR/NFLOOR to 0 again */
1349 /* Invalidate data cache, now no longer our stack */
1353 #endif /* CONFIG_SYS_INIT_RAM_DCACHE */
1356 * On some 440er platforms the cache is enabled in the first TLB (Boot-CS)
1357 * to speed up the boot process. Now this cache needs to be disabled.
1359 #if defined(CONFIG_440)
1360 /* Clear all potential pending exceptions */
1363 addi r1,r0,CONFIG_SYS_TLB_FOR_BOOT_FLASH /* Use defined TLB */
1364 tlbre r0,r1,0x0002 /* Read contents */
1365 ori r0,r0,0x0c00 /* Or in the inhibit, write through bit */
1366 tlbwe r0,r1,0x0002 /* Save it out */
1369 #endif /* defined(CONFIG_440) */
1370 mr r1, r3 /* Set new stack pointer */
1371 mr r9, r4 /* Save copy of Init Data pointer */
1372 mr r10, r5 /* Save copy of Destination Address */
1375 mr r3, r5 /* Destination Address */
1376 lis r4, CONFIG_SYS_MONITOR_BASE@h /* Source Address */
1377 ori r4, r4, CONFIG_SYS_MONITOR_BASE@l
1378 lwz r5, GOT(__init_end)
1380 li r6, L1_CACHE_BYTES /* Cache Line Size */
1385 * New GOT-PTR = (old GOT-PTR - CONFIG_SYS_MONITOR_BASE) + Destination Address
1391 /* First our own GOT */
1393 /* then the one used by the C code */
1403 beq cr1,4f /* In place copy is not necessary */
1404 beq 7f /* Protect against 0 count */
1423 * Now flush the cache: note that we must start from a cache aligned
1424 * address. Otherwise we might miss one cache line.
1428 beq 7f /* Always flush prefetch queue in any case */
1436 sync /* Wait for all dcbst to complete on bus */
1442 7: sync /* Wait for all icbi to complete on bus */
1446 * We are done. Do not return, instead branch to second part of board
1447 * initialization, now running from RAM.
1450 addi r0, r10, in_ram - _start + _START_OFFSET
1452 blr /* NEVER RETURNS! */
1457 * Relocation Function, r12 point to got2+0x8000
1459 * Adjust got2 pointers, no need to check for 0, this code
1460 * already puts a few entries in the table.
1462 li r0,__got2_entries@sectoff@l
1463 la r3,GOT(_GOT2_TABLE_)
1464 lwz r11,GOT(_GOT2_TABLE_)
1476 * Now adjust the fixups and the pointers to the fixups
1477 * in case we need to move ourselves again.
1479 li r0,__fixup_entries@sectoff@l
1480 lwz r3,GOT(_FIXUP_TABLE_)
1496 * Now clear BSS segment
1498 lwz r3,GOT(__bss_start)
1499 lwz r4,GOT(__bss_end)
1521 mr r3, r9 /* Init Data pointer */
1522 mr r4, r10 /* Destination Address */
1526 * Copy exception vector code to low memory
1529 * r7: source address, r8: end address, r9: target address
1533 mflr r4 /* save link register */
1535 lwz r7, GOT(_start_of_vectors)
1536 lwz r8, GOT(_end_of_vectors)
1538 li r9, 0x100 /* reset vector always at 0x100 */
1541 bgelr /* return if r7>=r8 - just in case */
1551 * relocate `hdlr' and `int_return' entries
1553 li r7, .L_MachineCheck - _start + _START_OFFSET
1554 li r8, Alignment - _start + _START_OFFSET
1557 addi r7, r7, 0x100 /* next exception vector */
1561 li r7, .L_Alignment - _start + _START_OFFSET
1564 li r7, .L_ProgramCheck - _start + _START_OFFSET
1568 li r7, .L_FPUnavailable - _start + _START_OFFSET
1571 li r7, .L_Decrementer - _start + _START_OFFSET
1574 li r7, .L_APU - _start + _START_OFFSET
1577 li r7, .L_InstructionTLBError - _start + _START_OFFSET
1580 li r7, .L_DataTLBError - _start + _START_OFFSET
1582 #else /* CONFIG_440 */
1583 li r7, .L_PIT - _start + _START_OFFSET
1586 li r7, .L_InstructionTLBMiss - _start + _START_OFFSET
1589 li r7, .L_DataTLBMiss - _start + _START_OFFSET
1591 #endif /* CONFIG_440 */
1593 li r7, .L_DebugBreakpoint - _start + _START_OFFSET
1596 #if !defined(CONFIG_440)
1597 addi r7,r0,0x1000 /* set ME bit (Machine Exceptions) */
1598 oris r7,r7,0x0002 /* set CE bit (Critical Exceptions) */
1599 mtmsr r7 /* change MSR */
1602 b __440_msr_continue
1605 addi r7,r0,0x1000 /* set ME bit (Machine Exceptions) */
1606 oris r7,r7,0x0002 /* set CE bit (Critical Exceptions) */
1614 mtlr r4 /* restore link register */
1616 #endif /* CONFIG_SPL_BUILD */
1618 #if defined(CONFIG_440)
1619 /*----------------------------------------------------------------------------+
1621 +----------------------------------------------------------------------------*/
1622 function_prolog(dcbz_area)
1623 rlwinm. r5,r4,0,27,31
1624 rlwinm r5,r4,27,5,31
1633 function_epilog(dcbz_area)
1634 #endif /* CONFIG_440 */
1635 #endif /* CONFIG_NAND_SPL */
1637 /*------------------------------------------------------------------------------- */
1639 /* Description: Input 8 bits */
1640 /*------------------------------------------------------------------------------- */
1646 /*------------------------------------------------------------------------------- */
1647 /* Function: out8 */
1648 /* Description: Output 8 bits */
1649 /*------------------------------------------------------------------------------- */
1655 /*------------------------------------------------------------------------------- */
1656 /* Function: out32 */
1657 /* Description: Output 32 bits */
1658 /*------------------------------------------------------------------------------- */
1664 /*------------------------------------------------------------------------------- */
1665 /* Function: in32 */
1666 /* Description: Input 32 bits */
1667 /*------------------------------------------------------------------------------- */
1673 /**************************************************************************/
1674 /* PPC405EP specific stuff */
1675 /**************************************************************************/
1679 #ifdef CONFIG_BUBINGA
1681 * Initialize EBC chip selects 1 & 4 and GPIO pins (for alternate
1682 * function) to support FPGA and NVRAM accesses below.
1685 lis r3,GPIO0_OSRH@h /* config GPIO output select */
1686 ori r3,r3,GPIO0_OSRH@l
1687 lis r4,CONFIG_SYS_GPIO0_OSRH@h
1688 ori r4,r4,CONFIG_SYS_GPIO0_OSRH@l
1691 ori r3,r3,GPIO0_OSRL@l
1692 lis r4,CONFIG_SYS_GPIO0_OSRL@h
1693 ori r4,r4,CONFIG_SYS_GPIO0_OSRL@l
1696 lis r3,GPIO0_ISR1H@h /* config GPIO input select */
1697 ori r3,r3,GPIO0_ISR1H@l
1698 lis r4,CONFIG_SYS_GPIO0_ISR1H@h
1699 ori r4,r4,CONFIG_SYS_GPIO0_ISR1H@l
1701 lis r3,GPIO0_ISR1L@h
1702 ori r3,r3,GPIO0_ISR1L@l
1703 lis r4,CONFIG_SYS_GPIO0_ISR1L@h
1704 ori r4,r4,CONFIG_SYS_GPIO0_ISR1L@l
1707 lis r3,GPIO0_TSRH@h /* config GPIO three-state select */
1708 ori r3,r3,GPIO0_TSRH@l
1709 lis r4,CONFIG_SYS_GPIO0_TSRH@h
1710 ori r4,r4,CONFIG_SYS_GPIO0_TSRH@l
1713 ori r3,r3,GPIO0_TSRL@l
1714 lis r4,CONFIG_SYS_GPIO0_TSRL@h
1715 ori r4,r4,CONFIG_SYS_GPIO0_TSRL@l
1718 lis r3,GPIO0_TCR@h /* config GPIO driver output enables */
1719 ori r3,r3,GPIO0_TCR@l
1720 lis r4,CONFIG_SYS_GPIO0_TCR@h
1721 ori r4,r4,CONFIG_SYS_GPIO0_TCR@l
1724 li r3,PB1AP /* program EBC bank 1 for RTC access */
1725 mtdcr EBC0_CFGADDR,r3
1726 lis r3,CONFIG_SYS_EBC_PB1AP@h
1727 ori r3,r3,CONFIG_SYS_EBC_PB1AP@l
1728 mtdcr EBC0_CFGDATA,r3
1730 mtdcr EBC0_CFGADDR,r3
1731 lis r3,CONFIG_SYS_EBC_PB1CR@h
1732 ori r3,r3,CONFIG_SYS_EBC_PB1CR@l
1733 mtdcr EBC0_CFGDATA,r3
1735 li r3,PB1AP /* program EBC bank 1 for RTC access */
1736 mtdcr EBC0_CFGADDR,r3
1737 lis r3,CONFIG_SYS_EBC_PB1AP@h
1738 ori r3,r3,CONFIG_SYS_EBC_PB1AP@l
1739 mtdcr EBC0_CFGDATA,r3
1741 mtdcr EBC0_CFGADDR,r3
1742 lis r3,CONFIG_SYS_EBC_PB1CR@h
1743 ori r3,r3,CONFIG_SYS_EBC_PB1CR@l
1744 mtdcr EBC0_CFGDATA,r3
1746 li r3,PB4AP /* program EBC bank 4 for FPGA access */
1747 mtdcr EBC0_CFGADDR,r3
1748 lis r3,CONFIG_SYS_EBC_PB4AP@h
1749 ori r3,r3,CONFIG_SYS_EBC_PB4AP@l
1750 mtdcr EBC0_CFGDATA,r3
1752 mtdcr EBC0_CFGADDR,r3
1753 lis r3,CONFIG_SYS_EBC_PB4CR@h
1754 ori r3,r3,CONFIG_SYS_EBC_PB4CR@l
1755 mtdcr EBC0_CFGDATA,r3
1759 !-----------------------------------------------------------------------
1760 ! Check to see if chip is in bypass mode.
1761 ! If so, write stored CPC0_PLLMR0 and CPC0_PLLMR1 values and perform a
1762 ! CPU reset Otherwise, skip this step and keep going.
1763 ! Note: Running BIOS in bypass mode is not supported since PLB speed
1764 ! will not be fast enough for the SDRAM (min 66MHz)
1765 !-----------------------------------------------------------------------
1767 mfdcr r5, CPC0_PLLMR1
1768 rlwinm r4,r5,1,0x1 /* get system clock source (SSCS) */
1771 beq pll_done /* if SSCS =b'1' then PLL has */
1772 /* already been set */
1773 /* and CPU has been reset */
1774 /* so skip to next section */
1776 #ifdef CONFIG_BUBINGA
1778 !-----------------------------------------------------------------------
1779 ! Read NVRAM to get value to write in PLLMR.
1780 ! If value has not been correctly saved, write default value
1781 ! Default config values (assuming on-board 33MHz SYS_CLK) are above.
1782 ! See CPU_DEFAULT_200 and CPU_DEFAULT_266 above.
1784 ! WARNING: This code assumes the first three words in the nvram_t
1785 ! structure in openbios.h. Changing the beginning of
1786 ! the structure will break this code.
1788 !-----------------------------------------------------------------------
1790 addis r3,0,NVRAM_BASE@h
1791 addi r3,r3,NVRAM_BASE@l
1794 addis r5,0,NVRVFY1@h
1795 addi r5,r5,NVRVFY1@l
1796 cmp cr0,0,r4,r5 /* Compare 1st NVRAM Magic number*/
1800 addis r5,0,NVRVFY2@h
1801 addi r5,r5,NVRVFY2@l
1802 cmp cr0,0,r4,r5 /* Compare 2 NVRAM Magic number */
1804 addi r3,r3,8 /* Skip over conf_size */
1805 lwz r4, 4(r3) /* Load PLLMR1 value from NVRAM */
1806 lwz r3, 0(r3) /* Load PLLMR0 value from NVRAM */
1807 rlwinm r5,r4,1,0x1 /* get system clock source (SSCS) */
1808 cmpi cr0,0,r5,1 /* See if PLL is locked */
1811 #endif /* CONFIG_BUBINGA */
1815 andi. r5, r4, CPC0_BOOT_SEP@l
1816 bne strap_1 /* serial eeprom present */
1817 addis r5,0,CPLD_REG0_ADDR@h
1818 ori r5,r5,CPLD_REG0_ADDR@l
1821 #endif /* CONFIG_TAIHU */
1823 #if defined(CONFIG_ZEUS)
1825 andi. r5, r4, CPC0_BOOT_SEP@l
1826 bne strap_1 /* serial eeprom present */
1833 mfdcr r3, CPC0_PLLMR0
1834 mfdcr r4, CPC0_PLLMR1
1838 addis r3,0,PLLMR0_DEFAULT@h /* PLLMR0 default value */
1839 ori r3,r3,PLLMR0_DEFAULT@l /* */
1840 addis r4,0,PLLMR1_DEFAULT@h /* PLLMR1 default value */
1841 ori r4,r4,PLLMR1_DEFAULT@l /* */
1846 addis r3,0,PLLMR0_DEFAULT_PCI66@h
1847 ori r3,r3,PLLMR0_DEFAULT_PCI66@l
1848 addis r4,0,PLLMR1_DEFAULT_PCI66@h
1849 ori r4,r4,PLLMR1_DEFAULT_PCI66@l
1852 mfdcr r3, CPC0_PLLMR0
1853 mfdcr r4, CPC0_PLLMR1
1854 #endif /* CONFIG_TAIHU */
1857 b pll_write /* Write the CPC0_PLLMR with new value */
1861 !-----------------------------------------------------------------------
1862 ! Clear Soft Reset Register
1863 ! This is needed to enable PCI if not booting from serial EPROM
1864 !-----------------------------------------------------------------------
1874 blr /* return to main code */
1877 !-----------------------------------------------------------------------------
1878 ! Function: pll_write
1879 ! Description: Updates the value of the CPC0_PLLMR according to CMOS27E documentation
1881 ! 1. Pll is first disabled (de-activated by putting in bypass mode)
1883 ! 3. Clock dividers are set while PLL is held in reset and bypassed
1884 ! 4. PLL Reset is cleared
1885 ! 5. Wait 100us for PLL to lock
1886 ! 6. A core reset is performed
1887 ! Input: r3 = Value to write to CPC0_PLLMR0
1888 ! Input: r4 = Value to write to CPC0_PLLMR1
1890 !-----------------------------------------------------------------------------
1896 ori r5,r5,0x0101 /* Stop the UART clocks */
1897 mtdcr CPC0_UCR,r5 /* Before changing PLL */
1899 mfdcr r5, CPC0_PLLMR1
1900 rlwinm r5,r5,0,0x7FFFFFFF /* Disable PLL */
1901 mtdcr CPC0_PLLMR1,r5
1902 oris r5,r5,0x4000 /* Set PLL Reset */
1903 mtdcr CPC0_PLLMR1,r5
1905 mtdcr CPC0_PLLMR0,r3 /* Set clock dividers */
1906 rlwinm r5,r4,0,0x3FFFFFFF /* Reset & Bypass new PLL dividers */
1907 oris r5,r5,0x4000 /* Set PLL Reset */
1908 mtdcr CPC0_PLLMR1,r5 /* Set clock dividers */
1909 rlwinm r5,r5,0,0xBFFFFFFF /* Clear PLL Reset */
1910 mtdcr CPC0_PLLMR1,r5
1913 ! Wait min of 100us for PLL to lock.
1914 ! See CMOS 27E databook for more info.
1915 ! At 200MHz, that means waiting 20,000 instructions
1917 addi r3,0,20000 /* 2000 = 0x4e20 */
1922 oris r5,r5,0x8000 /* Enable PLL */
1923 mtdcr CPC0_PLLMR1,r5 /* Engage */
1926 * Reset CPU to guarantee timings are OK
1927 * Not sure if this is needed...
1930 mtspr SPRN_DBCR0,r3 /* This will cause a CPU core reset, and */
1931 /* execution will continue from the poweron */
1932 /* vector of 0xfffffffc */
1933 #endif /* CONFIG_405EP */
1935 #if defined(CONFIG_440)
1936 /*----------------------------------------------------------------------------+
1938 +----------------------------------------------------------------------------*/
1939 function_prolog(mttlb3)
1942 function_epilog(mttlb3)
1944 /*----------------------------------------------------------------------------+
1946 +----------------------------------------------------------------------------*/
1947 function_prolog(mftlb3)
1950 function_epilog(mftlb3)
1952 /*----------------------------------------------------------------------------+
1954 +----------------------------------------------------------------------------*/
1955 function_prolog(mttlb2)
1958 function_epilog(mttlb2)
1960 /*----------------------------------------------------------------------------+
1962 +----------------------------------------------------------------------------*/
1963 function_prolog(mftlb2)
1966 function_epilog(mftlb2)
1968 /*----------------------------------------------------------------------------+
1970 +----------------------------------------------------------------------------*/
1971 function_prolog(mttlb1)
1974 function_epilog(mttlb1)
1976 /*----------------------------------------------------------------------------+
1978 +----------------------------------------------------------------------------*/
1979 function_prolog(mftlb1)
1982 function_epilog(mftlb1)
1983 #endif /* CONFIG_440 */
1985 #if defined(CONFIG_NAND_SPL)
1987 * void nand_boot_relocate(dst, src, bytes)
1989 * r3 = Destination address to copy code to (in SDRAM)
1990 * r4 = Source address to copy code from
1991 * r5 = size to copy in bytes
1999 * Copy SPL from icache into SDRAM
2011 * Calculate "corrected" link register, so that we "continue"
2012 * in execution in destination range
2014 sub r3,r7,r6 /* r3 = src - dst */
2015 sub r8,r8,r3 /* r8 = link-reg - (src - dst) */
2021 * First initialize SDRAM. It has to be available *before* calling
2024 lis r3,CONFIG_SYS_SDRAM_BASE@h
2025 ori r3,r3,CONFIG_SYS_SDRAM_BASE@l
2029 * Now copy the 4k SPL code into SDRAM and continue execution
2032 lis r3,CONFIG_SYS_NAND_BOOT_SPL_DST@h
2033 ori r3,r3,CONFIG_SYS_NAND_BOOT_SPL_DST@l
2034 lis r4,CONFIG_SYS_NAND_BOOT_SPL_SRC@h
2035 ori r4,r4,CONFIG_SYS_NAND_BOOT_SPL_SRC@l
2036 lis r5,CONFIG_SYS_NAND_BOOT_SPL_SIZE@h
2037 ori r5,r5,CONFIG_SYS_NAND_BOOT_SPL_SIZE@l
2038 bl nand_boot_relocate
2041 * We're running from SDRAM now!!!
2043 * It is necessary for 4xx systems to relocate from running at
2044 * the original location (0xfffffxxx) to somewhere else (SDRAM
2045 * preferably). This is because CS0 needs to be reconfigured for
2046 * NAND access. And we can't reconfigure this CS when currently
2047 * "running" from it.
2051 * Finally call nand_boot() to load main NAND U-Boot image from
2052 * NAND and jump to it.
2054 bl nand_boot /* will not return */
2055 #endif /* CONFIG_NAND_SPL */