1*a47a12beSStefan Roese /* 2*a47a12beSStefan Roese * Copyright (C) 2004-2009 Freescale Semiconductor, Inc. 3*a47a12beSStefan Roese * 4*a47a12beSStefan Roese * See file CREDITS for list of people who contributed to this 5*a47a12beSStefan Roese * project. 6*a47a12beSStefan Roese * 7*a47a12beSStefan Roese * This program is free software; you can redistribute it and/or 8*a47a12beSStefan Roese * modify it under the terms of the GNU General Public License as 9*a47a12beSStefan Roese * published by the Free Software Foundation; either version 2 of 10*a47a12beSStefan Roese * the License, or (at your option) any later version. 11*a47a12beSStefan Roese * 12*a47a12beSStefan Roese * This program is distributed in the hope that it will be useful, 13*a47a12beSStefan Roese * but WITHOUT ANY WARRANTY; without even the implied warranty of 14*a47a12beSStefan Roese * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15*a47a12beSStefan Roese * GNU General Public License for more details. 16*a47a12beSStefan Roese * 17*a47a12beSStefan Roese * You should have received a copy of the GNU General Public License 18*a47a12beSStefan Roese * along with this program; if not, write to the Free Software 19*a47a12beSStefan Roese * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20*a47a12beSStefan Roese * MA 02111-1307 USA 21*a47a12beSStefan Roese */ 22*a47a12beSStefan Roese 23*a47a12beSStefan Roese #include <common.h> 24*a47a12beSStefan Roese #include <mpc83xx.h> 25*a47a12beSStefan Roese #include <ioports.h> 26*a47a12beSStefan Roese #include <asm/io.h> 27*a47a12beSStefan Roese #ifdef CONFIG_USB_EHCI_FSL 28*a47a12beSStefan Roese #include <usb/ehci-fsl.h> 29*a47a12beSStefan Roese #endif 30*a47a12beSStefan Roese 31*a47a12beSStefan Roese DECLARE_GLOBAL_DATA_PTR; 32*a47a12beSStefan Roese 33*a47a12beSStefan Roese #ifdef CONFIG_QE 34*a47a12beSStefan Roese extern qe_iop_conf_t qe_iop_conf_tab[]; 35*a47a12beSStefan Roese extern void qe_config_iopin(u8 port, u8 pin, int dir, 36*a47a12beSStefan Roese int open_drain, int assign); 37*a47a12beSStefan Roese extern void qe_init(uint qe_base); 38*a47a12beSStefan Roese extern void qe_reset(void); 39*a47a12beSStefan Roese 40*a47a12beSStefan Roese static void config_qe_ioports(void) 41*a47a12beSStefan Roese { 42*a47a12beSStefan Roese u8 port, pin; 43*a47a12beSStefan Roese int dir, open_drain, assign; 44*a47a12beSStefan Roese int i; 45*a47a12beSStefan Roese 46*a47a12beSStefan Roese for (i = 0; qe_iop_conf_tab[i].assign != QE_IOP_TAB_END; i++) { 47*a47a12beSStefan Roese port = qe_iop_conf_tab[i].port; 48*a47a12beSStefan Roese pin = qe_iop_conf_tab[i].pin; 49*a47a12beSStefan Roese dir = qe_iop_conf_tab[i].dir; 50*a47a12beSStefan Roese open_drain = qe_iop_conf_tab[i].open_drain; 51*a47a12beSStefan Roese assign = qe_iop_conf_tab[i].assign; 52*a47a12beSStefan Roese qe_config_iopin(port, pin, dir, open_drain, assign); 53*a47a12beSStefan Roese } 54*a47a12beSStefan Roese } 55*a47a12beSStefan Roese #endif 56*a47a12beSStefan Roese 57*a47a12beSStefan Roese /* 58*a47a12beSStefan Roese * Breathe some life into the CPU... 59*a47a12beSStefan Roese * 60*a47a12beSStefan Roese * Set up the memory map, 61*a47a12beSStefan Roese * initialize a bunch of registers, 62*a47a12beSStefan Roese * initialize the UPM's 63*a47a12beSStefan Roese */ 64*a47a12beSStefan Roese void cpu_init_f (volatile immap_t * im) 65*a47a12beSStefan Roese { 66*a47a12beSStefan Roese __be32 acr_mask = 67*a47a12beSStefan Roese #ifdef CONFIG_SYS_ACR_PIPE_DEP /* Arbiter pipeline depth */ 68*a47a12beSStefan Roese (ACR_PIPE_DEP << ACR_PIPE_DEP_SHIFT) | 69*a47a12beSStefan Roese #endif 70*a47a12beSStefan Roese #ifdef CONFIG_SYS_ACR_RPTCNT /* Arbiter repeat count */ 71*a47a12beSStefan Roese (ACR_RPTCNT << ACR_RPTCNT_SHIFT) | 72*a47a12beSStefan Roese #endif 73*a47a12beSStefan Roese #ifdef CONFIG_SYS_ACR_APARK /* Arbiter address parking mode */ 74*a47a12beSStefan Roese (ACR_APARK << ACR_APARK_SHIFT) | 75*a47a12beSStefan Roese #endif 76*a47a12beSStefan Roese #ifdef CONFIG_SYS_ACR_PARKM /* Arbiter parking master */ 77*a47a12beSStefan Roese (ACR_PARKM << ACR_PARKM_SHIFT) | 78*a47a12beSStefan Roese #endif 79*a47a12beSStefan Roese 0; 80*a47a12beSStefan Roese __be32 acr_val = 81*a47a12beSStefan Roese #ifdef CONFIG_SYS_ACR_PIPE_DEP /* Arbiter pipeline depth */ 82*a47a12beSStefan Roese (CONFIG_SYS_ACR_PIPE_DEP << ACR_PIPE_DEP_SHIFT) | 83*a47a12beSStefan Roese #endif 84*a47a12beSStefan Roese #ifdef CONFIG_SYS_ACR_RPTCNT /* Arbiter repeat count */ 85*a47a12beSStefan Roese (CONFIG_SYS_ACR_RPTCNT << ACR_RPTCNT_SHIFT) | 86*a47a12beSStefan Roese #endif 87*a47a12beSStefan Roese #ifdef CONFIG_SYS_ACR_APARK /* Arbiter address parking mode */ 88*a47a12beSStefan Roese (CONFIG_SYS_ACR_APARK << ACR_APARK_SHIFT) | 89*a47a12beSStefan Roese #endif 90*a47a12beSStefan Roese #ifdef CONFIG_SYS_ACR_PARKM /* Arbiter parking master */ 91*a47a12beSStefan Roese (CONFIG_SYS_ACR_PARKM << ACR_PARKM_SHIFT) | 92*a47a12beSStefan Roese #endif 93*a47a12beSStefan Roese 0; 94*a47a12beSStefan Roese __be32 spcr_mask = 95*a47a12beSStefan Roese #ifdef CONFIG_SYS_SPCR_OPT /* Optimize transactions between CSB and other dev */ 96*a47a12beSStefan Roese (SPCR_OPT << SPCR_OPT_SHIFT) | 97*a47a12beSStefan Roese #endif 98*a47a12beSStefan Roese #ifdef CONFIG_SYS_SPCR_TSECEP /* all eTSEC's Emergency priority */ 99*a47a12beSStefan Roese (SPCR_TSECEP << SPCR_TSECEP_SHIFT) | 100*a47a12beSStefan Roese #endif 101*a47a12beSStefan Roese #ifdef CONFIG_SYS_SPCR_TSEC1EP /* TSEC1 Emergency priority */ 102*a47a12beSStefan Roese (SPCR_TSEC1EP << SPCR_TSEC1EP_SHIFT) | 103*a47a12beSStefan Roese #endif 104*a47a12beSStefan Roese #ifdef CONFIG_SYS_SPCR_TSEC2EP /* TSEC2 Emergency priority */ 105*a47a12beSStefan Roese (SPCR_TSEC2EP << SPCR_TSEC2EP_SHIFT) | 106*a47a12beSStefan Roese #endif 107*a47a12beSStefan Roese 0; 108*a47a12beSStefan Roese __be32 spcr_val = 109*a47a12beSStefan Roese #ifdef CONFIG_SYS_SPCR_OPT 110*a47a12beSStefan Roese (CONFIG_SYS_SPCR_OPT << SPCR_OPT_SHIFT) | 111*a47a12beSStefan Roese #endif 112*a47a12beSStefan Roese #ifdef CONFIG_SYS_SPCR_TSECEP /* all eTSEC's Emergency priority */ 113*a47a12beSStefan Roese (CONFIG_SYS_SPCR_TSECEP << SPCR_TSECEP_SHIFT) | 114*a47a12beSStefan Roese #endif 115*a47a12beSStefan Roese #ifdef CONFIG_SYS_SPCR_TSEC1EP /* TSEC1 Emergency priority */ 116*a47a12beSStefan Roese (CONFIG_SYS_SPCR_TSEC1EP << SPCR_TSEC1EP_SHIFT) | 117*a47a12beSStefan Roese #endif 118*a47a12beSStefan Roese #ifdef CONFIG_SYS_SPCR_TSEC2EP /* TSEC2 Emergency priority */ 119*a47a12beSStefan Roese (CONFIG_SYS_SPCR_TSEC2EP << SPCR_TSEC2EP_SHIFT) | 120*a47a12beSStefan Roese #endif 121*a47a12beSStefan Roese 0; 122*a47a12beSStefan Roese __be32 sccr_mask = 123*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */ 124*a47a12beSStefan Roese (SCCR_ENCCM << SCCR_ENCCM_SHIFT) | 125*a47a12beSStefan Roese #endif 126*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */ 127*a47a12beSStefan Roese (SCCR_PCICM << SCCR_PCICM_SHIFT) | 128*a47a12beSStefan Roese #endif 129*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */ 130*a47a12beSStefan Roese (SCCR_TSECCM << SCCR_TSECCM_SHIFT) | 131*a47a12beSStefan Roese #endif 132*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */ 133*a47a12beSStefan Roese (SCCR_TSEC1CM << SCCR_TSEC1CM_SHIFT) | 134*a47a12beSStefan Roese #endif 135*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */ 136*a47a12beSStefan Roese (SCCR_TSEC2CM << SCCR_TSEC2CM_SHIFT) | 137*a47a12beSStefan Roese #endif 138*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */ 139*a47a12beSStefan Roese (SCCR_TSEC1ON << SCCR_TSEC1ON_SHIFT) | 140*a47a12beSStefan Roese #endif 141*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */ 142*a47a12beSStefan Roese (SCCR_TSEC2ON << SCCR_TSEC2ON_SHIFT) | 143*a47a12beSStefan Roese #endif 144*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */ 145*a47a12beSStefan Roese (SCCR_USBMPHCM << SCCR_USBMPHCM_SHIFT) | 146*a47a12beSStefan Roese #endif 147*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_USBDRCM /* USB DR clock mode */ 148*a47a12beSStefan Roese (SCCR_USBDRCM << SCCR_USBDRCM_SHIFT) | 149*a47a12beSStefan Roese #endif 150*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */ 151*a47a12beSStefan Roese (SCCR_SATACM << SCCR_SATACM_SHIFT) | 152*a47a12beSStefan Roese #endif 153*a47a12beSStefan Roese 0; 154*a47a12beSStefan Roese __be32 sccr_val = 155*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */ 156*a47a12beSStefan Roese (CONFIG_SYS_SCCR_ENCCM << SCCR_ENCCM_SHIFT) | 157*a47a12beSStefan Roese #endif 158*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */ 159*a47a12beSStefan Roese (CONFIG_SYS_SCCR_PCICM << SCCR_PCICM_SHIFT) | 160*a47a12beSStefan Roese #endif 161*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */ 162*a47a12beSStefan Roese (CONFIG_SYS_SCCR_TSECCM << SCCR_TSECCM_SHIFT) | 163*a47a12beSStefan Roese #endif 164*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */ 165*a47a12beSStefan Roese (CONFIG_SYS_SCCR_TSEC1CM << SCCR_TSEC1CM_SHIFT) | 166*a47a12beSStefan Roese #endif 167*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */ 168*a47a12beSStefan Roese (CONFIG_SYS_SCCR_TSEC2CM << SCCR_TSEC2CM_SHIFT) | 169*a47a12beSStefan Roese #endif 170*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */ 171*a47a12beSStefan Roese (CONFIG_SYS_SCCR_TSEC1ON << SCCR_TSEC1ON_SHIFT) | 172*a47a12beSStefan Roese #endif 173*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */ 174*a47a12beSStefan Roese (CONFIG_SYS_SCCR_TSEC2ON << SCCR_TSEC2ON_SHIFT) | 175*a47a12beSStefan Roese #endif 176*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */ 177*a47a12beSStefan Roese (CONFIG_SYS_SCCR_USBMPHCM << SCCR_USBMPHCM_SHIFT) | 178*a47a12beSStefan Roese #endif 179*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_USBDRCM /* USB DR clock mode */ 180*a47a12beSStefan Roese (CONFIG_SYS_SCCR_USBDRCM << SCCR_USBDRCM_SHIFT) | 181*a47a12beSStefan Roese #endif 182*a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */ 183*a47a12beSStefan Roese (CONFIG_SYS_SCCR_SATACM << SCCR_SATACM_SHIFT) | 184*a47a12beSStefan Roese #endif 185*a47a12beSStefan Roese 0; 186*a47a12beSStefan Roese __be32 lcrr_mask = 187*a47a12beSStefan Roese #ifdef CONFIG_SYS_LCRR_DBYP /* PLL bypass */ 188*a47a12beSStefan Roese LCRR_DBYP | 189*a47a12beSStefan Roese #endif 190*a47a12beSStefan Roese #ifdef CONFIG_SYS_LCRR_EADC /* external address delay */ 191*a47a12beSStefan Roese LCRR_EADC | 192*a47a12beSStefan Roese #endif 193*a47a12beSStefan Roese #ifdef CONFIG_SYS_LCRR_CLKDIV /* system clock divider */ 194*a47a12beSStefan Roese LCRR_CLKDIV | 195*a47a12beSStefan Roese #endif 196*a47a12beSStefan Roese 0; 197*a47a12beSStefan Roese __be32 lcrr_val = 198*a47a12beSStefan Roese #ifdef CONFIG_SYS_LCRR_DBYP /* PLL bypass */ 199*a47a12beSStefan Roese CONFIG_SYS_LCRR_DBYP | 200*a47a12beSStefan Roese #endif 201*a47a12beSStefan Roese #ifdef CONFIG_SYS_LCRR_EADC 202*a47a12beSStefan Roese CONFIG_SYS_LCRR_EADC | 203*a47a12beSStefan Roese #endif 204*a47a12beSStefan Roese #ifdef CONFIG_SYS_LCRR_CLKDIV /* system clock divider */ 205*a47a12beSStefan Roese CONFIG_SYS_LCRR_CLKDIV | 206*a47a12beSStefan Roese #endif 207*a47a12beSStefan Roese 0; 208*a47a12beSStefan Roese 209*a47a12beSStefan Roese /* Pointer is writable since we allocated a register for it */ 210*a47a12beSStefan Roese gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET); 211*a47a12beSStefan Roese 212*a47a12beSStefan Roese /* Clear initial global data */ 213*a47a12beSStefan Roese memset ((void *) gd, 0, sizeof (gd_t)); 214*a47a12beSStefan Roese 215*a47a12beSStefan Roese /* system performance tweaking */ 216*a47a12beSStefan Roese clrsetbits_be32(&im->arbiter.acr, acr_mask, acr_val); 217*a47a12beSStefan Roese 218*a47a12beSStefan Roese clrsetbits_be32(&im->sysconf.spcr, spcr_mask, spcr_val); 219*a47a12beSStefan Roese 220*a47a12beSStefan Roese clrsetbits_be32(&im->clk.sccr, sccr_mask, sccr_val); 221*a47a12beSStefan Roese 222*a47a12beSStefan Roese /* RSR - Reset Status Register - clear all status (4.6.1.3) */ 223*a47a12beSStefan Roese gd->reset_status = __raw_readl(&im->reset.rsr); 224*a47a12beSStefan Roese __raw_writel(~(RSR_RES), &im->reset.rsr); 225*a47a12beSStefan Roese 226*a47a12beSStefan Roese /* AER - Arbiter Event Register - store status */ 227*a47a12beSStefan Roese gd->arbiter_event_attributes = __raw_readl(&im->arbiter.aeatr); 228*a47a12beSStefan Roese gd->arbiter_event_address = __raw_readl(&im->arbiter.aeadr); 229*a47a12beSStefan Roese 230*a47a12beSStefan Roese /* 231*a47a12beSStefan Roese * RMR - Reset Mode Register 232*a47a12beSStefan Roese * contains checkstop reset enable (4.6.1.4) 233*a47a12beSStefan Roese */ 234*a47a12beSStefan Roese __raw_writel(RMR_CSRE & (1<<RMR_CSRE_SHIFT), &im->reset.rmr); 235*a47a12beSStefan Roese 236*a47a12beSStefan Roese /* LCRR - Clock Ratio Register (10.3.1.16) 237*a47a12beSStefan Roese * write, read, and isync per MPC8379ERM rev.1 CLKDEV field description 238*a47a12beSStefan Roese */ 239*a47a12beSStefan Roese clrsetbits_be32(&im->lbus.lcrr, lcrr_mask, lcrr_val); 240*a47a12beSStefan Roese __raw_readl(&im->lbus.lcrr); 241*a47a12beSStefan Roese isync(); 242*a47a12beSStefan Roese 243*a47a12beSStefan Roese /* Enable Time Base & Decrementer ( so we will have udelay() )*/ 244*a47a12beSStefan Roese setbits_be32(&im->sysconf.spcr, SPCR_TBEN); 245*a47a12beSStefan Roese 246*a47a12beSStefan Roese /* System General Purpose Register */ 247*a47a12beSStefan Roese #ifdef CONFIG_SYS_SICRH 248*a47a12beSStefan Roese #if defined(CONFIG_MPC834x) || defined(CONFIG_MPC8313) 249*a47a12beSStefan Roese /* regarding to MPC34x manual rev.1 bits 28..29 must be preserved */ 250*a47a12beSStefan Roese __raw_writel((im->sysconf.sicrh & 0x0000000C) | CONFIG_SYS_SICRH, 251*a47a12beSStefan Roese &im->sysconf.sicrh); 252*a47a12beSStefan Roese #else 253*a47a12beSStefan Roese __raw_writel(CONFIG_SYS_SICRH, &im->sysconf.sicrh); 254*a47a12beSStefan Roese #endif 255*a47a12beSStefan Roese #endif 256*a47a12beSStefan Roese #ifdef CONFIG_SYS_SICRL 257*a47a12beSStefan Roese __raw_writel(CONFIG_SYS_SICRL, &im->sysconf.sicrl); 258*a47a12beSStefan Roese #endif 259*a47a12beSStefan Roese #ifdef CONFIG_SYS_DDRCDR /* DDR control driver register */ 260*a47a12beSStefan Roese __raw_writel(CONFIG_SYS_DDRCDR, &im->sysconf.ddrcdr); 261*a47a12beSStefan Roese #endif 262*a47a12beSStefan Roese #ifdef CONFIG_SYS_OBIR /* Output buffer impedance register */ 263*a47a12beSStefan Roese __raw_writel(CONFIG_SYS_OBIR, &im->sysconf.obir); 264*a47a12beSStefan Roese #endif 265*a47a12beSStefan Roese 266*a47a12beSStefan Roese #ifdef CONFIG_QE 267*a47a12beSStefan Roese /* Config QE ioports */ 268*a47a12beSStefan Roese config_qe_ioports(); 269*a47a12beSStefan Roese #endif 270*a47a12beSStefan Roese 271*a47a12beSStefan Roese /* 272*a47a12beSStefan Roese * Memory Controller: 273*a47a12beSStefan Roese */ 274*a47a12beSStefan Roese 275*a47a12beSStefan Roese /* Map banks 0 and 1 to the FLASH banks 0 and 1 at preliminary 276*a47a12beSStefan Roese * addresses - these have to be modified later when FLASH size 277*a47a12beSStefan Roese * has been determined 278*a47a12beSStefan Roese */ 279*a47a12beSStefan Roese 280*a47a12beSStefan Roese #if defined(CONFIG_SYS_BR0_PRELIM) \ 281*a47a12beSStefan Roese && defined(CONFIG_SYS_OR0_PRELIM) \ 282*a47a12beSStefan Roese && defined(CONFIG_SYS_LBLAWBAR0_PRELIM) \ 283*a47a12beSStefan Roese && defined(CONFIG_SYS_LBLAWAR0_PRELIM) 284*a47a12beSStefan Roese im->lbus.bank[0].br = CONFIG_SYS_BR0_PRELIM; 285*a47a12beSStefan Roese im->lbus.bank[0].or = CONFIG_SYS_OR0_PRELIM; 286*a47a12beSStefan Roese im->sysconf.lblaw[0].bar = CONFIG_SYS_LBLAWBAR0_PRELIM; 287*a47a12beSStefan Roese im->sysconf.lblaw[0].ar = CONFIG_SYS_LBLAWAR0_PRELIM; 288*a47a12beSStefan Roese #else 289*a47a12beSStefan Roese #error CONFIG_SYS_BR0_PRELIM, CONFIG_SYS_OR0_PRELIM, CONFIG_SYS_LBLAWBAR0_PRELIM & CONFIG_SYS_LBLAWAR0_PRELIM must be defined 290*a47a12beSStefan Roese #endif 291*a47a12beSStefan Roese 292*a47a12beSStefan Roese #if defined(CONFIG_SYS_BR1_PRELIM) && defined(CONFIG_SYS_OR1_PRELIM) 293*a47a12beSStefan Roese im->lbus.bank[1].br = CONFIG_SYS_BR1_PRELIM; 294*a47a12beSStefan Roese im->lbus.bank[1].or = CONFIG_SYS_OR1_PRELIM; 295*a47a12beSStefan Roese #endif 296*a47a12beSStefan Roese #if defined(CONFIG_SYS_LBLAWBAR1_PRELIM) && defined(CONFIG_SYS_LBLAWAR1_PRELIM) 297*a47a12beSStefan Roese im->sysconf.lblaw[1].bar = CONFIG_SYS_LBLAWBAR1_PRELIM; 298*a47a12beSStefan Roese im->sysconf.lblaw[1].ar = CONFIG_SYS_LBLAWAR1_PRELIM; 299*a47a12beSStefan Roese #endif 300*a47a12beSStefan Roese #if defined(CONFIG_SYS_BR2_PRELIM) && defined(CONFIG_SYS_OR2_PRELIM) 301*a47a12beSStefan Roese im->lbus.bank[2].br = CONFIG_SYS_BR2_PRELIM; 302*a47a12beSStefan Roese im->lbus.bank[2].or = CONFIG_SYS_OR2_PRELIM; 303*a47a12beSStefan Roese #endif 304*a47a12beSStefan Roese #if defined(CONFIG_SYS_LBLAWBAR2_PRELIM) && defined(CONFIG_SYS_LBLAWAR2_PRELIM) 305*a47a12beSStefan Roese im->sysconf.lblaw[2].bar = CONFIG_SYS_LBLAWBAR2_PRELIM; 306*a47a12beSStefan Roese im->sysconf.lblaw[2].ar = CONFIG_SYS_LBLAWAR2_PRELIM; 307*a47a12beSStefan Roese #endif 308*a47a12beSStefan Roese #if defined(CONFIG_SYS_BR3_PRELIM) && defined(CONFIG_SYS_OR3_PRELIM) 309*a47a12beSStefan Roese im->lbus.bank[3].br = CONFIG_SYS_BR3_PRELIM; 310*a47a12beSStefan Roese im->lbus.bank[3].or = CONFIG_SYS_OR3_PRELIM; 311*a47a12beSStefan Roese #endif 312*a47a12beSStefan Roese #if defined(CONFIG_SYS_LBLAWBAR3_PRELIM) && defined(CONFIG_SYS_LBLAWAR3_PRELIM) 313*a47a12beSStefan Roese im->sysconf.lblaw[3].bar = CONFIG_SYS_LBLAWBAR3_PRELIM; 314*a47a12beSStefan Roese im->sysconf.lblaw[3].ar = CONFIG_SYS_LBLAWAR3_PRELIM; 315*a47a12beSStefan Roese #endif 316*a47a12beSStefan Roese #if defined(CONFIG_SYS_BR4_PRELIM) && defined(CONFIG_SYS_OR4_PRELIM) 317*a47a12beSStefan Roese im->lbus.bank[4].br = CONFIG_SYS_BR4_PRELIM; 318*a47a12beSStefan Roese im->lbus.bank[4].or = CONFIG_SYS_OR4_PRELIM; 319*a47a12beSStefan Roese #endif 320*a47a12beSStefan Roese #if defined(CONFIG_SYS_LBLAWBAR4_PRELIM) && defined(CONFIG_SYS_LBLAWAR4_PRELIM) 321*a47a12beSStefan Roese im->sysconf.lblaw[4].bar = CONFIG_SYS_LBLAWBAR4_PRELIM; 322*a47a12beSStefan Roese im->sysconf.lblaw[4].ar = CONFIG_SYS_LBLAWAR4_PRELIM; 323*a47a12beSStefan Roese #endif 324*a47a12beSStefan Roese #if defined(CONFIG_SYS_BR5_PRELIM) && defined(CONFIG_SYS_OR5_PRELIM) 325*a47a12beSStefan Roese im->lbus.bank[5].br = CONFIG_SYS_BR5_PRELIM; 326*a47a12beSStefan Roese im->lbus.bank[5].or = CONFIG_SYS_OR5_PRELIM; 327*a47a12beSStefan Roese #endif 328*a47a12beSStefan Roese #if defined(CONFIG_SYS_LBLAWBAR5_PRELIM) && defined(CONFIG_SYS_LBLAWAR5_PRELIM) 329*a47a12beSStefan Roese im->sysconf.lblaw[5].bar = CONFIG_SYS_LBLAWBAR5_PRELIM; 330*a47a12beSStefan Roese im->sysconf.lblaw[5].ar = CONFIG_SYS_LBLAWAR5_PRELIM; 331*a47a12beSStefan Roese #endif 332*a47a12beSStefan Roese #if defined(CONFIG_SYS_BR6_PRELIM) && defined(CONFIG_SYS_OR6_PRELIM) 333*a47a12beSStefan Roese im->lbus.bank[6].br = CONFIG_SYS_BR6_PRELIM; 334*a47a12beSStefan Roese im->lbus.bank[6].or = CONFIG_SYS_OR6_PRELIM; 335*a47a12beSStefan Roese #endif 336*a47a12beSStefan Roese #if defined(CONFIG_SYS_LBLAWBAR6_PRELIM) && defined(CONFIG_SYS_LBLAWAR6_PRELIM) 337*a47a12beSStefan Roese im->sysconf.lblaw[6].bar = CONFIG_SYS_LBLAWBAR6_PRELIM; 338*a47a12beSStefan Roese im->sysconf.lblaw[6].ar = CONFIG_SYS_LBLAWAR6_PRELIM; 339*a47a12beSStefan Roese #endif 340*a47a12beSStefan Roese #if defined(CONFIG_SYS_BR7_PRELIM) && defined(CONFIG_SYS_OR7_PRELIM) 341*a47a12beSStefan Roese im->lbus.bank[7].br = CONFIG_SYS_BR7_PRELIM; 342*a47a12beSStefan Roese im->lbus.bank[7].or = CONFIG_SYS_OR7_PRELIM; 343*a47a12beSStefan Roese #endif 344*a47a12beSStefan Roese #if defined(CONFIG_SYS_LBLAWBAR7_PRELIM) && defined(CONFIG_SYS_LBLAWAR7_PRELIM) 345*a47a12beSStefan Roese im->sysconf.lblaw[7].bar = CONFIG_SYS_LBLAWBAR7_PRELIM; 346*a47a12beSStefan Roese im->sysconf.lblaw[7].ar = CONFIG_SYS_LBLAWAR7_PRELIM; 347*a47a12beSStefan Roese #endif 348*a47a12beSStefan Roese #ifdef CONFIG_SYS_GPIO1_PRELIM 349*a47a12beSStefan Roese im->gpio[0].dat = CONFIG_SYS_GPIO1_DAT; 350*a47a12beSStefan Roese im->gpio[0].dir = CONFIG_SYS_GPIO1_DIR; 351*a47a12beSStefan Roese #endif 352*a47a12beSStefan Roese #ifdef CONFIG_SYS_GPIO2_PRELIM 353*a47a12beSStefan Roese im->gpio[1].dat = CONFIG_SYS_GPIO2_DAT; 354*a47a12beSStefan Roese im->gpio[1].dir = CONFIG_SYS_GPIO2_DIR; 355*a47a12beSStefan Roese #endif 356*a47a12beSStefan Roese #ifdef CONFIG_USB_EHCI_FSL 357*a47a12beSStefan Roese #ifndef CONFIG_MPC834x 358*a47a12beSStefan Roese uint32_t temp; 359*a47a12beSStefan Roese struct usb_ehci *ehci = (struct usb_ehci *)CONFIG_SYS_MPC8xxx_USB_ADDR; 360*a47a12beSStefan Roese 361*a47a12beSStefan Roese /* Configure interface. */ 362*a47a12beSStefan Roese setbits_be32(&ehci->control, REFSEL_16MHZ | UTMI_PHY_EN); 363*a47a12beSStefan Roese 364*a47a12beSStefan Roese /* Wait for clock to stabilize */ 365*a47a12beSStefan Roese do { 366*a47a12beSStefan Roese temp = __raw_readl(&ehci->control); 367*a47a12beSStefan Roese udelay(1000); 368*a47a12beSStefan Roese } while (!(temp & PHY_CLK_VALID)); 369*a47a12beSStefan Roese #endif 370*a47a12beSStefan Roese #endif 371*a47a12beSStefan Roese } 372*a47a12beSStefan Roese 373*a47a12beSStefan Roese int cpu_init_r (void) 374*a47a12beSStefan Roese { 375*a47a12beSStefan Roese #ifdef CONFIG_QE 376*a47a12beSStefan Roese uint qe_base = CONFIG_SYS_IMMR + 0x00100000; /* QE immr base */ 377*a47a12beSStefan Roese 378*a47a12beSStefan Roese qe_init(qe_base); 379*a47a12beSStefan Roese qe_reset(); 380*a47a12beSStefan Roese #endif 381*a47a12beSStefan Roese return 0; 382*a47a12beSStefan Roese } 383*a47a12beSStefan Roese 384*a47a12beSStefan Roese /* 385*a47a12beSStefan Roese * Print out the bus arbiter event 386*a47a12beSStefan Roese */ 387*a47a12beSStefan Roese #if defined(CONFIG_DISPLAY_AER_FULL) 388*a47a12beSStefan Roese static int print_83xx_arb_event(int force) 389*a47a12beSStefan Roese { 390*a47a12beSStefan Roese static char* event[] = { 391*a47a12beSStefan Roese "Address Time Out", 392*a47a12beSStefan Roese "Data Time Out", 393*a47a12beSStefan Roese "Address Only Transfer Type", 394*a47a12beSStefan Roese "External Control Word Transfer Type", 395*a47a12beSStefan Roese "Reserved Transfer Type", 396*a47a12beSStefan Roese "Transfer Error", 397*a47a12beSStefan Roese "reserved", 398*a47a12beSStefan Roese "reserved" 399*a47a12beSStefan Roese }; 400*a47a12beSStefan Roese static char* master[] = { 401*a47a12beSStefan Roese "e300 Core Data Transaction", 402*a47a12beSStefan Roese "reserved", 403*a47a12beSStefan Roese "e300 Core Instruction Fetch", 404*a47a12beSStefan Roese "reserved", 405*a47a12beSStefan Roese "TSEC1", 406*a47a12beSStefan Roese "TSEC2", 407*a47a12beSStefan Roese "USB MPH", 408*a47a12beSStefan Roese "USB DR", 409*a47a12beSStefan Roese "Encryption Core", 410*a47a12beSStefan Roese "I2C Boot Sequencer", 411*a47a12beSStefan Roese "JTAG", 412*a47a12beSStefan Roese "reserved", 413*a47a12beSStefan Roese "eSDHC", 414*a47a12beSStefan Roese "PCI1", 415*a47a12beSStefan Roese "PCI2", 416*a47a12beSStefan Roese "DMA", 417*a47a12beSStefan Roese "QUICC Engine 00", 418*a47a12beSStefan Roese "QUICC Engine 01", 419*a47a12beSStefan Roese "QUICC Engine 10", 420*a47a12beSStefan Roese "QUICC Engine 11", 421*a47a12beSStefan Roese "reserved", 422*a47a12beSStefan Roese "reserved", 423*a47a12beSStefan Roese "reserved", 424*a47a12beSStefan Roese "reserved", 425*a47a12beSStefan Roese "SATA1", 426*a47a12beSStefan Roese "SATA2", 427*a47a12beSStefan Roese "SATA3", 428*a47a12beSStefan Roese "SATA4", 429*a47a12beSStefan Roese "reserved", 430*a47a12beSStefan Roese "PCI Express 1", 431*a47a12beSStefan Roese "PCI Express 2", 432*a47a12beSStefan Roese "TDM-DMAC" 433*a47a12beSStefan Roese }; 434*a47a12beSStefan Roese static char *transfer[] = { 435*a47a12beSStefan Roese "Address-only, Clean Block", 436*a47a12beSStefan Roese "Address-only, lwarx reservation set", 437*a47a12beSStefan Roese "Single-beat or Burst write", 438*a47a12beSStefan Roese "reserved", 439*a47a12beSStefan Roese "Address-only, Flush Block", 440*a47a12beSStefan Roese "reserved", 441*a47a12beSStefan Roese "Burst write", 442*a47a12beSStefan Roese "reserved", 443*a47a12beSStefan Roese "Address-only, sync", 444*a47a12beSStefan Roese "Address-only, tlbsync", 445*a47a12beSStefan Roese "Single-beat or Burst read", 446*a47a12beSStefan Roese "Single-beat or Burst read", 447*a47a12beSStefan Roese "Address-only, Kill Block", 448*a47a12beSStefan Roese "Address-only, icbi", 449*a47a12beSStefan Roese "Burst read", 450*a47a12beSStefan Roese "reserved", 451*a47a12beSStefan Roese "Address-only, eieio", 452*a47a12beSStefan Roese "reserved", 453*a47a12beSStefan Roese "Single-beat write", 454*a47a12beSStefan Roese "reserved", 455*a47a12beSStefan Roese "ecowx - Illegal single-beat write", 456*a47a12beSStefan Roese "reserved", 457*a47a12beSStefan Roese "reserved", 458*a47a12beSStefan Roese "reserved", 459*a47a12beSStefan Roese "Address-only, TLB Invalidate", 460*a47a12beSStefan Roese "reserved", 461*a47a12beSStefan Roese "Single-beat or Burst read", 462*a47a12beSStefan Roese "reserved", 463*a47a12beSStefan Roese "eciwx - Illegal single-beat read", 464*a47a12beSStefan Roese "reserved", 465*a47a12beSStefan Roese "Burst read", 466*a47a12beSStefan Roese "reserved" 467*a47a12beSStefan Roese }; 468*a47a12beSStefan Roese 469*a47a12beSStefan Roese int etype = (gd->arbiter_event_attributes & AEATR_EVENT) 470*a47a12beSStefan Roese >> AEATR_EVENT_SHIFT; 471*a47a12beSStefan Roese int mstr_id = (gd->arbiter_event_attributes & AEATR_MSTR_ID) 472*a47a12beSStefan Roese >> AEATR_MSTR_ID_SHIFT; 473*a47a12beSStefan Roese int tbst = (gd->arbiter_event_attributes & AEATR_TBST) 474*a47a12beSStefan Roese >> AEATR_TBST_SHIFT; 475*a47a12beSStefan Roese int tsize = (gd->arbiter_event_attributes & AEATR_TSIZE) 476*a47a12beSStefan Roese >> AEATR_TSIZE_SHIFT; 477*a47a12beSStefan Roese int ttype = (gd->arbiter_event_attributes & AEATR_TTYPE) 478*a47a12beSStefan Roese >> AEATR_TTYPE_SHIFT; 479*a47a12beSStefan Roese 480*a47a12beSStefan Roese if (!force && !gd->arbiter_event_address) 481*a47a12beSStefan Roese return 0; 482*a47a12beSStefan Roese 483*a47a12beSStefan Roese puts("Arbiter Event Status:\n"); 484*a47a12beSStefan Roese printf(" Event Address: 0x%08lX\n", gd->arbiter_event_address); 485*a47a12beSStefan Roese printf(" Event Type: 0x%1x = %s\n", etype, event[etype]); 486*a47a12beSStefan Roese printf(" Master ID: 0x%02x = %s\n", mstr_id, master[mstr_id]); 487*a47a12beSStefan Roese printf(" Transfer Size: 0x%1x = %d bytes\n", (tbst<<3) | tsize, 488*a47a12beSStefan Roese tbst ? (tsize ? tsize : 8) : 16 + 8 * tsize); 489*a47a12beSStefan Roese printf(" Transfer Type: 0x%02x = %s\n", ttype, transfer[ttype]); 490*a47a12beSStefan Roese 491*a47a12beSStefan Roese return gd->arbiter_event_address; 492*a47a12beSStefan Roese } 493*a47a12beSStefan Roese 494*a47a12beSStefan Roese #elif defined(CONFIG_DISPLAY_AER_BRIEF) 495*a47a12beSStefan Roese 496*a47a12beSStefan Roese static int print_83xx_arb_event(int force) 497*a47a12beSStefan Roese { 498*a47a12beSStefan Roese if (!force && !gd->arbiter_event_address) 499*a47a12beSStefan Roese return 0; 500*a47a12beSStefan Roese 501*a47a12beSStefan Roese printf("Arbiter Event Status: AEATR=0x%08lX, AEADR=0x%08lX\n", 502*a47a12beSStefan Roese gd->arbiter_event_attributes, gd->arbiter_event_address); 503*a47a12beSStefan Roese 504*a47a12beSStefan Roese return gd->arbiter_event_address; 505*a47a12beSStefan Roese } 506*a47a12beSStefan Roese #endif /* CONFIG_DISPLAY_AER_xxxx */ 507*a47a12beSStefan Roese 508*a47a12beSStefan Roese /* 509*a47a12beSStefan Roese * Figure out the cause of the reset 510*a47a12beSStefan Roese */ 511*a47a12beSStefan Roese int prt_83xx_rsr(void) 512*a47a12beSStefan Roese { 513*a47a12beSStefan Roese static struct { 514*a47a12beSStefan Roese ulong mask; 515*a47a12beSStefan Roese char *desc; 516*a47a12beSStefan Roese } bits[] = { 517*a47a12beSStefan Roese { 518*a47a12beSStefan Roese RSR_SWSR, "Software Soft"}, { 519*a47a12beSStefan Roese RSR_SWHR, "Software Hard"}, { 520*a47a12beSStefan Roese RSR_JSRS, "JTAG Soft"}, { 521*a47a12beSStefan Roese RSR_CSHR, "Check Stop"}, { 522*a47a12beSStefan Roese RSR_SWRS, "Software Watchdog"}, { 523*a47a12beSStefan Roese RSR_BMRS, "Bus Monitor"}, { 524*a47a12beSStefan Roese RSR_SRS, "External/Internal Soft"}, { 525*a47a12beSStefan Roese RSR_HRS, "External/Internal Hard"} 526*a47a12beSStefan Roese }; 527*a47a12beSStefan Roese static int n = sizeof bits / sizeof bits[0]; 528*a47a12beSStefan Roese ulong rsr = gd->reset_status; 529*a47a12beSStefan Roese int i; 530*a47a12beSStefan Roese char *sep; 531*a47a12beSStefan Roese 532*a47a12beSStefan Roese puts("Reset Status:"); 533*a47a12beSStefan Roese 534*a47a12beSStefan Roese sep = " "; 535*a47a12beSStefan Roese for (i = 0; i < n; i++) 536*a47a12beSStefan Roese if (rsr & bits[i].mask) { 537*a47a12beSStefan Roese printf("%s%s", sep, bits[i].desc); 538*a47a12beSStefan Roese sep = ", "; 539*a47a12beSStefan Roese } 540*a47a12beSStefan Roese puts("\n"); 541*a47a12beSStefan Roese 542*a47a12beSStefan Roese #if defined(CONFIG_DISPLAY_AER_FULL) || defined(CONFIG_DISPLAY_AER_BRIEF) 543*a47a12beSStefan Roese print_83xx_arb_event(rsr & RSR_BMRS); 544*a47a12beSStefan Roese #endif 545*a47a12beSStefan Roese puts("\n"); 546*a47a12beSStefan Roese 547*a47a12beSStefan Roese return 0; 548*a47a12beSStefan Roese } 549