xref: /rk3399_rockchip-uboot/arch/powerpc/cpu/mpc85xx/cpu_init.c (revision 7cad2e38d61e27ea59fb7944f7e647e97ef292d3)
1a47a12beSStefan Roese /*
2a09b9b68SKumar Gala  * Copyright 2007-2011 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  *
101a459660SWolfgang Denk  * SPDX-License-Identifier:	GPL-2.0+
11a47a12beSStefan Roese  */
12a47a12beSStefan Roese 
13a47a12beSStefan Roese #include <common.h>
14a47a12beSStefan Roese #include <watchdog.h>
15a47a12beSStefan Roese #include <asm/processor.h>
16a47a12beSStefan Roese #include <ioports.h>
17f54fe87aSKumar Gala #include <sata.h>
18c916d7c9SKumar Gala #include <fm_eth.h>
19a47a12beSStefan Roese #include <asm/io.h>
20fd3c9befSKumar Gala #include <asm/cache.h>
21a47a12beSStefan Roese #include <asm/mmu.h>
22133fbfa9SYork Sun #include <asm/fsl_errata.h>
23a47a12beSStefan Roese #include <asm/fsl_law.h>
24f54fe87aSKumar Gala #include <asm/fsl_serdes.h>
255ffa88ecSLiu Gang #include <asm/fsl_srio.h>
269dee205dSramneek mehresh #include <fsl_usb.h>
2757125f22SYork Sun #include <hwconfig.h>
28fbc20aabSTimur Tabi #include <linux/compiler.h>
29a47a12beSStefan Roese #include "mp.h"
30b9eebfadSRuchika Gupta #ifdef CONFIG_FSL_CAAM
31b9eebfadSRuchika Gupta #include <fsl_sec.h>
32b9eebfadSRuchika Gupta #endif
33f2717b47STimur Tabi #ifdef CONFIG_SYS_QE_FMAN_FW_IN_NAND
34a7b1e1b7SHaiying Wang #include <nand.h>
35a7b1e1b7SHaiying Wang #include <errno.h>
36a7b1e1b7SHaiying Wang #endif
37a47a12beSStefan Roese 
38fbc20aabSTimur Tabi #include "../../../../drivers/block/fsl_sata.h"
392a44efebSZhao Qiang #ifdef CONFIG_U_QE
402a44efebSZhao Qiang #include "../../../../drivers/qe/qe.h"
412a44efebSZhao Qiang #endif
42fbc20aabSTimur Tabi 
43a47a12beSStefan Roese DECLARE_GLOBAL_DATA_PTR;
44a47a12beSStefan Roese 
45d1c561cdSNikhil Badola #ifdef CONFIG_SYS_FSL_SINGLE_SOURCE_CLK
46d1c561cdSNikhil Badola /*
47d1c561cdSNikhil Badola  * For deriving usb clock from 100MHz sysclk, reference divisor is set
48d1c561cdSNikhil Badola  * to a value of 5, which gives an intermediate value 20(100/5). The
49d1c561cdSNikhil Badola  * multiplication factor integer is set to 24, which when multiplied to
50d1c561cdSNikhil Badola  * above intermediate value provides clock for usb ip.
51d1c561cdSNikhil Badola  */
52d1c561cdSNikhil Badola void usb_single_source_clk_configure(struct ccsr_usb_phy *usb_phy)
53d1c561cdSNikhil Badola {
54d1c561cdSNikhil Badola 	sys_info_t sysinfo;
55d1c561cdSNikhil Badola 
56d1c561cdSNikhil Badola 	get_sys_info(&sysinfo);
57d1c561cdSNikhil Badola 	if (sysinfo.diff_sysclk == 1) {
58d1c561cdSNikhil Badola 		clrbits_be32(&usb_phy->pllprg[1],
59d1c561cdSNikhil Badola 			     CONFIG_SYS_FSL_USB_PLLPRG2_MFI);
60d1c561cdSNikhil Badola 		setbits_be32(&usb_phy->pllprg[1],
61d1c561cdSNikhil Badola 			     CONFIG_SYS_FSL_USB_PLLPRG2_REF_DIV_INTERNAL_CLK |
62d1c561cdSNikhil Badola 			     CONFIG_SYS_FSL_USB_PLLPRG2_MFI_INTERNAL_CLK |
63d1c561cdSNikhil Badola 			     CONFIG_SYS_FSL_USB_INTERNAL_SOC_CLK_EN);
64d1c561cdSNikhil Badola 		}
65d1c561cdSNikhil Badola }
66d1c561cdSNikhil Badola #endif
67d1c561cdSNikhil Badola 
689c641a87SSuresh Gupta #ifdef CONFIG_SYS_FSL_ERRATUM_A006261
699c641a87SSuresh Gupta void fsl_erratum_a006261_workaround(struct ccsr_usb_phy __iomem *usb_phy)
709c641a87SSuresh Gupta {
719c641a87SSuresh Gupta #ifdef CONFIG_SYS_FSL_USB_DUAL_PHY_ENABLE
729c641a87SSuresh Gupta 	u32 xcvrprg = in_be32(&usb_phy->port1.xcvrprg);
739c641a87SSuresh Gupta 
749c641a87SSuresh Gupta 	/* Increase Disconnect Threshold by 50mV */
759c641a87SSuresh Gupta 	xcvrprg &= ~CONFIG_SYS_FSL_USB_XCVRPRG_HS_DCNT_PROG_MASK |
769c641a87SSuresh Gupta 						INC_DCNT_THRESHOLD_50MV;
779c641a87SSuresh Gupta 	/* Enable programming of USB High speed Disconnect threshold */
789c641a87SSuresh Gupta 	xcvrprg |= CONFIG_SYS_FSL_USB_XCVRPRG_HS_DCNT_PROG_EN;
799c641a87SSuresh Gupta 	out_be32(&usb_phy->port1.xcvrprg, xcvrprg);
809c641a87SSuresh Gupta 
819c641a87SSuresh Gupta 	xcvrprg = in_be32(&usb_phy->port2.xcvrprg);
829c641a87SSuresh Gupta 	/* Increase Disconnect Threshold by 50mV */
839c641a87SSuresh Gupta 	xcvrprg &= ~CONFIG_SYS_FSL_USB_XCVRPRG_HS_DCNT_PROG_MASK |
849c641a87SSuresh Gupta 						INC_DCNT_THRESHOLD_50MV;
859c641a87SSuresh Gupta 	/* Enable programming of USB High speed Disconnect threshold */
869c641a87SSuresh Gupta 	xcvrprg |= CONFIG_SYS_FSL_USB_XCVRPRG_HS_DCNT_PROG_EN;
879c641a87SSuresh Gupta 	out_be32(&usb_phy->port2.xcvrprg, xcvrprg);
889c641a87SSuresh Gupta #else
899c641a87SSuresh Gupta 
909c641a87SSuresh Gupta 	u32 temp = 0;
919c641a87SSuresh Gupta 	u32 status = in_be32(&usb_phy->status1);
929c641a87SSuresh Gupta 
939c641a87SSuresh Gupta 	u32 squelch_prog_rd_0_2 =
949c641a87SSuresh Gupta 		(status >> CONFIG_SYS_FSL_USB_SQUELCH_PROG_RD_0)
959c641a87SSuresh Gupta 			& CONFIG_SYS_FSL_USB_SQUELCH_PROG_MASK;
969c641a87SSuresh Gupta 
979c641a87SSuresh Gupta 	u32 squelch_prog_rd_3_5 =
989c641a87SSuresh Gupta 		(status >> CONFIG_SYS_FSL_USB_SQUELCH_PROG_RD_3)
999c641a87SSuresh Gupta 			& CONFIG_SYS_FSL_USB_SQUELCH_PROG_MASK;
1009c641a87SSuresh Gupta 
1019c641a87SSuresh Gupta 	setbits_be32(&usb_phy->config1,
1029c641a87SSuresh Gupta 		     CONFIG_SYS_FSL_USB_HS_DISCNCT_INC);
1039c641a87SSuresh Gupta 	setbits_be32(&usb_phy->config2,
1049c641a87SSuresh Gupta 		     CONFIG_SYS_FSL_USB_RX_AUTO_CAL_RD_WR_SEL);
1059c641a87SSuresh Gupta 
1069c641a87SSuresh Gupta 	temp = squelch_prog_rd_0_2 << CONFIG_SYS_FSL_USB_SQUELCH_PROG_WR_0;
1079c641a87SSuresh Gupta 	out_be32(&usb_phy->config2, in_be32(&usb_phy->config2) | temp);
1089c641a87SSuresh Gupta 
1099c641a87SSuresh Gupta 	temp = squelch_prog_rd_3_5 << CONFIG_SYS_FSL_USB_SQUELCH_PROG_WR_3;
1109c641a87SSuresh Gupta 	out_be32(&usb_phy->config2, in_be32(&usb_phy->config2) | temp);
1119c641a87SSuresh Gupta #endif
1129c641a87SSuresh Gupta }
1139c641a87SSuresh Gupta #endif
1149c641a87SSuresh Gupta 
1159c641a87SSuresh Gupta 
1162a44efebSZhao Qiang #if defined(CONFIG_QE) && !defined(CONFIG_U_QE)
117a47a12beSStefan Roese extern qe_iop_conf_t qe_iop_conf_tab[];
118a47a12beSStefan Roese extern void qe_config_iopin(u8 port, u8 pin, int dir,
119a47a12beSStefan Roese 				int open_drain, int assign);
120a47a12beSStefan Roese extern void qe_init(uint qe_base);
121a47a12beSStefan Roese extern void qe_reset(void);
122a47a12beSStefan Roese 
123a47a12beSStefan Roese static void config_qe_ioports(void)
124a47a12beSStefan Roese {
125a47a12beSStefan Roese 	u8      port, pin;
126a47a12beSStefan Roese 	int     dir, open_drain, assign;
127a47a12beSStefan Roese 	int     i;
128a47a12beSStefan Roese 
129a47a12beSStefan Roese 	for (i = 0; qe_iop_conf_tab[i].assign != QE_IOP_TAB_END; i++) {
130a47a12beSStefan Roese 		port		= qe_iop_conf_tab[i].port;
131a47a12beSStefan Roese 		pin		= qe_iop_conf_tab[i].pin;
132a47a12beSStefan Roese 		dir		= qe_iop_conf_tab[i].dir;
133a47a12beSStefan Roese 		open_drain	= qe_iop_conf_tab[i].open_drain;
134a47a12beSStefan Roese 		assign		= qe_iop_conf_tab[i].assign;
135a47a12beSStefan Roese 		qe_config_iopin(port, pin, dir, open_drain, assign);
136a47a12beSStefan Roese 	}
137a47a12beSStefan Roese }
138a47a12beSStefan Roese #endif
139a47a12beSStefan Roese 
140a47a12beSStefan Roese #ifdef CONFIG_CPM2
141a47a12beSStefan Roese void config_8560_ioports (volatile ccsr_cpm_t * cpm)
142a47a12beSStefan Roese {
143a47a12beSStefan Roese 	int portnum;
144a47a12beSStefan Roese 
145a47a12beSStefan Roese 	for (portnum = 0; portnum < 4; portnum++) {
146a47a12beSStefan Roese 		uint pmsk = 0,
147a47a12beSStefan Roese 		     ppar = 0,
148a47a12beSStefan Roese 		     psor = 0,
149a47a12beSStefan Roese 		     pdir = 0,
150a47a12beSStefan Roese 		     podr = 0,
151a47a12beSStefan Roese 		     pdat = 0;
152a47a12beSStefan Roese 		iop_conf_t *iopc = (iop_conf_t *) & iop_conf_tab[portnum][0];
153a47a12beSStefan Roese 		iop_conf_t *eiopc = iopc + 32;
154a47a12beSStefan Roese 		uint msk = 1;
155a47a12beSStefan Roese 
156a47a12beSStefan Roese 		/*
157a47a12beSStefan Roese 		 * NOTE:
158a47a12beSStefan Roese 		 * index 0 refers to pin 31,
159a47a12beSStefan Roese 		 * index 31 refers to pin 0
160a47a12beSStefan Roese 		 */
161a47a12beSStefan Roese 		while (iopc < eiopc) {
162a47a12beSStefan Roese 			if (iopc->conf) {
163a47a12beSStefan Roese 				pmsk |= msk;
164a47a12beSStefan Roese 				if (iopc->ppar)
165a47a12beSStefan Roese 					ppar |= msk;
166a47a12beSStefan Roese 				if (iopc->psor)
167a47a12beSStefan Roese 					psor |= msk;
168a47a12beSStefan Roese 				if (iopc->pdir)
169a47a12beSStefan Roese 					pdir |= msk;
170a47a12beSStefan Roese 				if (iopc->podr)
171a47a12beSStefan Roese 					podr |= msk;
172a47a12beSStefan Roese 				if (iopc->pdat)
173a47a12beSStefan Roese 					pdat |= msk;
174a47a12beSStefan Roese 			}
175a47a12beSStefan Roese 
176a47a12beSStefan Roese 			msk <<= 1;
177a47a12beSStefan Roese 			iopc++;
178a47a12beSStefan Roese 		}
179a47a12beSStefan Roese 
180a47a12beSStefan Roese 		if (pmsk != 0) {
181a47a12beSStefan Roese 			volatile ioport_t *iop = ioport_addr (cpm, portnum);
182a47a12beSStefan Roese 			uint tpmsk = ~pmsk;
183a47a12beSStefan Roese 
184a47a12beSStefan Roese 			/*
185a47a12beSStefan Roese 			 * the (somewhat confused) paragraph at the
186a47a12beSStefan Roese 			 * bottom of page 35-5 warns that there might
187a47a12beSStefan Roese 			 * be "unknown behaviour" when programming
188a47a12beSStefan Roese 			 * PSORx and PDIRx, if PPARx = 1, so I
189a47a12beSStefan Roese 			 * decided this meant I had to disable the
190a47a12beSStefan Roese 			 * dedicated function first, and enable it
191a47a12beSStefan Roese 			 * last.
192a47a12beSStefan Roese 			 */
193a47a12beSStefan Roese 			iop->ppar &= tpmsk;
194a47a12beSStefan Roese 			iop->psor = (iop->psor & tpmsk) | psor;
195a47a12beSStefan Roese 			iop->podr = (iop->podr & tpmsk) | podr;
196a47a12beSStefan Roese 			iop->pdat = (iop->pdat & tpmsk) | pdat;
197a47a12beSStefan Roese 			iop->pdir = (iop->pdir & tpmsk) | pdir;
198a47a12beSStefan Roese 			iop->ppar |= ppar;
199a47a12beSStefan Roese 		}
200a47a12beSStefan Roese 	}
201a47a12beSStefan Roese }
202a47a12beSStefan Roese #endif
203a47a12beSStefan Roese 
2046aba33e9SKumar Gala #ifdef CONFIG_SYS_FSL_CPC
205fb4a2409SAneesh Bansal #if defined(CONFIG_RAMBOOT_PBL) || defined(CONFIG_SYS_CPC_REINIT_F)
2067cb72723STang Yuantian void disable_cpc_sram(void)
2076aba33e9SKumar Gala {
2086aba33e9SKumar Gala 	int i;
2096aba33e9SKumar Gala 
2106aba33e9SKumar Gala 	cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR;
2116aba33e9SKumar Gala 
2126aba33e9SKumar Gala 	for (i = 0; i < CONFIG_SYS_NUM_CPC; i++, cpc++) {
2132a9fab82SShaohui Xie 		if (in_be32(&cpc->cpcsrcr0) & CPC_SRCR0_SRAMEN) {
2142a9fab82SShaohui Xie 			/* find and disable LAW of SRAM */
2152a9fab82SShaohui Xie 			struct law_entry law = find_law(CONFIG_SYS_INIT_L3_ADDR);
2162a9fab82SShaohui Xie 
2172a9fab82SShaohui Xie 			if (law.index == -1) {
2182a9fab82SShaohui Xie 				printf("\nFatal error happened\n");
2192a9fab82SShaohui Xie 				return;
2202a9fab82SShaohui Xie 			}
2212a9fab82SShaohui Xie 			disable_law(law.index);
2222a9fab82SShaohui Xie 
2232a9fab82SShaohui Xie 			clrbits_be32(&cpc->cpchdbcr0, CPC_HDBCR0_CDQ_SPEC_DIS);
2242a9fab82SShaohui Xie 			out_be32(&cpc->cpccsr0, 0);
2252a9fab82SShaohui Xie 			out_be32(&cpc->cpcsrcr0, 0);
2262a9fab82SShaohui Xie 		}
227fb4a2409SAneesh Bansal 	}
228fb4a2409SAneesh Bansal }
2292a9fab82SShaohui Xie #endif
2306aba33e9SKumar Gala 
231377ffcfaSSandeep Singh #if defined(T1040_TDM_QUIRK_CCSR_BASE)
232377ffcfaSSandeep Singh #ifdef CONFIG_POST
233377ffcfaSSandeep Singh #error POST memory test cannot be enabled with TDM
234377ffcfaSSandeep Singh #endif
235377ffcfaSSandeep Singh static void enable_tdm_law(void)
236377ffcfaSSandeep Singh {
237377ffcfaSSandeep Singh 	int ret;
238377ffcfaSSandeep Singh 	char buffer[HWCONFIG_BUFFER_SIZE] = {0};
239377ffcfaSSandeep Singh 	int tdm_hwconfig_enabled = 0;
240377ffcfaSSandeep Singh 
241377ffcfaSSandeep Singh 	/*
242377ffcfaSSandeep Singh 	 * Extract hwconfig from environment since environment
243377ffcfaSSandeep Singh 	 * is not setup properly yet. Search for tdm entry in
244377ffcfaSSandeep Singh 	 * hwconfig.
245377ffcfaSSandeep Singh 	 */
246377ffcfaSSandeep Singh 	ret = getenv_f("hwconfig", buffer, sizeof(buffer));
247377ffcfaSSandeep Singh 	if (ret > 0) {
248377ffcfaSSandeep Singh 		tdm_hwconfig_enabled = hwconfig_f("tdm", buffer);
249377ffcfaSSandeep Singh 		/* If tdm is defined in hwconfig, set law for tdm workaround */
250377ffcfaSSandeep Singh 		if (tdm_hwconfig_enabled)
251377ffcfaSSandeep Singh 			set_next_law(T1040_TDM_QUIRK_CCSR_BASE, LAW_SIZE_16M,
252377ffcfaSSandeep Singh 				     LAW_TRGT_IF_CCSR);
253377ffcfaSSandeep Singh 	}
254377ffcfaSSandeep Singh }
255377ffcfaSSandeep Singh #endif
256377ffcfaSSandeep Singh 
2577cb72723STang Yuantian void enable_cpc(void)
258fb4a2409SAneesh Bansal {
259fb4a2409SAneesh Bansal 	int i;
260390619ddSShaveta Leekha 	int ret;
261fb4a2409SAneesh Bansal 	u32 size = 0;
262390619ddSShaveta Leekha 	u32 cpccfg0;
263390619ddSShaveta Leekha 	char buffer[HWCONFIG_BUFFER_SIZE];
264390619ddSShaveta Leekha 	char cpc_subarg[16];
265390619ddSShaveta Leekha 	bool have_hwconfig = false;
266390619ddSShaveta Leekha 	int cpc_args = 0;
267fb4a2409SAneesh Bansal 	cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR;
268fb4a2409SAneesh Bansal 
269390619ddSShaveta Leekha 	/* Extract hwconfig from environment */
270390619ddSShaveta Leekha 	ret = getenv_f("hwconfig", buffer, sizeof(buffer));
271390619ddSShaveta Leekha 	if (ret > 0) {
272390619ddSShaveta Leekha 		/*
273390619ddSShaveta Leekha 		 * If "en_cpc" is not defined in hwconfig then by default all
274390619ddSShaveta Leekha 		 * cpcs are enable. If this config is defined then individual
275390619ddSShaveta Leekha 		 * cpcs which have to be enabled should also be defined.
276390619ddSShaveta Leekha 		 * e.g en_cpc:cpc1,cpc2;
277390619ddSShaveta Leekha 		 */
278390619ddSShaveta Leekha 		if (hwconfig_f("en_cpc", buffer))
279390619ddSShaveta Leekha 			have_hwconfig = true;
280390619ddSShaveta Leekha 	}
281390619ddSShaveta Leekha 
282fb4a2409SAneesh Bansal 	for (i = 0; i < CONFIG_SYS_NUM_CPC; i++, cpc++) {
283390619ddSShaveta Leekha 		if (have_hwconfig) {
284390619ddSShaveta Leekha 			sprintf(cpc_subarg, "cpc%u", i + 1);
285390619ddSShaveta Leekha 			cpc_args = hwconfig_sub_f("en_cpc", cpc_subarg, buffer);
286390619ddSShaveta Leekha 			if (cpc_args == 0)
287390619ddSShaveta Leekha 				continue;
288390619ddSShaveta Leekha 		}
289390619ddSShaveta Leekha 		cpccfg0 = in_be32(&cpc->cpccfg0);
290fb4a2409SAneesh Bansal 		size += CPC_CFG0_SZ_K(cpccfg0);
291fb4a2409SAneesh Bansal 
2921d2c2a62SKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A002
2931d2c2a62SKumar Gala 		setbits_be32(&cpc->cpchdbcr0, CPC_HDBCR0_TAG_ECC_SCRUB_DIS);
2941d2c2a62SKumar Gala #endif
295868da593SKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A003
296868da593SKumar Gala 		setbits_be32(&cpc->cpchdbcr0, CPC_HDBCR0_DATA_ECC_SCRUB_DIS);
297868da593SKumar Gala #endif
29882125192SScott Wood #ifdef CONFIG_SYS_FSL_ERRATUM_A006593
29982125192SScott Wood 		setbits_be32(&cpc->cpchdbcr0, 1 << (31 - 21));
30082125192SScott Wood #endif
301133fbfa9SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_A006379
302133fbfa9SYork Sun 		if (has_erratum_a006379()) {
303133fbfa9SYork Sun 			setbits_be32(&cpc->cpchdbcr0,
304133fbfa9SYork Sun 				     CPC_HDBCR0_SPLRU_LEVEL_EN);
305133fbfa9SYork Sun 		}
306133fbfa9SYork Sun #endif
3071d2c2a62SKumar Gala 
3086aba33e9SKumar Gala 		out_be32(&cpc->cpccsr0, CPC_CSR0_CE | CPC_CSR0_PE);
3096aba33e9SKumar Gala 		/* Read back to sync write */
3106aba33e9SKumar Gala 		in_be32(&cpc->cpccsr0);
3116aba33e9SKumar Gala 
3126aba33e9SKumar Gala 	}
3136aba33e9SKumar Gala 
3142f848f97SShruti Kanetkar 	puts("Corenet Platform Cache: ");
3152f848f97SShruti Kanetkar 	print_size(size * 1024, " enabled\n");
3166aba33e9SKumar Gala }
3176aba33e9SKumar Gala 
318e56143e5SKim Phillips static void invalidate_cpc(void)
3196aba33e9SKumar Gala {
3206aba33e9SKumar Gala 	int i;
3216aba33e9SKumar Gala 	cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR;
3226aba33e9SKumar Gala 
3236aba33e9SKumar Gala 	for (i = 0; i < CONFIG_SYS_NUM_CPC; i++, cpc++) {
3242a9fab82SShaohui Xie 		/* skip CPC when it used as all SRAM */
3252a9fab82SShaohui Xie 		if (in_be32(&cpc->cpcsrcr0) & CPC_SRCR0_SRAMEN)
3262a9fab82SShaohui Xie 			continue;
3276aba33e9SKumar Gala 		/* Flash invalidate the CPC and clear all the locks */
3286aba33e9SKumar Gala 		out_be32(&cpc->cpccsr0, CPC_CSR0_FI | CPC_CSR0_LFC);
3296aba33e9SKumar Gala 		while (in_be32(&cpc->cpccsr0) & (CPC_CSR0_FI | CPC_CSR0_LFC))
3306aba33e9SKumar Gala 			;
3316aba33e9SKumar Gala 	}
3326aba33e9SKumar Gala }
3336aba33e9SKumar Gala #else
3346aba33e9SKumar Gala #define enable_cpc()
3356aba33e9SKumar Gala #define invalidate_cpc()
3367cb72723STang Yuantian #define disable_cpc_sram()
3376aba33e9SKumar Gala #endif /* CONFIG_SYS_FSL_CPC */
3386aba33e9SKumar Gala 
339a47a12beSStefan Roese /*
340a47a12beSStefan Roese  * Breathe some life into the CPU...
341a47a12beSStefan Roese  *
342a47a12beSStefan Roese  * Set up the memory map
343a47a12beSStefan Roese  * initialize a bunch of registers
344a47a12beSStefan Roese  */
345a47a12beSStefan Roese 
346a47a12beSStefan Roese #ifdef CONFIG_FSL_CORENET
347a47a12beSStefan Roese static void corenet_tb_init(void)
348a47a12beSStefan Roese {
349a47a12beSStefan Roese 	volatile ccsr_rcpm_t *rcpm =
350a47a12beSStefan Roese 		(void *)(CONFIG_SYS_FSL_CORENET_RCPM_ADDR);
351a47a12beSStefan Roese 	volatile ccsr_pic_t *pic =
352680c613aSKim Phillips 		(void *)(CONFIG_SYS_MPC8xxx_PIC_ADDR);
353a47a12beSStefan Roese 	u32 whoami = in_be32(&pic->whoami);
354a47a12beSStefan Roese 
355a47a12beSStefan Roese 	/* Enable the timebase register for this core */
356a47a12beSStefan Roese 	out_be32(&rcpm->ctbenrl, (1 << whoami));
357a47a12beSStefan Roese }
358a47a12beSStefan Roese #endif
359a47a12beSStefan Roese 
360c3678b09SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_A007212
361c3678b09SYork Sun void fsl_erratum_a007212_workaround(void)
362c3678b09SYork Sun {
363c3678b09SYork Sun 	ccsr_gur_t __iomem *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
364c3678b09SYork Sun 	u32 ddr_pll_ratio;
365c3678b09SYork Sun 	u32 __iomem *plldgdcr1 = (void *)(CONFIG_SYS_DCSRBAR + 0x21c20);
366c3678b09SYork Sun 	u32 __iomem *plldadcr1 = (void *)(CONFIG_SYS_DCSRBAR + 0x21c28);
367c3678b09SYork Sun 	u32 __iomem *dpdovrcr4 = (void *)(CONFIG_SYS_DCSRBAR + 0x21e80);
368c3678b09SYork Sun #if (CONFIG_NUM_DDR_CONTROLLERS >= 2)
369c3678b09SYork Sun 	u32 __iomem *plldgdcr2 = (void *)(CONFIG_SYS_DCSRBAR + 0x21c40);
370c3678b09SYork Sun 	u32 __iomem *plldadcr2 = (void *)(CONFIG_SYS_DCSRBAR + 0x21c48);
371c3678b09SYork Sun #if (CONFIG_NUM_DDR_CONTROLLERS >= 3)
372c3678b09SYork Sun 	u32 __iomem *plldgdcr3 = (void *)(CONFIG_SYS_DCSRBAR + 0x21c60);
373c3678b09SYork Sun 	u32 __iomem *plldadcr3 = (void *)(CONFIG_SYS_DCSRBAR + 0x21c68);
374c3678b09SYork Sun #endif
375c3678b09SYork Sun #endif
376c3678b09SYork Sun 	/*
377c3678b09SYork Sun 	 * Even this workaround applies to selected version of SoCs, it is
378c3678b09SYork Sun 	 * safe to apply to all versions, with the limitation of odd ratios.
379c3678b09SYork Sun 	 * If RCW has disabled DDR PLL, we have to apply this workaround,
380c3678b09SYork Sun 	 * otherwise DDR will not work.
381c3678b09SYork Sun 	 */
382c3678b09SYork Sun 	ddr_pll_ratio = (in_be32(&gur->rcwsr[0]) >>
383c3678b09SYork Sun 		FSL_CORENET_RCWSR0_MEM_PLL_RAT_SHIFT) &
384c3678b09SYork Sun 		FSL_CORENET_RCWSR0_MEM_PLL_RAT_MASK;
385c3678b09SYork Sun 	/* check if RCW sets ratio to 0, required by this workaround */
386c3678b09SYork Sun 	if (ddr_pll_ratio != 0)
387c3678b09SYork Sun 		return;
388c3678b09SYork Sun 	ddr_pll_ratio = (in_be32(&gur->rcwsr[0]) >>
389c3678b09SYork Sun 		FSL_CORENET_RCWSR0_MEM_PLL_RAT_RESV_SHIFT) &
390c3678b09SYork Sun 		FSL_CORENET_RCWSR0_MEM_PLL_RAT_MASK;
391c3678b09SYork Sun 	/* check if reserved bits have the desired ratio */
392c3678b09SYork Sun 	if (ddr_pll_ratio == 0) {
393c3678b09SYork Sun 		printf("Error: Unknown DDR PLL ratio!\n");
394c3678b09SYork Sun 		return;
395c3678b09SYork Sun 	}
396c3678b09SYork Sun 	ddr_pll_ratio >>= 1;
397c3678b09SYork Sun 
398c3678b09SYork Sun 	setbits_be32(plldadcr1, 0x02000001);
399c3678b09SYork Sun #if (CONFIG_NUM_DDR_CONTROLLERS >= 2)
400c3678b09SYork Sun 	setbits_be32(plldadcr2, 0x02000001);
401c3678b09SYork Sun #if (CONFIG_NUM_DDR_CONTROLLERS >= 3)
402c3678b09SYork Sun 	setbits_be32(plldadcr3, 0x02000001);
403c3678b09SYork Sun #endif
404c3678b09SYork Sun #endif
405c3678b09SYork Sun 	setbits_be32(dpdovrcr4, 0xe0000000);
406c3678b09SYork Sun 	out_be32(plldgdcr1, 0x08000001 | (ddr_pll_ratio << 1));
407c3678b09SYork Sun #if (CONFIG_NUM_DDR_CONTROLLERS >= 2)
408c3678b09SYork Sun 	out_be32(plldgdcr2, 0x08000001 | (ddr_pll_ratio << 1));
409c3678b09SYork Sun #if (CONFIG_NUM_DDR_CONTROLLERS >= 3)
410c3678b09SYork Sun 	out_be32(plldgdcr3, 0x08000001 | (ddr_pll_ratio << 1));
411c3678b09SYork Sun #endif
412c3678b09SYork Sun #endif
413c3678b09SYork Sun 	udelay(100);
414c3678b09SYork Sun 	clrbits_be32(plldadcr1, 0x02000001);
415c3678b09SYork Sun #if (CONFIG_NUM_DDR_CONTROLLERS >= 2)
416c3678b09SYork Sun 	clrbits_be32(plldadcr2, 0x02000001);
417c3678b09SYork Sun #if (CONFIG_NUM_DDR_CONTROLLERS >= 3)
418c3678b09SYork Sun 	clrbits_be32(plldadcr3, 0x02000001);
419c3678b09SYork Sun #endif
420c3678b09SYork Sun #endif
421c3678b09SYork Sun 	clrbits_be32(dpdovrcr4, 0xe0000000);
422c3678b09SYork Sun }
423c3678b09SYork Sun #endif
424c3678b09SYork Sun 
425701e6401SYork Sun ulong cpu_init_f(void)
426a47a12beSStefan Roese {
427701e6401SYork Sun 	ulong flag = 0;
428a47a12beSStefan Roese 	extern void m8560_cpm_reset (void);
429*7cad2e38SRuchika Gupta #if defined(CONFIG_SYS_DCSRBAR_PHYS) || \
430*7cad2e38SRuchika Gupta 	(defined(CONFIG_SECURE_BOOT) && defined(CONFIG_FSL_CORENET))
431f110fe94SStephen George 	ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
432f110fe94SStephen George #endif
4337065b7d4SRuchika Gupta #if defined(CONFIG_SECURE_BOOT)
4347065b7d4SRuchika Gupta 	struct law_entry law;
4357065b7d4SRuchika Gupta #endif
436a47a12beSStefan Roese #ifdef CONFIG_MPC8548
437a47a12beSStefan Roese 	ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR);
438a47a12beSStefan Roese 	uint svr = get_svr();
439a47a12beSStefan Roese 
440a47a12beSStefan Roese 	/*
441a47a12beSStefan Roese 	 * CPU2 errata workaround: A core hang possible while executing
442a47a12beSStefan Roese 	 * a msync instruction and a snoopable transaction from an I/O
443a47a12beSStefan Roese 	 * master tagged to make quick forward progress is present.
444a47a12beSStefan Roese 	 * Fixed in silicon rev 2.1.
445a47a12beSStefan Roese 	 */
446a47a12beSStefan Roese 	if ((SVR_MAJ(svr) == 1) || ((SVR_MAJ(svr) == 2 && SVR_MIN(svr) == 0x0)))
447a47a12beSStefan Roese 		out_be32(&ecm->eebpcr, in_be32(&ecm->eebpcr) | (1 << 16));
448a47a12beSStefan Roese #endif
449a47a12beSStefan Roese 
450a47a12beSStefan Roese 	disable_tlb(14);
451a47a12beSStefan Roese 	disable_tlb(15);
452a47a12beSStefan Roese 
4537065b7d4SRuchika Gupta #if defined(CONFIG_SECURE_BOOT)
4547065b7d4SRuchika Gupta 	/* Disable the LAW created for NOR flash by the PBI commands */
4557065b7d4SRuchika Gupta 	law = find_law(CONFIG_SYS_PBI_FLASH_BASE);
4567065b7d4SRuchika Gupta 	if (law.index != -1)
4577065b7d4SRuchika Gupta 		disable_law(law.index);
458fb4a2409SAneesh Bansal 
459fb4a2409SAneesh Bansal #if defined(CONFIG_SYS_CPC_REINIT_F)
460fb4a2409SAneesh Bansal 	disable_cpc_sram();
461fb4a2409SAneesh Bansal #endif
462*7cad2e38SRuchika Gupta 
463*7cad2e38SRuchika Gupta #if defined(CONFIG_FSL_CORENET)
464*7cad2e38SRuchika Gupta 	/* Put PAMU in bypass mode */
465*7cad2e38SRuchika Gupta 	out_be32(&gur->pamubypenr, FSL_CORENET_PAMU_BYPASS);
466*7cad2e38SRuchika Gupta #endif
467*7cad2e38SRuchika Gupta 
4687065b7d4SRuchika Gupta #endif
4697065b7d4SRuchika Gupta 
470a47a12beSStefan Roese #ifdef CONFIG_CPM2
471a47a12beSStefan Roese 	config_8560_ioports((ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR);
472a47a12beSStefan Roese #endif
473a47a12beSStefan Roese 
474f51cdaf1SBecky Bruce        init_early_memctl_regs();
475a47a12beSStefan Roese 
476a47a12beSStefan Roese #if defined(CONFIG_CPM2)
477a47a12beSStefan Roese 	m8560_cpm_reset();
478a47a12beSStefan Roese #endif
4792a44efebSZhao Qiang 
4802a44efebSZhao Qiang #if defined(CONFIG_QE) && !defined(CONFIG_U_QE)
481a47a12beSStefan Roese 	/* Config QE ioports */
482a47a12beSStefan Roese 	config_qe_ioports();
483a47a12beSStefan Roese #endif
4842a44efebSZhao Qiang 
485a47a12beSStefan Roese #if defined(CONFIG_FSL_DMA)
486a47a12beSStefan Roese 	dma_init();
487a47a12beSStefan Roese #endif
488a47a12beSStefan Roese #ifdef CONFIG_FSL_CORENET
489a47a12beSStefan Roese 	corenet_tb_init();
490a47a12beSStefan Roese #endif
491a47a12beSStefan Roese 	init_used_tlb_cams();
4926aba33e9SKumar Gala 
4936aba33e9SKumar Gala 	/* Invalidate the CPC before DDR gets enabled */
4946aba33e9SKumar Gala 	invalidate_cpc();
495f110fe94SStephen George 
496f110fe94SStephen George  #ifdef CONFIG_SYS_DCSRBAR_PHYS
497f110fe94SStephen George 	/* set DCSRCR so that DCSR space is 1G */
498f110fe94SStephen George 	setbits_be32(&gur->dcsrcr, FSL_CORENET_DCSR_SZ_1G);
499f110fe94SStephen George 	in_be32(&gur->dcsrcr);
500f110fe94SStephen George #endif
501f110fe94SStephen George 
502aade2004STang Yuantian #ifdef CONFIG_SYS_DCSRBAR_PHYS
503aade2004STang Yuantian #ifdef CONFIG_DEEP_SLEEP
504aade2004STang Yuantian 	/* disable the console if boot from deep sleep */
505aade2004STang Yuantian 	if (in_be32(&gur->scrtsr[0]) & (1 << 3))
506701e6401SYork Sun 		flag = GD_FLG_SILENT | GD_FLG_DISABLE_CONSOLE;
507aade2004STang Yuantian #endif
508aade2004STang Yuantian #endif
509c3678b09SYork Sun #ifdef CONFIG_SYS_FSL_ERRATUM_A007212
510c3678b09SYork Sun 	fsl_erratum_a007212_workaround();
511c3678b09SYork Sun #endif
512c3678b09SYork Sun 
513701e6401SYork Sun 	return flag;
514a47a12beSStefan Roese }
515a47a12beSStefan Roese 
51635079aa9SKumar Gala /* Implement a dummy function for those platforms w/o SERDES */
51735079aa9SKumar Gala static void __fsl_serdes__init(void)
51835079aa9SKumar Gala {
51935079aa9SKumar Gala 	return ;
52035079aa9SKumar Gala }
52135079aa9SKumar Gala __attribute__((weak, alias("__fsl_serdes__init"))) void fsl_serdes_init(void);
522a47a12beSStefan Roese 
523e9827468SPrabhakar Kushwaha #if defined(CONFIG_SYS_FSL_QORIQ_CHASSIS2) && defined(CONFIG_E6500)
5246d2b9da1SYork Sun int enable_cluster_l2(void)
5256d2b9da1SYork Sun {
5266d2b9da1SYork Sun 	int i = 0;
5275122dfaeSShengzhou Liu 	u32 cluster, svr = get_svr();
5286d2b9da1SYork Sun 	ccsr_gur_t *gur = (void __iomem *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
5296d2b9da1SYork Sun 	struct ccsr_cluster_l2 __iomem *l2cache;
5306d2b9da1SYork Sun 
5315122dfaeSShengzhou Liu 	/* only the L2 of first cluster should be enabled as expected on T4080,
5325122dfaeSShengzhou Liu 	 * but there is no EOC in the first cluster as HW sake, so return here
5335122dfaeSShengzhou Liu 	 * to skip enabling L2 cache of the 2nd cluster.
5345122dfaeSShengzhou Liu 	 */
5355122dfaeSShengzhou Liu 	if (SVR_SOC_VER(svr) == SVR_T4080)
5365122dfaeSShengzhou Liu 		return 0;
5375122dfaeSShengzhou Liu 
5386d2b9da1SYork Sun 	cluster = in_be32(&gur->tp_cluster[i].lower);
5396d2b9da1SYork Sun 	if (cluster & TP_CLUSTER_EOC)
5406d2b9da1SYork Sun 		return 0;
5416d2b9da1SYork Sun 
5426d2b9da1SYork Sun 	/* The first cache has already been set up, so skip it */
5436d2b9da1SYork Sun 	i++;
5446d2b9da1SYork Sun 
5456d2b9da1SYork Sun 	/* Look through the remaining clusters, and set up their caches */
5466d2b9da1SYork Sun 	do {
547db9a8070SPrabhakar Kushwaha 		int j, cluster_valid = 0;
548db9a8070SPrabhakar Kushwaha 
5496d2b9da1SYork Sun 		l2cache = (void __iomem *)(CONFIG_SYS_FSL_CLUSTER_1_L2 + i * 0x40000);
550db9a8070SPrabhakar Kushwaha 
5516d2b9da1SYork Sun 		cluster = in_be32(&gur->tp_cluster[i].lower);
5526d2b9da1SYork Sun 
553db9a8070SPrabhakar Kushwaha 		/* check that at least one core/accel is enabled in cluster */
554db9a8070SPrabhakar Kushwaha 		for (j = 0; j < 4; j++) {
555db9a8070SPrabhakar Kushwaha 			u32 idx = (cluster >> (j*8)) & TP_CLUSTER_INIT_MASK;
556db9a8070SPrabhakar Kushwaha 			u32 type = in_be32(&gur->tp_ityp[idx]);
557db9a8070SPrabhakar Kushwaha 
558a1399a91SShaveta Leekha 			if ((type & TP_ITYP_AV) &&
559a1399a91SShaveta Leekha 			    TP_ITYP_TYPE(type) == TP_ITYP_TYPE_PPC)
560db9a8070SPrabhakar Kushwaha 				cluster_valid = 1;
561db9a8070SPrabhakar Kushwaha 		}
562db9a8070SPrabhakar Kushwaha 
563db9a8070SPrabhakar Kushwaha 		if (cluster_valid) {
5646d2b9da1SYork Sun 			/* set stash ID to (cluster) * 2 + 32 + 1 */
5656d2b9da1SYork Sun 			clrsetbits_be32(&l2cache->l2csr1, 0xff, 32 + i * 2 + 1);
5666d2b9da1SYork Sun 
5676d2b9da1SYork Sun 			printf("enable l2 for cluster %d %p\n", i, l2cache);
5686d2b9da1SYork Sun 
5696d2b9da1SYork Sun 			out_be32(&l2cache->l2csr0, L2CSR0_L2FI|L2CSR0_L2LFC);
570db9a8070SPrabhakar Kushwaha 			while ((in_be32(&l2cache->l2csr0)
571db9a8070SPrabhakar Kushwaha 				& (L2CSR0_L2FI|L2CSR0_L2LFC)) != 0)
5726d2b9da1SYork Sun 					;
5739cd95ac7SJames Yang 			out_be32(&l2cache->l2csr0, L2CSR0_L2E|L2CSR0_L2PE|L2CSR0_L2REP_MODE);
574db9a8070SPrabhakar Kushwaha 		}
5756d2b9da1SYork Sun 		i++;
5766d2b9da1SYork Sun 	} while (!(cluster & TP_CLUSTER_EOC));
5776d2b9da1SYork Sun 
5786d2b9da1SYork Sun 	return 0;
5796d2b9da1SYork Sun }
5806d2b9da1SYork Sun #endif
5816d2b9da1SYork Sun 
582a47a12beSStefan Roese /*
583a47a12beSStefan Roese  * Initialize L2 as cache.
584a47a12beSStefan Roese  */
5857cb72723STang Yuantian int l2cache_init(void)
586a47a12beSStefan Roese {
587fbc20aabSTimur Tabi 	__maybe_unused u32 svr = get_svr();
5886d2b9da1SYork Sun #ifdef CONFIG_L2_CACHE
5896d2b9da1SYork Sun 	ccsr_l2cache_t *l2cache = (void __iomem *)CONFIG_SYS_MPC85xx_L2_ADDR;
590e9827468SPrabhakar Kushwaha #elif defined(CONFIG_SYS_FSL_QORIQ_CHASSIS2) && defined(CONFIG_E6500)
5916d2b9da1SYork Sun 	struct ccsr_cluster_l2 * l2cache = (void __iomem *)CONFIG_SYS_FSL_CLUSTER_1_L2;
5923f0202edSLan Chunhe #endif
5932a5fcb83SYork Sun 
594a47a12beSStefan Roese 	puts ("L2:    ");
595a47a12beSStefan Roese 
596a47a12beSStefan Roese #if defined(CONFIG_L2_CACHE)
597a47a12beSStefan Roese 	volatile uint cache_ctl;
598fbc20aabSTimur Tabi 	uint ver;
599a47a12beSStefan Roese 	u32 l2siz_field;
600a47a12beSStefan Roese 
601a47a12beSStefan Roese 	ver = SVR_SOC_VER(svr);
602a47a12beSStefan Roese 
603a47a12beSStefan Roese 	asm("msync;isync");
604a47a12beSStefan Roese 	cache_ctl = l2cache->l2ctl;
605a47a12beSStefan Roese 
606a47a12beSStefan Roese #if defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_SYS_INIT_L2_ADDR)
607a47a12beSStefan Roese 	if (cache_ctl & MPC85xx_L2CTL_L2E) {
608a47a12beSStefan Roese 		/* Clear L2 SRAM memory-mapped base address */
609a47a12beSStefan Roese 		out_be32(&l2cache->l2srbar0, 0x0);
610a47a12beSStefan Roese 		out_be32(&l2cache->l2srbar1, 0x0);
611a47a12beSStefan Roese 
612a47a12beSStefan Roese 		/* set MBECCDIS=0, SBECCDIS=0 */
613a47a12beSStefan Roese 		clrbits_be32(&l2cache->l2errdis,
614a47a12beSStefan Roese 				(MPC85xx_L2ERRDIS_MBECC |
615a47a12beSStefan Roese 				 MPC85xx_L2ERRDIS_SBECC));
616a47a12beSStefan Roese 
617a47a12beSStefan Roese 		/* set L2E=0, L2SRAM=0 */
618a47a12beSStefan Roese 		clrbits_be32(&l2cache->l2ctl,
619a47a12beSStefan Roese 				(MPC85xx_L2CTL_L2E |
620a47a12beSStefan Roese 				 MPC85xx_L2CTL_L2SRAM_ENTIRE));
621a47a12beSStefan Roese 	}
622a47a12beSStefan Roese #endif
623a47a12beSStefan Roese 
624a47a12beSStefan Roese 	l2siz_field = (cache_ctl >> 28) & 0x3;
625a47a12beSStefan Roese 
626a47a12beSStefan Roese 	switch (l2siz_field) {
627a47a12beSStefan Roese 	case 0x0:
628a47a12beSStefan Roese 		printf(" unknown size (0x%08x)\n", cache_ctl);
629a47a12beSStefan Roese 		return -1;
630a47a12beSStefan Roese 		break;
631a47a12beSStefan Roese 	case 0x1:
632a47a12beSStefan Roese 		if (ver == SVR_8540 || ver == SVR_8560   ||
63348f6a5c3SYork Sun 		    ver == SVR_8541 || ver == SVR_8555) {
6346b44d9e5SShruti Kanetkar 			puts("128 KiB ");
6356b44d9e5SShruti Kanetkar 			/* set L2E=1, L2I=1, & L2BLKSZ=1 (128 KiBibyte) */
636a47a12beSStefan Roese 			cache_ctl = 0xc4000000;
637a47a12beSStefan Roese 		} else {
6386b44d9e5SShruti Kanetkar 			puts("256 KiB ");
639a47a12beSStefan Roese 			cache_ctl = 0xc0000000; /* set L2E=1, L2I=1, & L2SRAM=0 */
640a47a12beSStefan Roese 		}
641a47a12beSStefan Roese 		break;
642a47a12beSStefan Roese 	case 0x2:
643a47a12beSStefan Roese 		if (ver == SVR_8540 || ver == SVR_8560   ||
64448f6a5c3SYork Sun 		    ver == SVR_8541 || ver == SVR_8555) {
6456b44d9e5SShruti Kanetkar 			puts("256 KiB ");
6466b44d9e5SShruti Kanetkar 			/* set L2E=1, L2I=1, & L2BLKSZ=2 (256 KiBibyte) */
647a47a12beSStefan Roese 			cache_ctl = 0xc8000000;
648a47a12beSStefan Roese 		} else {
6496b44d9e5SShruti Kanetkar 			puts("512 KiB ");
650a47a12beSStefan Roese 			/* set L2E=1, L2I=1, & L2SRAM=0 */
651a47a12beSStefan Roese 			cache_ctl = 0xc0000000;
652a47a12beSStefan Roese 		}
653a47a12beSStefan Roese 		break;
654a47a12beSStefan Roese 	case 0x3:
6556b44d9e5SShruti Kanetkar 		puts("1024 KiB ");
656a47a12beSStefan Roese 		/* set L2E=1, L2I=1, & L2SRAM=0 */
657a47a12beSStefan Roese 		cache_ctl = 0xc0000000;
658a47a12beSStefan Roese 		break;
659a47a12beSStefan Roese 	}
660a47a12beSStefan Roese 
661a47a12beSStefan Roese 	if (l2cache->l2ctl & MPC85xx_L2CTL_L2E) {
662a47a12beSStefan Roese 		puts("already enabled");
663888279b5SHaiying Wang #if defined(CONFIG_SYS_INIT_L2_ADDR) && defined(CONFIG_SYS_FLASH_BASE)
664e4c9a35dSKumar Gala 		u32 l2srbar = l2cache->l2srbar0;
665a47a12beSStefan Roese 		if (l2cache->l2ctl & MPC85xx_L2CTL_L2SRAM_ENTIRE
666a47a12beSStefan Roese 				&& l2srbar >= CONFIG_SYS_FLASH_BASE) {
667a47a12beSStefan Roese 			l2srbar = CONFIG_SYS_INIT_L2_ADDR;
668a47a12beSStefan Roese 			l2cache->l2srbar0 = l2srbar;
6699a511bd6SScott Wood 			printf(", moving to 0x%08x", CONFIG_SYS_INIT_L2_ADDR);
670a47a12beSStefan Roese 		}
671a47a12beSStefan Roese #endif /* CONFIG_SYS_INIT_L2_ADDR */
672a47a12beSStefan Roese 		puts("\n");
673a47a12beSStefan Roese 	} else {
674a47a12beSStefan Roese 		asm("msync;isync");
675a47a12beSStefan Roese 		l2cache->l2ctl = cache_ctl; /* invalidate & enable */
676a47a12beSStefan Roese 		asm("msync;isync");
677a47a12beSStefan Roese 		puts("enabled\n");
678a47a12beSStefan Roese 	}
679a47a12beSStefan Roese #elif defined(CONFIG_BACKSIDE_L2_CACHE)
68048f6a5c3SYork Sun 	if (SVR_SOC_VER(svr) == SVR_P2040) {
681acf3f8daSKumar Gala 		puts("N/A\n");
682acf3f8daSKumar Gala 		goto skip_l2;
683acf3f8daSKumar Gala 	}
684acf3f8daSKumar Gala 
685a47a12beSStefan Roese 	u32 l2cfg0 = mfspr(SPRN_L2CFG0);
686a47a12beSStefan Roese 
687a47a12beSStefan Roese 	/* invalidate the L2 cache */
688a47a12beSStefan Roese 	mtspr(SPRN_L2CSR0, (L2CSR0_L2FI|L2CSR0_L2LFC));
689a47a12beSStefan Roese 	while (mfspr(SPRN_L2CSR0) & (L2CSR0_L2FI|L2CSR0_L2LFC))
690a47a12beSStefan Roese 		;
691a47a12beSStefan Roese 
692a47a12beSStefan Roese #ifdef CONFIG_SYS_CACHE_STASHING
693a47a12beSStefan Roese 	/* set stash id to (coreID) * 2 + 32 + L2 (1) */
694a47a12beSStefan Roese 	mtspr(SPRN_L2CSR1, (32 + 1));
695a47a12beSStefan Roese #endif
696a47a12beSStefan Roese 
697a47a12beSStefan Roese 	/* enable the cache */
698a47a12beSStefan Roese 	mtspr(SPRN_L2CSR0, CONFIG_SYS_INIT_L2CSR0);
699a47a12beSStefan Roese 
700a47a12beSStefan Roese 	if (CONFIG_SYS_INIT_L2CSR0 & L2CSR0_L2E) {
701a47a12beSStefan Roese 		while (!(mfspr(SPRN_L2CSR0) & L2CSR0_L2E))
702a47a12beSStefan Roese 			;
7032f848f97SShruti Kanetkar 		print_size((l2cfg0 & 0x3fff) * 64 * 1024, " enabled\n");
704a47a12beSStefan Roese 	}
705acf3f8daSKumar Gala 
706acf3f8daSKumar Gala skip_l2:
707e9827468SPrabhakar Kushwaha #elif defined(CONFIG_SYS_FSL_QORIQ_CHASSIS2) && defined(CONFIG_E6500)
7086d2b9da1SYork Sun 	if (l2cache->l2csr0 & L2CSR0_L2E)
7092f848f97SShruti Kanetkar 		print_size((l2cache->l2cfg0 & 0x3fff) * 64 * 1024,
7102f848f97SShruti Kanetkar 			   " enabled\n");
7116d2b9da1SYork Sun 
7126d2b9da1SYork Sun 	enable_cluster_l2();
713a47a12beSStefan Roese #else
714a47a12beSStefan Roese 	puts("disabled\n");
715a47a12beSStefan Roese #endif
7166aba33e9SKumar Gala 
7177cb72723STang Yuantian 	return 0;
7187cb72723STang Yuantian }
7197cb72723STang Yuantian 
7207cb72723STang Yuantian /*
7217cb72723STang Yuantian  *
7227cb72723STang Yuantian  * The newer 8548, etc, parts have twice as much cache, but
7237cb72723STang Yuantian  * use the same bit-encoding as the older 8555, etc, parts.
7247cb72723STang Yuantian  *
7257cb72723STang Yuantian  */
7267cb72723STang Yuantian int cpu_init_r(void)
7277cb72723STang Yuantian {
7287cb72723STang Yuantian 	__maybe_unused u32 svr = get_svr();
7297cb72723STang Yuantian #ifdef CONFIG_SYS_LBC_LCRR
7307cb72723STang Yuantian 	fsl_lbc_t *lbc = (void __iomem *)LBC_BASE_ADDR;
7317cb72723STang Yuantian #endif
7327cb72723STang Yuantian #if defined(CONFIG_PPC_SPINTABLE_COMPATIBLE) && defined(CONFIG_MP)
7337cb72723STang Yuantian 	extern int spin_table_compat;
7347cb72723STang Yuantian 	const char *spin;
7357cb72723STang Yuantian #endif
7367cb72723STang Yuantian #ifdef CONFIG_SYS_FSL_ERRATUM_SEC_A003571
7377cb72723STang Yuantian 	ccsr_sec_t __iomem *sec = (void *)CONFIG_SYS_FSL_SEC_ADDR;
7387cb72723STang Yuantian #endif
7397cb72723STang Yuantian #if defined(CONFIG_SYS_P4080_ERRATUM_CPU22) || \
7407cb72723STang Yuantian 	defined(CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011)
7417cb72723STang Yuantian 	/*
7427cb72723STang Yuantian 	 * CPU22 and NMG_CPU_A011 share the same workaround.
7437cb72723STang Yuantian 	 * CPU22 applies to P4080 rev 1.0, 2.0, fixed in 3.0
7447cb72723STang Yuantian 	 * NMG_CPU_A011 applies to P4080 rev 1.0, 2.0, fixed in 3.0
7457cb72723STang Yuantian 	 * also applies to P3041 rev 1.0, 1.1, P2041 rev 1.0, 1.1, both
7467cb72723STang Yuantian 	 * fixed in 2.0. NMG_CPU_A011 is activated by default and can
7477cb72723STang Yuantian 	 * be disabled by hwconfig with syntax:
7487cb72723STang Yuantian 	 *
7497cb72723STang Yuantian 	 * fsl_cpu_a011:disable
7507cb72723STang Yuantian 	 */
7517cb72723STang Yuantian 	extern int enable_cpu_a011_workaround;
7527cb72723STang Yuantian #ifdef CONFIG_SYS_P4080_ERRATUM_CPU22
7537cb72723STang Yuantian 	enable_cpu_a011_workaround = (SVR_MAJ(svr) < 3);
7547cb72723STang Yuantian #else
7557cb72723STang Yuantian 	char buffer[HWCONFIG_BUFFER_SIZE];
7567cb72723STang Yuantian 	char *buf = NULL;
7577cb72723STang Yuantian 	int n, res;
7587cb72723STang Yuantian 
7597cb72723STang Yuantian 	n = getenv_f("hwconfig", buffer, sizeof(buffer));
7607cb72723STang Yuantian 	if (n > 0)
7617cb72723STang Yuantian 		buf = buffer;
7627cb72723STang Yuantian 
7637cb72723STang Yuantian 	res = hwconfig_arg_cmp_f("fsl_cpu_a011", "disable", buf);
7647cb72723STang Yuantian 	if (res > 0) {
7657cb72723STang Yuantian 		enable_cpu_a011_workaround = 0;
7667cb72723STang Yuantian 	} else {
7677cb72723STang Yuantian 		if (n >= HWCONFIG_BUFFER_SIZE) {
7687cb72723STang Yuantian 			printf("fsl_cpu_a011 was not found. hwconfig variable "
7697cb72723STang Yuantian 				"may be too long\n");
7707cb72723STang Yuantian 		}
7717cb72723STang Yuantian 		enable_cpu_a011_workaround =
7727cb72723STang Yuantian 			(SVR_SOC_VER(svr) == SVR_P4080 && SVR_MAJ(svr) < 3) ||
7737cb72723STang Yuantian 			(SVR_SOC_VER(svr) != SVR_P4080 && SVR_MAJ(svr) < 2);
7747cb72723STang Yuantian 	}
7757cb72723STang Yuantian #endif
7767cb72723STang Yuantian 	if (enable_cpu_a011_workaround) {
7777cb72723STang Yuantian 		flush_dcache();
7787cb72723STang Yuantian 		mtspr(L1CSR2, (mfspr(L1CSR2) | L1CSR2_DCWS));
7797cb72723STang Yuantian 		sync();
7807cb72723STang Yuantian 	}
7817cb72723STang Yuantian #endif
7827cb72723STang Yuantian #ifdef CONFIG_SYS_FSL_ERRATUM_A005812
7837cb72723STang Yuantian 	/*
7847cb72723STang Yuantian 	 * A-005812 workaround sets bit 32 of SPR 976 for SoCs running
7857cb72723STang Yuantian 	 * in write shadow mode. Checking DCWS before setting SPR 976.
7867cb72723STang Yuantian 	 */
7877cb72723STang Yuantian 	if (mfspr(L1CSR2) & L1CSR2_DCWS)
7887cb72723STang Yuantian 		mtspr(SPRN_HDBCR0, (mfspr(SPRN_HDBCR0) | 0x80000000));
7897cb72723STang Yuantian #endif
7907cb72723STang Yuantian 
7917cb72723STang Yuantian #if defined(CONFIG_PPC_SPINTABLE_COMPATIBLE) && defined(CONFIG_MP)
7927cb72723STang Yuantian 	spin = getenv("spin_table_compat");
7937cb72723STang Yuantian 	if (spin && (*spin == 'n'))
7947cb72723STang Yuantian 		spin_table_compat = 0;
7957cb72723STang Yuantian 	else
7967cb72723STang Yuantian 		spin_table_compat = 1;
7977cb72723STang Yuantian #endif
7987cb72723STang Yuantian 
7997cb72723STang Yuantian 	l2cache_init();
800fb4a2409SAneesh Bansal #if defined(CONFIG_RAMBOOT_PBL)
801fb4a2409SAneesh Bansal 	disable_cpc_sram();
802fb4a2409SAneesh Bansal #endif
8036aba33e9SKumar Gala 	enable_cpc();
804377ffcfaSSandeep Singh #if defined(T1040_TDM_QUIRK_CCSR_BASE)
805377ffcfaSSandeep Singh 	enable_tdm_law();
806377ffcfaSSandeep Singh #endif
8076aba33e9SKumar Gala 
808cb93071bSYork Sun #ifndef CONFIG_SYS_FSL_NO_SERDES
809af025065SKumar Gala 	/* needs to be in ram since code uses global static vars */
810af025065SKumar Gala 	fsl_serdes_init();
811cb93071bSYork Sun #endif
812af025065SKumar Gala 
813424bf942SShengzhou Liu #ifdef CONFIG_SYS_FSL_ERRATUM_SEC_A003571
814424bf942SShengzhou Liu #define MCFGR_AXIPIPE 0x000000f0
815424bf942SShengzhou Liu 	if (IS_SVR_REV(svr, 1, 0))
816028dbb8dSRuchika Gupta 		sec_clrbits32(&sec->mcfgr, MCFGR_AXIPIPE);
817424bf942SShengzhou Liu #endif
818424bf942SShengzhou Liu 
81972bd83cdSShengzhou Liu #ifdef CONFIG_SYS_FSL_ERRATUM_A005871
82072bd83cdSShengzhou Liu 	if (IS_SVR_REV(svr, 1, 0)) {
82172bd83cdSShengzhou Liu 		int i;
82272bd83cdSShengzhou Liu 		__be32 *p = (void __iomem *)CONFIG_SYS_DCSRBAR + 0xb004c;
82372bd83cdSShengzhou Liu 
82472bd83cdSShengzhou Liu 		for (i = 0; i < 12; i++) {
82572bd83cdSShengzhou Liu 			p += i + (i > 5 ? 11 : 0);
82672bd83cdSShengzhou Liu 			out_be32(p, 0x2);
82772bd83cdSShengzhou Liu 		}
82872bd83cdSShengzhou Liu 		p = (void __iomem *)CONFIG_SYS_DCSRBAR + 0xb0108;
82972bd83cdSShengzhou Liu 		out_be32(p, 0x34);
83072bd83cdSShengzhou Liu 	}
83172bd83cdSShengzhou Liu #endif
83272bd83cdSShengzhou Liu 
833a09b9b68SKumar Gala #ifdef CONFIG_SYS_SRIO
834a09b9b68SKumar Gala 	srio_init();
835c8b28152SLiu Gang #ifdef CONFIG_SRIO_PCIE_BOOT_MASTER
836ff65f126SLiu Gang 	char *s = getenv("bootmaster");
837ff65f126SLiu Gang 	if (s) {
838ff65f126SLiu Gang 		if (!strcmp(s, "SRIO1")) {
839ff65f126SLiu Gang 			srio_boot_master(1);
840ff65f126SLiu Gang 			srio_boot_master_release_slave(1);
841ff65f126SLiu Gang 		}
842ff65f126SLiu Gang 		if (!strcmp(s, "SRIO2")) {
843ff65f126SLiu Gang 			srio_boot_master(2);
844ff65f126SLiu Gang 			srio_boot_master_release_slave(2);
845ff65f126SLiu Gang 		}
846ff65f126SLiu Gang 	}
8475ffa88ecSLiu Gang #endif
848a09b9b68SKumar Gala #endif
849a09b9b68SKumar Gala 
850a47a12beSStefan Roese #if defined(CONFIG_MP)
851a47a12beSStefan Roese 	setup_mp();
852a47a12beSStefan Roese #endif
8533f0202edSLan Chunhe 
8544e0be34aSZang Roy-R61911 #ifdef CONFIG_SYS_FSL_ERRATUM_ESDHC13
855ae026ffdSRoy Zang 	{
8564e0be34aSZang Roy-R61911 		if (SVR_MAJ(svr) < 3) {
857ae026ffdSRoy Zang 			void *p;
858ae026ffdSRoy Zang 			p = (void *)CONFIG_SYS_DCSRBAR + 0x20520;
859ae026ffdSRoy Zang 			setbits_be32(p, 1 << (31 - 14));
860ae026ffdSRoy Zang 		}
8614e0be34aSZang Roy-R61911 	}
862ae026ffdSRoy Zang #endif
863ae026ffdSRoy Zang 
8643f0202edSLan Chunhe #ifdef CONFIG_SYS_LBC_LCRR
8653f0202edSLan Chunhe 	/*
8663f0202edSLan Chunhe 	 * Modify the CLKDIV field of LCRR register to improve the writing
8673f0202edSLan Chunhe 	 * speed for NOR flash.
8683f0202edSLan Chunhe 	 */
8693f0202edSLan Chunhe 	clrsetbits_be32(&lbc->lcrr, LCRR_CLKDIV, CONFIG_SYS_LBC_LCRR);
8703f0202edSLan Chunhe 	__raw_readl(&lbc->lcrr);
8713f0202edSLan Chunhe 	isync();
8722b3a1cddSKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_NMG_LBC103
8732b3a1cddSKumar Gala 	udelay(100);
8742b3a1cddSKumar Gala #endif
8753f0202edSLan Chunhe #endif
8763f0202edSLan Chunhe 
87786221f09SRoy Zang #ifdef CONFIG_SYS_FSL_USB1_PHY_ENABLE
87886221f09SRoy Zang 	{
8799dee205dSramneek mehresh 		struct ccsr_usb_phy __iomem *usb_phy1 =
88086221f09SRoy Zang 			(void *)CONFIG_SYS_MPC85xx_USB1_PHY_ADDR;
8819c641a87SSuresh Gupta #ifdef CONFIG_SYS_FSL_ERRATUM_A006261
8829c641a87SSuresh Gupta 		if (has_erratum_a006261())
8839c641a87SSuresh Gupta 			fsl_erratum_a006261_workaround(usb_phy1);
8849c641a87SSuresh Gupta #endif
88586221f09SRoy Zang 		out_be32(&usb_phy1->usb_enable_override,
88686221f09SRoy Zang 				CONFIG_SYS_FSL_USB_ENABLE_OVERRIDE);
88786221f09SRoy Zang 	}
88886221f09SRoy Zang #endif
88986221f09SRoy Zang #ifdef CONFIG_SYS_FSL_USB2_PHY_ENABLE
89086221f09SRoy Zang 	{
8919dee205dSramneek mehresh 		struct ccsr_usb_phy __iomem *usb_phy2 =
89286221f09SRoy Zang 			(void *)CONFIG_SYS_MPC85xx_USB2_PHY_ADDR;
8939c641a87SSuresh Gupta #ifdef CONFIG_SYS_FSL_ERRATUM_A006261
8949c641a87SSuresh Gupta 		if (has_erratum_a006261())
8959c641a87SSuresh Gupta 			fsl_erratum_a006261_workaround(usb_phy2);
8969c641a87SSuresh Gupta #endif
89786221f09SRoy Zang 		out_be32(&usb_phy2->usb_enable_override,
89886221f09SRoy Zang 				CONFIG_SYS_FSL_USB_ENABLE_OVERRIDE);
89986221f09SRoy Zang 	}
90086221f09SRoy Zang #endif
90186221f09SRoy Zang 
90299d7b0a4SXulei #ifdef CONFIG_SYS_FSL_ERRATUM_USB14
90399d7b0a4SXulei 	/* On P204x/P304x/P50x0 Rev1.0, USB transmit will result internal
90499d7b0a4SXulei 	 * multi-bit ECC errors which has impact on performance, so software
90599d7b0a4SXulei 	 * should disable all ECC reporting from USB1 and USB2.
90699d7b0a4SXulei 	 */
90799d7b0a4SXulei 	if (IS_SVR_REV(get_svr(), 1, 0)) {
90899d7b0a4SXulei 		struct dcsr_dcfg_regs *dcfg = (struct dcsr_dcfg_regs *)
90999d7b0a4SXulei 			(CONFIG_SYS_DCSRBAR + CONFIG_SYS_DCSR_DCFG_OFFSET);
91099d7b0a4SXulei 		setbits_be32(&dcfg->ecccr1,
91199d7b0a4SXulei 				(DCSR_DCFG_ECC_DISABLE_USB1 |
91299d7b0a4SXulei 				 DCSR_DCFG_ECC_DISABLE_USB2));
91399d7b0a4SXulei 	}
91499d7b0a4SXulei #endif
91599d7b0a4SXulei 
9163fa75c87SRoy Zang #if defined(CONFIG_SYS_FSL_USB_DUAL_PHY_ENABLE)
9179dee205dSramneek mehresh 		struct ccsr_usb_phy __iomem *usb_phy =
9183fa75c87SRoy Zang 			(void *)CONFIG_SYS_MPC85xx_USB1_PHY_ADDR;
9193fa75c87SRoy Zang 		setbits_be32(&usb_phy->pllprg[1],
9203fa75c87SRoy Zang 			     CONFIG_SYS_FSL_USB_PLLPRG2_PHY2_CLK_EN |
9213fa75c87SRoy Zang 			     CONFIG_SYS_FSL_USB_PLLPRG2_PHY1_CLK_EN |
9223fa75c87SRoy Zang 			     CONFIG_SYS_FSL_USB_PLLPRG2_MFI |
9233fa75c87SRoy Zang 			     CONFIG_SYS_FSL_USB_PLLPRG2_PLL_EN);
924d1c561cdSNikhil Badola #ifdef CONFIG_SYS_FSL_SINGLE_SOURCE_CLK
925d1c561cdSNikhil Badola 		usb_single_source_clk_configure(usb_phy);
926d1c561cdSNikhil Badola #endif
9273fa75c87SRoy Zang 		setbits_be32(&usb_phy->port1.ctrl,
9283fa75c87SRoy Zang 			     CONFIG_SYS_FSL_USB_CTRL_PHY_EN);
9293fa75c87SRoy Zang 		setbits_be32(&usb_phy->port1.drvvbuscfg,
9303fa75c87SRoy Zang 			     CONFIG_SYS_FSL_USB_DRVVBUS_CR_EN);
9313fa75c87SRoy Zang 		setbits_be32(&usb_phy->port1.pwrfltcfg,
9323fa75c87SRoy Zang 			     CONFIG_SYS_FSL_USB_PWRFLT_CR_EN);
9333fa75c87SRoy Zang 		setbits_be32(&usb_phy->port2.ctrl,
9343fa75c87SRoy Zang 			     CONFIG_SYS_FSL_USB_CTRL_PHY_EN);
9353fa75c87SRoy Zang 		setbits_be32(&usb_phy->port2.drvvbuscfg,
9363fa75c87SRoy Zang 			     CONFIG_SYS_FSL_USB_DRVVBUS_CR_EN);
9373fa75c87SRoy Zang 		setbits_be32(&usb_phy->port2.pwrfltcfg,
9383fa75c87SRoy Zang 			     CONFIG_SYS_FSL_USB_PWRFLT_CR_EN);
9399c641a87SSuresh Gupta 
9409c641a87SSuresh Gupta #ifdef CONFIG_SYS_FSL_ERRATUM_A006261
9419c641a87SSuresh Gupta 		if (has_erratum_a006261())
9429c641a87SSuresh Gupta 			fsl_erratum_a006261_workaround(usb_phy);
9433fa75c87SRoy Zang #endif
9443fa75c87SRoy Zang 
9459c641a87SSuresh Gupta #endif /* CONFIG_SYS_FSL_USB_DUAL_PHY_ENABLE */
9469c641a87SSuresh Gupta 
947c916d7c9SKumar Gala #ifdef CONFIG_FMAN_ENET
948c916d7c9SKumar Gala 	fman_enet_init();
949c916d7c9SKumar Gala #endif
950c916d7c9SKumar Gala 
951b9eebfadSRuchika Gupta #ifdef CONFIG_FSL_CAAM
952b9eebfadSRuchika Gupta 	sec_init();
953b9eebfadSRuchika Gupta #endif
954b9eebfadSRuchika Gupta 
955fbc20aabSTimur Tabi #if defined(CONFIG_FSL_SATA_V2) && defined(CONFIG_FSL_SATA_ERRATUM_A001)
956fbc20aabSTimur Tabi 	/*
957fbc20aabSTimur Tabi 	 * For P1022/1013 Rev1.0 silicon, after power on SATA host
958fbc20aabSTimur Tabi 	 * controller is configured in legacy mode instead of the
959fbc20aabSTimur Tabi 	 * expected enterprise mode. Software needs to clear bit[28]
960fbc20aabSTimur Tabi 	 * of HControl register to change to enterprise mode from
961fbc20aabSTimur Tabi 	 * legacy mode.  We assume that the controller is offline.
962fbc20aabSTimur Tabi 	 */
963fbc20aabSTimur Tabi 	if (IS_SVR_REV(svr, 1, 0) &&
964fbc20aabSTimur Tabi 	    ((SVR_SOC_VER(svr) == SVR_P1022) ||
96548f6a5c3SYork Sun 	     (SVR_SOC_VER(svr) == SVR_P1013))) {
966fbc20aabSTimur Tabi 		fsl_sata_reg_t *reg;
967fbc20aabSTimur Tabi 
968fbc20aabSTimur Tabi 		/* first SATA controller */
969fbc20aabSTimur Tabi 		reg = (void *)CONFIG_SYS_MPC85xx_SATA1_ADDR;
970fbc20aabSTimur Tabi 		clrbits_le32(&reg->hcontrol, HCONTROL_ENTERPRISE_EN);
971fbc20aabSTimur Tabi 
972fbc20aabSTimur Tabi 		/* second SATA controller */
973fbc20aabSTimur Tabi 		reg = (void *)CONFIG_SYS_MPC85xx_SATA2_ADDR;
974fbc20aabSTimur Tabi 		clrbits_le32(&reg->hcontrol, HCONTROL_ENTERPRISE_EN);
975fbc20aabSTimur Tabi 	}
976fbc20aabSTimur Tabi #endif
977fbc20aabSTimur Tabi 
978f13c9156SAlexander Graf 	init_used_tlb_cams();
979fbc20aabSTimur Tabi 
980a47a12beSStefan Roese 	return 0;
981a47a12beSStefan Roese }
982a47a12beSStefan Roese 
983a47a12beSStefan Roese void arch_preboot_os(void)
984a47a12beSStefan Roese {
985a47a12beSStefan Roese 	u32 msr;
986a47a12beSStefan Roese 
987a47a12beSStefan Roese 	/*
988a47a12beSStefan Roese 	 * We are changing interrupt offsets and are about to boot the OS so
989a47a12beSStefan Roese 	 * we need to make sure we disable all async interrupts. EE is already
990a47a12beSStefan Roese 	 * disabled by the time we get called.
991a47a12beSStefan Roese 	 */
992a47a12beSStefan Roese 	msr = mfmsr();
9935344f7a2SPrabhakar Kushwaha 	msr &= ~(MSR_ME|MSR_CE);
994a47a12beSStefan Roese 	mtmsr(msr);
995a47a12beSStefan Roese }
996f54fe87aSKumar Gala 
997f54fe87aSKumar Gala #if defined(CONFIG_CMD_SATA) && defined(CONFIG_FSL_SATA)
998f54fe87aSKumar Gala int sata_initialize(void)
999f54fe87aSKumar Gala {
1000f54fe87aSKumar Gala 	if (is_serdes_configured(SATA1) || is_serdes_configured(SATA2))
1001f54fe87aSKumar Gala 		return __sata_initialize();
1002f54fe87aSKumar Gala 
1003f54fe87aSKumar Gala 	return 1;
1004f54fe87aSKumar Gala }
1005f54fe87aSKumar Gala #endif
1006f9a33f1cSKumar Gala 
1007f9a33f1cSKumar Gala void cpu_secondary_init_r(void)
1008f9a33f1cSKumar Gala {
10092a44efebSZhao Qiang #ifdef CONFIG_U_QE
10102a44efebSZhao Qiang 	uint qe_base = CONFIG_SYS_IMMR + 0x00140000; /* QE immr base */
10112a44efebSZhao Qiang #elif defined CONFIG_QE
1012f9a33f1cSKumar Gala 	uint qe_base = CONFIG_SYS_IMMR + 0x00080000; /* QE immr base */
10132a44efebSZhao Qiang #endif
10142a44efebSZhao Qiang 
10152a44efebSZhao Qiang #ifdef CONFIG_QE
1016f9a33f1cSKumar Gala 	qe_init(qe_base);
1017f9a33f1cSKumar Gala 	qe_reset();
1018f9a33f1cSKumar Gala #endif
1019f9a33f1cSKumar Gala }
1020