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 * 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> 33f54fe87aSKumar Gala #include <sata.h> 34a47a12beSStefan Roese #include <asm/io.h> 35fd3c9befSKumar Gala #include <asm/cache.h> 36a47a12beSStefan Roese #include <asm/mmu.h> 37a47a12beSStefan Roese #include <asm/fsl_law.h> 38f54fe87aSKumar Gala #include <asm/fsl_serdes.h> 39a47a12beSStefan Roese #include "mp.h" 40a7b1e1b7SHaiying Wang #ifdef CONFIG_SYS_QE_FW_IN_NAND 41a7b1e1b7SHaiying Wang #include <nand.h> 42a7b1e1b7SHaiying Wang #include <errno.h> 43a7b1e1b7SHaiying Wang #endif 44a47a12beSStefan Roese 45a47a12beSStefan Roese DECLARE_GLOBAL_DATA_PTR; 46a47a12beSStefan Roese 47a09b9b68SKumar Gala extern void srio_init(void); 48a09b9b68SKumar Gala 49a47a12beSStefan Roese #ifdef CONFIG_QE 50a47a12beSStefan Roese extern qe_iop_conf_t qe_iop_conf_tab[]; 51a47a12beSStefan Roese extern void qe_config_iopin(u8 port, u8 pin, int dir, 52a47a12beSStefan Roese int open_drain, int assign); 53a47a12beSStefan Roese extern void qe_init(uint qe_base); 54a47a12beSStefan Roese extern void qe_reset(void); 55a47a12beSStefan Roese 56a47a12beSStefan Roese static void config_qe_ioports(void) 57a47a12beSStefan Roese { 58a47a12beSStefan Roese u8 port, pin; 59a47a12beSStefan Roese int dir, open_drain, assign; 60a47a12beSStefan Roese int i; 61a47a12beSStefan Roese 62a47a12beSStefan Roese for (i = 0; qe_iop_conf_tab[i].assign != QE_IOP_TAB_END; i++) { 63a47a12beSStefan Roese port = qe_iop_conf_tab[i].port; 64a47a12beSStefan Roese pin = qe_iop_conf_tab[i].pin; 65a47a12beSStefan Roese dir = qe_iop_conf_tab[i].dir; 66a47a12beSStefan Roese open_drain = qe_iop_conf_tab[i].open_drain; 67a47a12beSStefan Roese assign = qe_iop_conf_tab[i].assign; 68a47a12beSStefan Roese qe_config_iopin(port, pin, dir, open_drain, assign); 69a47a12beSStefan Roese } 70a47a12beSStefan Roese } 71a47a12beSStefan Roese #endif 72a47a12beSStefan Roese 73a47a12beSStefan Roese #ifdef CONFIG_CPM2 74a47a12beSStefan Roese void config_8560_ioports (volatile ccsr_cpm_t * cpm) 75a47a12beSStefan Roese { 76a47a12beSStefan Roese int portnum; 77a47a12beSStefan Roese 78a47a12beSStefan Roese for (portnum = 0; portnum < 4; portnum++) { 79a47a12beSStefan Roese uint pmsk = 0, 80a47a12beSStefan Roese ppar = 0, 81a47a12beSStefan Roese psor = 0, 82a47a12beSStefan Roese pdir = 0, 83a47a12beSStefan Roese podr = 0, 84a47a12beSStefan Roese pdat = 0; 85a47a12beSStefan Roese iop_conf_t *iopc = (iop_conf_t *) & iop_conf_tab[portnum][0]; 86a47a12beSStefan Roese iop_conf_t *eiopc = iopc + 32; 87a47a12beSStefan Roese uint msk = 1; 88a47a12beSStefan Roese 89a47a12beSStefan Roese /* 90a47a12beSStefan Roese * NOTE: 91a47a12beSStefan Roese * index 0 refers to pin 31, 92a47a12beSStefan Roese * index 31 refers to pin 0 93a47a12beSStefan Roese */ 94a47a12beSStefan Roese while (iopc < eiopc) { 95a47a12beSStefan Roese if (iopc->conf) { 96a47a12beSStefan Roese pmsk |= msk; 97a47a12beSStefan Roese if (iopc->ppar) 98a47a12beSStefan Roese ppar |= msk; 99a47a12beSStefan Roese if (iopc->psor) 100a47a12beSStefan Roese psor |= msk; 101a47a12beSStefan Roese if (iopc->pdir) 102a47a12beSStefan Roese pdir |= msk; 103a47a12beSStefan Roese if (iopc->podr) 104a47a12beSStefan Roese podr |= msk; 105a47a12beSStefan Roese if (iopc->pdat) 106a47a12beSStefan Roese pdat |= msk; 107a47a12beSStefan Roese } 108a47a12beSStefan Roese 109a47a12beSStefan Roese msk <<= 1; 110a47a12beSStefan Roese iopc++; 111a47a12beSStefan Roese } 112a47a12beSStefan Roese 113a47a12beSStefan Roese if (pmsk != 0) { 114a47a12beSStefan Roese volatile ioport_t *iop = ioport_addr (cpm, portnum); 115a47a12beSStefan Roese uint tpmsk = ~pmsk; 116a47a12beSStefan Roese 117a47a12beSStefan Roese /* 118a47a12beSStefan Roese * the (somewhat confused) paragraph at the 119a47a12beSStefan Roese * bottom of page 35-5 warns that there might 120a47a12beSStefan Roese * be "unknown behaviour" when programming 121a47a12beSStefan Roese * PSORx and PDIRx, if PPARx = 1, so I 122a47a12beSStefan Roese * decided this meant I had to disable the 123a47a12beSStefan Roese * dedicated function first, and enable it 124a47a12beSStefan Roese * last. 125a47a12beSStefan Roese */ 126a47a12beSStefan Roese iop->ppar &= tpmsk; 127a47a12beSStefan Roese iop->psor = (iop->psor & tpmsk) | psor; 128a47a12beSStefan Roese iop->podr = (iop->podr & tpmsk) | podr; 129a47a12beSStefan Roese iop->pdat = (iop->pdat & tpmsk) | pdat; 130a47a12beSStefan Roese iop->pdir = (iop->pdir & tpmsk) | pdir; 131a47a12beSStefan Roese iop->ppar |= ppar; 132a47a12beSStefan Roese } 133a47a12beSStefan Roese } 134a47a12beSStefan Roese } 135a47a12beSStefan Roese #endif 136a47a12beSStefan Roese 1376aba33e9SKumar Gala #ifdef CONFIG_SYS_FSL_CPC 1386aba33e9SKumar Gala static void enable_cpc(void) 1396aba33e9SKumar Gala { 1406aba33e9SKumar Gala int i; 1416aba33e9SKumar Gala u32 size = 0; 1426aba33e9SKumar Gala 1436aba33e9SKumar Gala cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR; 1446aba33e9SKumar Gala 1456aba33e9SKumar Gala for (i = 0; i < CONFIG_SYS_NUM_CPC; i++, cpc++) { 1466aba33e9SKumar Gala u32 cpccfg0 = in_be32(&cpc->cpccfg0); 1476aba33e9SKumar Gala size += CPC_CFG0_SZ_K(cpccfg0); 1482a9fab82SShaohui Xie #ifdef CONFIG_RAMBOOT_PBL 1492a9fab82SShaohui Xie if (in_be32(&cpc->cpcsrcr0) & CPC_SRCR0_SRAMEN) { 1502a9fab82SShaohui Xie /* find and disable LAW of SRAM */ 1512a9fab82SShaohui Xie struct law_entry law = find_law(CONFIG_SYS_INIT_L3_ADDR); 1522a9fab82SShaohui Xie 1532a9fab82SShaohui Xie if (law.index == -1) { 1542a9fab82SShaohui Xie printf("\nFatal error happened\n"); 1552a9fab82SShaohui Xie return; 1562a9fab82SShaohui Xie } 1572a9fab82SShaohui Xie disable_law(law.index); 1582a9fab82SShaohui Xie 1592a9fab82SShaohui Xie clrbits_be32(&cpc->cpchdbcr0, CPC_HDBCR0_CDQ_SPEC_DIS); 1602a9fab82SShaohui Xie out_be32(&cpc->cpccsr0, 0); 1612a9fab82SShaohui Xie out_be32(&cpc->cpcsrcr0, 0); 1622a9fab82SShaohui Xie } 1632a9fab82SShaohui Xie #endif 1646aba33e9SKumar Gala 1651d2c2a62SKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A002 1661d2c2a62SKumar Gala setbits_be32(&cpc->cpchdbcr0, CPC_HDBCR0_TAG_ECC_SCRUB_DIS); 1671d2c2a62SKumar Gala #endif 168868da593SKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A003 169868da593SKumar Gala setbits_be32(&cpc->cpchdbcr0, CPC_HDBCR0_DATA_ECC_SCRUB_DIS); 170868da593SKumar Gala #endif 1711d2c2a62SKumar Gala 1726aba33e9SKumar Gala out_be32(&cpc->cpccsr0, CPC_CSR0_CE | CPC_CSR0_PE); 1736aba33e9SKumar Gala /* Read back to sync write */ 1746aba33e9SKumar Gala in_be32(&cpc->cpccsr0); 1756aba33e9SKumar Gala 1766aba33e9SKumar Gala } 1776aba33e9SKumar Gala 1786aba33e9SKumar Gala printf("Corenet Platform Cache: %d KB enabled\n", size); 1796aba33e9SKumar Gala } 1806aba33e9SKumar Gala 1816aba33e9SKumar Gala void invalidate_cpc(void) 1826aba33e9SKumar Gala { 1836aba33e9SKumar Gala int i; 1846aba33e9SKumar Gala cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR; 1856aba33e9SKumar Gala 1866aba33e9SKumar Gala for (i = 0; i < CONFIG_SYS_NUM_CPC; i++, cpc++) { 1872a9fab82SShaohui Xie /* skip CPC when it used as all SRAM */ 1882a9fab82SShaohui Xie if (in_be32(&cpc->cpcsrcr0) & CPC_SRCR0_SRAMEN) 1892a9fab82SShaohui Xie continue; 1906aba33e9SKumar Gala /* Flash invalidate the CPC and clear all the locks */ 1916aba33e9SKumar Gala out_be32(&cpc->cpccsr0, CPC_CSR0_FI | CPC_CSR0_LFC); 1926aba33e9SKumar Gala while (in_be32(&cpc->cpccsr0) & (CPC_CSR0_FI | CPC_CSR0_LFC)) 1936aba33e9SKumar Gala ; 1946aba33e9SKumar Gala } 1956aba33e9SKumar Gala } 1966aba33e9SKumar Gala #else 1976aba33e9SKumar Gala #define enable_cpc() 1986aba33e9SKumar Gala #define invalidate_cpc() 1996aba33e9SKumar Gala #endif /* CONFIG_SYS_FSL_CPC */ 2006aba33e9SKumar Gala 201a47a12beSStefan Roese /* 202a47a12beSStefan Roese * Breathe some life into the CPU... 203a47a12beSStefan Roese * 204a47a12beSStefan Roese * Set up the memory map 205a47a12beSStefan Roese * initialize a bunch of registers 206a47a12beSStefan Roese */ 207a47a12beSStefan Roese 208a47a12beSStefan Roese #ifdef CONFIG_FSL_CORENET 209a47a12beSStefan Roese static void corenet_tb_init(void) 210a47a12beSStefan Roese { 211a47a12beSStefan Roese volatile ccsr_rcpm_t *rcpm = 212a47a12beSStefan Roese (void *)(CONFIG_SYS_FSL_CORENET_RCPM_ADDR); 213a47a12beSStefan Roese volatile ccsr_pic_t *pic = 214680c613aSKim Phillips (void *)(CONFIG_SYS_MPC8xxx_PIC_ADDR); 215a47a12beSStefan Roese u32 whoami = in_be32(&pic->whoami); 216a47a12beSStefan Roese 217a47a12beSStefan Roese /* Enable the timebase register for this core */ 218a47a12beSStefan Roese out_be32(&rcpm->ctbenrl, (1 << whoami)); 219a47a12beSStefan Roese } 220a47a12beSStefan Roese #endif 221a47a12beSStefan Roese 222a47a12beSStefan Roese void cpu_init_f (void) 223a47a12beSStefan Roese { 224a47a12beSStefan Roese extern void m8560_cpm_reset (void); 225f110fe94SStephen George #ifdef CONFIG_SYS_DCSRBAR_PHYS 226f110fe94SStephen George ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); 227f110fe94SStephen George #endif 228f110fe94SStephen George 229a47a12beSStefan Roese #ifdef CONFIG_MPC8548 230a47a12beSStefan Roese ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR); 231a47a12beSStefan Roese uint svr = get_svr(); 232a47a12beSStefan Roese 233a47a12beSStefan Roese /* 234a47a12beSStefan Roese * CPU2 errata workaround: A core hang possible while executing 235a47a12beSStefan Roese * a msync instruction and a snoopable transaction from an I/O 236a47a12beSStefan Roese * master tagged to make quick forward progress is present. 237a47a12beSStefan Roese * Fixed in silicon rev 2.1. 238a47a12beSStefan Roese */ 239a47a12beSStefan Roese if ((SVR_MAJ(svr) == 1) || ((SVR_MAJ(svr) == 2 && SVR_MIN(svr) == 0x0))) 240a47a12beSStefan Roese out_be32(&ecm->eebpcr, in_be32(&ecm->eebpcr) | (1 << 16)); 241a47a12beSStefan Roese #endif 242a47a12beSStefan Roese 243a47a12beSStefan Roese disable_tlb(14); 244a47a12beSStefan Roese disable_tlb(15); 245a47a12beSStefan Roese 246a47a12beSStefan Roese #ifdef CONFIG_CPM2 247a47a12beSStefan Roese config_8560_ioports((ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR); 248a47a12beSStefan Roese #endif 249a47a12beSStefan Roese 250f51cdaf1SBecky Bruce init_early_memctl_regs(); 251a47a12beSStefan Roese 252a47a12beSStefan Roese #if defined(CONFIG_CPM2) 253a47a12beSStefan Roese m8560_cpm_reset(); 254a47a12beSStefan Roese #endif 255a47a12beSStefan Roese #ifdef CONFIG_QE 256a47a12beSStefan Roese /* Config QE ioports */ 257a47a12beSStefan Roese config_qe_ioports(); 258a47a12beSStefan Roese #endif 259a47a12beSStefan Roese #if defined(CONFIG_FSL_DMA) 260a47a12beSStefan Roese dma_init(); 261a47a12beSStefan Roese #endif 262a47a12beSStefan Roese #ifdef CONFIG_FSL_CORENET 263a47a12beSStefan Roese corenet_tb_init(); 264a47a12beSStefan Roese #endif 265a47a12beSStefan Roese init_used_tlb_cams(); 2666aba33e9SKumar Gala 2676aba33e9SKumar Gala /* Invalidate the CPC before DDR gets enabled */ 2686aba33e9SKumar Gala invalidate_cpc(); 269f110fe94SStephen George 270f110fe94SStephen George #ifdef CONFIG_SYS_DCSRBAR_PHYS 271f110fe94SStephen George /* set DCSRCR so that DCSR space is 1G */ 272f110fe94SStephen George setbits_be32(&gur->dcsrcr, FSL_CORENET_DCSR_SZ_1G); 273f110fe94SStephen George in_be32(&gur->dcsrcr); 274f110fe94SStephen George #endif 275f110fe94SStephen George 276a47a12beSStefan Roese } 277a47a12beSStefan Roese 27835079aa9SKumar Gala /* Implement a dummy function for those platforms w/o SERDES */ 27935079aa9SKumar Gala static void __fsl_serdes__init(void) 28035079aa9SKumar Gala { 28135079aa9SKumar Gala return ; 28235079aa9SKumar Gala } 28335079aa9SKumar Gala __attribute__((weak, alias("__fsl_serdes__init"))) void fsl_serdes_init(void); 284a47a12beSStefan Roese 285a47a12beSStefan Roese /* 286a47a12beSStefan Roese * Initialize L2 as cache. 287a47a12beSStefan Roese * 288a47a12beSStefan Roese * The newer 8548, etc, parts have twice as much cache, but 289a47a12beSStefan Roese * use the same bit-encoding as the older 8555, etc, parts. 290a47a12beSStefan Roese * 291a47a12beSStefan Roese */ 292a47a12beSStefan Roese int cpu_init_r(void) 293a47a12beSStefan Roese { 2943f0202edSLan Chunhe #ifdef CONFIG_SYS_LBC_LCRR 295f51cdaf1SBecky Bruce volatile fsl_lbc_t *lbc = LBC_BASE_ADDR; 2963f0202edSLan Chunhe #endif 2973f0202edSLan Chunhe 298fd3c9befSKumar Gala #if defined(CONFIG_SYS_P4080_ERRATUM_CPU22) 299fd3c9befSKumar Gala flush_dcache(); 300fd3c9befSKumar Gala mtspr(L1CSR2, (mfspr(L1CSR2) | L1CSR2_DCWS)); 301fd3c9befSKumar Gala sync(); 302fd3c9befSKumar Gala #endif 303fd3c9befSKumar Gala 304a47a12beSStefan Roese puts ("L2: "); 305a47a12beSStefan Roese 306a47a12beSStefan Roese #if defined(CONFIG_L2_CACHE) 307a47a12beSStefan Roese volatile ccsr_l2cache_t *l2cache = (void *)CONFIG_SYS_MPC85xx_L2_ADDR; 308a47a12beSStefan Roese volatile uint cache_ctl; 309a47a12beSStefan Roese uint svr, ver; 310a47a12beSStefan Roese uint l2srbar; 311a47a12beSStefan Roese u32 l2siz_field; 312a47a12beSStefan Roese 313a47a12beSStefan Roese svr = get_svr(); 314a47a12beSStefan Roese ver = SVR_SOC_VER(svr); 315a47a12beSStefan Roese 316a47a12beSStefan Roese asm("msync;isync"); 317a47a12beSStefan Roese cache_ctl = l2cache->l2ctl; 318a47a12beSStefan Roese 319a47a12beSStefan Roese #if defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_SYS_INIT_L2_ADDR) 320a47a12beSStefan Roese if (cache_ctl & MPC85xx_L2CTL_L2E) { 321a47a12beSStefan Roese /* Clear L2 SRAM memory-mapped base address */ 322a47a12beSStefan Roese out_be32(&l2cache->l2srbar0, 0x0); 323a47a12beSStefan Roese out_be32(&l2cache->l2srbar1, 0x0); 324a47a12beSStefan Roese 325a47a12beSStefan Roese /* set MBECCDIS=0, SBECCDIS=0 */ 326a47a12beSStefan Roese clrbits_be32(&l2cache->l2errdis, 327a47a12beSStefan Roese (MPC85xx_L2ERRDIS_MBECC | 328a47a12beSStefan Roese MPC85xx_L2ERRDIS_SBECC)); 329a47a12beSStefan Roese 330a47a12beSStefan Roese /* set L2E=0, L2SRAM=0 */ 331a47a12beSStefan Roese clrbits_be32(&l2cache->l2ctl, 332a47a12beSStefan Roese (MPC85xx_L2CTL_L2E | 333a47a12beSStefan Roese MPC85xx_L2CTL_L2SRAM_ENTIRE)); 334a47a12beSStefan Roese } 335a47a12beSStefan Roese #endif 336a47a12beSStefan Roese 337a47a12beSStefan Roese l2siz_field = (cache_ctl >> 28) & 0x3; 338a47a12beSStefan Roese 339a47a12beSStefan Roese switch (l2siz_field) { 340a47a12beSStefan Roese case 0x0: 341a47a12beSStefan Roese printf(" unknown size (0x%08x)\n", cache_ctl); 342a47a12beSStefan Roese return -1; 343a47a12beSStefan Roese break; 344a47a12beSStefan Roese case 0x1: 345a47a12beSStefan Roese if (ver == SVR_8540 || ver == SVR_8560 || 346a47a12beSStefan Roese ver == SVR_8541 || ver == SVR_8541_E || 347a47a12beSStefan Roese ver == SVR_8555 || ver == SVR_8555_E) { 348a47a12beSStefan Roese puts("128 KB "); 349a47a12beSStefan Roese /* set L2E=1, L2I=1, & L2BLKSZ=1 (128 Kbyte) */ 350a47a12beSStefan Roese cache_ctl = 0xc4000000; 351a47a12beSStefan Roese } else { 352a47a12beSStefan Roese puts("256 KB "); 353a47a12beSStefan Roese cache_ctl = 0xc0000000; /* set L2E=1, L2I=1, & L2SRAM=0 */ 354a47a12beSStefan Roese } 355a47a12beSStefan Roese break; 356a47a12beSStefan Roese case 0x2: 357a47a12beSStefan Roese if (ver == SVR_8540 || ver == SVR_8560 || 358a47a12beSStefan Roese ver == SVR_8541 || ver == SVR_8541_E || 359a47a12beSStefan Roese ver == SVR_8555 || ver == SVR_8555_E) { 360a47a12beSStefan Roese puts("256 KB "); 361a47a12beSStefan Roese /* set L2E=1, L2I=1, & L2BLKSZ=2 (256 Kbyte) */ 362a47a12beSStefan Roese cache_ctl = 0xc8000000; 363a47a12beSStefan Roese } else { 364a47a12beSStefan Roese puts ("512 KB "); 365a47a12beSStefan Roese /* set L2E=1, L2I=1, & L2SRAM=0 */ 366a47a12beSStefan Roese cache_ctl = 0xc0000000; 367a47a12beSStefan Roese } 368a47a12beSStefan Roese break; 369a47a12beSStefan Roese case 0x3: 370a47a12beSStefan Roese puts("1024 KB "); 371a47a12beSStefan Roese /* set L2E=1, L2I=1, & L2SRAM=0 */ 372a47a12beSStefan Roese cache_ctl = 0xc0000000; 373a47a12beSStefan Roese break; 374a47a12beSStefan Roese } 375a47a12beSStefan Roese 376a47a12beSStefan Roese if (l2cache->l2ctl & MPC85xx_L2CTL_L2E) { 377a47a12beSStefan Roese puts("already enabled"); 378a47a12beSStefan Roese l2srbar = l2cache->l2srbar0; 379888279b5SHaiying Wang #if defined(CONFIG_SYS_INIT_L2_ADDR) && defined(CONFIG_SYS_FLASH_BASE) 380a47a12beSStefan Roese if (l2cache->l2ctl & MPC85xx_L2CTL_L2SRAM_ENTIRE 381a47a12beSStefan Roese && l2srbar >= CONFIG_SYS_FLASH_BASE) { 382a47a12beSStefan Roese l2srbar = CONFIG_SYS_INIT_L2_ADDR; 383a47a12beSStefan Roese l2cache->l2srbar0 = l2srbar; 384a47a12beSStefan Roese printf("moving to 0x%08x", CONFIG_SYS_INIT_L2_ADDR); 385a47a12beSStefan Roese } 386a47a12beSStefan Roese #endif /* CONFIG_SYS_INIT_L2_ADDR */ 387a47a12beSStefan Roese puts("\n"); 388a47a12beSStefan Roese } else { 389a47a12beSStefan Roese asm("msync;isync"); 390a47a12beSStefan Roese l2cache->l2ctl = cache_ctl; /* invalidate & enable */ 391a47a12beSStefan Roese asm("msync;isync"); 392a47a12beSStefan Roese puts("enabled\n"); 393a47a12beSStefan Roese } 394a47a12beSStefan Roese #elif defined(CONFIG_BACKSIDE_L2_CACHE) 395*acf3f8daSKumar Gala if ((SVR_SOC_VER(get_svr()) == SVR_P2040) || 396*acf3f8daSKumar Gala (SVR_SOC_VER(get_svr()) == SVR_P2040_E)) { 397*acf3f8daSKumar Gala puts("N/A\n"); 398*acf3f8daSKumar Gala goto skip_l2; 399*acf3f8daSKumar Gala } 400*acf3f8daSKumar Gala 401a47a12beSStefan Roese u32 l2cfg0 = mfspr(SPRN_L2CFG0); 402a47a12beSStefan Roese 403a47a12beSStefan Roese /* invalidate the L2 cache */ 404a47a12beSStefan Roese mtspr(SPRN_L2CSR0, (L2CSR0_L2FI|L2CSR0_L2LFC)); 405a47a12beSStefan Roese while (mfspr(SPRN_L2CSR0) & (L2CSR0_L2FI|L2CSR0_L2LFC)) 406a47a12beSStefan Roese ; 407a47a12beSStefan Roese 408a47a12beSStefan Roese #ifdef CONFIG_SYS_CACHE_STASHING 409a47a12beSStefan Roese /* set stash id to (coreID) * 2 + 32 + L2 (1) */ 410a47a12beSStefan Roese mtspr(SPRN_L2CSR1, (32 + 1)); 411a47a12beSStefan Roese #endif 412a47a12beSStefan Roese 413a47a12beSStefan Roese /* enable the cache */ 414a47a12beSStefan Roese mtspr(SPRN_L2CSR0, CONFIG_SYS_INIT_L2CSR0); 415a47a12beSStefan Roese 416a47a12beSStefan Roese if (CONFIG_SYS_INIT_L2CSR0 & L2CSR0_L2E) { 417a47a12beSStefan Roese while (!(mfspr(SPRN_L2CSR0) & L2CSR0_L2E)) 418a47a12beSStefan Roese ; 419a47a12beSStefan Roese printf("%d KB enabled\n", (l2cfg0 & 0x3fff) * 64); 420a47a12beSStefan Roese } 421*acf3f8daSKumar Gala 422*acf3f8daSKumar Gala skip_l2: 423a47a12beSStefan Roese #else 424a47a12beSStefan Roese puts("disabled\n"); 425a47a12beSStefan Roese #endif 4266aba33e9SKumar Gala 4276aba33e9SKumar Gala enable_cpc(); 4286aba33e9SKumar Gala 429af025065SKumar Gala /* needs to be in ram since code uses global static vars */ 430af025065SKumar Gala fsl_serdes_init(); 431af025065SKumar Gala 432a09b9b68SKumar Gala #ifdef CONFIG_SYS_SRIO 433a09b9b68SKumar Gala srio_init(); 434a09b9b68SKumar Gala #endif 435a09b9b68SKumar Gala 436a47a12beSStefan Roese #if defined(CONFIG_MP) 437a47a12beSStefan Roese setup_mp(); 438a47a12beSStefan Roese #endif 4393f0202edSLan Chunhe 440ae026ffdSRoy Zang #ifdef CONFIG_SYS_FSL_ERRATUM_ESDHC136 441ae026ffdSRoy Zang { 442ae026ffdSRoy Zang void *p; 443ae026ffdSRoy Zang p = (void *)CONFIG_SYS_DCSRBAR + 0x20520; 444ae026ffdSRoy Zang setbits_be32(p, 1 << (31 - 14)); 445ae026ffdSRoy Zang } 446ae026ffdSRoy Zang #endif 447ae026ffdSRoy Zang 4483f0202edSLan Chunhe #ifdef CONFIG_SYS_LBC_LCRR 4493f0202edSLan Chunhe /* 4503f0202edSLan Chunhe * Modify the CLKDIV field of LCRR register to improve the writing 4513f0202edSLan Chunhe * speed for NOR flash. 4523f0202edSLan Chunhe */ 4533f0202edSLan Chunhe clrsetbits_be32(&lbc->lcrr, LCRR_CLKDIV, CONFIG_SYS_LBC_LCRR); 4543f0202edSLan Chunhe __raw_readl(&lbc->lcrr); 4553f0202edSLan Chunhe isync(); 4563f0202edSLan Chunhe #endif 4573f0202edSLan Chunhe 45886221f09SRoy Zang #ifdef CONFIG_SYS_FSL_USB1_PHY_ENABLE 45986221f09SRoy Zang { 46086221f09SRoy Zang ccsr_usb_phy_t *usb_phy1 = 46186221f09SRoy Zang (void *)CONFIG_SYS_MPC85xx_USB1_PHY_ADDR; 46286221f09SRoy Zang out_be32(&usb_phy1->usb_enable_override, 46386221f09SRoy Zang CONFIG_SYS_FSL_USB_ENABLE_OVERRIDE); 46486221f09SRoy Zang } 46586221f09SRoy Zang #endif 46686221f09SRoy Zang #ifdef CONFIG_SYS_FSL_USB2_PHY_ENABLE 46786221f09SRoy Zang { 46886221f09SRoy Zang ccsr_usb_phy_t *usb_phy2 = 46986221f09SRoy Zang (void *)CONFIG_SYS_MPC85xx_USB2_PHY_ADDR; 47086221f09SRoy Zang out_be32(&usb_phy2->usb_enable_override, 47186221f09SRoy Zang CONFIG_SYS_FSL_USB_ENABLE_OVERRIDE); 47286221f09SRoy Zang } 47386221f09SRoy Zang #endif 47486221f09SRoy Zang 475a47a12beSStefan Roese return 0; 476a47a12beSStefan Roese } 477a47a12beSStefan Roese 478a47a12beSStefan Roese extern void setup_ivors(void); 479a47a12beSStefan Roese 480a47a12beSStefan Roese void arch_preboot_os(void) 481a47a12beSStefan Roese { 482a47a12beSStefan Roese u32 msr; 483a47a12beSStefan Roese 484a47a12beSStefan Roese /* 485a47a12beSStefan Roese * We are changing interrupt offsets and are about to boot the OS so 486a47a12beSStefan Roese * we need to make sure we disable all async interrupts. EE is already 487a47a12beSStefan Roese * disabled by the time we get called. 488a47a12beSStefan Roese */ 489a47a12beSStefan Roese msr = mfmsr(); 490a47a12beSStefan Roese msr &= ~(MSR_ME|MSR_CE|MSR_DE); 491a47a12beSStefan Roese mtmsr(msr); 492a47a12beSStefan Roese 493a47a12beSStefan Roese setup_ivors(); 494a47a12beSStefan Roese } 495f54fe87aSKumar Gala 496f54fe87aSKumar Gala #if defined(CONFIG_CMD_SATA) && defined(CONFIG_FSL_SATA) 497f54fe87aSKumar Gala int sata_initialize(void) 498f54fe87aSKumar Gala { 499f54fe87aSKumar Gala if (is_serdes_configured(SATA1) || is_serdes_configured(SATA2)) 500f54fe87aSKumar Gala return __sata_initialize(); 501f54fe87aSKumar Gala 502f54fe87aSKumar Gala return 1; 503f54fe87aSKumar Gala } 504f54fe87aSKumar Gala #endif 505f9a33f1cSKumar Gala 506f9a33f1cSKumar Gala void cpu_secondary_init_r(void) 507f9a33f1cSKumar Gala { 508f9a33f1cSKumar Gala #ifdef CONFIG_QE 509f9a33f1cSKumar Gala uint qe_base = CONFIG_SYS_IMMR + 0x00080000; /* QE immr base */ 510a7b1e1b7SHaiying Wang #ifdef CONFIG_SYS_QE_FW_IN_NAND 511a7b1e1b7SHaiying Wang int ret; 512a7b1e1b7SHaiying Wang size_t fw_length = CONFIG_SYS_QE_FW_LENGTH; 513a7b1e1b7SHaiying Wang 514a7b1e1b7SHaiying Wang /* load QE firmware from NAND flash to DDR first */ 515a7b1e1b7SHaiying Wang ret = nand_read(&nand_info[0], (loff_t)CONFIG_SYS_QE_FW_IN_NAND, 516a7b1e1b7SHaiying Wang &fw_length, (u_char *)CONFIG_SYS_QE_FW_ADDR); 517a7b1e1b7SHaiying Wang 518a7b1e1b7SHaiying Wang if (ret && ret == -EUCLEAN) { 519a7b1e1b7SHaiying Wang printf ("NAND read for QE firmware at offset %x failed %d\n", 520a7b1e1b7SHaiying Wang CONFIG_SYS_QE_FW_IN_NAND, ret); 521a7b1e1b7SHaiying Wang } 522a7b1e1b7SHaiying Wang #endif 523f9a33f1cSKumar Gala qe_init(qe_base); 524f9a33f1cSKumar Gala qe_reset(); 525f9a33f1cSKumar Gala #endif 526f9a33f1cSKumar Gala } 527