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" 40a47a12beSStefan Roese 41a47a12beSStefan Roese DECLARE_GLOBAL_DATA_PTR; 42a47a12beSStefan Roese 43a09b9b68SKumar Gala extern void srio_init(void); 44a09b9b68SKumar Gala 45a47a12beSStefan Roese #ifdef CONFIG_QE 46a47a12beSStefan Roese extern qe_iop_conf_t qe_iop_conf_tab[]; 47a47a12beSStefan Roese extern void qe_config_iopin(u8 port, u8 pin, int dir, 48a47a12beSStefan Roese int open_drain, int assign); 49a47a12beSStefan Roese extern void qe_init(uint qe_base); 50a47a12beSStefan Roese extern void qe_reset(void); 51a47a12beSStefan Roese 52a47a12beSStefan Roese static void config_qe_ioports(void) 53a47a12beSStefan Roese { 54a47a12beSStefan Roese u8 port, pin; 55a47a12beSStefan Roese int dir, open_drain, assign; 56a47a12beSStefan Roese int i; 57a47a12beSStefan Roese 58a47a12beSStefan Roese for (i = 0; qe_iop_conf_tab[i].assign != QE_IOP_TAB_END; i++) { 59a47a12beSStefan Roese port = qe_iop_conf_tab[i].port; 60a47a12beSStefan Roese pin = qe_iop_conf_tab[i].pin; 61a47a12beSStefan Roese dir = qe_iop_conf_tab[i].dir; 62a47a12beSStefan Roese open_drain = qe_iop_conf_tab[i].open_drain; 63a47a12beSStefan Roese assign = qe_iop_conf_tab[i].assign; 64a47a12beSStefan Roese qe_config_iopin(port, pin, dir, open_drain, assign); 65a47a12beSStefan Roese } 66a47a12beSStefan Roese } 67a47a12beSStefan Roese #endif 68a47a12beSStefan Roese 69a47a12beSStefan Roese #ifdef CONFIG_CPM2 70a47a12beSStefan Roese void config_8560_ioports (volatile ccsr_cpm_t * cpm) 71a47a12beSStefan Roese { 72a47a12beSStefan Roese int portnum; 73a47a12beSStefan Roese 74a47a12beSStefan Roese for (portnum = 0; portnum < 4; portnum++) { 75a47a12beSStefan Roese uint pmsk = 0, 76a47a12beSStefan Roese ppar = 0, 77a47a12beSStefan Roese psor = 0, 78a47a12beSStefan Roese pdir = 0, 79a47a12beSStefan Roese podr = 0, 80a47a12beSStefan Roese pdat = 0; 81a47a12beSStefan Roese iop_conf_t *iopc = (iop_conf_t *) & iop_conf_tab[portnum][0]; 82a47a12beSStefan Roese iop_conf_t *eiopc = iopc + 32; 83a47a12beSStefan Roese uint msk = 1; 84a47a12beSStefan Roese 85a47a12beSStefan Roese /* 86a47a12beSStefan Roese * NOTE: 87a47a12beSStefan Roese * index 0 refers to pin 31, 88a47a12beSStefan Roese * index 31 refers to pin 0 89a47a12beSStefan Roese */ 90a47a12beSStefan Roese while (iopc < eiopc) { 91a47a12beSStefan Roese if (iopc->conf) { 92a47a12beSStefan Roese pmsk |= msk; 93a47a12beSStefan Roese if (iopc->ppar) 94a47a12beSStefan Roese ppar |= msk; 95a47a12beSStefan Roese if (iopc->psor) 96a47a12beSStefan Roese psor |= msk; 97a47a12beSStefan Roese if (iopc->pdir) 98a47a12beSStefan Roese pdir |= msk; 99a47a12beSStefan Roese if (iopc->podr) 100a47a12beSStefan Roese podr |= msk; 101a47a12beSStefan Roese if (iopc->pdat) 102a47a12beSStefan Roese pdat |= msk; 103a47a12beSStefan Roese } 104a47a12beSStefan Roese 105a47a12beSStefan Roese msk <<= 1; 106a47a12beSStefan Roese iopc++; 107a47a12beSStefan Roese } 108a47a12beSStefan Roese 109a47a12beSStefan Roese if (pmsk != 0) { 110a47a12beSStefan Roese volatile ioport_t *iop = ioport_addr (cpm, portnum); 111a47a12beSStefan Roese uint tpmsk = ~pmsk; 112a47a12beSStefan Roese 113a47a12beSStefan Roese /* 114a47a12beSStefan Roese * the (somewhat confused) paragraph at the 115a47a12beSStefan Roese * bottom of page 35-5 warns that there might 116a47a12beSStefan Roese * be "unknown behaviour" when programming 117a47a12beSStefan Roese * PSORx and PDIRx, if PPARx = 1, so I 118a47a12beSStefan Roese * decided this meant I had to disable the 119a47a12beSStefan Roese * dedicated function first, and enable it 120a47a12beSStefan Roese * last. 121a47a12beSStefan Roese */ 122a47a12beSStefan Roese iop->ppar &= tpmsk; 123a47a12beSStefan Roese iop->psor = (iop->psor & tpmsk) | psor; 124a47a12beSStefan Roese iop->podr = (iop->podr & tpmsk) | podr; 125a47a12beSStefan Roese iop->pdat = (iop->pdat & tpmsk) | pdat; 126a47a12beSStefan Roese iop->pdir = (iop->pdir & tpmsk) | pdir; 127a47a12beSStefan Roese iop->ppar |= ppar; 128a47a12beSStefan Roese } 129a47a12beSStefan Roese } 130a47a12beSStefan Roese } 131a47a12beSStefan Roese #endif 132a47a12beSStefan Roese 1336aba33e9SKumar Gala #ifdef CONFIG_SYS_FSL_CPC 1346aba33e9SKumar Gala static void enable_cpc(void) 1356aba33e9SKumar Gala { 1366aba33e9SKumar Gala int i; 1376aba33e9SKumar Gala u32 size = 0; 1386aba33e9SKumar Gala 1396aba33e9SKumar Gala cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR; 1406aba33e9SKumar Gala 1416aba33e9SKumar Gala for (i = 0; i < CONFIG_SYS_NUM_CPC; i++, cpc++) { 1426aba33e9SKumar Gala u32 cpccfg0 = in_be32(&cpc->cpccfg0); 1436aba33e9SKumar Gala size += CPC_CFG0_SZ_K(cpccfg0); 1446aba33e9SKumar Gala 145*1d2c2a62SKumar Gala #ifdef CONFIG_SYS_FSL_ERRATUM_CPC_A002 146*1d2c2a62SKumar Gala setbits_be32(&cpc->cpchdbcr0, CPC_HDBCR0_TAG_ECC_SCRUB_DIS); 147*1d2c2a62SKumar Gala #endif 148*1d2c2a62SKumar Gala 1496aba33e9SKumar Gala out_be32(&cpc->cpccsr0, CPC_CSR0_CE | CPC_CSR0_PE); 1506aba33e9SKumar Gala /* Read back to sync write */ 1516aba33e9SKumar Gala in_be32(&cpc->cpccsr0); 1526aba33e9SKumar Gala 1536aba33e9SKumar Gala } 1546aba33e9SKumar Gala 1556aba33e9SKumar Gala printf("Corenet Platform Cache: %d KB enabled\n", size); 1566aba33e9SKumar Gala } 1576aba33e9SKumar Gala 1586aba33e9SKumar Gala void invalidate_cpc(void) 1596aba33e9SKumar Gala { 1606aba33e9SKumar Gala int i; 1616aba33e9SKumar Gala cpc_corenet_t *cpc = (cpc_corenet_t *)CONFIG_SYS_FSL_CPC_ADDR; 1626aba33e9SKumar Gala 1636aba33e9SKumar Gala for (i = 0; i < CONFIG_SYS_NUM_CPC; i++, cpc++) { 1646aba33e9SKumar Gala /* Flash invalidate the CPC and clear all the locks */ 1656aba33e9SKumar Gala out_be32(&cpc->cpccsr0, CPC_CSR0_FI | CPC_CSR0_LFC); 1666aba33e9SKumar Gala while (in_be32(&cpc->cpccsr0) & (CPC_CSR0_FI | CPC_CSR0_LFC)) 1676aba33e9SKumar Gala ; 1686aba33e9SKumar Gala } 1696aba33e9SKumar Gala } 1706aba33e9SKumar Gala #else 1716aba33e9SKumar Gala #define enable_cpc() 1726aba33e9SKumar Gala #define invalidate_cpc() 1736aba33e9SKumar Gala #endif /* CONFIG_SYS_FSL_CPC */ 1746aba33e9SKumar Gala 175a47a12beSStefan Roese /* 176a47a12beSStefan Roese * Breathe some life into the CPU... 177a47a12beSStefan Roese * 178a47a12beSStefan Roese * Set up the memory map 179a47a12beSStefan Roese * initialize a bunch of registers 180a47a12beSStefan Roese */ 181a47a12beSStefan Roese 182a47a12beSStefan Roese #ifdef CONFIG_FSL_CORENET 183a47a12beSStefan Roese static void corenet_tb_init(void) 184a47a12beSStefan Roese { 185a47a12beSStefan Roese volatile ccsr_rcpm_t *rcpm = 186a47a12beSStefan Roese (void *)(CONFIG_SYS_FSL_CORENET_RCPM_ADDR); 187a47a12beSStefan Roese volatile ccsr_pic_t *pic = 188680c613aSKim Phillips (void *)(CONFIG_SYS_MPC8xxx_PIC_ADDR); 189a47a12beSStefan Roese u32 whoami = in_be32(&pic->whoami); 190a47a12beSStefan Roese 191a47a12beSStefan Roese /* Enable the timebase register for this core */ 192a47a12beSStefan Roese out_be32(&rcpm->ctbenrl, (1 << whoami)); 193a47a12beSStefan Roese } 194a47a12beSStefan Roese #endif 195a47a12beSStefan Roese 196a47a12beSStefan Roese void cpu_init_f (void) 197a47a12beSStefan Roese { 198a47a12beSStefan Roese extern void m8560_cpm_reset (void); 199a47a12beSStefan Roese #ifdef CONFIG_MPC8548 200a47a12beSStefan Roese ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR); 201a47a12beSStefan Roese uint svr = get_svr(); 202a47a12beSStefan Roese 203a47a12beSStefan Roese /* 204a47a12beSStefan Roese * CPU2 errata workaround: A core hang possible while executing 205a47a12beSStefan Roese * a msync instruction and a snoopable transaction from an I/O 206a47a12beSStefan Roese * master tagged to make quick forward progress is present. 207a47a12beSStefan Roese * Fixed in silicon rev 2.1. 208a47a12beSStefan Roese */ 209a47a12beSStefan Roese if ((SVR_MAJ(svr) == 1) || ((SVR_MAJ(svr) == 2 && SVR_MIN(svr) == 0x0))) 210a47a12beSStefan Roese out_be32(&ecm->eebpcr, in_be32(&ecm->eebpcr) | (1 << 16)); 211a47a12beSStefan Roese #endif 212a47a12beSStefan Roese 213a47a12beSStefan Roese disable_tlb(14); 214a47a12beSStefan Roese disable_tlb(15); 215a47a12beSStefan Roese 216a47a12beSStefan Roese #ifdef CONFIG_CPM2 217a47a12beSStefan Roese config_8560_ioports((ccsr_cpm_t *)CONFIG_SYS_MPC85xx_CPM_ADDR); 218a47a12beSStefan Roese #endif 219a47a12beSStefan Roese 220f51cdaf1SBecky Bruce init_early_memctl_regs(); 221a47a12beSStefan Roese 222a47a12beSStefan Roese #if defined(CONFIG_CPM2) 223a47a12beSStefan Roese m8560_cpm_reset(); 224a47a12beSStefan Roese #endif 225a47a12beSStefan Roese #ifdef CONFIG_QE 226a47a12beSStefan Roese /* Config QE ioports */ 227a47a12beSStefan Roese config_qe_ioports(); 228a47a12beSStefan Roese #endif 229a47a12beSStefan Roese #if defined(CONFIG_FSL_DMA) 230a47a12beSStefan Roese dma_init(); 231a47a12beSStefan Roese #endif 232a47a12beSStefan Roese #ifdef CONFIG_FSL_CORENET 233a47a12beSStefan Roese corenet_tb_init(); 234a47a12beSStefan Roese #endif 235a47a12beSStefan Roese init_used_tlb_cams(); 2366aba33e9SKumar Gala 2376aba33e9SKumar Gala /* Invalidate the CPC before DDR gets enabled */ 2386aba33e9SKumar Gala invalidate_cpc(); 239a47a12beSStefan Roese } 240a47a12beSStefan Roese 24135079aa9SKumar Gala /* Implement a dummy function for those platforms w/o SERDES */ 24235079aa9SKumar Gala static void __fsl_serdes__init(void) 24335079aa9SKumar Gala { 24435079aa9SKumar Gala return ; 24535079aa9SKumar Gala } 24635079aa9SKumar Gala __attribute__((weak, alias("__fsl_serdes__init"))) void fsl_serdes_init(void); 247a47a12beSStefan Roese 248a47a12beSStefan Roese /* 249a47a12beSStefan Roese * Initialize L2 as cache. 250a47a12beSStefan Roese * 251a47a12beSStefan Roese * The newer 8548, etc, parts have twice as much cache, but 252a47a12beSStefan Roese * use the same bit-encoding as the older 8555, etc, parts. 253a47a12beSStefan Roese * 254a47a12beSStefan Roese */ 255a47a12beSStefan Roese int cpu_init_r(void) 256a47a12beSStefan Roese { 2573f0202edSLan Chunhe #ifdef CONFIG_SYS_LBC_LCRR 258f51cdaf1SBecky Bruce volatile fsl_lbc_t *lbc = LBC_BASE_ADDR; 2593f0202edSLan Chunhe #endif 2603f0202edSLan Chunhe 261fd3c9befSKumar Gala #if defined(CONFIG_SYS_P4080_ERRATUM_CPU22) 262fd3c9befSKumar Gala flush_dcache(); 263fd3c9befSKumar Gala mtspr(L1CSR2, (mfspr(L1CSR2) | L1CSR2_DCWS)); 264fd3c9befSKumar Gala sync(); 265fd3c9befSKumar Gala #endif 266fd3c9befSKumar Gala 267a47a12beSStefan Roese puts ("L2: "); 268a47a12beSStefan Roese 269a47a12beSStefan Roese #if defined(CONFIG_L2_CACHE) 270a47a12beSStefan Roese volatile ccsr_l2cache_t *l2cache = (void *)CONFIG_SYS_MPC85xx_L2_ADDR; 271a47a12beSStefan Roese volatile uint cache_ctl; 272a47a12beSStefan Roese uint svr, ver; 273a47a12beSStefan Roese uint l2srbar; 274a47a12beSStefan Roese u32 l2siz_field; 275a47a12beSStefan Roese 276a47a12beSStefan Roese svr = get_svr(); 277a47a12beSStefan Roese ver = SVR_SOC_VER(svr); 278a47a12beSStefan Roese 279a47a12beSStefan Roese asm("msync;isync"); 280a47a12beSStefan Roese cache_ctl = l2cache->l2ctl; 281a47a12beSStefan Roese 282a47a12beSStefan Roese #if defined(CONFIG_SYS_RAMBOOT) && defined(CONFIG_SYS_INIT_L2_ADDR) 283a47a12beSStefan Roese if (cache_ctl & MPC85xx_L2CTL_L2E) { 284a47a12beSStefan Roese /* Clear L2 SRAM memory-mapped base address */ 285a47a12beSStefan Roese out_be32(&l2cache->l2srbar0, 0x0); 286a47a12beSStefan Roese out_be32(&l2cache->l2srbar1, 0x0); 287a47a12beSStefan Roese 288a47a12beSStefan Roese /* set MBECCDIS=0, SBECCDIS=0 */ 289a47a12beSStefan Roese clrbits_be32(&l2cache->l2errdis, 290a47a12beSStefan Roese (MPC85xx_L2ERRDIS_MBECC | 291a47a12beSStefan Roese MPC85xx_L2ERRDIS_SBECC)); 292a47a12beSStefan Roese 293a47a12beSStefan Roese /* set L2E=0, L2SRAM=0 */ 294a47a12beSStefan Roese clrbits_be32(&l2cache->l2ctl, 295a47a12beSStefan Roese (MPC85xx_L2CTL_L2E | 296a47a12beSStefan Roese MPC85xx_L2CTL_L2SRAM_ENTIRE)); 297a47a12beSStefan Roese } 298a47a12beSStefan Roese #endif 299a47a12beSStefan Roese 300a47a12beSStefan Roese l2siz_field = (cache_ctl >> 28) & 0x3; 301a47a12beSStefan Roese 302a47a12beSStefan Roese switch (l2siz_field) { 303a47a12beSStefan Roese case 0x0: 304a47a12beSStefan Roese printf(" unknown size (0x%08x)\n", cache_ctl); 305a47a12beSStefan Roese return -1; 306a47a12beSStefan Roese break; 307a47a12beSStefan Roese case 0x1: 308a47a12beSStefan Roese if (ver == SVR_8540 || ver == SVR_8560 || 309a47a12beSStefan Roese ver == SVR_8541 || ver == SVR_8541_E || 310a47a12beSStefan Roese ver == SVR_8555 || ver == SVR_8555_E) { 311a47a12beSStefan Roese puts("128 KB "); 312a47a12beSStefan Roese /* set L2E=1, L2I=1, & L2BLKSZ=1 (128 Kbyte) */ 313a47a12beSStefan Roese cache_ctl = 0xc4000000; 314a47a12beSStefan Roese } else { 315a47a12beSStefan Roese puts("256 KB "); 316a47a12beSStefan Roese cache_ctl = 0xc0000000; /* set L2E=1, L2I=1, & L2SRAM=0 */ 317a47a12beSStefan Roese } 318a47a12beSStefan Roese break; 319a47a12beSStefan Roese case 0x2: 320a47a12beSStefan Roese if (ver == SVR_8540 || ver == SVR_8560 || 321a47a12beSStefan Roese ver == SVR_8541 || ver == SVR_8541_E || 322a47a12beSStefan Roese ver == SVR_8555 || ver == SVR_8555_E) { 323a47a12beSStefan Roese puts("256 KB "); 324a47a12beSStefan Roese /* set L2E=1, L2I=1, & L2BLKSZ=2 (256 Kbyte) */ 325a47a12beSStefan Roese cache_ctl = 0xc8000000; 326a47a12beSStefan Roese } else { 327a47a12beSStefan Roese puts ("512 KB "); 328a47a12beSStefan Roese /* set L2E=1, L2I=1, & L2SRAM=0 */ 329a47a12beSStefan Roese cache_ctl = 0xc0000000; 330a47a12beSStefan Roese } 331a47a12beSStefan Roese break; 332a47a12beSStefan Roese case 0x3: 333a47a12beSStefan Roese puts("1024 KB "); 334a47a12beSStefan Roese /* set L2E=1, L2I=1, & L2SRAM=0 */ 335a47a12beSStefan Roese cache_ctl = 0xc0000000; 336a47a12beSStefan Roese break; 337a47a12beSStefan Roese } 338a47a12beSStefan Roese 339a47a12beSStefan Roese if (l2cache->l2ctl & MPC85xx_L2CTL_L2E) { 340a47a12beSStefan Roese puts("already enabled"); 341a47a12beSStefan Roese l2srbar = l2cache->l2srbar0; 342888279b5SHaiying Wang #if defined(CONFIG_SYS_INIT_L2_ADDR) && defined(CONFIG_SYS_FLASH_BASE) 343a47a12beSStefan Roese if (l2cache->l2ctl & MPC85xx_L2CTL_L2SRAM_ENTIRE 344a47a12beSStefan Roese && l2srbar >= CONFIG_SYS_FLASH_BASE) { 345a47a12beSStefan Roese l2srbar = CONFIG_SYS_INIT_L2_ADDR; 346a47a12beSStefan Roese l2cache->l2srbar0 = l2srbar; 347a47a12beSStefan Roese printf("moving to 0x%08x", CONFIG_SYS_INIT_L2_ADDR); 348a47a12beSStefan Roese } 349a47a12beSStefan Roese #endif /* CONFIG_SYS_INIT_L2_ADDR */ 350a47a12beSStefan Roese puts("\n"); 351a47a12beSStefan Roese } else { 352a47a12beSStefan Roese asm("msync;isync"); 353a47a12beSStefan Roese l2cache->l2ctl = cache_ctl; /* invalidate & enable */ 354a47a12beSStefan Roese asm("msync;isync"); 355a47a12beSStefan Roese puts("enabled\n"); 356a47a12beSStefan Roese } 357a47a12beSStefan Roese #elif defined(CONFIG_BACKSIDE_L2_CACHE) 358a47a12beSStefan Roese u32 l2cfg0 = mfspr(SPRN_L2CFG0); 359a47a12beSStefan Roese 360a47a12beSStefan Roese /* invalidate the L2 cache */ 361a47a12beSStefan Roese mtspr(SPRN_L2CSR0, (L2CSR0_L2FI|L2CSR0_L2LFC)); 362a47a12beSStefan Roese while (mfspr(SPRN_L2CSR0) & (L2CSR0_L2FI|L2CSR0_L2LFC)) 363a47a12beSStefan Roese ; 364a47a12beSStefan Roese 365a47a12beSStefan Roese #ifdef CONFIG_SYS_CACHE_STASHING 366a47a12beSStefan Roese /* set stash id to (coreID) * 2 + 32 + L2 (1) */ 367a47a12beSStefan Roese mtspr(SPRN_L2CSR1, (32 + 1)); 368a47a12beSStefan Roese #endif 369a47a12beSStefan Roese 370a47a12beSStefan Roese /* enable the cache */ 371a47a12beSStefan Roese mtspr(SPRN_L2CSR0, CONFIG_SYS_INIT_L2CSR0); 372a47a12beSStefan Roese 373a47a12beSStefan Roese if (CONFIG_SYS_INIT_L2CSR0 & L2CSR0_L2E) { 374a47a12beSStefan Roese while (!(mfspr(SPRN_L2CSR0) & L2CSR0_L2E)) 375a47a12beSStefan Roese ; 376a47a12beSStefan Roese printf("%d KB enabled\n", (l2cfg0 & 0x3fff) * 64); 377a47a12beSStefan Roese } 378a47a12beSStefan Roese #else 379a47a12beSStefan Roese puts("disabled\n"); 380a47a12beSStefan Roese #endif 3816aba33e9SKumar Gala 3826aba33e9SKumar Gala enable_cpc(); 3836aba33e9SKumar Gala 384a47a12beSStefan Roese #ifdef CONFIG_QE 385a47a12beSStefan Roese uint qe_base = CONFIG_SYS_IMMR + 0x00080000; /* QE immr base */ 386a47a12beSStefan Roese qe_init(qe_base); 387a47a12beSStefan Roese qe_reset(); 388a47a12beSStefan Roese #endif 389a47a12beSStefan Roese 390af025065SKumar Gala /* needs to be in ram since code uses global static vars */ 391af025065SKumar Gala fsl_serdes_init(); 392af025065SKumar Gala 393a09b9b68SKumar Gala #ifdef CONFIG_SYS_SRIO 394a09b9b68SKumar Gala srio_init(); 395a09b9b68SKumar Gala #endif 396a09b9b68SKumar Gala 397a47a12beSStefan Roese #if defined(CONFIG_MP) 398a47a12beSStefan Roese setup_mp(); 399a47a12beSStefan Roese #endif 4003f0202edSLan Chunhe 401ae026ffdSRoy Zang #ifdef CONFIG_SYS_FSL_ERRATUM_ESDHC136 402ae026ffdSRoy Zang { 403ae026ffdSRoy Zang void *p; 404ae026ffdSRoy Zang p = (void *)CONFIG_SYS_DCSRBAR + 0x20520; 405ae026ffdSRoy Zang setbits_be32(p, 1 << (31 - 14)); 406ae026ffdSRoy Zang } 407ae026ffdSRoy Zang #endif 408ae026ffdSRoy Zang 4093f0202edSLan Chunhe #ifdef CONFIG_SYS_LBC_LCRR 4103f0202edSLan Chunhe /* 4113f0202edSLan Chunhe * Modify the CLKDIV field of LCRR register to improve the writing 4123f0202edSLan Chunhe * speed for NOR flash. 4133f0202edSLan Chunhe */ 4143f0202edSLan Chunhe clrsetbits_be32(&lbc->lcrr, LCRR_CLKDIV, CONFIG_SYS_LBC_LCRR); 4153f0202edSLan Chunhe __raw_readl(&lbc->lcrr); 4163f0202edSLan Chunhe isync(); 4173f0202edSLan Chunhe #endif 4183f0202edSLan Chunhe 419a47a12beSStefan Roese return 0; 420a47a12beSStefan Roese } 421a47a12beSStefan Roese 422a47a12beSStefan Roese extern void setup_ivors(void); 423a47a12beSStefan Roese 424a47a12beSStefan Roese void arch_preboot_os(void) 425a47a12beSStefan Roese { 426a47a12beSStefan Roese u32 msr; 427a47a12beSStefan Roese 428a47a12beSStefan Roese /* 429a47a12beSStefan Roese * We are changing interrupt offsets and are about to boot the OS so 430a47a12beSStefan Roese * we need to make sure we disable all async interrupts. EE is already 431a47a12beSStefan Roese * disabled by the time we get called. 432a47a12beSStefan Roese */ 433a47a12beSStefan Roese msr = mfmsr(); 434a47a12beSStefan Roese msr &= ~(MSR_ME|MSR_CE|MSR_DE); 435a47a12beSStefan Roese mtmsr(msr); 436a47a12beSStefan Roese 437a47a12beSStefan Roese setup_ivors(); 438a47a12beSStefan Roese } 439f54fe87aSKumar Gala 440f54fe87aSKumar Gala #if defined(CONFIG_CMD_SATA) && defined(CONFIG_FSL_SATA) 441f54fe87aSKumar Gala int sata_initialize(void) 442f54fe87aSKumar Gala { 443f54fe87aSKumar Gala if (is_serdes_configured(SATA1) || is_serdes_configured(SATA2)) 444f54fe87aSKumar Gala return __sata_initialize(); 445f54fe87aSKumar Gala 446f54fe87aSKumar Gala return 1; 447f54fe87aSKumar Gala } 448f54fe87aSKumar Gala #endif 449