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
187 * Set up GOT: Global Offset Table
189 * Use r12 to access the GOT
191 #if !defined(CONFIG_SPL_BUILD)
193 GOT_ENTRY(_GOT2_TABLE_)
194 GOT_ENTRY(_FIXUP_TABLE_)
197 GOT_ENTRY(_start_of_vectors)
198 GOT_ENTRY(_end_of_vectors)
199 GOT_ENTRY(transfer_to_handler)
201 GOT_ENTRY(__init_end)
203 GOT_ENTRY(__bss_start)
205 #endif /* CONFIG_SPL_BUILD */
207 #if defined(CONFIG_SYS_RAMBOOT) || defined(CONFIG_BOOT_FROM_XMD)
209 * 4xx RAM-booting U-Boot image is started from offset 0
215 #if defined(CONFIG_SPL) && !defined(CONFIG_SPL_BUILD)
217 * This is the entry of the real U-Boot from a board port
218 * that supports SPL booting on the PPC4xx. We only need
219 * to call board_init_f() here. Everything else has already
220 * been done in the SPL u-boot version.
222 GET_GOT /* initialize GOT access */
223 bl board_init_f /* run 1st part of board init code (in Flash)*/
224 /* NOTREACHED - board_init_f() does not return */
228 * 440 Startup -- on reset only the top 4k of the effective
229 * address space is mapped in by an entry in the instruction
230 * and data shadow TLB. The .bootpg section is located in the
231 * top 4k & does only what's necessary to map in the the rest
232 * of the boot rom. Once the boot rom is mapped in we can
233 * proceed with normal startup.
235 * NOTE: CS0 only covers the top 2MB of the effective address
239 #if defined(CONFIG_440)
240 .section .bootpg,"ax"
243 /**************************************************************************/
245 /*--------------------------------------------------------------------+
246 | 440EPX BUP Change - Hardware team request
247 +--------------------------------------------------------------------*/
248 #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
253 /*----------------------------------------------------------------+
254 | Core bug fix. Clear the esr
255 +-----------------------------------------------------------------*/
258 /*----------------------------------------------------------------*/
259 /* Clear and set up some registers. */
260 /*----------------------------------------------------------------*/
261 iccci r0,r0 /* NOTE: operands not used for 440 */
262 dccci r0,r0 /* NOTE: operands not used for 440 */
269 /* NOTE: 440GX adds machine check status regs */
270 #if defined(CONFIG_440) && !defined(CONFIG_440GP)
277 /*----------------------------------------------------------------*/
279 /*----------------------------------------------------------------*/
280 /* Disable store gathering & broadcast, guarantee inst/data
281 * cache block touch, force load/store alignment
282 * (see errata 1.12: 440_33)
284 lis r1,0x0030 /* store gathering & broadcast disable */
285 ori r1,r1,0x6000 /* cache touch */
288 /*----------------------------------------------------------------*/
289 /* Initialize debug */
290 /*----------------------------------------------------------------*/
292 andis. r1, r1, 0x8000 /* test DBCR0[EDM] bit */
293 bne skip_debug_init /* if set, don't clear debug register */
295 ori r1,r1,CCR0_DTB@l /* Disable Trace Broadcast */
309 mtspr SPRN_DBSR,r1 /* Clear all valid bits */
312 #if defined (CONFIG_440SPE)
313 /*----------------------------------------------------------------+
314 | Initialize Core Configuration Reg1.
315 | a. ICDPEI: Record even parity. Normal operation.
316 | b. ICTPEI: Record even parity. Normal operation.
317 | c. DCTPEI: Record even parity. Normal operation.
318 | d. DCDPEI: Record even parity. Normal operation.
319 | e. DCUPEI: Record even parity. Normal operation.
320 | f. DCMPEI: Record even parity. Normal operation.
321 | g. FCOM: Normal operation
322 | h. MMUPEI: Record even parity. Normal operation.
323 | i. FFF: Flush only as much data as necessary.
324 | j. TCS: Timebase increments from CPU clock.
325 +-----------------------------------------------------------------*/
329 /*----------------------------------------------------------------+
330 | Reset the timebase.
331 | The previous write to CCR1 sets the timebase source.
332 +-----------------------------------------------------------------*/
337 /*----------------------------------------------------------------*/
338 /* Setup interrupt vectors */
339 /*----------------------------------------------------------------*/
340 mtspr SPRN_IVPR,r0 /* Vectors start at 0x0000_0000 */
342 mtspr SPRN_IVOR0,r1 /* Critical input */
344 mtspr SPRN_IVOR1,r1 /* Machine check */
346 mtspr SPRN_IVOR2,r1 /* Data storage */
348 mtspr SPRN_IVOR3,r1 /* Instruction storage */
350 mtspr SPRN_IVOR4,r1 /* External interrupt */
352 mtspr SPRN_IVOR5,r1 /* Alignment */
354 mtspr SPRN_IVOR6,r1 /* Program check */
356 mtspr SPRN_IVOR7,r1 /* Floating point unavailable */
358 mtspr SPRN_IVOR8,r1 /* System call */
360 mtspr SPRN_IVOR9,r1 /* Auxiliary Processor unavailable */
362 mtspr SPRN_IVOR10,r1 /* Decrementer */
364 mtspr SPRN_IVOR13,r1 /* Data TLB error */
366 mtspr SPRN_IVOR14,r1 /* Instr TLB error */
368 mtspr SPRN_IVOR15,r1 /* Debug */
370 /*----------------------------------------------------------------*/
371 /* Configure cache regions */
372 /*----------------------------------------------------------------*/
390 /*----------------------------------------------------------------*/
391 /* Cache victim limits */
392 /*----------------------------------------------------------------*/
393 /* floors 0, ceiling max to use the entire cache -- nothing locked
400 /*----------------------------------------------------------------+
401 |Initialize MMUCR[STID] = 0.
402 +-----------------------------------------------------------------*/
409 /*----------------------------------------------------------------*/
410 /* Clear all TLB entries -- TID = 0, TS = 0 */
411 /*----------------------------------------------------------------*/
413 #ifdef CONFIG_SYS_RAMBOOT
414 li r4,0 /* Start with TLB #0 */
416 li r4,1 /* Start with TLB #1 */
418 li r1,64 /* 64 TLB entries */
419 sub r1,r1,r4 /* calculate last TLB # */
422 #ifdef CONFIG_SYS_RAMBOOT
423 tlbre r3,r4,0 /* Read contents from TLB word #0 to get EPN */
424 rlwinm. r3,r3,0,0xfffffc00 /* Mask EPN */
425 beq tlbnxt /* Skip EPN=0 TLB, this is the SDRAM TLB */
427 tlbwe r0,r4,0 /* Invalidate all entries (V=0)*/
430 tlbnxt: addi r4,r4,1 /* Next TLB */
433 /*----------------------------------------------------------------*/
434 /* TLB entry setup -- step thru tlbtab */
435 /*----------------------------------------------------------------*/
436 #if defined(CONFIG_440SPE_REVA)
437 /*----------------------------------------------------------------*/
438 /* We have different TLB tables for revA and rev B of 440SPe */
439 /*----------------------------------------------------------------*/
451 bl tlbtab /* Get tlbtab pointer */
454 li r1,0x003f /* 64 TLB entries max */
460 #ifdef CONFIG_SYS_RAMBOOT
461 tlbre r3,r4,0 /* Read contents from TLB word #0 */
462 rlwinm. r3,r3,0,0x00000200 /* Mask V (valid) bit */
463 bne tlbnx2 /* Skip V=1 TLB, this is the SDRAM TLB */
467 beq 2f /* 0 marks end */
470 tlbwe r0,r4,0 /* TLB Word 0 */
471 tlbwe r1,r4,1 /* TLB Word 1 */
472 tlbwe r2,r4,2 /* TLB Word 2 */
473 tlbnx2: addi r4,r4,1 /* Next TLB */
476 /*----------------------------------------------------------------*/
477 /* Continue from 'normal' start */
478 /*----------------------------------------------------------------*/
484 mtspr SPRN_SRR1,r0 /* Keep things disabled for now */
488 #endif /* CONFIG_440 */
491 * r3 - 1st arg to board_init(): IMMP pointer
492 * r4 - 2nd arg to board_init(): boot flag
494 #if !defined(CONFIG_SPL_BUILD)
496 .long 0x27051956 /* U-Boot Magic Number */
497 .globl version_string
499 .ascii U_BOOT_VERSION_STRING, "\0"
501 . = EXC_OFF_SYS_RESET
502 .globl _start_of_vectors
505 /* Critical input. */
506 CRIT_EXCEPTION(0x100, CritcalInput, UnknownException)
510 MCK_EXCEPTION(0x200, MachineCheck, MachineCheckException)
512 CRIT_EXCEPTION(0x200, MachineCheck, MachineCheckException)
513 #endif /* CONFIG_440 */
515 /* Data Storage exception. */
516 STD_EXCEPTION(0x300, DataStorage, UnknownException)
518 /* Instruction Storage exception. */
519 STD_EXCEPTION(0x400, InstStorage, UnknownException)
521 /* External Interrupt exception. */
522 STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
524 /* Alignment exception. */
527 EXCEPTION_PROLOG(SRR0, SRR1)
532 addi r3,r1,STACK_FRAME_OVERHEAD
533 EXC_XFER_TEMPLATE(Alignment, AlignmentException, MSR_KERNEL, COPY_EE)
535 /* Program check exception */
538 EXCEPTION_PROLOG(SRR0, SRR1)
539 addi r3,r1,STACK_FRAME_OVERHEAD
540 EXC_XFER_TEMPLATE(ProgramCheck, ProgramCheckException,
544 STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
545 STD_EXCEPTION(0x900, Decrementer, DecrementerPITException)
546 STD_EXCEPTION(0xa00, APU, UnknownException)
548 STD_EXCEPTION(0xc00, SystemCall, UnknownException)
551 STD_EXCEPTION(0x1300, DataTLBError, UnknownException)
552 STD_EXCEPTION(0x1400, InstructionTLBError, UnknownException)
554 STD_EXCEPTION(0x1000, PIT, DecrementerPITException)
555 STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException)
556 STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException)
558 CRIT_EXCEPTION(0x2000, DebugBreakpoint, DebugException )
560 .globl _end_of_vectors
567 #if defined(CONFIG_SPL) && !defined(CONFIG_SPL_BUILD)
569 * This is the entry of the real U-Boot from a board port
570 * that supports SPL booting on the PPC4xx. We only need
571 * to call board_init_f() here. Everything else has already
572 * been done in the SPL u-boot version.
574 GET_GOT /* initialize GOT access */
575 bl board_init_f /* run 1st part of board init code (in Flash)*/
576 /* NOTREACHED - board_init_f() does not return */
579 /*****************************************************************************/
580 #if defined(CONFIG_440)
582 /*----------------------------------------------------------------*/
583 /* Clear and set up some registers. */
584 /*----------------------------------------------------------------*/
587 mtspr SPRN_DEC,r0 /* prevent dec exceptions */
588 mtspr SPRN_TBWL,r0 /* prevent fit & wdt exceptions */
590 mtspr SPRN_TSR,r1 /* clear all timer exception status */
591 mtspr SPRN_TCR,r0 /* disable all */
592 mtspr SPRN_ESR,r0 /* clear exception syndrome register */
593 mtxer r0 /* clear integer exception register */
595 /*----------------------------------------------------------------*/
596 /* Debug setup -- some (not very good) ice's need an event*/
597 /* to establish control :-( Define CONFIG_SYS_INIT_DBCR to the dbsr */
598 /* value you need in this case 0x8cff 0000 should do the trick */
599 /*----------------------------------------------------------------*/
600 #if defined(CONFIG_SYS_INIT_DBCR)
603 mtspr SPRN_DBSR,r1 /* Clear all status bits */
604 lis r0,CONFIG_SYS_INIT_DBCR@h
605 ori r0,r0,CONFIG_SYS_INIT_DBCR@l
610 /*----------------------------------------------------------------*/
611 /* Setup the internal SRAM */
612 /*----------------------------------------------------------------*/
615 #ifdef CONFIG_SYS_INIT_RAM_DCACHE
616 /* Clear Dcache to use as RAM */
617 addis r3,r0,CONFIG_SYS_INIT_RAM_ADDR@h
618 ori r3,r3,CONFIG_SYS_INIT_RAM_ADDR@l
619 addis r4,r0,CONFIG_SYS_INIT_RAM_SIZE@h
620 ori r4,r4,CONFIG_SYS_INIT_RAM_SIZE@l
621 rlwinm. r5,r4,0,27,31
633 * Lock the init-ram/stack in d-cache, so that other regions
634 * may use d-cache as well
635 * Note, that this current implementation locks exactly 4k
636 * of d-cache, so please make sure that you don't define a
637 * bigger init-ram area. Take a look at the lwmon5 440EPx
638 * implementation as a reference.
642 /* 8. set TFLOOR/NFLOOR to 8 (-> 8*16*32 bytes locked -> 4k) */
658 #endif /* CONFIG_SYS_INIT_RAM_DCACHE */
660 /* 440EP & 440GR are only 440er PPC's without internal SRAM */
661 #if !defined(CONFIG_440EP) && !defined(CONFIG_440GR)
662 /* not all PPC's have internal SRAM usable as L2-cache */
663 #if defined(CONFIG_440GX) || \
664 defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
665 defined(CONFIG_460SX)
666 mtdcr L2_CACHE_CFG,r0 /* Ensure L2 Cache is off */
667 #elif defined(CONFIG_460EX) || defined(CONFIG_460GT)
669 ori r1,r1,0x0008 /* Set L2_CACHE_CFG[RDBW]=1 */
670 mtdcr L2_CACHE_CFG,r1
676 and r1,r1,r2 /* Disable parity check */
679 and r1,r1,r2 /* Disable pwr mgmt */
682 lis r1,0x8000 /* BAS = 8000_0000 */
683 #if defined(CONFIG_440GX) || defined(CONFIG_440SP)
684 ori r1,r1,0x0980 /* first 64k */
685 mtdcr ISRAM0_SB0CR,r1
687 ori r1,r1,0x0980 /* second 64k */
688 mtdcr ISRAM0_SB1CR,r1
690 ori r1,r1, 0x0980 /* third 64k */
691 mtdcr ISRAM0_SB2CR,r1
693 ori r1,r1, 0x0980 /* fourth 64k */
694 mtdcr ISRAM0_SB3CR,r1
695 #elif defined(CONFIG_440SPE) || defined(CONFIG_460EX) || \
696 defined(CONFIG_460GT)
697 lis r1,0x0000 /* BAS = X_0000_0000 */
698 ori r1,r1,0x0984 /* first 64k */
699 mtdcr ISRAM0_SB0CR,r1
701 ori r1,r1,0x0984 /* second 64k */
702 mtdcr ISRAM0_SB1CR,r1
704 ori r1,r1, 0x0984 /* third 64k */
705 mtdcr ISRAM0_SB2CR,r1
707 ori r1,r1, 0x0984 /* fourth 64k */
708 mtdcr ISRAM0_SB3CR,r1
709 #if defined(CONFIG_460EX) || defined(CONFIG_460GT)
713 and r1,r1,r2 /* Disable parity check */
716 and r1,r1,r2 /* Disable pwr mgmt */
719 lis r1,0x0004 /* BAS = 4_0004_0000 */
720 ori r1,r1,ISRAM1_SIZE /* ocm size */
721 mtdcr ISRAM1_SB0CR,r1
723 #elif defined(CONFIG_460SX)
724 lis r1,0x0000 /* BAS = 0000_0000 */
725 ori r1,r1,0x0B84 /* first 128k */
726 mtdcr ISRAM0_SB0CR,r1
728 ori r1,r1,0x0B84 /* second 128k */
729 mtdcr ISRAM0_SB1CR,r1
731 ori r1,r1, 0x0B84 /* third 128k */
732 mtdcr ISRAM0_SB2CR,r1
734 ori r1,r1, 0x0B84 /* fourth 128k */
735 mtdcr ISRAM0_SB3CR,r1
736 #elif defined(CONFIG_440GP)
737 ori r1,r1,0x0380 /* 8k rw */
738 mtdcr ISRAM0_SB0CR,r1
739 mtdcr ISRAM0_SB1CR,r0 /* Disable bank 1 */
741 #endif /* #if !defined(CONFIG_440EP) && !defined(CONFIG_440GR) */
743 /*----------------------------------------------------------------*/
744 /* Setup the stack in internal SRAM */
745 /*----------------------------------------------------------------*/
746 lis r1,CONFIG_SYS_INIT_RAM_ADDR@h
747 ori r1,r1,CONFIG_SYS_INIT_SP_OFFSET@l
750 stwu r0,-4(r1) /* Terminate call chain */
752 stwu r1,-8(r1) /* Save back chain and move SP */
753 lis r0,RESET_VECTOR@h /* Address of reset vector */
754 ori r0,r0, RESET_VECTOR@l
755 stwu r1,-8(r1) /* Save back chain and move SP */
756 stw r0,+12(r1) /* Save return addr (underflow vect) */
758 #ifndef CONFIG_SPL_BUILD
762 bl cpu_init_f /* run low-level CPU init code (from Flash) */
764 /* NOTREACHED - board_init_f() does not return */
766 #endif /* CONFIG_440 */
768 /*****************************************************************************/
769 #if defined(CONFIG_405GP) || \
770 defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \
771 defined(CONFIG_405EX) || defined(CONFIG_405)
772 /*----------------------------------------------------------------------- */
773 /* Clear and set up some registers. */
774 /*----------------------------------------------------------------------- */
776 #if !defined(CONFIG_405EX)
780 * On 405EX, completely clearing the SGR leads to PPC hangup
781 * upon PCIe configuration access. The PCIe memory regions
782 * need to be guarded!
789 mtesr r4 /* clear Exception Syndrome Reg */
790 mttcr r4 /* clear Timer Control Reg */
791 mtxer r4 /* clear Fixed-Point Exception Reg */
792 mtevpr r4 /* clear Exception Vector Prefix Reg */
793 addi r4,r0,(0xFFFF-0x10000) /* set r4 to 0xFFFFFFFF (status in the */
794 /* dbsr is cleared by setting bits to 1) */
795 mtdbsr r4 /* clear/reset the dbsr */
797 /* Invalidate the i- and d-caches. */
801 /* Set-up icache cacheability. */
802 lis r4, CONFIG_SYS_ICACHE_SACR_VALUE@h
803 ori r4, r4, CONFIG_SYS_ICACHE_SACR_VALUE@l
807 /* Set-up dcache cacheability. */
808 lis r4, CONFIG_SYS_DCACHE_SACR_VALUE@h
809 ori r4, r4, CONFIG_SYS_DCACHE_SACR_VALUE@l
812 #if !(defined(CONFIG_SYS_EBC_PB0AP) && defined(CONFIG_SYS_EBC_PB0CR))\
813 && !defined (CONFIG_XILINX_405)
814 /*----------------------------------------------------------------------- */
815 /* Tune the speed and size for flash CS0 */
816 /*----------------------------------------------------------------------- */
817 bl ext_bus_cntlr_init
820 #if !(defined(CONFIG_SYS_INIT_DCACHE_CS) || defined(CONFIG_SYS_TEMP_STACK_OCM))
822 * For boards that don't have OCM and can't use the data cache
823 * for their primordial stack, setup stack here directly after the
824 * SDRAM is initialized in ext_bus_cntlr_init.
826 lis r1, CONFIG_SYS_INIT_RAM_ADDR@h
827 ori r1,r1,CONFIG_SYS_INIT_SP_OFFSET /* set up the stack in SDRAM */
829 li r0, 0 /* Make room for stack frame header and */
830 stwu r0, -4(r1) /* clear final stack frame so that */
831 stwu r0, -4(r1) /* stack backtraces terminate cleanly */
833 * Set up a dummy frame to store reset vector as return address.
834 * this causes stack underflow to reset board.
836 stwu r1, -8(r1) /* Save back chain and move SP */
837 lis r0, RESET_VECTOR@h /* Address of reset vector */
838 ori r0, r0, RESET_VECTOR@l
839 stwu r1, -8(r1) /* Save back chain and move SP */
840 stw r0, +12(r1) /* Save return addr (underflow vect) */
841 #endif /* !(CONFIG_SYS_INIT_DCACHE_CS || !CONFIG_SYS_TEM_STACK_OCM) */
843 #if defined(CONFIG_405EP)
844 /*----------------------------------------------------------------------- */
845 /* DMA Status, clear to come up clean */
846 /*----------------------------------------------------------------------- */
847 addis r3,r0, 0xFFFF /* Clear all existing DMA status */
851 bl ppc405ep_init /* do ppc405ep specific init */
852 #endif /* CONFIG_405EP */
854 #if defined(CONFIG_SYS_OCM_DATA_ADDR) && defined(CONFIG_SYS_OCM_DATA_SIZE)
855 #if defined(CONFIG_405EZ)
856 /********************************************************************
857 * Setup OCM - On Chip Memory - PPC405EZ uses OCM Controller V2
858 *******************************************************************/
860 * We can map the OCM on the PLB3, so map it at
861 * CONFIG_SYS_OCM_DATA_ADDR + 0x8000
863 lis r3,CONFIG_SYS_OCM_DATA_ADDR@h /* OCM location */
864 ori r3,r3,CONFIG_SYS_OCM_DATA_ADDR@l
865 ori r3,r3,0x0270 /* 16K for Bank 1, R/W/Enable */
866 mtdcr OCM0_PLBCR1,r3 /* Set PLB Access */
867 ori r3,r3,0x4000 /* Add 0x4000 for bank 2 */
868 mtdcr OCM0_PLBCR2,r3 /* Set PLB Access */
871 lis r3,CONFIG_SYS_OCM_DATA_ADDR@h /* OCM location */
872 ori r3,r3,CONFIG_SYS_OCM_DATA_ADDR@l
873 ori r3,r3,0x0270 /* 16K for Bank 1, R/W/Enable */
874 mtdcr OCM0_DSRC1, r3 /* Set Data Side */
875 mtdcr OCM0_ISRC1, r3 /* Set Instruction Side */
876 ori r3,r3,0x4000 /* Add 0x4000 for bank 2 */
877 mtdcr OCM0_DSRC2, r3 /* Set Data Side */
878 mtdcr OCM0_ISRC2, r3 /* Set Instruction Side */
879 addis r3,0,0x0800 /* OCM Data Parity Disable - 1 Wait State */
883 #else /* CONFIG_405EZ */
884 /********************************************************************
885 * Setup OCM - On Chip Memory
886 *******************************************************************/
890 mfdcr r3, OCM0_ISCNTL /* get instr-side IRAM config */
891 mfdcr r4, OCM0_DSCNTL /* get data-side IRAM config */
892 and r3, r3, r0 /* disable data-side IRAM */
893 and r4, r4, r0 /* disable data-side IRAM */
894 mtdcr OCM0_ISCNTL, r3 /* set instr-side IRAM config */
895 mtdcr OCM0_DSCNTL, r4 /* set data-side IRAM config */
898 lis r3,CONFIG_SYS_OCM_DATA_ADDR@h /* OCM location */
899 ori r3,r3,CONFIG_SYS_OCM_DATA_ADDR@l
901 addis r4, 0, 0xC000 /* OCM data area enabled */
902 mtdcr OCM0_DSCNTL, r4
904 #endif /* CONFIG_405EZ */
907 /*----------------------------------------------------------------------- */
908 /* Setup temporary stack in DCACHE or OCM if needed for SDRAM SPD. */
909 /*----------------------------------------------------------------------- */
910 #ifdef CONFIG_SYS_INIT_DCACHE_CS
912 mtdcr EBC0_CFGADDR, r4
913 lis r4, CONFIG_SYS_INIT_DCACHE_PBxAR@h
914 ori r4, r4, CONFIG_SYS_INIT_DCACHE_PBxAR@l
915 mtdcr EBC0_CFGDATA, r4
918 mtdcr EBC0_CFGADDR, r4
919 lis r4, CONFIG_SYS_INIT_DCACHE_PBxCR@h
920 ori r4, r4, CONFIG_SYS_INIT_DCACHE_PBxCR@l
921 mtdcr EBC0_CFGDATA, r4
924 * Enable the data cache for the 128MB storage access control region
925 * at CONFIG_SYS_INIT_RAM_ADDR.
928 oris r4, r4, PPC_128MB_SACR_VALUE(CONFIG_SYS_INIT_RAM_ADDR)@h
929 ori r4, r4, PPC_128MB_SACR_VALUE(CONFIG_SYS_INIT_RAM_ADDR)@l
933 * Preallocate data cache lines to be used to avoid a subsequent
934 * cache miss and an ensuing machine check exception when exceptions
939 lis r3, CONFIG_SYS_INIT_RAM_ADDR@h
940 ori r3, r3, CONFIG_SYS_INIT_RAM_ADDR@l
942 lis r4, CONFIG_SYS_INIT_RAM_SIZE@h
943 ori r4, r4, CONFIG_SYS_INIT_RAM_SIZE@l
946 * Convert the size, in bytes, to the number of cache lines/blocks
949 clrlwi. r5, r4, (32 - L1_CACHE_SHIFT)
950 srwi r5, r4, L1_CACHE_SHIFT
956 /* Preallocate the computed number of cache blocks. */
957 ..alloc_dcache_block:
959 addi r3, r3, L1_CACHE_BYTES
960 bdnz ..alloc_dcache_block
964 * Load the initial stack pointer and data area and convert the size,
965 * in bytes, to the number of words to initialize to a known value.
967 lis r1, CONFIG_SYS_INIT_RAM_ADDR@h
968 ori r1, r1, CONFIG_SYS_INIT_SP_OFFSET@l
970 lis r4, (CONFIG_SYS_INIT_RAM_SIZE >> 2)@h
971 ori r4, r4, (CONFIG_SYS_INIT_RAM_SIZE >> 2)@l
974 lis r2, CONFIG_SYS_INIT_RAM_ADDR@h
975 ori r2, r2, CONFIG_SYS_INIT_RAM_SIZE@l
977 lis r4, CONFIG_SYS_INIT_RAM_PATTERN@h
978 ori r4, r4, CONFIG_SYS_INIT_RAM_PATTERN@l
985 * Make room for stack frame header and clear final stack frame so
986 * that stack backtraces terminate cleanly.
992 * Set up a dummy frame to store reset vector as return address.
993 * this causes stack underflow to reset board.
995 stwu r1, -8(r1) /* Save back chain and move SP */
996 addis r0, 0, RESET_VECTOR@h /* Address of reset vector */
997 ori r0, r0, RESET_VECTOR@l
998 stwu r1, -8(r1) /* Save back chain and move SP */
999 stw r0, +12(r1) /* Save return addr (underflow vect) */
1001 #elif defined(CONFIG_SYS_TEMP_STACK_OCM) && \
1002 (defined(CONFIG_SYS_OCM_DATA_ADDR) && defined(CONFIG_SYS_OCM_DATA_SIZE))
1007 /* Set up Stack at top of OCM */
1008 lis r1, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)@h
1009 ori r1, r1, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET)@l
1011 /* Set up a zeroized stack frame so that backtrace works right */
1017 * Set up a dummy frame to store reset vector as return address.
1018 * this causes stack underflow to reset board.
1020 stwu r1, -8(r1) /* Save back chain and move SP */
1021 lis r0, RESET_VECTOR@h /* Address of reset vector */
1022 ori r0, r0, RESET_VECTOR@l
1023 stwu r1, -8(r1) /* Save back chain and move SP */
1024 stw r0, +12(r1) /* Save return addr (underflow vect) */
1025 #endif /* CONFIG_SYS_INIT_DCACHE_CS */
1027 GET_GOT /* initialize GOT access */
1029 bl cpu_init_f /* run low-level CPU init code (from Flash) */
1031 bl board_init_f /* run first part of init code (from Flash) */
1032 /* NOTREACHED - board_init_f() does not return */
1034 #endif /* CONFIG_405GP || CONFIG_405 || CONFIG_405EP */
1035 /*----------------------------------------------------------------------- */
1038 #if !defined(CONFIG_SPL_BUILD)
1040 * This code finishes saving the registers to the exception frame
1041 * and jumps to the appropriate handler for the exception.
1042 * Register r21 is pointer into trap frame, r1 has new stack pointer.
1044 .globl transfer_to_handler
1045 transfer_to_handler:
1055 andi. r24,r23,0x3f00 /* get vector offset */
1059 mtspr SPRG2,r22 /* r1 is now kernel sp */
1060 lwz r24,0(r23) /* virtual address of handler */
1061 lwz r23,4(r23) /* where to go when done */
1066 rfi /* jump to handler, enable MMU */
1069 mfmsr r28 /* Disable interrupts */
1073 SYNC /* Some chip revs need this... */
1088 lwz r2,_NIP(r1) /* Restore environment */
1099 mfmsr r28 /* Disable interrupts */
1103 SYNC /* Some chip revs need this... */
1118 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 */
1151 mtspr SPRN_MCSRR0,r2
1152 mtspr SPRN_MCSRR1,r0
1158 #endif /* CONFIG_440 */
1166 /*------------------------------------------------------------------------------- */
1167 /* Function: out16 */
1168 /* Description: Output 16 bits */
1169 /*------------------------------------------------------------------------------- */
1175 /*------------------------------------------------------------------------------- */
1176 /* Function: out16r */
1177 /* Description: Byte reverse and output 16 bits */
1178 /*------------------------------------------------------------------------------- */
1184 /*------------------------------------------------------------------------------- */
1185 /* Function: out32r */
1186 /* Description: Byte reverse and output 32 bits */
1187 /*------------------------------------------------------------------------------- */
1193 /*------------------------------------------------------------------------------- */
1194 /* Function: in16 */
1195 /* Description: Input 16 bits */
1196 /*------------------------------------------------------------------------------- */
1202 /*------------------------------------------------------------------------------- */
1203 /* Function: in16r */
1204 /* Description: Input 16 bits and byte reverse */
1205 /*------------------------------------------------------------------------------- */
1211 /*------------------------------------------------------------------------------- */
1212 /* Function: in32r */
1213 /* Description: Input 32 bits and byte reverse */
1214 /*------------------------------------------------------------------------------- */
1220 #if !defined(CONFIG_SPL_BUILD)
1222 * void relocate_code (addr_sp, gd, addr_moni)
1224 * This "function" does not return, instead it continues in RAM
1225 * after relocating the monitor code.
1227 * r3 = Relocated stack pointer
1228 * r4 = Relocated global data pointer
1229 * r5 = Relocated text pointer
1231 .globl relocate_code
1233 #if defined(CONFIG_4xx_DCACHE) || defined(CONFIG_SYS_INIT_DCACHE_CS)
1235 * We need to flush the initial global data (gd_t) and bd_info
1236 * before the dcache will be invalidated.
1239 /* Save registers */
1245 * Flush complete dcache, this is faster than flushing the
1246 * ranges for global_data and bd_info instead.
1250 #if defined(CONFIG_SYS_INIT_DCACHE_CS)
1252 * Undo the earlier data cache set-up for the primordial stack and
1253 * data area. First, invalidate the data cache and then disable data
1254 * cacheability for that area. Finally, restore the EBC values, if
1258 /* Invalidate the primordial stack and data area in cache */
1259 lis r3, CONFIG_SYS_INIT_RAM_ADDR@h
1260 ori r3, r3, CONFIG_SYS_INIT_RAM_ADDR@l
1262 lis r4, CONFIG_SYS_INIT_RAM_SIZE@h
1263 ori r4, r4, CONFIG_SYS_INIT_RAM_SIZE@l
1266 bl invalidate_dcache_range
1268 /* Disable cacheability for the region */
1270 lis r4, ~PPC_128MB_SACR_VALUE(CONFIG_SYS_INIT_RAM_ADDR)@h
1271 ori r4, r4, ~PPC_128MB_SACR_VALUE(CONFIG_SYS_INIT_RAM_ADDR)@l
1275 /* Restore the EBC parameters */
1277 mtdcr EBC0_CFGADDR, r3
1279 ori r3, r3, PBxAP_VAL@l
1280 mtdcr EBC0_CFGDATA, r3
1283 mtdcr EBC0_CFGADDR, r3
1285 ori r3, r3, PBxCR_VAL@l
1286 mtdcr EBC0_CFGDATA, r3
1287 #endif /* defined(CONFIG_SYS_INIT_DCACHE_CS) */
1289 /* Restore registers */
1293 #endif /* defined(CONFIG_4xx_DCACHE) || defined(CONFIG_SYS_INIT_DCACHE_CS) */
1295 #ifdef CONFIG_SYS_INIT_RAM_DCACHE
1297 * Unlock the previously locked d-cache
1301 /* set TFLOOR/NFLOOR to 0 again */
1318 /* Invalidate data cache, now no longer our stack */
1322 #endif /* CONFIG_SYS_INIT_RAM_DCACHE */
1325 * On some 440er platforms the cache is enabled in the first TLB (Boot-CS)
1326 * to speed up the boot process. Now this cache needs to be disabled.
1328 #if defined(CONFIG_440)
1329 /* Clear all potential pending exceptions */
1332 addi r1,r0,CONFIG_SYS_TLB_FOR_BOOT_FLASH /* Use defined TLB */
1333 tlbre r0,r1,0x0002 /* Read contents */
1334 ori r0,r0,0x0c00 /* Or in the inhibit, write through bit */
1335 tlbwe r0,r1,0x0002 /* Save it out */
1338 #endif /* defined(CONFIG_440) */
1339 mr r1, r3 /* Set new stack pointer */
1340 mr r9, r4 /* Save copy of Init Data pointer */
1341 mr r10, r5 /* Save copy of Destination Address */
1344 mr r3, r5 /* Destination Address */
1345 lis r4, CONFIG_SYS_MONITOR_BASE@h /* Source Address */
1346 ori r4, r4, CONFIG_SYS_MONITOR_BASE@l
1347 lwz r5, GOT(__init_end)
1349 li r6, L1_CACHE_BYTES /* Cache Line Size */
1354 * New GOT-PTR = (old GOT-PTR - CONFIG_SYS_MONITOR_BASE) + Destination Address
1360 /* First our own GOT */
1362 /* then the one used by the C code */
1372 beq cr1,4f /* In place copy is not necessary */
1373 beq 7f /* Protect against 0 count */
1392 * Now flush the cache: note that we must start from a cache aligned
1393 * address. Otherwise we might miss one cache line.
1397 beq 7f /* Always flush prefetch queue in any case */
1405 sync /* Wait for all dcbst to complete on bus */
1411 7: sync /* Wait for all icbi to complete on bus */
1415 * We are done. Do not return, instead branch to second part of board
1416 * initialization, now running from RAM.
1419 addi r0, r10, in_ram - _start + _START_OFFSET
1421 blr /* NEVER RETURNS! */
1426 * Relocation Function, r12 point to got2+0x8000
1428 * Adjust got2 pointers, no need to check for 0, this code
1429 * already puts a few entries in the table.
1431 li r0,__got2_entries@sectoff@l
1432 la r3,GOT(_GOT2_TABLE_)
1433 lwz r11,GOT(_GOT2_TABLE_)
1445 * Now adjust the fixups and the pointers to the fixups
1446 * in case we need to move ourselves again.
1448 li r0,__fixup_entries@sectoff@l
1449 lwz r3,GOT(_FIXUP_TABLE_)
1465 * Now clear BSS segment
1467 lwz r3,GOT(__bss_start)
1468 lwz r4,GOT(__bss_end)
1490 mr r3, r9 /* Init Data pointer */
1491 mr r4, r10 /* Destination Address */
1495 * Copy exception vector code to low memory
1498 * r7: source address, r8: end address, r9: target address
1502 mflr r4 /* save link register */
1504 lwz r7, GOT(_start_of_vectors)
1505 lwz r8, GOT(_end_of_vectors)
1507 li r9, 0x100 /* reset vector always at 0x100 */
1510 bgelr /* return if r7>=r8 - just in case */
1520 * relocate `hdlr' and `int_return' entries
1522 li r7, .L_MachineCheck - _start + _START_OFFSET
1523 li r8, Alignment - _start + _START_OFFSET
1526 addi r7, r7, 0x100 /* next exception vector */
1530 li r7, .L_Alignment - _start + _START_OFFSET
1533 li r7, .L_ProgramCheck - _start + _START_OFFSET
1537 li r7, .L_FPUnavailable - _start + _START_OFFSET
1540 li r7, .L_Decrementer - _start + _START_OFFSET
1543 li r7, .L_APU - _start + _START_OFFSET
1546 li r7, .L_InstructionTLBError - _start + _START_OFFSET
1549 li r7, .L_DataTLBError - _start + _START_OFFSET
1551 #else /* CONFIG_440 */
1552 li r7, .L_PIT - _start + _START_OFFSET
1555 li r7, .L_InstructionTLBMiss - _start + _START_OFFSET
1558 li r7, .L_DataTLBMiss - _start + _START_OFFSET
1560 #endif /* CONFIG_440 */
1562 li r7, .L_DebugBreakpoint - _start + _START_OFFSET
1565 #if !defined(CONFIG_440)
1566 addi r7,r0,0x1000 /* set ME bit (Machine Exceptions) */
1567 oris r7,r7,0x0002 /* set CE bit (Critical Exceptions) */
1568 mtmsr r7 /* change MSR */
1571 b __440_msr_continue
1574 addi r7,r0,0x1000 /* set ME bit (Machine Exceptions) */
1575 oris r7,r7,0x0002 /* set CE bit (Critical Exceptions) */
1583 mtlr r4 /* restore link register */
1585 #endif /* CONFIG_SPL_BUILD */
1587 #if defined(CONFIG_440)
1588 /*----------------------------------------------------------------------------+
1590 +----------------------------------------------------------------------------*/
1591 function_prolog(dcbz_area)
1592 rlwinm. r5,r4,0,27,31
1593 rlwinm r5,r4,27,5,31
1602 function_epilog(dcbz_area)
1603 #endif /* CONFIG_440 */
1604 #endif /* CONFIG_SPL_BUILD */
1606 /*------------------------------------------------------------------------------- */
1608 /* Description: Input 8 bits */
1609 /*------------------------------------------------------------------------------- */
1615 /*------------------------------------------------------------------------------- */
1616 /* Function: out8 */
1617 /* Description: Output 8 bits */
1618 /*------------------------------------------------------------------------------- */
1624 /*------------------------------------------------------------------------------- */
1625 /* Function: out32 */
1626 /* Description: Output 32 bits */
1627 /*------------------------------------------------------------------------------- */
1633 /*------------------------------------------------------------------------------- */
1634 /* Function: in32 */
1635 /* Description: Input 32 bits */
1636 /*------------------------------------------------------------------------------- */
1642 /**************************************************************************/
1643 /* PPC405EP specific stuff */
1644 /**************************************************************************/
1648 #ifdef CONFIG_BUBINGA
1650 * Initialize EBC chip selects 1 & 4 and GPIO pins (for alternate
1651 * function) to support FPGA and NVRAM accesses below.
1654 lis r3,GPIO0_OSRH@h /* config GPIO output select */
1655 ori r3,r3,GPIO0_OSRH@l
1656 lis r4,CONFIG_SYS_GPIO0_OSRH@h
1657 ori r4,r4,CONFIG_SYS_GPIO0_OSRH@l
1660 ori r3,r3,GPIO0_OSRL@l
1661 lis r4,CONFIG_SYS_GPIO0_OSRL@h
1662 ori r4,r4,CONFIG_SYS_GPIO0_OSRL@l
1665 lis r3,GPIO0_ISR1H@h /* config GPIO input select */
1666 ori r3,r3,GPIO0_ISR1H@l
1667 lis r4,CONFIG_SYS_GPIO0_ISR1H@h
1668 ori r4,r4,CONFIG_SYS_GPIO0_ISR1H@l
1670 lis r3,GPIO0_ISR1L@h
1671 ori r3,r3,GPIO0_ISR1L@l
1672 lis r4,CONFIG_SYS_GPIO0_ISR1L@h
1673 ori r4,r4,CONFIG_SYS_GPIO0_ISR1L@l
1676 lis r3,GPIO0_TSRH@h /* config GPIO three-state select */
1677 ori r3,r3,GPIO0_TSRH@l
1678 lis r4,CONFIG_SYS_GPIO0_TSRH@h
1679 ori r4,r4,CONFIG_SYS_GPIO0_TSRH@l
1682 ori r3,r3,GPIO0_TSRL@l
1683 lis r4,CONFIG_SYS_GPIO0_TSRL@h
1684 ori r4,r4,CONFIG_SYS_GPIO0_TSRL@l
1687 lis r3,GPIO0_TCR@h /* config GPIO driver output enables */
1688 ori r3,r3,GPIO0_TCR@l
1689 lis r4,CONFIG_SYS_GPIO0_TCR@h
1690 ori r4,r4,CONFIG_SYS_GPIO0_TCR@l
1693 li r3,PB1AP /* program EBC bank 1 for RTC access */
1694 mtdcr EBC0_CFGADDR,r3
1695 lis r3,CONFIG_SYS_EBC_PB1AP@h
1696 ori r3,r3,CONFIG_SYS_EBC_PB1AP@l
1697 mtdcr EBC0_CFGDATA,r3
1699 mtdcr EBC0_CFGADDR,r3
1700 lis r3,CONFIG_SYS_EBC_PB1CR@h
1701 ori r3,r3,CONFIG_SYS_EBC_PB1CR@l
1702 mtdcr EBC0_CFGDATA,r3
1704 li r3,PB1AP /* program EBC bank 1 for RTC access */
1705 mtdcr EBC0_CFGADDR,r3
1706 lis r3,CONFIG_SYS_EBC_PB1AP@h
1707 ori r3,r3,CONFIG_SYS_EBC_PB1AP@l
1708 mtdcr EBC0_CFGDATA,r3
1710 mtdcr EBC0_CFGADDR,r3
1711 lis r3,CONFIG_SYS_EBC_PB1CR@h
1712 ori r3,r3,CONFIG_SYS_EBC_PB1CR@l
1713 mtdcr EBC0_CFGDATA,r3
1715 li r3,PB4AP /* program EBC bank 4 for FPGA access */
1716 mtdcr EBC0_CFGADDR,r3
1717 lis r3,CONFIG_SYS_EBC_PB4AP@h
1718 ori r3,r3,CONFIG_SYS_EBC_PB4AP@l
1719 mtdcr EBC0_CFGDATA,r3
1721 mtdcr EBC0_CFGADDR,r3
1722 lis r3,CONFIG_SYS_EBC_PB4CR@h
1723 ori r3,r3,CONFIG_SYS_EBC_PB4CR@l
1724 mtdcr EBC0_CFGDATA,r3
1728 !-----------------------------------------------------------------------
1729 ! Check to see if chip is in bypass mode.
1730 ! If so, write stored CPC0_PLLMR0 and CPC0_PLLMR1 values and perform a
1731 ! CPU reset Otherwise, skip this step and keep going.
1732 ! Note: Running BIOS in bypass mode is not supported since PLB speed
1733 ! will not be fast enough for the SDRAM (min 66MHz)
1734 !-----------------------------------------------------------------------
1736 mfdcr r5, CPC0_PLLMR1
1737 rlwinm r4,r5,1,0x1 /* get system clock source (SSCS) */
1740 beq pll_done /* if SSCS =b'1' then PLL has */
1741 /* already been set */
1742 /* and CPU has been reset */
1743 /* so skip to next section */
1745 #ifdef CONFIG_BUBINGA
1747 !-----------------------------------------------------------------------
1748 ! Read NVRAM to get value to write in PLLMR.
1749 ! If value has not been correctly saved, write default value
1750 ! Default config values (assuming on-board 33MHz SYS_CLK) are above.
1751 ! See CPU_DEFAULT_200 and CPU_DEFAULT_266 above.
1753 ! WARNING: This code assumes the first three words in the nvram_t
1754 ! structure in openbios.h. Changing the beginning of
1755 ! the structure will break this code.
1757 !-----------------------------------------------------------------------
1759 addis r3,0,NVRAM_BASE@h
1760 addi r3,r3,NVRAM_BASE@l
1763 addis r5,0,NVRVFY1@h
1764 addi r5,r5,NVRVFY1@l
1765 cmp cr0,0,r4,r5 /* Compare 1st NVRAM Magic number*/
1769 addis r5,0,NVRVFY2@h
1770 addi r5,r5,NVRVFY2@l
1771 cmp cr0,0,r4,r5 /* Compare 2 NVRAM Magic number */
1773 addi r3,r3,8 /* Skip over conf_size */
1774 lwz r4, 4(r3) /* Load PLLMR1 value from NVRAM */
1775 lwz r3, 0(r3) /* Load PLLMR0 value from NVRAM */
1776 rlwinm r5,r4,1,0x1 /* get system clock source (SSCS) */
1777 cmpi cr0,0,r5,1 /* See if PLL is locked */
1780 #endif /* CONFIG_BUBINGA */
1784 andi. r5, r4, CPC0_BOOT_SEP@l
1785 bne strap_1 /* serial eeprom present */
1786 addis r5,0,CPLD_REG0_ADDR@h
1787 ori r5,r5,CPLD_REG0_ADDR@l
1790 #endif /* CONFIG_TAIHU */
1792 #if defined(CONFIG_ZEUS)
1794 andi. r5, r4, CPC0_BOOT_SEP@l
1795 bne strap_1 /* serial eeprom present */
1802 mfdcr r3, CPC0_PLLMR0
1803 mfdcr r4, CPC0_PLLMR1
1807 addis r3,0,PLLMR0_DEFAULT@h /* PLLMR0 default value */
1808 ori r3,r3,PLLMR0_DEFAULT@l /* */
1809 addis r4,0,PLLMR1_DEFAULT@h /* PLLMR1 default value */
1810 ori r4,r4,PLLMR1_DEFAULT@l /* */
1815 addis r3,0,PLLMR0_DEFAULT_PCI66@h
1816 ori r3,r3,PLLMR0_DEFAULT_PCI66@l
1817 addis r4,0,PLLMR1_DEFAULT_PCI66@h
1818 ori r4,r4,PLLMR1_DEFAULT_PCI66@l
1821 mfdcr r3, CPC0_PLLMR0
1822 mfdcr r4, CPC0_PLLMR1
1823 #endif /* CONFIG_TAIHU */
1826 b pll_write /* Write the CPC0_PLLMR with new value */
1830 !-----------------------------------------------------------------------
1831 ! Clear Soft Reset Register
1832 ! This is needed to enable PCI if not booting from serial EPROM
1833 !-----------------------------------------------------------------------
1843 blr /* return to main code */
1846 !-----------------------------------------------------------------------------
1847 ! Function: pll_write
1848 ! Description: Updates the value of the CPC0_PLLMR according to CMOS27E documentation
1850 ! 1. Pll is first disabled (de-activated by putting in bypass mode)
1852 ! 3. Clock dividers are set while PLL is held in reset and bypassed
1853 ! 4. PLL Reset is cleared
1854 ! 5. Wait 100us for PLL to lock
1855 ! 6. A core reset is performed
1856 ! Input: r3 = Value to write to CPC0_PLLMR0
1857 ! Input: r4 = Value to write to CPC0_PLLMR1
1859 !-----------------------------------------------------------------------------
1865 ori r5,r5,0x0101 /* Stop the UART clocks */
1866 mtdcr CPC0_UCR,r5 /* Before changing PLL */
1868 mfdcr r5, CPC0_PLLMR1
1869 rlwinm r5,r5,0,0x7FFFFFFF /* Disable PLL */
1870 mtdcr CPC0_PLLMR1,r5
1871 oris r5,r5,0x4000 /* Set PLL Reset */
1872 mtdcr CPC0_PLLMR1,r5
1874 mtdcr CPC0_PLLMR0,r3 /* Set clock dividers */
1875 rlwinm r5,r4,0,0x3FFFFFFF /* Reset & Bypass new PLL dividers */
1876 oris r5,r5,0x4000 /* Set PLL Reset */
1877 mtdcr CPC0_PLLMR1,r5 /* Set clock dividers */
1878 rlwinm r5,r5,0,0xBFFFFFFF /* Clear PLL Reset */
1879 mtdcr CPC0_PLLMR1,r5
1882 ! Wait min of 100us for PLL to lock.
1883 ! See CMOS 27E databook for more info.
1884 ! At 200MHz, that means waiting 20,000 instructions
1886 addi r3,0,20000 /* 2000 = 0x4e20 */
1891 oris r5,r5,0x8000 /* Enable PLL */
1892 mtdcr CPC0_PLLMR1,r5 /* Engage */
1895 * Reset CPU to guarantee timings are OK
1896 * Not sure if this is needed...
1899 mtspr SPRN_DBCR0,r3 /* This will cause a CPU core reset, and */
1900 /* execution will continue from the poweron */
1901 /* vector of 0xfffffffc */
1902 #endif /* CONFIG_405EP */
1904 #if defined(CONFIG_440)
1905 /*----------------------------------------------------------------------------+
1907 +----------------------------------------------------------------------------*/
1908 function_prolog(mttlb3)
1911 function_epilog(mttlb3)
1913 /*----------------------------------------------------------------------------+
1915 +----------------------------------------------------------------------------*/
1916 function_prolog(mftlb3)
1919 function_epilog(mftlb3)
1921 /*----------------------------------------------------------------------------+
1923 +----------------------------------------------------------------------------*/
1924 function_prolog(mttlb2)
1927 function_epilog(mttlb2)
1929 /*----------------------------------------------------------------------------+
1931 +----------------------------------------------------------------------------*/
1932 function_prolog(mftlb2)
1935 function_epilog(mftlb2)
1937 /*----------------------------------------------------------------------------+
1939 +----------------------------------------------------------------------------*/
1940 function_prolog(mttlb1)
1943 function_epilog(mttlb1)
1945 /*----------------------------------------------------------------------------+
1947 +----------------------------------------------------------------------------*/
1948 function_prolog(mftlb1)
1951 function_epilog(mftlb1)
1952 #endif /* CONFIG_440 */