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 * See file CREDITS for list of people who contributed to this
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 /*------------------------------------------------------------------------------+
29 * This source code has been made available to you by IBM on an AS-IS
30 * basis. Anyone receiving this source is licensed under IBM
31 * copyrights to use it in any way he or she deems fit, including
32 * copying it, modifying it, compiling it, and redistributing it either
33 * with or without modifications. No license under IBM patents or
34 * patent applications is to be implied by the copyright license.
36 * Any user of this software should understand that IBM cannot provide
37 * technical support for this software and will not be responsible for
38 * any consequences resulting from the use of this software.
40 * Any person who transfers this source code or any derivative work
41 * must include the IBM copyright notice, this paragraph, and the
42 * preceding two paragraphs in the transferred software.
44 * COPYRIGHT I B M CORPORATION 1995
45 * LICENSED MATERIAL - PROGRAM PROPERTY OF I B M
46 *-------------------------------------------------------------------------------
49 /* U-Boot - Startup Code for AMCC 4xx PowerPC based Embedded Boards
52 * The processor starts at 0xfffffffc and the code is executed
54 * in memory, but as long we don't jump around before relocating.
55 * board_init lies at a quite high address and when the cpu has
56 * jumped there, everything is ok.
57 * This works because the cpu gives the FLASH (CS0) the whole
58 * address space at startup, and board_init lies as a echo of
59 * the flash somewhere up there in the memorymap.
61 * board_init will change CS0 to be positioned at the correct
62 * address and (s)dram will be positioned at address 0
68 #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
70 #include <ppc_asm.tmpl>
73 #include <asm/cache.h>
76 #ifndef CONFIG_IDENT_STRING
77 #define CONFIG_IDENT_STRING ""
80 #ifdef CFG_INIT_DCACHE_CS
81 # if (CFG_INIT_DCACHE_CS == 0)
84 # if (defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR))
85 # define PBxAP_VAL CFG_EBC_PB0AP
86 # define PBxCR_VAL CFG_EBC_PB0CR
89 # if (CFG_INIT_DCACHE_CS == 1)
92 # if (defined(CFG_EBC_PB1AP) && defined(CFG_EBC_PB1CR))
93 # define PBxAP_VAL CFG_EBC_PB1AP
94 # define PBxCR_VAL CFG_EBC_PB1CR
97 # if (CFG_INIT_DCACHE_CS == 2)
100 # if (defined(CFG_EBC_PB2AP) && defined(CFG_EBC_PB2CR))
101 # define PBxAP_VAL CFG_EBC_PB2AP
102 # define PBxCR_VAL CFG_EBC_PB2CR
105 # if (CFG_INIT_DCACHE_CS == 3)
108 # if (defined(CFG_EBC_PB3AP) && defined(CFG_EBC_PB3CR))
109 # define PBxAP_VAL CFG_EBC_PB3AP
110 # define PBxCR_VAL CFG_EBC_PB3CR
113 # if (CFG_INIT_DCACHE_CS == 4)
116 # if (defined(CFG_EBC_PB4AP) && defined(CFG_EBC_PB4CR))
117 # define PBxAP_VAL CFG_EBC_PB4AP
118 # define PBxCR_VAL CFG_EBC_PB4CR
121 # if (CFG_INIT_DCACHE_CS == 5)
124 # if (defined(CFG_EBC_PB5AP) && defined(CFG_EBC_PB5CR))
125 # define PBxAP_VAL CFG_EBC_PB5AP
126 # define PBxCR_VAL CFG_EBC_PB5CR
129 # if (CFG_INIT_DCACHE_CS == 6)
132 # if (defined(CFG_EBC_PB6AP) && defined(CFG_EBC_PB6CR))
133 # define PBxAP_VAL CFG_EBC_PB6AP
134 # define PBxCR_VAL CFG_EBC_PB6CR
137 # if (CFG_INIT_DCACHE_CS == 7)
140 # if (defined(CFG_EBC_PB7AP) && defined(CFG_EBC_PB7CR))
141 # define PBxAP_VAL CFG_EBC_PB7AP
142 # define PBxCR_VAL CFG_EBC_PB7CR
152 * Memory Bank x (nothingness) initialization CFG_INIT_RAM_ADDR + 64 MiB
153 * used as temporary stack pointer for the primordial stack
155 # ifndef CFG_INIT_DCACHE_PBxAR
156 # define CFG_INIT_DCACHE_PBxAR (EBC_BXAP_BME_DISABLED | \
157 EBC_BXAP_TWT_ENCODE(7) | \
158 EBC_BXAP_BCE_DISABLE | \
159 EBC_BXAP_BCT_2TRANS | \
160 EBC_BXAP_CSN_ENCODE(0) | \
161 EBC_BXAP_OEN_ENCODE(0) | \
162 EBC_BXAP_WBN_ENCODE(0) | \
163 EBC_BXAP_WBF_ENCODE(0) | \
164 EBC_BXAP_TH_ENCODE(2) | \
165 EBC_BXAP_RE_DISABLED | \
166 EBC_BXAP_SOR_NONDELAYED | \
167 EBC_BXAP_BEM_WRITEONLY | \
168 EBC_BXAP_PEN_DISABLED)
169 # endif /* CFG_INIT_DCACHE_PBxAR */
170 # ifndef CFG_INIT_DCACHE_PBxCR
171 # define CFG_INIT_DCACHE_PBxCR (EBC_BXCR_BAS_ENCODE(CFG_INIT_RAM_ADDR) | \
175 # endif /* CFG_INIT_DCACHE_PBxCR */
176 # ifndef CFG_INIT_RAM_PATTERN
177 # define CFG_INIT_RAM_PATTERN 0xDEADDEAD
179 #endif /* CFG_INIT_DCACHE_CS */
181 #if (defined(CFG_INIT_RAM_DCACHE) && (CFG_INIT_RAM_END > (4 << 10)))
182 #error Only 4k of init-ram is supported - please adjust CFG_INIT_RAM_END!
186 * Unless otherwise overriden, enable two 128MB cachable instruction regions
187 * at CFG_SDRAM_BASE and another 128MB cacheable instruction region covering
188 * NOR flash at CFG_FLASH_BASE. Disable all cacheable data regions.
190 #if !defined(CFG_ICACHE_SACR_VALUE)
191 # define CFG_ICACHE_SACR_VALUE \
192 (PPC_128MB_SACR_VALUE(CFG_SDRAM_BASE + ( 0 << 20)) | \
193 PPC_128MB_SACR_VALUE(CFG_SDRAM_BASE + (128 << 20)) | \
194 PPC_128MB_SACR_VALUE(CFG_FLASH_BASE))
195 #endif /* !defined(CFG_ICACHE_SACR_VALUE) */
197 #if !defined(CFG_DCACHE_SACR_VALUE)
198 # define CFG_DCACHE_SACR_VALUE \
200 #endif /* !defined(CFG_DCACHE_SACR_VALUE) */
202 #define function_prolog(func_name) .text; \
206 #define function_epilog(func_name) .type func_name,@function; \
207 .size func_name,.-func_name
209 /* We don't want the MMU yet.
212 #define MSR_KERNEL ( MSR_ME ) /* Machine Check */
215 .extern ext_bus_cntlr_init
217 #ifdef CONFIG_NAND_U_BOOT
218 .extern reconfig_tlb0
222 * Set up GOT: Global Offset Table
224 * Use r14 to access the GOT
226 #if !defined(CONFIG_NAND_SPL)
228 GOT_ENTRY(_GOT2_TABLE_)
229 GOT_ENTRY(_FIXUP_TABLE_)
232 GOT_ENTRY(_start_of_vectors)
233 GOT_ENTRY(_end_of_vectors)
234 GOT_ENTRY(transfer_to_handler)
236 GOT_ENTRY(__init_end)
238 GOT_ENTRY(__bss_start)
240 #endif /* CONFIG_NAND_SPL */
242 #if defined(CONFIG_NAND_U_BOOT) && !defined(CONFIG_NAND_SPL)
244 * NAND U-Boot image is started from offset 0
247 #if defined(CONFIG_440)
251 bl cpu_init_f /* run low-level CPU init code (from Flash) */
256 * 440 Startup -- on reset only the top 4k of the effective
257 * address space is mapped in by an entry in the instruction
258 * and data shadow TLB. The .bootpg section is located in the
259 * top 4k & does only what's necessary to map in the the rest
260 * of the boot rom. Once the boot rom is mapped in we can
261 * proceed with normal startup.
263 * NOTE: CS0 only covers the top 2MB of the effective address
267 #if defined(CONFIG_440)
268 #if !defined(CONFIG_NAND_SPL)
269 .section .bootpg,"ax"
273 /**************************************************************************/
275 /*--------------------------------------------------------------------+
276 | 440EPX BUP Change - Hardware team request
277 +--------------------------------------------------------------------*/
278 #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX)
283 /*----------------------------------------------------------------+
284 | Core bug fix. Clear the esr
285 +-----------------------------------------------------------------*/
288 /*----------------------------------------------------------------*/
289 /* Clear and set up some registers. */
290 /*----------------------------------------------------------------*/
291 iccci r0,r0 /* NOTE: operands not used for 440 */
292 dccci r0,r0 /* NOTE: operands not used for 440 */
299 /* NOTE: 440GX adds machine check status regs */
300 #if defined(CONFIG_440) && !defined(CONFIG_440GP)
307 /*----------------------------------------------------------------*/
309 /*----------------------------------------------------------------*/
310 /* Disable store gathering & broadcast, guarantee inst/data
311 * cache block touch, force load/store alignment
312 * (see errata 1.12: 440_33)
314 lis r1,0x0030 /* store gathering & broadcast disable */
315 ori r1,r1,0x6000 /* cache touch */
318 /*----------------------------------------------------------------*/
319 /* Initialize debug */
320 /*----------------------------------------------------------------*/
322 andis. r1, r1, 0x8000 /* test DBCR0[EDM] bit */
323 bne skip_debug_init /* if set, don't clear debug register */
336 mtspr dbsr,r1 /* Clear all valid bits */
339 #if defined (CONFIG_440SPE)
340 /*----------------------------------------------------------------+
341 | Initialize Core Configuration Reg1.
342 | a. ICDPEI: Record even parity. Normal operation.
343 | b. ICTPEI: Record even parity. Normal operation.
344 | c. DCTPEI: Record even parity. Normal operation.
345 | d. DCDPEI: Record even parity. Normal operation.
346 | e. DCUPEI: Record even parity. Normal operation.
347 | f. DCMPEI: Record even parity. Normal operation.
348 | g. FCOM: Normal operation
349 | h. MMUPEI: Record even parity. Normal operation.
350 | i. FFF: Flush only as much data as necessary.
351 | j. TCS: Timebase increments from CPU clock.
352 +-----------------------------------------------------------------*/
356 /*----------------------------------------------------------------+
357 | Reset the timebase.
358 | The previous write to CCR1 sets the timebase source.
359 +-----------------------------------------------------------------*/
364 /*----------------------------------------------------------------*/
365 /* Setup interrupt vectors */
366 /*----------------------------------------------------------------*/
367 mtspr ivpr,r0 /* Vectors start at 0x0000_0000 */
369 mtspr ivor0,r1 /* Critical input */
371 mtspr ivor1,r1 /* Machine check */
373 mtspr ivor2,r1 /* Data storage */
375 mtspr ivor3,r1 /* Instruction storage */
377 mtspr ivor4,r1 /* External interrupt */
379 mtspr ivor5,r1 /* Alignment */
381 mtspr ivor6,r1 /* Program check */
383 mtspr ivor7,r1 /* Floating point unavailable */
385 mtspr ivor8,r1 /* System call */
387 mtspr ivor9,r1 /* Auxiliary Processor unavailable */
389 mtspr ivor10,r1 /* Decrementer */
391 mtspr ivor13,r1 /* Data TLB error */
393 mtspr ivor14,r1 /* Instr TLB error */
395 mtspr ivor15,r1 /* Debug */
397 /*----------------------------------------------------------------*/
398 /* Configure cache regions */
399 /*----------------------------------------------------------------*/
417 /*----------------------------------------------------------------*/
418 /* Cache victim limits */
419 /*----------------------------------------------------------------*/
420 /* floors 0, ceiling max to use the entire cache -- nothing locked
427 /*----------------------------------------------------------------+
428 |Initialize MMUCR[STID] = 0.
429 +-----------------------------------------------------------------*/
436 /*----------------------------------------------------------------*/
437 /* Clear all TLB entries -- TID = 0, TS = 0 */
438 /*----------------------------------------------------------------*/
440 li r1,0x003f /* 64 TLB entries */
442 rsttlb: tlbwe r0,r1,0x0000 /* Invalidate all entries (V=0)*/
448 /*----------------------------------------------------------------*/
449 /* TLB entry setup -- step thru tlbtab */
450 /*----------------------------------------------------------------*/
451 #if defined(CONFIG_440SPE)
452 /*----------------------------------------------------------------*/
453 /* We have different TLB tables for revA and rev B of 440SPe */
454 /*----------------------------------------------------------------*/
466 bl tlbtab /* Get tlbtab pointer */
469 li r1,0x003f /* 64 TLB entries max */
476 beq 2f /* 0 marks end */
479 tlbwe r0,r4,0 /* TLB Word 0 */
480 tlbwe r1,r4,1 /* TLB Word 1 */
481 tlbwe r2,r4,2 /* TLB Word 2 */
482 addi r4,r4,1 /* Next TLB */
485 /*----------------------------------------------------------------*/
486 /* Continue from 'normal' start */
487 /*----------------------------------------------------------------*/
490 #if defined(CONFIG_NAND_SPL)
491 #if defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
492 defined(CONFIG_460EX) || defined(CONFIG_460GT)
494 * Enable internal SRAM (only on 440EPx/GRx, 440EP/GR have no OCM)
499 and r1,r1,r2 /* Disable parity check */
502 and r1,r1,r2 /* Disable pwr mgmt */
504 #if defined(CONFIG_460EX) || defined(CONFIG_460GT)
505 lis r1,0x4000 /* BAS = 8000_0000 */
506 ori r1,r1,0x4580 /* 16k */
507 mtdcr isram0_sb0cr,r1
510 #if defined(CONFIG_440EP)
512 * On 440EP with no internal SRAM, we setup SDRAM very early
513 * and copy the NAND_SPL to SDRAM and jump to it
515 /* Clear Dcache to use as RAM */
516 addis r3,r0,CFG_INIT_RAM_ADDR@h
517 ori r3,r3,CFG_INIT_RAM_ADDR@l
518 addis r4,r0,CFG_INIT_RAM_END@h
519 ori r4,r4,CFG_INIT_RAM_END@l
520 rlwinm. r5,r4,0,27,31
530 /*----------------------------------------------------------------*/
531 /* Setup the stack in internal SRAM */
532 /*----------------------------------------------------------------*/
533 lis r1,CFG_INIT_RAM_ADDR@h
534 ori r1,r1,CFG_INIT_SP_OFFSET@l
537 stwu r0,-4(r1) /* Terminate call chain */
539 stwu r1,-8(r1) /* Save back chain and move SP */
540 lis r0,RESET_VECTOR@h /* Address of reset vector */
541 ori r0,r0, RESET_VECTOR@l
542 stwu r1,-8(r1) /* Save back chain and move SP */
543 stw r0,+12(r1) /* Save return addr (underflow vect) */
547 #endif /* CONFIG_440EP */
550 * Copy SPL from cache into internal SRAM
552 li r4,(CFG_NAND_BOOT_SPL_SIZE >> 2) - 1
554 lis r2,CFG_NAND_BOOT_SPL_SRC@h
555 ori r2,r2,CFG_NAND_BOOT_SPL_SRC@l
556 lis r3,CFG_NAND_BOOT_SPL_DST@h
557 ori r3,r3,CFG_NAND_BOOT_SPL_DST@l
564 * Jump to code in RAM
568 lis r3,(CFG_NAND_BOOT_SPL_SRC - CFG_NAND_BOOT_SPL_DST)@h
569 ori r3,r3,(CFG_NAND_BOOT_SPL_SRC - CFG_NAND_BOOT_SPL_DST)@l
578 #endif /* CONFIG_NAND_SPL */
584 mtspr srr1,r0 /* Keep things disabled for now */
588 #endif /* CONFIG_440 */
591 * r3 - 1st arg to board_init(): IMMP pointer
592 * r4 - 2nd arg to board_init(): boot flag
594 #ifndef CONFIG_NAND_SPL
596 .long 0x27051956 /* U-Boot Magic Number */
597 .globl version_string
599 .ascii U_BOOT_VERSION
600 .ascii " (", __DATE__, " - ", __TIME__, ")"
601 .ascii CONFIG_IDENT_STRING, "\0"
603 . = EXC_OFF_SYS_RESET
604 .globl _start_of_vectors
607 /* Critical input. */
608 CRIT_EXCEPTION(0x100, CritcalInput, UnknownException)
612 MCK_EXCEPTION(0x200, MachineCheck, MachineCheckException)
614 CRIT_EXCEPTION(0x200, MachineCheck, MachineCheckException)
615 #endif /* CONFIG_440 */
617 /* Data Storage exception. */
618 STD_EXCEPTION(0x300, DataStorage, UnknownException)
620 /* Instruction Storage exception. */
621 STD_EXCEPTION(0x400, InstStorage, UnknownException)
623 /* External Interrupt exception. */
624 STD_EXCEPTION(0x500, ExtInterrupt, external_interrupt)
626 /* Alignment exception. */
629 EXCEPTION_PROLOG(SRR0, SRR1)
634 addi r3,r1,STACK_FRAME_OVERHEAD
636 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
637 lwz r6,GOT(transfer_to_handler)
641 .long AlignmentException - _start + _START_OFFSET
642 .long int_return - _start + _START_OFFSET
644 /* Program check exception */
647 EXCEPTION_PROLOG(SRR0, SRR1)
648 addi r3,r1,STACK_FRAME_OVERHEAD
650 rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */
651 lwz r6,GOT(transfer_to_handler)
655 .long ProgramCheckException - _start + _START_OFFSET
656 .long int_return - _start + _START_OFFSET
659 STD_EXCEPTION(0x800, FPUnavailable, UnknownException)
660 STD_EXCEPTION(0x900, Decrementer, DecrementerPITException)
661 STD_EXCEPTION(0xa00, APU, UnknownException)
663 STD_EXCEPTION(0xc00, SystemCall, UnknownException)
666 STD_EXCEPTION(0x1300, DataTLBError, UnknownException)
667 STD_EXCEPTION(0x1400, InstructionTLBError, UnknownException)
669 STD_EXCEPTION(0x1000, PIT, DecrementerPITException)
670 STD_EXCEPTION(0x1100, InstructionTLBMiss, UnknownException)
671 STD_EXCEPTION(0x1200, DataTLBMiss, UnknownException)
673 CRIT_EXCEPTION(0x2000, DebugBreakpoint, DebugException )
675 .globl _end_of_vectors
682 /*****************************************************************************/
683 #if defined(CONFIG_440)
685 /*----------------------------------------------------------------*/
686 /* Clear and set up some registers. */
687 /*----------------------------------------------------------------*/
690 mtspr dec,r0 /* prevent dec exceptions */
691 mtspr tbl,r0 /* prevent fit & wdt exceptions */
693 mtspr tsr,r1 /* clear all timer exception status */
694 mtspr tcr,r0 /* disable all */
695 mtspr esr,r0 /* clear exception syndrome register */
696 mtxer r0 /* clear integer exception register */
698 /*----------------------------------------------------------------*/
699 /* Debug setup -- some (not very good) ice's need an event*/
700 /* to establish control :-( Define CFG_INIT_DBCR to the dbsr */
701 /* value you need in this case 0x8cff 0000 should do the trick */
702 /*----------------------------------------------------------------*/
703 #if defined(CFG_INIT_DBCR)
706 mtspr dbsr,r1 /* Clear all status bits */
707 lis r0,CFG_INIT_DBCR@h
708 ori r0,r0,CFG_INIT_DBCR@l
713 /*----------------------------------------------------------------*/
714 /* Setup the internal SRAM */
715 /*----------------------------------------------------------------*/
718 #ifdef CFG_INIT_RAM_DCACHE
719 /* Clear Dcache to use as RAM */
720 addis r3,r0,CFG_INIT_RAM_ADDR@h
721 ori r3,r3,CFG_INIT_RAM_ADDR@l
722 addis r4,r0,CFG_INIT_RAM_END@h
723 ori r4,r4,CFG_INIT_RAM_END@l
724 rlwinm. r5,r4,0,27,31
736 * Lock the init-ram/stack in d-cache, so that other regions
737 * may use d-cache as well
738 * Note, that this current implementation locks exactly 4k
739 * of d-cache, so please make sure that you don't define a
740 * bigger init-ram area. Take a look at the lwmon5 440EPx
741 * implementation as a reference.
745 /* 8. set TFLOOR/NFLOOR to 8 (-> 8*16*32 bytes locked -> 4k) */
761 #endif /* CFG_INIT_RAM_DCACHE */
763 /* 440EP & 440GR are only 440er PPC's without internal SRAM */
764 #if !defined(CONFIG_440EP) && !defined(CONFIG_440GR)
765 /* not all PPC's have internal SRAM usable as L2-cache */
766 #if defined(CONFIG_440GX) || \
767 defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
768 defined(CONFIG_460EX) || defined(CONFIG_460GT)
769 mtdcr l2_cache_cfg,r0 /* Ensure L2 Cache is off */
775 and r1,r1,r2 /* Disable parity check */
778 and r1,r1,r2 /* Disable pwr mgmt */
781 lis r1,0x8000 /* BAS = 8000_0000 */
782 #if defined(CONFIG_440GX) || defined(CONFIG_440SP)
783 ori r1,r1,0x0980 /* first 64k */
784 mtdcr isram0_sb0cr,r1
786 ori r1,r1,0x0980 /* second 64k */
787 mtdcr isram0_sb1cr,r1
789 ori r1,r1, 0x0980 /* third 64k */
790 mtdcr isram0_sb2cr,r1
792 ori r1,r1, 0x0980 /* fourth 64k */
793 mtdcr isram0_sb3cr,r1
794 #elif defined(CONFIG_440SPE)
795 lis r1,0x0000 /* BAS = 0000_0000 */
796 ori r1,r1,0x0984 /* first 64k */
797 mtdcr isram0_sb0cr,r1
799 ori r1,r1,0x0984 /* second 64k */
800 mtdcr isram0_sb1cr,r1
802 ori r1,r1, 0x0984 /* third 64k */
803 mtdcr isram0_sb2cr,r1
805 ori r1,r1, 0x0984 /* fourth 64k */
806 mtdcr isram0_sb3cr,r1
807 #elif defined(CONFIG_460EX) || defined(CONFIG_460GT)
808 lis r1,0x4000 /* BAS = 8000_0000 */
809 ori r1,r1,0x4580 /* 16k */
810 mtdcr isram0_sb0cr,r1
811 #elif defined(CONFIG_440GP)
812 ori r1,r1,0x0380 /* 8k rw */
813 mtdcr isram0_sb0cr,r1
814 mtdcr isram0_sb1cr,r0 /* Disable bank 1 */
816 #endif /* #if !defined(CONFIG_440EP) && !defined(CONFIG_440GR) */
818 /*----------------------------------------------------------------*/
819 /* Setup the stack in internal SRAM */
820 /*----------------------------------------------------------------*/
821 lis r1,CFG_INIT_RAM_ADDR@h
822 ori r1,r1,CFG_INIT_SP_OFFSET@l
825 stwu r0,-4(r1) /* Terminate call chain */
827 stwu r1,-8(r1) /* Save back chain and move SP */
828 lis r0,RESET_VECTOR@h /* Address of reset vector */
829 ori r0,r0, RESET_VECTOR@l
830 stwu r1,-8(r1) /* Save back chain and move SP */
831 stw r0,+12(r1) /* Save return addr (underflow vect) */
833 #ifdef CONFIG_NAND_SPL
834 bl nand_boot /* will not return */
838 bl cpu_init_f /* run low-level CPU init code (from Flash) */
842 #endif /* CONFIG_440 */
844 /*****************************************************************************/
846 /*----------------------------------------------------------------------- */
847 /* Set up some machine state registers. */
848 /*----------------------------------------------------------------------- */
849 addi r0,r0,0x0000 /* initialize r0 to zero */
850 mtspr esr,r0 /* clear Exception Syndrome Reg */
851 mttcr r0 /* timer control register */
852 mtexier r0 /* disable all interrupts */
853 addis r4,r0,0xFFFF /* set r4 to 0xFFFFFFFF (status in the */
854 ori r4,r4,0xFFFF /* dbsr is cleared by setting bits to 1) */
855 mtdbsr r4 /* clear/reset the dbsr */
856 mtexisr r4 /* clear all pending interrupts */
858 mtexier r4 /* enable critical exceptions */
859 addis r4,r0,0x0000 /* assume 403GCX - enable core clk */
860 ori r4,r4,0x4020 /* dbling (no harm done on GA and GC */
861 mtiocr r4 /* since bit not used) & DRC to latch */
862 /* data bus on rising edge of CAS */
863 /*----------------------------------------------------------------------- */
865 /*----------------------------------------------------------------------- */
867 /*----------------------------------------------------------------------- */
868 /* Invalidate i-cache and d-cache TAG arrays. */
869 /*----------------------------------------------------------------------- */
870 addi r3,0,1024 /* 1/4 of I-cache size, half of D-cache */
871 addi r4,0,1024 /* 1/4 of I-cache */
876 addic. r3,r3,-16 /* move back one cache line */
877 bne ..cloop /* loop back to do rest until r3 = 0 */
880 /* initialize IOP480 so it can read 1 MB code area for SRAM spaces */
881 /* this requires enabling MA[17..0], by default only MA[12..0] are enabled. */
884 /* first copy IOP480 register base address into r3 */
885 addis r3,0,0x5000 /* IOP480 register base address hi */
886 /* ori r3,r3,0x0000 / IOP480 register base address lo */
889 /* use r4 as the working variable */
890 /* turn on CS3 (LOCCTL.7) */
891 lwz r4,0x84(r3) /* LOCTL is at offset 0x84 */
892 andi. r4,r4,0xff7f /* make bit 7 = 0 -- CS3 mode */
893 stw r4,0x84(r3) /* LOCTL is at offset 0x84 */
896 #ifdef CONFIG_DASA_SIM
897 /* use r4 as the working variable */
898 /* turn on MA17 (LOCCTL.7) */
899 lwz r4,0x84(r3) /* LOCTL is at offset 0x84 */
900 ori r4,r4,0x80 /* make bit 7 = 1 -- MA17 mode */
901 stw r4,0x84(r3) /* LOCTL is at offset 0x84 */
904 /* turn on MA16..13 (LCS0BRD.12 = 0) */
905 lwz r4,0x100(r3) /* LCS0BRD is at offset 0x100 */
906 andi. r4,r4,0xefff /* make bit 12 = 0 */
907 stw r4,0x100(r3) /* LCS0BRD is at offset 0x100 */
909 /* make sure above stores all comlete before going on */
912 /* last thing, set local init status done bit (DEVINIT.31) */
913 lwz r4,0x80(r3) /* DEVINIT is at offset 0x80 */
914 oris r4,r4,0x8000 /* make bit 31 = 1 */
915 stw r4,0x80(r3) /* DEVINIT is at offset 0x80 */
917 /* clear all pending interrupts and disable all interrupts */
918 li r4,-1 /* set p1 to 0xffffffff */
919 stw r4,0x1b0(r3) /* clear all pending interrupts */
920 stw r4,0x1b8(r3) /* clear all pending interrupts */
921 li r4,0 /* set r4 to 0 */
922 stw r4,0x1b4(r3) /* disable all interrupts */
923 stw r4,0x1bc(r3) /* disable all interrupts */
925 /* make sure above stores all comlete before going on */
928 /* Set-up icache cacheability. */
929 lis r1, CFG_ICACHE_SACR_VALUE@h
930 ori r1, r1, CFG_ICACHE_SACR_VALUE@l
934 /* Set-up dcache cacheability. */
935 lis r1, CFG_DCACHE_SACR_VALUE@h
936 ori r1, r1, CFG_DCACHE_SACR_VALUE@l
939 addis r1,r0,CFG_INIT_RAM_ADDR@h
940 ori r1,r1,CFG_INIT_SP_OFFSET /* set up the stack to SDRAM */
941 li r0, 0 /* Make room for stack frame header and */
942 stwu r0, -4(r1) /* clear final stack frame so that */
943 stwu r0, -4(r1) /* stack backtraces terminate cleanly */
945 GET_GOT /* initialize GOT access */
947 bl board_init_f /* run first part of init code (from Flash) */
949 #endif /* CONFIG_IOP480 */
951 /*****************************************************************************/
952 #if defined(CONFIG_405GP) || defined(CONFIG_405CR) || \
953 defined(CONFIG_405EP) || defined(CONFIG_405EZ) || \
954 defined(CONFIG_405EX) || defined(CONFIG_405)
955 /*----------------------------------------------------------------------- */
956 /* Clear and set up some registers. */
957 /*----------------------------------------------------------------------- */
959 #if !defined(CONFIG_405EX)
963 * On 405EX, completely clearing the SGR leads to PPC hangup
964 * upon PCIe configuration access. The PCIe memory regions
965 * need to be guarded!
972 mtesr r4 /* clear Exception Syndrome Reg */
973 mttcr r4 /* clear Timer Control Reg */
974 mtxer r4 /* clear Fixed-Point Exception Reg */
975 mtevpr r4 /* clear Exception Vector Prefix Reg */
976 addi r4,r0,(0xFFFF-0x10000) /* set r4 to 0xFFFFFFFF (status in the */
977 /* dbsr is cleared by setting bits to 1) */
978 mtdbsr r4 /* clear/reset the dbsr */
980 /* Invalidate the i- and d-caches. */
984 /* Set-up icache cacheability. */
985 lis r4, CFG_ICACHE_SACR_VALUE@h
986 ori r4, r4, CFG_ICACHE_SACR_VALUE@l
990 /* Set-up dcache cacheability. */
991 lis r4, CFG_DCACHE_SACR_VALUE@h
992 ori r4, r4, CFG_DCACHE_SACR_VALUE@l
995 #if !(defined(CFG_EBC_PB0AP) && defined(CFG_EBC_PB0CR)) || defined(CONFIG_405EX)
996 /*----------------------------------------------------------------------- */
997 /* Tune the speed and size for flash CS0 */
998 /*----------------------------------------------------------------------- */
999 bl ext_bus_cntlr_init
1001 #if !(defined(CFG_INIT_DCACHE_CS) || defined(CFG_TEMP_STACK_OCM))
1003 * For boards that don't have OCM and can't use the data cache
1004 * for their primordial stack, setup stack here directly after the
1005 * SDRAM is initialized in ext_bus_cntlr_init.
1007 lis r1, CFG_INIT_RAM_ADDR@h
1008 ori r1,r1,CFG_INIT_SP_OFFSET /* set up the stack in SDRAM */
1010 li r0, 0 /* Make room for stack frame header and */
1011 stwu r0, -4(r1) /* clear final stack frame so that */
1012 stwu r0, -4(r1) /* stack backtraces terminate cleanly */
1014 * Set up a dummy frame to store reset vector as return address.
1015 * this causes stack underflow to reset board.
1017 stwu r1, -8(r1) /* Save back chain and move SP */
1018 lis r0, RESET_VECTOR@h /* Address of reset vector */
1019 ori r0, r0, RESET_VECTOR@l
1020 stwu r1, -8(r1) /* Save back chain and move SP */
1021 stw r0, +12(r1) /* Save return addr (underflow vect) */
1022 #endif /* !(CFG_INIT_DCACHE_CS || !CFG_TEM_STACK_OCM) */
1024 #if defined(CONFIG_405EP)
1025 /*----------------------------------------------------------------------- */
1026 /* DMA Status, clear to come up clean */
1027 /*----------------------------------------------------------------------- */
1028 addis r3,r0, 0xFFFF /* Clear all existing DMA status */
1032 bl ppc405ep_init /* do ppc405ep specific init */
1033 #endif /* CONFIG_405EP */
1035 #if defined(CFG_OCM_DATA_ADDR) && defined(CFG_OCM_DATA_SIZE)
1036 #if defined(CONFIG_405EZ)
1037 /********************************************************************
1038 * Setup OCM - On Chip Memory - PPC405EZ uses OCM Controller V2
1039 *******************************************************************/
1041 * We can map the OCM on the PLB3, so map it at
1042 * CFG_OCM_DATA_ADDR + 0x8000
1044 lis r3,CFG_OCM_DATA_ADDR@h /* OCM location */
1045 ori r3,r3,CFG_OCM_DATA_ADDR@l
1046 ori r3,r3,0x0270 /* 16K for Bank 1, R/W/Enable */
1047 mtdcr ocmplb3cr1,r3 /* Set PLB Access */
1048 ori r3,r3,0x4000 /* Add 0x4000 for bank 2 */
1049 mtdcr ocmplb3cr2,r3 /* Set PLB Access */
1052 lis r3,CFG_OCM_DATA_ADDR@h /* OCM location */
1053 ori r3,r3,CFG_OCM_DATA_ADDR@l
1054 ori r3,r3,0x0270 /* 16K for Bank 1, R/W/Enable */
1055 mtdcr ocmdscr1, r3 /* Set Data Side */
1056 mtdcr ocmiscr1, r3 /* Set Instruction Side */
1057 ori r3,r3,0x4000 /* Add 0x4000 for bank 2 */
1058 mtdcr ocmdscr2, r3 /* Set Data Side */
1059 mtdcr ocmiscr2, r3 /* Set Instruction Side */
1060 addis r3,0,0x0800 /* OCM Data Parity Disable - 1 Wait State */
1064 #else /* CONFIG_405EZ */
1065 /********************************************************************
1066 * Setup OCM - On Chip Memory
1067 *******************************************************************/
1071 mfdcr r3, ocmiscntl /* get instr-side IRAM config */
1072 mfdcr r4, ocmdscntl /* get data-side IRAM config */
1073 and r3, r3, r0 /* disable data-side IRAM */
1074 and r4, r4, r0 /* disable data-side IRAM */
1075 mtdcr ocmiscntl, r3 /* set instr-side IRAM config */
1076 mtdcr ocmdscntl, r4 /* set data-side IRAM config */
1079 lis r3,CFG_OCM_DATA_ADDR@h /* OCM location */
1080 ori r3,r3,CFG_OCM_DATA_ADDR@l
1082 addis r4, 0, 0xC000 /* OCM data area enabled */
1085 #endif /* CONFIG_405EZ */
1088 #ifdef CONFIG_NAND_SPL
1090 * Copy SPL from cache into internal SRAM
1092 li r4,(CFG_NAND_BOOT_SPL_SIZE >> 2) - 1
1094 lis r2,CFG_NAND_BOOT_SPL_SRC@h
1095 ori r2,r2,CFG_NAND_BOOT_SPL_SRC@l
1096 lis r3,CFG_NAND_BOOT_SPL_DST@h
1097 ori r3,r3,CFG_NAND_BOOT_SPL_DST@l
1104 * Jump to code in RAM
1108 lis r3,(CFG_NAND_BOOT_SPL_SRC - CFG_NAND_BOOT_SPL_DST)@h
1109 ori r3,r3,(CFG_NAND_BOOT_SPL_SRC - CFG_NAND_BOOT_SPL_DST)@l
1118 #endif /* CONFIG_NAND_SPL */
1120 /*----------------------------------------------------------------------- */
1121 /* Setup temporary stack in DCACHE or OCM if needed for SDRAM SPD. */
1122 /*----------------------------------------------------------------------- */
1123 #ifdef CFG_INIT_DCACHE_CS
1126 lis r4, CFG_INIT_DCACHE_PBxAR@h
1127 ori r4, r4, CFG_INIT_DCACHE_PBxAR@l
1132 lis r4, CFG_INIT_DCACHE_PBxCR@h
1133 ori r4, r4, CFG_INIT_DCACHE_PBxCR@l
1137 * Enable the data cache for the 128MB storage access control region
1138 * at CFG_INIT_RAM_ADDR.
1141 oris r4, r4, PPC_128MB_SACR_VALUE(CFG_INIT_RAM_ADDR)@h
1142 ori r4, r4, PPC_128MB_SACR_VALUE(CFG_INIT_RAM_ADDR)@l
1146 * Preallocate data cache lines to be used to avoid a subsequent
1147 * cache miss and an ensuing machine check exception when exceptions
1152 lis r3, CFG_INIT_RAM_ADDR@h
1153 ori r3, r3, CFG_INIT_RAM_ADDR@l
1155 lis r4, CFG_INIT_RAM_END@h
1156 ori r4, r4, CFG_INIT_RAM_END@l
1159 * Convert the size, in bytes, to the number of cache lines/blocks
1162 clrlwi. r5, r4, (32 - L1_CACHE_SHIFT)
1163 srwi r5, r4, L1_CACHE_SHIFT
1169 /* Preallocate the computed number of cache blocks. */
1170 ..alloc_dcache_block:
1172 addi r3, r3, L1_CACHE_BYTES
1173 bdnz ..alloc_dcache_block
1177 * Load the initial stack pointer and data area and convert the size,
1178 * in bytes, to the number of words to initialize to a known value.
1180 lis r1, CFG_INIT_RAM_ADDR@h
1181 ori r1, r1, CFG_INIT_SP_OFFSET@l
1183 lis r4, (CFG_INIT_RAM_END >> 2)@h
1184 ori r4, r4, (CFG_INIT_RAM_END >> 2)@l
1187 lis r2, CFG_INIT_RAM_ADDR@h
1188 ori r2, r2, CFG_INIT_RAM_END@l
1190 lis r4, CFG_INIT_RAM_PATTERN@h
1191 ori r4, r4, CFG_INIT_RAM_PATTERN@l
1198 * Make room for stack frame header and clear final stack frame so
1199 * that stack backtraces terminate cleanly.
1205 * Set up a dummy frame to store reset vector as return address.
1206 * this causes stack underflow to reset board.
1208 stwu r1, -8(r1) /* Save back chain and move SP */
1209 addis r0, 0, RESET_VECTOR@h /* Address of reset vector */
1210 ori r0, r0, RESET_VECTOR@l
1211 stwu r1, -8(r1) /* Save back chain and move SP */
1212 stw r0, +12(r1) /* Save return addr (underflow vect) */
1214 #elif defined(CFG_TEMP_STACK_OCM) && \
1215 (defined(CFG_OCM_DATA_ADDR) && defined(CFG_OCM_DATA_SIZE))
1220 /* Set up Stack at top of OCM */
1221 lis r1, (CFG_INIT_RAM_ADDR + CFG_INIT_SP_OFFSET)@h
1222 ori r1, r1, (CFG_INIT_RAM_ADDR + CFG_INIT_SP_OFFSET)@l
1224 /* Set up a zeroized stack frame so that backtrace works right */
1230 * Set up a dummy frame to store reset vector as return address.
1231 * this causes stack underflow to reset board.
1233 stwu r1, -8(r1) /* Save back chain and move SP */
1234 lis r0, RESET_VECTOR@h /* Address of reset vector */
1235 ori r0, r0, RESET_VECTOR@l
1236 stwu r1, -8(r1) /* Save back chain and move SP */
1237 stw r0, +12(r1) /* Save return addr (underflow vect) */
1238 #endif /* CFG_INIT_DCACHE_CS */
1240 /*----------------------------------------------------------------------- */
1241 /* Initialize SDRAM Controller */
1242 /*----------------------------------------------------------------------- */
1245 #ifdef CONFIG_NAND_SPL
1246 bl nand_boot /* will not return */
1248 GET_GOT /* initialize GOT access */
1250 bl cpu_init_f /* run low-level CPU init code (from Flash) */
1252 /* NEVER RETURNS! */
1253 bl board_init_f /* run first part of init code (from Flash) */
1254 #endif /* CONFIG_NAND_SPL */
1256 #endif /* CONFIG_405GP || CONFIG_405CR || CONFIG_405 || CONFIG_405EP */
1257 /*----------------------------------------------------------------------- */
1260 #ifndef CONFIG_NAND_SPL
1262 * This code finishes saving the registers to the exception frame
1263 * and jumps to the appropriate handler for the exception.
1264 * Register r21 is pointer into trap frame, r1 has new stack pointer.
1266 .globl transfer_to_handler
1267 transfer_to_handler:
1277 andi. r24,r23,0x3f00 /* get vector offset */
1281 mtspr SPRG2,r22 /* r1 is now kernel sp */
1282 lwz r24,0(r23) /* virtual address of handler */
1283 lwz r23,4(r23) /* where to go when done */
1288 rfi /* jump to handler, enable MMU */
1291 mfmsr r28 /* Disable interrupts */
1295 SYNC /* Some chip revs need this... */
1310 lwz r2,_NIP(r1) /* Restore environment */
1321 mfmsr r28 /* Disable interrupts */
1325 SYNC /* Some chip revs need this... */
1340 lwz r2,_NIP(r1) /* Restore environment */
1352 mfmsr r28 /* Disable interrupts */
1356 SYNC /* Some chip revs need this... */
1371 lwz r2,_NIP(r1) /* Restore environment */
1380 #endif /* CONFIG_440 */
1388 /*------------------------------------------------------------------------------- */
1389 /* Function: out16 */
1390 /* Description: Output 16 bits */
1391 /*------------------------------------------------------------------------------- */
1397 /*------------------------------------------------------------------------------- */
1398 /* Function: out16r */
1399 /* Description: Byte reverse and output 16 bits */
1400 /*------------------------------------------------------------------------------- */
1406 /*------------------------------------------------------------------------------- */
1407 /* Function: out32r */
1408 /* Description: Byte reverse and output 32 bits */
1409 /*------------------------------------------------------------------------------- */
1415 /*------------------------------------------------------------------------------- */
1416 /* Function: in16 */
1417 /* Description: Input 16 bits */
1418 /*------------------------------------------------------------------------------- */
1424 /*------------------------------------------------------------------------------- */
1425 /* Function: in16r */
1426 /* Description: Input 16 bits and byte reverse */
1427 /*------------------------------------------------------------------------------- */
1433 /*------------------------------------------------------------------------------- */
1434 /* Function: in32r */
1435 /* Description: Input 32 bits and byte reverse */
1436 /*------------------------------------------------------------------------------- */
1443 * void relocate_code (addr_sp, gd, addr_moni)
1445 * This "function" does not return, instead it continues in RAM
1446 * after relocating the monitor code.
1448 * r3 = Relocated stack pointer
1449 * r4 = Relocated global data pointer
1450 * r5 = Relocated text pointer
1452 .globl relocate_code
1454 #if defined(CONFIG_4xx_DCACHE) || defined(CFG_INIT_DCACHE_CS)
1456 * We need to flush the initial global data (gd_t) before the dcache
1457 * will be invalidated.
1460 /* Save registers */
1465 /* Flush initial global data range */
1467 addi r4, r4, CFG_GBL_DATA_SIZE@l
1468 bl flush_dcache_range
1470 #if defined(CFG_INIT_DCACHE_CS)
1472 * Undo the earlier data cache set-up for the primordial stack and
1473 * data area. First, invalidate the data cache and then disable data
1474 * cacheability for that area. Finally, restore the EBC values, if
1478 /* Invalidate the primordial stack and data area in cache */
1479 lis r3, CFG_INIT_RAM_ADDR@h
1480 ori r3, r3, CFG_INIT_RAM_ADDR@l
1482 lis r4, CFG_INIT_RAM_END@h
1483 ori r4, r4, CFG_INIT_RAM_END@l
1486 bl invalidate_dcache_range
1488 /* Disable cacheability for the region */
1490 lis r4, ~PPC_128MB_SACR_VALUE(CFG_INIT_RAM_ADDR)@h
1491 ori r4, r4, ~PPC_128MB_SACR_VALUE(CFG_INIT_RAM_ADDR)@l
1495 /* Restore the EBC parameters */
1499 ori r3, r3, PBxAP_VAL@l
1505 ori r3, r3, PBxCR_VAL@l
1507 #endif /* defined(CFG_INIT_DCACHE_CS) */
1509 /* Restore registers */
1513 #endif /* defined(CONFIG_4xx_DCACHE) || defined(CFG_INIT_DCACHE_CS) */
1515 #ifdef CFG_INIT_RAM_DCACHE
1517 * Unlock the previously locked d-cache
1521 /* set TFLOOR/NFLOOR to 0 again */
1537 #endif /* CFG_INIT_RAM_DCACHE */
1539 #if defined(CONFIG_440EP) || defined(CONFIG_440GR) || \
1540 defined(CONFIG_440EPX) || defined(CONFIG_440GRX) || \
1541 defined(CONFIG_440SP) || defined(CONFIG_440SPE) || \
1542 defined(CONFIG_460EX) || defined(CONFIG_460GT)
1544 * On some 440er platforms the cache is enabled in the first TLB (Boot-CS)
1545 * to speed up the boot process. Now this cache needs to be disabled.
1547 iccci 0,0 /* Invalidate inst cache */
1548 dccci 0,0 /* Invalidate data cache, now no longer our stack */
1551 #ifdef CFG_TLB_FOR_BOOT_FLASH
1552 addi r1,r0,CFG_TLB_FOR_BOOT_FLASH /* Use defined TLB */
1554 addi r1,r0,0x0000 /* Default TLB entry is #0 */
1555 #endif /* CFG_TLB_FOR_BOOT_FLASH */
1556 tlbre r0,r1,0x0002 /* Read contents */
1557 ori r0,r0,0x0c00 /* Or in the inhibit, write through bit */
1558 tlbwe r0,r1,0x0002 /* Save it out */
1561 #endif /* defined(CONFIG_440EP) || ... || defined(CONFIG_460GT) */
1562 mr r1, r3 /* Set new stack pointer */
1563 mr r9, r4 /* Save copy of Init Data pointer */
1564 mr r10, r5 /* Save copy of Destination Address */
1566 mr r3, r5 /* Destination Address */
1567 lis r4, CFG_MONITOR_BASE@h /* Source Address */
1568 ori r4, r4, CFG_MONITOR_BASE@l
1569 lwz r5, GOT(__init_end)
1571 li r6, L1_CACHE_BYTES /* Cache Line Size */
1576 * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address
1582 /* First our own GOT */
1584 /* then the one used by the C code */
1594 beq cr1,4f /* In place copy is not necessary */
1595 beq 7f /* Protect against 0 count */
1614 * Now flush the cache: note that we must start from a cache aligned
1615 * address. Otherwise we might miss one cache line.
1619 beq 7f /* Always flush prefetch queue in any case */
1627 sync /* Wait for all dcbst to complete on bus */
1633 7: sync /* Wait for all icbi to complete on bus */
1637 * We are done. Do not return, instead branch to second part of board
1638 * initialization, now running from RAM.
1641 addi r0, r10, in_ram - _start + _START_OFFSET
1643 blr /* NEVER RETURNS! */
1648 * Relocation Function, r14 point to got2+0x8000
1650 * Adjust got2 pointers, no need to check for 0, this code
1651 * already puts a few entries in the table.
1653 li r0,__got2_entries@sectoff@l
1654 la r3,GOT(_GOT2_TABLE_)
1655 lwz r11,GOT(_GOT2_TABLE_)
1665 * Now adjust the fixups and the pointers to the fixups
1666 * in case we need to move ourselves again.
1668 2: li r0,__fixup_entries@sectoff@l
1669 lwz r3,GOT(_FIXUP_TABLE_)
1683 * Now clear BSS segment
1685 lwz r3,GOT(__bss_start)
1708 mr r3, r9 /* Init Data pointer */
1709 mr r4, r10 /* Destination Address */
1713 * Copy exception vector code to low memory
1716 * r7: source address, r8: end address, r9: target address
1720 lwz r7, GOT(_start_of_vectors)
1721 lwz r8, GOT(_end_of_vectors)
1723 li r9, 0x100 /* reset vector always at 0x100 */
1726 bgelr /* return if r7>=r8 - just in case */
1728 mflr r4 /* save link register */
1738 * relocate `hdlr' and `int_return' entries
1740 li r7, .L_MachineCheck - _start + _START_OFFSET
1741 li r8, Alignment - _start + _START_OFFSET
1744 addi r7, r7, 0x100 /* next exception vector */
1748 li r7, .L_Alignment - _start + _START_OFFSET
1751 li r7, .L_ProgramCheck - _start + _START_OFFSET
1755 li r7, .L_FPUnavailable - _start + _START_OFFSET
1758 li r7, .L_Decrementer - _start + _START_OFFSET
1761 li r7, .L_APU - _start + _START_OFFSET
1764 li r7, .L_InstructionTLBError - _start + _START_OFFSET
1767 li r7, .L_DataTLBError - _start + _START_OFFSET
1769 #else /* CONFIG_440 */
1770 li r7, .L_PIT - _start + _START_OFFSET
1773 li r7, .L_InstructionTLBMiss - _start + _START_OFFSET
1776 li r7, .L_DataTLBMiss - _start + _START_OFFSET
1778 #endif /* CONFIG_440 */
1780 li r7, .L_DebugBreakpoint - _start + _START_OFFSET
1783 #if !defined(CONFIG_440)
1784 addi r7,r0,0x1000 /* set ME bit (Machine Exceptions) */
1785 oris r7,r7,0x0002 /* set CE bit (Critical Exceptions) */
1786 mtmsr r7 /* change MSR */
1789 b __440_msr_continue
1792 addi r7,r0,0x1000 /* set ME bit (Machine Exceptions) */
1793 oris r7,r7,0x0002 /* set CE bit (Critical Exceptions) */
1801 mtlr r4 /* restore link register */
1805 * Function: relocate entries for one exception vector
1808 lwz r0, 0(r7) /* hdlr ... */
1809 add r0, r0, r3 /* ... += dest_addr */
1812 lwz r0, 4(r7) /* int_return ... */
1813 add r0, r0, r3 /* ... += dest_addr */
1818 #if defined(CONFIG_440)
1819 /*----------------------------------------------------------------------------+
1821 +----------------------------------------------------------------------------*/
1822 function_prolog(dcbz_area)
1823 rlwinm. r5,r4,0,27,31
1824 rlwinm r5,r4,27,5,31
1833 function_epilog(dcbz_area)
1834 #endif /* CONFIG_440 */
1835 #endif /* CONFIG_NAND_SPL */
1837 /*------------------------------------------------------------------------------- */
1839 /* Description: Input 8 bits */
1840 /*------------------------------------------------------------------------------- */
1846 /*------------------------------------------------------------------------------- */
1847 /* Function: out8 */
1848 /* Description: Output 8 bits */
1849 /*------------------------------------------------------------------------------- */
1855 /*------------------------------------------------------------------------------- */
1856 /* Function: out32 */
1857 /* Description: Output 32 bits */
1858 /*------------------------------------------------------------------------------- */
1864 /*------------------------------------------------------------------------------- */
1865 /* Function: in32 */
1866 /* Description: Input 32 bits */
1867 /*------------------------------------------------------------------------------- */
1873 /**************************************************************************/
1874 /* PPC405EP specific stuff */
1875 /**************************************************************************/
1879 #ifdef CONFIG_BUBINGA
1881 * Initialize EBC chip selects 1 & 4 and GPIO pins (for alternate
1882 * function) to support FPGA and NVRAM accesses below.
1885 lis r3,GPIO0_OSRH@h /* config GPIO output select */
1886 ori r3,r3,GPIO0_OSRH@l
1887 lis r4,CFG_GPIO0_OSRH@h
1888 ori r4,r4,CFG_GPIO0_OSRH@l
1891 ori r3,r3,GPIO0_OSRL@l
1892 lis r4,CFG_GPIO0_OSRL@h
1893 ori r4,r4,CFG_GPIO0_OSRL@l
1896 lis r3,GPIO0_ISR1H@h /* config GPIO input select */
1897 ori r3,r3,GPIO0_ISR1H@l
1898 lis r4,CFG_GPIO0_ISR1H@h
1899 ori r4,r4,CFG_GPIO0_ISR1H@l
1901 lis r3,GPIO0_ISR1L@h
1902 ori r3,r3,GPIO0_ISR1L@l
1903 lis r4,CFG_GPIO0_ISR1L@h
1904 ori r4,r4,CFG_GPIO0_ISR1L@l
1907 lis r3,GPIO0_TSRH@h /* config GPIO three-state select */
1908 ori r3,r3,GPIO0_TSRH@l
1909 lis r4,CFG_GPIO0_TSRH@h
1910 ori r4,r4,CFG_GPIO0_TSRH@l
1913 ori r3,r3,GPIO0_TSRL@l
1914 lis r4,CFG_GPIO0_TSRL@h
1915 ori r4,r4,CFG_GPIO0_TSRL@l
1918 lis r3,GPIO0_TCR@h /* config GPIO driver output enables */
1919 ori r3,r3,GPIO0_TCR@l
1920 lis r4,CFG_GPIO0_TCR@h
1921 ori r4,r4,CFG_GPIO0_TCR@l
1924 li r3,pb1ap /* program EBC bank 1 for RTC access */
1926 lis r3,CFG_EBC_PB1AP@h
1927 ori r3,r3,CFG_EBC_PB1AP@l
1931 lis r3,CFG_EBC_PB1CR@h
1932 ori r3,r3,CFG_EBC_PB1CR@l
1935 li r3,pb1ap /* program EBC bank 1 for RTC access */
1937 lis r3,CFG_EBC_PB1AP@h
1938 ori r3,r3,CFG_EBC_PB1AP@l
1942 lis r3,CFG_EBC_PB1CR@h
1943 ori r3,r3,CFG_EBC_PB1CR@l
1946 li r3,pb4ap /* program EBC bank 4 for FPGA access */
1948 lis r3,CFG_EBC_PB4AP@h
1949 ori r3,r3,CFG_EBC_PB4AP@l
1953 lis r3,CFG_EBC_PB4CR@h
1954 ori r3,r3,CFG_EBC_PB4CR@l
1959 !-----------------------------------------------------------------------
1960 ! Check to see if chip is in bypass mode.
1961 ! If so, write stored CPC0_PLLMR0 and CPC0_PLLMR1 values and perform a
1962 ! CPU reset Otherwise, skip this step and keep going.
1963 ! Note: Running BIOS in bypass mode is not supported since PLB speed
1964 ! will not be fast enough for the SDRAM (min 66MHz)
1965 !-----------------------------------------------------------------------
1967 mfdcr r5, CPC0_PLLMR1
1968 rlwinm r4,r5,1,0x1 /* get system clock source (SSCS) */
1971 beq pll_done /* if SSCS =b'1' then PLL has */
1972 /* already been set */
1973 /* and CPU has been reset */
1974 /* so skip to next section */
1976 #ifdef CONFIG_BUBINGA
1978 !-----------------------------------------------------------------------
1979 ! Read NVRAM to get value to write in PLLMR.
1980 ! If value has not been correctly saved, write default value
1981 ! Default config values (assuming on-board 33MHz SYS_CLK) are above.
1982 ! See CPU_DEFAULT_200 and CPU_DEFAULT_266 above.
1984 ! WARNING: This code assumes the first three words in the nvram_t
1985 ! structure in openbios.h. Changing the beginning of
1986 ! the structure will break this code.
1988 !-----------------------------------------------------------------------
1990 addis r3,0,NVRAM_BASE@h
1991 addi r3,r3,NVRAM_BASE@l
1994 addis r5,0,NVRVFY1@h
1995 addi r5,r5,NVRVFY1@l
1996 cmp cr0,0,r4,r5 /* Compare 1st NVRAM Magic number*/
2000 addis r5,0,NVRVFY2@h
2001 addi r5,r5,NVRVFY2@l
2002 cmp cr0,0,r4,r5 /* Compare 2 NVRAM Magic number */
2004 addi r3,r3,8 /* Skip over conf_size */
2005 lwz r4, 4(r3) /* Load PLLMR1 value from NVRAM */
2006 lwz r3, 0(r3) /* Load PLLMR0 value from NVRAM */
2007 rlwinm r5,r4,1,0x1 /* get system clock source (SSCS) */
2008 cmpi cr0,0,r5,1 /* See if PLL is locked */
2011 #endif /* CONFIG_BUBINGA */
2015 andi. r5, r4, CPC0_BOOT_SEP@l
2016 bne strap_1 /* serial eeprom present */
2017 addis r5,0,CPLD_REG0_ADDR@h
2018 ori r5,r5,CPLD_REG0_ADDR@l
2021 #endif /* CONFIG_TAIHU */
2023 #if defined(CONFIG_ZEUS)
2025 andi. r5, r4, CPC0_BOOT_SEP@l
2026 bne strap_1 /* serial eeprom present */
2033 mfdcr r3, CPC0_PLLMR0
2034 mfdcr r4, CPC0_PLLMR1
2038 addis r3,0,PLLMR0_DEFAULT@h /* PLLMR0 default value */
2039 ori r3,r3,PLLMR0_DEFAULT@l /* */
2040 addis r4,0,PLLMR1_DEFAULT@h /* PLLMR1 default value */
2041 ori r4,r4,PLLMR1_DEFAULT@l /* */
2046 addis r3,0,PLLMR0_DEFAULT_PCI66@h
2047 ori r3,r3,PLLMR0_DEFAULT_PCI66@l
2048 addis r4,0,PLLMR1_DEFAULT_PCI66@h
2049 ori r4,r4,PLLMR1_DEFAULT_PCI66@l
2052 mfdcr r3, CPC0_PLLMR0
2053 mfdcr r4, CPC0_PLLMR1
2054 #endif /* CONFIG_TAIHU */
2057 b pll_write /* Write the CPC0_PLLMR with new value */
2061 !-----------------------------------------------------------------------
2062 ! Clear Soft Reset Register
2063 ! This is needed to enable PCI if not booting from serial EPROM
2064 !-----------------------------------------------------------------------
2074 blr /* return to main code */
2077 !-----------------------------------------------------------------------------
2078 ! Function: pll_write
2079 ! Description: Updates the value of the CPC0_PLLMR according to CMOS27E documentation
2081 ! 1. Pll is first disabled (de-activated by putting in bypass mode)
2083 ! 3. Clock dividers are set while PLL is held in reset and bypassed
2084 ! 4. PLL Reset is cleared
2085 ! 5. Wait 100us for PLL to lock
2086 ! 6. A core reset is performed
2087 ! Input: r3 = Value to write to CPC0_PLLMR0
2088 ! Input: r4 = Value to write to CPC0_PLLMR1
2090 !-----------------------------------------------------------------------------
2095 ori r5,r5,0x0101 /* Stop the UART clocks */
2096 mtdcr CPC0_UCR,r5 /* Before changing PLL */
2098 mfdcr r5, CPC0_PLLMR1
2099 rlwinm r5,r5,0,0x7FFFFFFF /* Disable PLL */
2100 mtdcr CPC0_PLLMR1,r5
2101 oris r5,r5,0x4000 /* Set PLL Reset */
2102 mtdcr CPC0_PLLMR1,r5
2104 mtdcr CPC0_PLLMR0,r3 /* Set clock dividers */
2105 rlwinm r5,r4,0,0x3FFFFFFF /* Reset & Bypass new PLL dividers */
2106 oris r5,r5,0x4000 /* Set PLL Reset */
2107 mtdcr CPC0_PLLMR1,r5 /* Set clock dividers */
2108 rlwinm r5,r5,0,0xBFFFFFFF /* Clear PLL Reset */
2109 mtdcr CPC0_PLLMR1,r5
2112 ! Wait min of 100us for PLL to lock.
2113 ! See CMOS 27E databook for more info.
2114 ! At 200MHz, that means waiting 20,000 instructions
2116 addi r3,0,20000 /* 2000 = 0x4e20 */
2121 oris r5,r5,0x8000 /* Enable PLL */
2122 mtdcr CPC0_PLLMR1,r5 /* Engage */
2125 * Reset CPU to guarantee timings are OK
2126 * Not sure if this is needed...
2129 mtspr dbcr0,r3 /* This will cause a CPU core reset, and */
2130 /* execution will continue from the poweron */
2131 /* vector of 0xfffffffc */
2132 #endif /* CONFIG_405EP */
2134 #if defined(CONFIG_440)
2135 /*----------------------------------------------------------------------------+
2137 +----------------------------------------------------------------------------*/
2138 function_prolog(mttlb3)
2141 function_epilog(mttlb3)
2143 /*----------------------------------------------------------------------------+
2145 +----------------------------------------------------------------------------*/
2146 function_prolog(mftlb3)
2149 function_epilog(mftlb3)
2151 /*----------------------------------------------------------------------------+
2153 +----------------------------------------------------------------------------*/
2154 function_prolog(mttlb2)
2157 function_epilog(mttlb2)
2159 /*----------------------------------------------------------------------------+
2161 +----------------------------------------------------------------------------*/
2162 function_prolog(mftlb2)
2165 function_epilog(mftlb2)
2167 /*----------------------------------------------------------------------------+
2169 +----------------------------------------------------------------------------*/
2170 function_prolog(mttlb1)
2173 function_epilog(mttlb1)
2175 /*----------------------------------------------------------------------------+
2177 +----------------------------------------------------------------------------*/
2178 function_prolog(mftlb1)
2181 function_epilog(mftlb1)
2182 #endif /* CONFIG_440 */