Merge git://oss.sgi.com:8090/oss/git/xfs-2.6
[sfrench/cifs-2.6.git] / arch / ppc / boot / simple / head.S
1 /*
2  * Initial board bringup code for many different boards.
3  *
4  * Author: Tom Rini
5  *         trini@mvista.com
6  * Derived from arch/ppc/boot/prep/head.S (Cort Dougan, many others).
7  *
8  * 2001-2004 (c) MontaVista, Software, Inc.  This file is licensed under
9  * the terms of the GNU General Public License version 2.  This program
10  * is licensed "as is" without any warranty of any kind, whether express
11  * or implied.
12  */
13
14 #include <linux/config.h>
15 #include <asm/reg.h>
16 #include <asm/cache.h>
17 #include <asm/ppc_asm.h>
18
19         .text
20
21 /*
22  *      Begin at some arbitrary location in RAM or Flash
23  *        Initialize core registers
24  *        Configure memory controller (Not executing from RAM)
25  *      Move the boot code to the link address (8M)
26  *        Setup C stack
27  *        Initialize UART
28  *      Decompress the kernel to 0x0
29  *      Jump to the kernel entry
30  *
31  */
32
33         .globl  start
34 start:
35         bl      start_
36 #ifdef CONFIG_IBM_OPENBIOS
37         /* The IBM "Tree" bootrom knows that the address of the bootrom
38          * read only structure is 4 bytes after _start.
39          */
40         .long   0x62726f6d              # structure ID - "brom"
41         .long   0x5f726f00              #              - "_ro\0"
42         .long   1                       # structure version
43         .long   bootrom_cmdline         # address of *bootrom_cmdline
44 #endif
45
46 start_:
47 #ifdef CONFIG_FORCE
48         /* We have some really bad firmware.  We must disable the L1
49          * icache/dcache now or the board won't boot.
50          */
51         li      r4,0x0000
52         isync
53         mtspr   SPRN_HID0,r4
54         sync
55         isync
56 #endif
57
58 #if defined(CONFIG_MBX) || defined(CONFIG_RPX8260) || defined(CONFIG_PPC_PREP)
59         mr      r29,r3  /* On the MBX860, r3 is the board info pointer.
60                          * On the RPXSUPER, r3 points to the NVRAM
61                          * configuration keys.
62                          * On PReP, r3 is the pointer to the residual data.
63                          */
64 #endif
65
66 #if defined(CONFIG_XILINX_VIRTEX_4_FX)
67         /* PPC errata 213: only for Virtex-4 FX */
68         mfccr0  0
69         oris    0,0,0x50000000@h
70         mtccr0  0
71 #endif
72
73         mflr    r3      /* Save our actual starting address. */
74
75         /* The following functions we call must not modify r3 or r4.....
76         */
77 #ifdef CONFIG_6xx
78         /* On PReP we must look at the OpenFirmware pointer and sanity
79          * test it.  On other platforms, we disable the MMU right now
80          * and other bits.
81          */
82 #ifdef CONFIG_PPC_PREP
83 /*
84  * Save the OF pointer to r25, but only if the entry point is in a sane
85  * location; if not we store 0.  If there is no entry point, or it is
86  * invalid, we establish the default MSR value immediately.  Otherwise,
87  * we defer doing that, to allow OF functions to be called, until we
88  * begin uncompressing the kernel.
89  */
90         lis     r8,0x0fff               /* r8 = 0x0fffffff */
91         ori     r8,r8,0xffff
92
93         subc    r8,r8,r5                /* r8 = (r5 <= r8) ? ~0 : 0 */
94         subfe   r8,r8,r8
95         nand    r8,r8,r8
96
97         and.    r5,r5,r8                /* r5 will be cleared if (r5 > r8) */
98         bne+    haveOF
99
100         li      r8,MSR_IP|MSR_FP        /* Not OF: set MSR immediately */
101         mtmsr   r8
102         isync
103 haveOF:
104         mr      r25,r5
105 #else
106         bl      disable_6xx_mmu
107 #endif
108         bl      disable_6xx_l1cache
109
110         CLEAR_CACHES
111 #endif
112
113 #ifdef CONFIG_8xx
114         mfmsr   r8              /* Turn off interrupts */
115         li      r9,0
116         ori     r9,r9,MSR_EE
117         andc    r8,r8,r9
118         mtmsr   r8
119
120         /* We do this because some boot roms don't initialize the
121          * processor correctly. Don't do this if you want to debug
122          * using a BDM device.
123          */
124         li      r4,0            /* Zero DER to prevent FRZ */
125         mtspr   SPRN_DER,r4
126 #endif
127
128 #if defined(CONFIG_MBX) || defined(CONFIG_RPX8260) || defined(CONFIG_PPC_PREP)
129         mr      r4,r29  /* put the board info pointer where the relocate
130                          * routine will find it
131                          */
132 #endif
133
134         /* Get the load address.
135         */
136         subi    r3, r3, 4       /* Get the actual IP, not NIP */
137         b       relocate
138