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