xref: /rk3399_rockchip-uboot/arch/powerpc/cpu/mpc85xx/cpu_init.c (revision a47a12becf66f02a56da91c161e2edb625e9f20c)
1*a47a12beSStefan Roese /*
2*a47a12beSStefan Roese  * Copyright 2007-2009 Freescale Semiconductor, Inc.
3*a47a12beSStefan Roese  *
4*a47a12beSStefan Roese  * (C) Copyright 2003 Motorola Inc.
5*a47a12beSStefan Roese  * Modified by Xianghua Xiao, X.Xiao@motorola.com
6*a47a12beSStefan Roese  *
7*a47a12beSStefan Roese  * (C) Copyright 2000
8*a47a12beSStefan Roese  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
9*a47a12beSStefan Roese  *
10*a47a12beSStefan Roese  * See file CREDITS for list of people who contributed to this
11*a47a12beSStefan Roese  * project.
12*a47a12beSStefan Roese  *
13*a47a12beSStefan Roese  * This program is free software; you can redistribute it and/or
14*a47a12beSStefan Roese  * modify it under the terms of the GNU General Public License as
15*a47a12beSStefan Roese  * published by the Free Software Foundation; either version 2 of
16*a47a12beSStefan Roese  * the License, or (at your option) any later version.
17*a47a12beSStefan Roese  *
18*a47a12beSStefan Roese  * This program is distributed in the hope that it will be useful,
19*a47a12beSStefan Roese  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20*a47a12beSStefan Roese  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21*a47a12beSStefan Roese  * GNU General Public License for more details.
22*a47a12beSStefan Roese  *
23*a47a12beSStefan Roese  * You should have received a copy of the GNU General Public License
24*a47a12beSStefan Roese  * along with this program; if not, write to the Free Software
25*a47a12beSStefan Roese  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
26*a47a12beSStefan Roese  * MA 02111-1307 USA
27*a47a12beSStefan Roese  */
28*a47a12beSStefan Roese 
29*a47a12beSStefan Roese #include <common.h>
30*a47a12beSStefan Roese #include <watchdog.h>
31*a47a12beSStefan Roese #include <asm/processor.h>
32*a47a12beSStefan Roese #include <ioports.h>
33*a47a12beSStefan Roese #include <asm/io.h>
34*a47a12beSStefan Roese #include <asm/mmu.h>
35*a47a12beSStefan Roese #include <asm/fsl_law.h>
36*a47a12beSStefan Roese #include "mp.h"
37*a47a12beSStefan Roese 
38*a47a12beSStefan Roese DECLARE_GLOBAL_DATA_PTR;
39*a47a12beSStefan Roese 
40*a47a12beSStefan Roese #ifdef CONFIG_MPC8536
41*a47a12beSStefan Roese extern void fsl_serdes_init(void);
42*a47a12beSStefan Roese #endif
43*a47a12beSStefan Roese 
44*a47a12beSStefan Roese #ifdef CONFIG_QE
45*a47a12beSStefan Roese extern qe_iop_conf_t qe_iop_conf_tab[];
46*a47a12beSStefan Roese extern void qe_config_iopin(u8 port, u8 pin, int dir,
47*a47a12beSStefan Roese 				int open_drain, int assign);
48*a47a12beSStefan Roese extern void qe_init(uint qe_base);
49*a47a12beSStefan Roese extern void qe_reset(void);
50*a47a12beSStefan Roese 
51*a47a12beSStefan Roese static void config_qe_ioports(void)
52*a47a12beSStefan Roese {
53*a47a12beSStefan Roese 	u8      port, pin;
54*a47a12beSStefan Roese 	int     dir, open_drain, assign;
55*a47a12beSStefan Roese 	int     i;
56*a47a12beSStefan Roese 
57*a47a12beSStefan Roese 	for (i = 0; qe_iop_conf_tab[i].assign != QE_IOP_TAB_END; i++) {
58*a47a12beSStefan Roese 		port		= qe_iop_conf_tab[i].port;
59*a47a12beSStefan Roese 		pin		= qe_iop_conf_tab[i].pin;
60*a47a12beSStefan Roese 		dir		= qe_iop_conf_tab[i].dir;
61*a47a12beSStefan Roese 		open_drain	= qe_iop_conf_tab[i].open_drain;
62*a47a12beSStefan Roese 		assign		= qe_iop_conf_tab[i].assign;
63*a47a12beSStefan Roese 		qe_config_iopin(port, pin, dir, open_drain, assign);
64*a47a12beSStefan Roese 	}
65*a47a12beSStefan Roese }
66*a47a12beSStefan Roese #endif
67*a47a12beSStefan Roese 
68*a47a12beSStefan Roese #ifdef CONFIG_CPM2
69*a47a12beSStefan Roese void config_8560_ioports (volatile ccsr_cpm_t * cpm)
70*a47a12beSStefan Roese {
71*a47a12beSStefan Roese 	int portnum;
72*a47a12beSStefan Roese 
73*a47a12beSStefan Roese 	for (portnum = 0; portnum < 4; portnum++) {
74*a47a12beSStefan Roese 		uint pmsk = 0,
75*a47a12beSStefan Roese 		     ppar = 0,
76*a47a12beSStefan Roese 		     psor = 0,
77*a47a12beSStefan Roese 		     pdir = 0,
78*a47a12beSStefan Roese 		     podr = 0,
79*a47a12beSStefan Roese 		     pdat = 0;
80*a47a12beSStefan Roese 		iop_conf_t *iopc = (iop_conf_t *) & iop_conf_tab[portnum][0];
81*a47a12beSStefan Roese 		iop_conf_t *eiopc = iopc + 32;
82*a47a12beSStefan Roese 		uint msk = 1;
83*a47a12beSStefan Roese 
84*a47a12beSStefan Roese 		/*
85*a47a12beSStefan Roese 		 * NOTE:
86*a47a12beSStefan Roese 		 * index 0 refers to pin 31,
87*a47a12beSStefan Roese 		 * index 31 refers to pin 0
88*a47a12beSStefan Roese 		 */
89*a47a12beSStefan Roese 		while (iopc < eiopc) {
90*a47a12beSStefan Roese 			if (iopc->conf) {
91*a47a12beSStefan Roese 				pmsk |= msk;
92*a47a12beSStefan Roese 				if (iopc->ppar)
93*a47a12beSStefan Roese 					ppar |= msk;
94*a47a12beSStefan Roese 				if (iopc->psor)
95*a47a12beSStefan Roese 					psor |= msk;
96*a47a12beSStefan Roese 				if (iopc->pdir)
97*a47a12beSStefan Roese 					pdir |= msk;
98*a47a12beSStefan Roese 				if (iopc->podr)
99*a47a12beSStefan Roese 					podr |= msk;
100*a47a12beSStefan Roese 				if (iopc->pdat)
101*a47a12beSStefan Roese 					pdat |= msk;
102*a47a12beSStefan Roese 			}
103*a47a12beSStefan Roese 
104*a47a12beSStefan Roese 			msk <<= 1;
105*a47a12beSStefan Roese 			iopc++;
106*a47a12beSStefan Roese 		}
107*a47a12beSStefan Roese 
108*a47a12beSStefan Roese 		if (pmsk != 0) {
109*a47a12beSStefan Roese 			volatile ioport_t *iop = ioport_addr (cpm, portnum);
110*a47a12beSStefan Roese 			uint tpmsk = ~pmsk;
111*a47a12beSStefan Roese 
112*a47a12beSStefan Roese 			/*
113*a47a12beSStefan Roese 			 * the (somewhat confused) paragraph at the
114*a47a12beSStefan Roese 			 * bottom of page 35-5 warns that there might
115*a47a12beSStefan Roese 			 * be "unknown behaviour" when programming
116*a47a12beSStefan Roese 			 * PSORx and PDIRx, if PPARx = 1, so I
117*a47a12beSStefan Roese 			 * decided this meant I had to disable the
118*a47a12beSStefan Roese 			 * dedicated function first, and enable it
119*a47a12beSStefan Roese 			 * last.
120*a47a12beSStefan Roese 			 */
121*a47a12beSStefan Roese 			iop->ppar &= tpmsk;
122*a47a12beSStefan Roese 			iop->psor = (iop->psor & tpmsk) | psor;
123*a47a12beSStefan Roese 			iop->podr = (iop->podr & tpmsk) | podr;
124*a47a12beSStefan Roese 			iop->pdat = (iop->pdat & tpmsk) | pdat;
125*a47a12beSStefan Roese 			iop->pdir = (iop->pdir & tpmsk) | pdir;
126*a47a12beSStefan Roese 			iop->ppar |= ppar;
127*a47a12beSStefan Roese 		}
128*a47a12beSStefan Roese 	}
129*a47a12beSStefan Roese }
130*a47a12beSStefan Roese #endif
131*a47a12beSStefan Roese 
132*a47a12beSStefan Roese /*
133*a47a12beSStefan Roese  * Breathe some life into the CPU...
134*a47a12beSStefan Roese  *
135*a47a12beSStefan Roese  * Set up the memory map
136*a47a12beSStefan Roese  * initialize a bunch of registers
137*a47a12beSStefan Roese  */
138*a47a12beSStefan Roese 
139*a47a12beSStefan Roese #ifdef CONFIG_FSL_CORENET
140*a47a12beSStefan Roese static void corenet_tb_init(void)
141*a47a12beSStefan Roese {
142*a47a12beSStefan Roese 	volatile ccsr_rcpm_t *rcpm =
143*a47a12beSStefan Roese 		(void *)(CONFIG_SYS_FSL_CORENET_RCPM_ADDR);
144*a47a12beSStefan Roese 	volatile ccsr_pic_t *pic =
145*a47a12beSStefan Roese 		(void *)(CONFIG_SYS_MPC85xx_PIC_ADDR);
146*a47a12beSStefan Roese 	u32 whoami = in_be32(&pic->whoami);
147*a47a12beSStefan Roese 
148*a47a12beSStefan Roese 	/* Enable the timebase register for this core */
149*a47a12beSStefan Roese 	out_be32(&rcpm->ctbenrl, (1 << whoami));
150*a47a12beSStefan Roese }
151*a47a12beSStefan Roese #endif
152*a47a12beSStefan Roese 
153*a47a12beSStefan Roese void cpu_init_f (void)
154*a47a12beSStefan Roese {
155*a47a12beSStefan Roese 	volatile ccsr_lbc_t *memctl = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR);
156*a47a12beSStefan Roese 	extern void m8560_cpm_reset (void);
157*a47a12beSStefan Roese #ifdef CONFIG_MPC8548
158*a47a12beSStefan Roese 	ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR);
159*a47a12beSStefan Roese 	uint svr = get_svr();
160*a47a12beSStefan Roese 
161*a47a12beSStefan Roese 	/*
162*a47a12beSStefan Roese 	 * CPU2 errata workaround: A core hang possible while executing
163*a47a12beSStefan Roese 	 * a msync instruction and a snoopable transaction from an I/O
164*a47a12beSStefan Roese 	 * master tagged to make quick forward progress is present.
165*a47a12beSStefan Roese 	 * Fixed in silicon rev 2.1.
166*a47a12beSStefan Roese 	 */
167*a47a12beSStefan Roese 	if ((SVR_MAJ(svr) == 1) || ((SVR_MAJ(svr) == 2 && SVR_MIN(svr) == 0x0)))
168*a47a12beSStefan Roese 		out_be32(&ecm->eebpcr, in_be32(&ecm->eebpcr) | (1 << 16));
169*a47a12beSStefan Roese #endif
170*a47a12beSStefan Roese 
171*a47a12beSStefan Roese 	disable_tlb(14);
172*a47a12beSStefan Roese 	disable_tlb(15);
173*a47a12beSStefan Roese 
174*a47a12beSStefan Roese #ifdef CONFIG_CPM2
175*a47a12beSStefan Roese 	config_8560_ioports((ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR);
176*a47a12beSStefan Roese #endif
177*a47a12beSStefan Roese 
178*a47a12beSStefan Roese 	/* Map banks 0 and 1 to the FLASH banks 0 and 1 at preliminary
179*a47a12beSStefan Roese 	 * addresses - these have to be modified later when FLASH size
180*a47a12beSStefan Roese 	 * has been determined
181*a47a12beSStefan Roese 	 */
182*a47a12beSStefan Roese #if defined(CONFIG_SYS_OR0_REMAP)
183*a47a12beSStefan Roese 	memctl->or0 = CONFIG_SYS_OR0_REMAP;
184*a47a12beSStefan Roese #endif
185*a47a12beSStefan Roese #if defined(CONFIG_SYS_OR1_REMAP)
186*a47a12beSStefan Roese 	memctl->or1 = CONFIG_SYS_OR1_REMAP;
187*a47a12beSStefan Roese #endif
188*a47a12beSStefan Roese 
189*a47a12beSStefan Roese 	/* now restrict to preliminary range */
190*a47a12beSStefan Roese 	/* if cs1 is already set via debugger, leave cs0/cs1 alone */
191*a47a12beSStefan Roese 	if (! memctl->br1 & 1) {
192*a47a12beSStefan Roese #if defined(CONFIG_SYS_BR0_PRELIM) && defined(CONFIG_SYS_OR0_PRELIM)
193*a47a12beSStefan Roese 		memctl->br0 = CONFIG_SYS_BR0_PRELIM;
194*a47a12beSStefan Roese 		memctl->or0 = CONFIG_SYS_OR0_PRELIM;
195*a47a12beSStefan Roese #endif
196*a47a12beSStefan Roese 
197*a47a12beSStefan Roese #if defined(CONFIG_SYS_BR1_PRELIM) && defined(CONFIG_SYS_OR1_PRELIM)
198*a47a12beSStefan Roese 		memctl->or1 = CONFIG_SYS_OR1_PRELIM;
199*a47a12beSStefan Roese 		memctl->br1 = CONFIG_SYS_BR1_PRELIM;
200*a47a12beSStefan Roese #endif
201*a47a12beSStefan Roese 	}
202*a47a12beSStefan Roese 
203*a47a12beSStefan Roese #if defined(CONFIG_SYS_BR2_PRELIM) && defined(CONFIG_SYS_OR2_PRELIM)
204*a47a12beSStefan Roese 	memctl->or2 = CONFIG_SYS_OR2_PRELIM;
205*a47a12beSStefan Roese 	memctl->br2 = CONFIG_SYS_BR2_PRELIM;
206*a47a12beSStefan Roese #endif
207*a47a12beSStefan Roese 
208*a47a12beSStefan Roese #if defined(CONFIG_SYS_BR3_PRELIM) && defined(CONFIG_SYS_OR3_PRELIM)
209*a47a12beSStefan Roese 	memctl->or3 = CONFIG_SYS_OR3_PRELIM;
210*a47a12beSStefan Roese 	memctl->br3 = CONFIG_SYS_BR3_PRELIM;
211*a47a12beSStefan Roese #endif
212*a47a12beSStefan Roese 
213*a47a12beSStefan Roese #if defined(CONFIG_SYS_BR4_PRELIM) && defined(CONFIG_SYS_OR4_PRELIM)
214*a47a12beSStefan Roese 	memctl->or4 = CONFIG_SYS_OR4_PRELIM;
215*a47a12beSStefan Roese 	memctl->br4 = CONFIG_SYS_BR4_PRELIM;
216*a47a12beSStefan Roese #endif
217*a47a12beSStefan Roese 
218*a47a12beSStefan Roese #if defined(CONFIG_SYS_BR5_PRELIM) && defined(CONFIG_SYS_OR5_PRELIM)
219*a47a12beSStefan Roese 	memctl->or5 = CONFIG_SYS_OR5_PRELIM;
220*a47a12beSStefan Roese 	memctl->br5 = CONFIG_SYS_BR5_PRELIM;
221*a47a12beSStefan Roese #endif
222*a47a12beSStefan Roese 
223*a47a12beSStefan Roese #if defined(CONFIG_SYS_BR6_PRELIM) && defined(CONFIG_SYS_OR6_PRELIM)
224*a47a12beSStefan Roese 	memctl->or6 = CONFIG_SYS_OR6_PRELIM;
225*a47a12beSStefan Roese 	memctl->br6 = CONFIG_SYS_BR6_PRELIM;
226*a47a12beSStefan Roese #endif
227*a47a12beSStefan Roese 
228*a47a12beSStefan Roese #if defined(CONFIG_SYS_BR7_PRELIM) && defined(CONFIG_SYS_OR7_PRELIM)
229*a47a12beSStefan Roese 	memctl->or7 = CONFIG_SYS_OR7_PRELIM;
230*a47a12beSStefan Roese 	memctl->br7 = CONFIG_SYS_BR7_PRELIM;
231*a47a12beSStefan Roese #endif
232*a47a12beSStefan Roese 
233*a47a12beSStefan Roese #if defined(CONFIG_CPM2)
234*a47a12beSStefan Roese 	m8560_cpm_reset();
235*a47a12beSStefan Roese #endif
236*a47a12beSStefan Roese #ifdef CONFIG_QE
237*a47a12beSStefan Roese 	/* Config QE ioports */
238*a47a12beSStefan Roese 	config_qe_ioports();
239*a47a12beSStefan Roese #endif
240*a47a12beSStefan Roese #if defined(CONFIG_MPC8536)
241*a47a12beSStefan Roese 	fsl_serdes_init();
242*a47a12beSStefan Roese #endif
243*a47a12beSStefan Roese #if defined(CONFIG_FSL_DMA)
244*a47a12beSStefan Roese 	dma_init();
245*a47a12beSStefan Roese #endif
246*a47a12beSStefan Roese #ifdef CONFIG_FSL_CORENET
247*a47a12beSStefan Roese 	corenet_tb_init();
248*a47a12beSStefan Roese #endif
249*a47a12beSStefan Roese 	init_used_tlb_cams();
250*a47a12beSStefan Roese }
251*a47a12beSStefan Roese 
252*a47a12beSStefan Roese 
253*a47a12beSStefan Roese /*
254*a47a12beSStefan Roese  * Initialize L2 as cache.
255*a47a12beSStefan Roese  *
256*a47a12beSStefan Roese  * The newer 8548, etc, parts have twice as much cache, but
257*a47a12beSStefan Roese  * use the same bit-encoding as the older 8555, etc, parts.
258*a47a12beSStefan Roese  *
259*a47a12beSStefan Roese  */
260*a47a12beSStefan Roese 
261*a47a12beSStefan Roese int cpu_init_r(void)
262*a47a12beSStefan Roese {
263*a47a12beSStefan Roese 	puts ("L2:    ");
264*a47a12beSStefan Roese 
265*a47a12beSStefan Roese #if defined(CONFIG_L2_CACHE)
266*a47a12beSStefan Roese 	volatile ccsr_l2cache_t *l2cache = (void *)CONFIG_SYS_MPC85xx_L2_ADDR;
267*a47a12beSStefan Roese 	volatile uint cache_ctl;
268*a47a12beSStefan Roese 	uint svr, ver;
269*a47a12beSStefan Roese 	uint l2srbar;
270*a47a12beSStefan Roese 	u32 l2siz_field;
271*a47a12beSStefan Roese 
272*a47a12beSStefan Roese 	svr = get_svr();
273*a47a12beSStefan Roese 	ver = SVR_SOC_VER(svr);
274*a47a12beSStefan Roese 
275*a47a12beSStefan Roese 	asm("msync;isync");
276*a47a12beSStefan Roese 	cache_ctl = l2cache->l2ctl;
277*a47a12beSStefan Roese 
278*a47a12beSStefan Roese #if defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_SYS_INIT_L2_ADDR)
279*a47a12beSStefan Roese 	if (cache_ctl & MPC85xx_L2CTL_L2E) {
280*a47a12beSStefan Roese 		/* Clear L2 SRAM memory-mapped base address */
281*a47a12beSStefan Roese 		out_be32(&l2cache->l2srbar0, 0x0);
282*a47a12beSStefan Roese 		out_be32(&l2cache->l2srbar1, 0x0);
283*a47a12beSStefan Roese 
284*a47a12beSStefan Roese 		/* set MBECCDIS=0, SBECCDIS=0 */
285*a47a12beSStefan Roese 		clrbits_be32(&l2cache->l2errdis,
286*a47a12beSStefan Roese 				(MPC85xx_L2ERRDIS_MBECC |
287*a47a12beSStefan Roese 				 MPC85xx_L2ERRDIS_SBECC));
288*a47a12beSStefan Roese 
289*a47a12beSStefan Roese 		/* set L2E=0, L2SRAM=0 */
290*a47a12beSStefan Roese 		clrbits_be32(&l2cache->l2ctl,
291*a47a12beSStefan Roese 				(MPC85xx_L2CTL_L2E |
292*a47a12beSStefan Roese 				 MPC85xx_L2CTL_L2SRAM_ENTIRE));
293*a47a12beSStefan Roese 	}
294*a47a12beSStefan Roese #endif
295*a47a12beSStefan Roese 
296*a47a12beSStefan Roese 	l2siz_field = (cache_ctl >> 28) & 0x3;
297*a47a12beSStefan Roese 
298*a47a12beSStefan Roese 	switch (l2siz_field) {
299*a47a12beSStefan Roese 	case 0x0:
300*a47a12beSStefan Roese 		printf(" unknown size (0x%08x)\n", cache_ctl);
301*a47a12beSStefan Roese 		return -1;
302*a47a12beSStefan Roese 		break;
303*a47a12beSStefan Roese 	case 0x1:
304*a47a12beSStefan Roese 		if (ver == SVR_8540 || ver == SVR_8560   ||
305*a47a12beSStefan Roese 		    ver == SVR_8541 || ver == SVR_8541_E ||
306*a47a12beSStefan Roese 		    ver == SVR_8555 || ver == SVR_8555_E) {
307*a47a12beSStefan Roese 			puts("128 KB ");
308*a47a12beSStefan Roese 			/* set L2E=1, L2I=1, & L2BLKSZ=1 (128 Kbyte) */
309*a47a12beSStefan Roese 			cache_ctl = 0xc4000000;
310*a47a12beSStefan Roese 		} else {
311*a47a12beSStefan Roese 			puts("256 KB ");
312*a47a12beSStefan Roese 			cache_ctl = 0xc0000000; /* set L2E=1, L2I=1, & L2SRAM=0 */
313*a47a12beSStefan Roese 		}
314*a47a12beSStefan Roese 		break;
315*a47a12beSStefan Roese 	case 0x2:
316*a47a12beSStefan Roese 		if (ver == SVR_8540 || ver == SVR_8560   ||
317*a47a12beSStefan Roese 		    ver == SVR_8541 || ver == SVR_8541_E ||
318*a47a12beSStefan Roese 		    ver == SVR_8555 || ver == SVR_8555_E) {
319*a47a12beSStefan Roese 			puts("256 KB ");
320*a47a12beSStefan Roese 			/* set L2E=1, L2I=1, & L2BLKSZ=2 (256 Kbyte) */
321*a47a12beSStefan Roese 			cache_ctl = 0xc8000000;
322*a47a12beSStefan Roese 		} else {
323*a47a12beSStefan Roese 			puts ("512 KB ");
324*a47a12beSStefan Roese 			/* set L2E=1, L2I=1, & L2SRAM=0 */
325*a47a12beSStefan Roese 			cache_ctl = 0xc0000000;
326*a47a12beSStefan Roese 		}
327*a47a12beSStefan Roese 		break;
328*a47a12beSStefan Roese 	case 0x3:
329*a47a12beSStefan Roese 		puts("1024 KB ");
330*a47a12beSStefan Roese 		/* set L2E=1, L2I=1, & L2SRAM=0 */
331*a47a12beSStefan Roese 		cache_ctl = 0xc0000000;
332*a47a12beSStefan Roese 		break;
333*a47a12beSStefan Roese 	}
334*a47a12beSStefan Roese 
335*a47a12beSStefan Roese 	if (l2cache->l2ctl & MPC85xx_L2CTL_L2E) {
336*a47a12beSStefan Roese 		puts("already enabled");
337*a47a12beSStefan Roese 		l2srbar = l2cache->l2srbar0;
338*a47a12beSStefan Roese #ifdef CONFIG_SYS_INIT_L2_ADDR
339*a47a12beSStefan Roese 		if (l2cache->l2ctl & MPC85xx_L2CTL_L2SRAM_ENTIRE
340*a47a12beSStefan Roese 				&& l2srbar >= CONFIG_SYS_FLASH_BASE) {
341*a47a12beSStefan Roese 			l2srbar = CONFIG_SYS_INIT_L2_ADDR;
342*a47a12beSStefan Roese 			l2cache->l2srbar0 = l2srbar;
343*a47a12beSStefan Roese 			printf("moving to 0x%08x", CONFIG_SYS_INIT_L2_ADDR);
344*a47a12beSStefan Roese 		}
345*a47a12beSStefan Roese #endif /* CONFIG_SYS_INIT_L2_ADDR */
346*a47a12beSStefan Roese 		puts("\n");
347*a47a12beSStefan Roese 	} else {
348*a47a12beSStefan Roese 		asm("msync;isync");
349*a47a12beSStefan Roese 		l2cache->l2ctl = cache_ctl; /* invalidate & enable */
350*a47a12beSStefan Roese 		asm("msync;isync");
351*a47a12beSStefan Roese 		puts("enabled\n");
352*a47a12beSStefan Roese 	}
353*a47a12beSStefan Roese #elif defined(CONFIG_BACKSIDE_L2_CACHE)
354*a47a12beSStefan Roese 	u32 l2cfg0 = mfspr(SPRN_L2CFG0);
355*a47a12beSStefan Roese 
356*a47a12beSStefan Roese 	/* invalidate the L2 cache */
357*a47a12beSStefan Roese 	mtspr(SPRN_L2CSR0, (L2CSR0_L2FI|L2CSR0_L2LFC));
358*a47a12beSStefan Roese 	while (mfspr(SPRN_L2CSR0) & (L2CSR0_L2FI|L2CSR0_L2LFC))
359*a47a12beSStefan Roese 		;
360*a47a12beSStefan Roese 
361*a47a12beSStefan Roese #ifdef CONFIG_SYS_CACHE_STASHING
362*a47a12beSStefan Roese 	/* set stash id to (coreID) * 2 + 32 + L2 (1) */
363*a47a12beSStefan Roese 	mtspr(SPRN_L2CSR1, (32 + 1));
364*a47a12beSStefan Roese #endif
365*a47a12beSStefan Roese 
366*a47a12beSStefan Roese 	/* enable the cache */
367*a47a12beSStefan Roese 	mtspr(SPRN_L2CSR0, CONFIG_SYS_INIT_L2CSR0);
368*a47a12beSStefan Roese 
369*a47a12beSStefan Roese 	if (CONFIG_SYS_INIT_L2CSR0 & L2CSR0_L2E) {
370*a47a12beSStefan Roese 		while (!(mfspr(SPRN_L2CSR0) & L2CSR0_L2E))
371*a47a12beSStefan Roese 			;
372*a47a12beSStefan Roese 		printf("%d KB enabled\n", (l2cfg0 & 0x3fff) * 64);
373*a47a12beSStefan Roese 	}
374*a47a12beSStefan Roese #else
375*a47a12beSStefan Roese 	puts("disabled\n");
376*a47a12beSStefan Roese #endif
377*a47a12beSStefan Roese #ifdef CONFIG_QE
378*a47a12beSStefan Roese 	uint qe_base = CONFIG_SYS_IMMR + 0x00080000; /* QE immr base */
379*a47a12beSStefan Roese 	qe_init(qe_base);
380*a47a12beSStefan Roese 	qe_reset();
381*a47a12beSStefan Roese #endif
382*a47a12beSStefan Roese 
383*a47a12beSStefan Roese #if defined(CONFIG_MP)
384*a47a12beSStefan Roese 	setup_mp();
385*a47a12beSStefan Roese #endif
386*a47a12beSStefan Roese 	return 0;
387*a47a12beSStefan Roese }
388*a47a12beSStefan Roese 
389*a47a12beSStefan Roese extern void setup_ivors(void);
390*a47a12beSStefan Roese 
391*a47a12beSStefan Roese void arch_preboot_os(void)
392*a47a12beSStefan Roese {
393*a47a12beSStefan Roese 	u32 msr;
394*a47a12beSStefan Roese 
395*a47a12beSStefan Roese 	/*
396*a47a12beSStefan Roese 	 * We are changing interrupt offsets and are about to boot the OS so
397*a47a12beSStefan Roese 	 * we need to make sure we disable all async interrupts. EE is already
398*a47a12beSStefan Roese 	 * disabled by the time we get called.
399*a47a12beSStefan Roese 	 */
400*a47a12beSStefan Roese 	msr = mfmsr();
401*a47a12beSStefan Roese 	msr &= ~(MSR_ME|MSR_CE|MSR_DE);
402*a47a12beSStefan Roese 	mtmsr(msr);
403*a47a12beSStefan Roese 
404*a47a12beSStefan Roese 	setup_ivors();
405*a47a12beSStefan Roese }
406