1a47a12beSStefan Roese /* 2a47a12beSStefan Roese * Copyright (C) 2004-2009 Freescale Semiconductor, Inc. 3a47a12beSStefan Roese * 41a459660SWolfgang Denk * SPDX-License-Identifier: GPL-2.0+ 5a47a12beSStefan Roese */ 6a47a12beSStefan Roese 7a47a12beSStefan Roese #include <common.h> 8a47a12beSStefan Roese #include <mpc83xx.h> 9a47a12beSStefan Roese #include <ioports.h> 10a47a12beSStefan Roese #include <asm/io.h> 11a47a12beSStefan Roese #ifdef CONFIG_USB_EHCI_FSL 12e162c6b1SMateusz Kulikowski #include <usb/ehci-ci.h> 13a47a12beSStefan Roese #endif 14a47a12beSStefan Roese 15a47a12beSStefan Roese DECLARE_GLOBAL_DATA_PTR; 16a47a12beSStefan Roese 17a47a12beSStefan Roese #ifdef CONFIG_QE 18a47a12beSStefan Roese extern qe_iop_conf_t qe_iop_conf_tab[]; 19a47a12beSStefan Roese extern void qe_config_iopin(u8 port, u8 pin, int dir, 20a47a12beSStefan Roese int open_drain, int assign); 21a47a12beSStefan Roese extern void qe_init(uint qe_base); 22a47a12beSStefan Roese extern void qe_reset(void); 23a47a12beSStefan Roese 24a47a12beSStefan Roese static void config_qe_ioports(void) 25a47a12beSStefan Roese { 26a47a12beSStefan Roese u8 port, pin; 27a47a12beSStefan Roese int dir, open_drain, assign; 28a47a12beSStefan Roese int i; 29a47a12beSStefan Roese 30a47a12beSStefan Roese for (i = 0; qe_iop_conf_tab[i].assign != QE_IOP_TAB_END; i++) { 31a47a12beSStefan Roese port = qe_iop_conf_tab[i].port; 32a47a12beSStefan Roese pin = qe_iop_conf_tab[i].pin; 33a47a12beSStefan Roese dir = qe_iop_conf_tab[i].dir; 34a47a12beSStefan Roese open_drain = qe_iop_conf_tab[i].open_drain; 35a47a12beSStefan Roese assign = qe_iop_conf_tab[i].assign; 36a47a12beSStefan Roese qe_config_iopin(port, pin, dir, open_drain, assign); 37a47a12beSStefan Roese } 38a47a12beSStefan Roese } 39a47a12beSStefan Roese #endif 40a47a12beSStefan Roese 41a47a12beSStefan Roese /* 42a47a12beSStefan Roese * Breathe some life into the CPU... 43a47a12beSStefan Roese * 44a47a12beSStefan Roese * Set up the memory map, 45a47a12beSStefan Roese * initialize a bunch of registers, 46a47a12beSStefan Roese * initialize the UPM's 47a47a12beSStefan Roese */ 48a47a12beSStefan Roese void cpu_init_f (volatile immap_t * im) 49a47a12beSStefan Roese { 50a47a12beSStefan Roese __be32 acr_mask = 51a47a12beSStefan Roese #ifdef CONFIG_SYS_ACR_PIPE_DEP /* Arbiter pipeline depth */ 5271bd860cSKim Phillips ACR_PIPE_DEP | 53a47a12beSStefan Roese #endif 54a47a12beSStefan Roese #ifdef CONFIG_SYS_ACR_RPTCNT /* Arbiter repeat count */ 5571bd860cSKim Phillips ACR_RPTCNT | 56a47a12beSStefan Roese #endif 57a47a12beSStefan Roese #ifdef CONFIG_SYS_ACR_APARK /* Arbiter address parking mode */ 5871bd860cSKim Phillips ACR_APARK | 59a47a12beSStefan Roese #endif 60a47a12beSStefan Roese #ifdef CONFIG_SYS_ACR_PARKM /* Arbiter parking master */ 6171bd860cSKim Phillips ACR_PARKM | 62a47a12beSStefan Roese #endif 63a47a12beSStefan Roese 0; 64a47a12beSStefan Roese __be32 acr_val = 65a47a12beSStefan Roese #ifdef CONFIG_SYS_ACR_PIPE_DEP /* Arbiter pipeline depth */ 66a47a12beSStefan Roese (CONFIG_SYS_ACR_PIPE_DEP << ACR_PIPE_DEP_SHIFT) | 67a47a12beSStefan Roese #endif 68a47a12beSStefan Roese #ifdef CONFIG_SYS_ACR_RPTCNT /* Arbiter repeat count */ 69a47a12beSStefan Roese (CONFIG_SYS_ACR_RPTCNT << ACR_RPTCNT_SHIFT) | 70a47a12beSStefan Roese #endif 71a47a12beSStefan Roese #ifdef CONFIG_SYS_ACR_APARK /* Arbiter address parking mode */ 72a47a12beSStefan Roese (CONFIG_SYS_ACR_APARK << ACR_APARK_SHIFT) | 73a47a12beSStefan Roese #endif 74a47a12beSStefan Roese #ifdef CONFIG_SYS_ACR_PARKM /* Arbiter parking master */ 75a47a12beSStefan Roese (CONFIG_SYS_ACR_PARKM << ACR_PARKM_SHIFT) | 76a47a12beSStefan Roese #endif 77a47a12beSStefan Roese 0; 78a47a12beSStefan Roese __be32 spcr_mask = 79a47a12beSStefan Roese #ifdef CONFIG_SYS_SPCR_OPT /* Optimize transactions between CSB and other dev */ 8071bd860cSKim Phillips SPCR_OPT | 81a47a12beSStefan Roese #endif 82a47a12beSStefan Roese #ifdef CONFIG_SYS_SPCR_TSECEP /* all eTSEC's Emergency priority */ 8371bd860cSKim Phillips SPCR_TSECEP | 84a47a12beSStefan Roese #endif 85a47a12beSStefan Roese #ifdef CONFIG_SYS_SPCR_TSEC1EP /* TSEC1 Emergency priority */ 8671bd860cSKim Phillips SPCR_TSEC1EP | 87a47a12beSStefan Roese #endif 88a47a12beSStefan Roese #ifdef CONFIG_SYS_SPCR_TSEC2EP /* TSEC2 Emergency priority */ 8971bd860cSKim Phillips SPCR_TSEC2EP | 90a47a12beSStefan Roese #endif 91a47a12beSStefan Roese 0; 92a47a12beSStefan Roese __be32 spcr_val = 93a47a12beSStefan Roese #ifdef CONFIG_SYS_SPCR_OPT 94a47a12beSStefan Roese (CONFIG_SYS_SPCR_OPT << SPCR_OPT_SHIFT) | 95a47a12beSStefan Roese #endif 96a47a12beSStefan Roese #ifdef CONFIG_SYS_SPCR_TSECEP /* all eTSEC's Emergency priority */ 97a47a12beSStefan Roese (CONFIG_SYS_SPCR_TSECEP << SPCR_TSECEP_SHIFT) | 98a47a12beSStefan Roese #endif 99a47a12beSStefan Roese #ifdef CONFIG_SYS_SPCR_TSEC1EP /* TSEC1 Emergency priority */ 100a47a12beSStefan Roese (CONFIG_SYS_SPCR_TSEC1EP << SPCR_TSEC1EP_SHIFT) | 101a47a12beSStefan Roese #endif 102a47a12beSStefan Roese #ifdef CONFIG_SYS_SPCR_TSEC2EP /* TSEC2 Emergency priority */ 103a47a12beSStefan Roese (CONFIG_SYS_SPCR_TSEC2EP << SPCR_TSEC2EP_SHIFT) | 104a47a12beSStefan Roese #endif 105a47a12beSStefan Roese 0; 106a47a12beSStefan Roese __be32 sccr_mask = 107a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */ 10871bd860cSKim Phillips SCCR_ENCCM | 109a47a12beSStefan Roese #endif 110a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */ 11171bd860cSKim Phillips SCCR_PCICM | 112a47a12beSStefan Roese #endif 113f1371048SIlya Yanok #ifdef CONFIG_SYS_SCCR_PCIEXP1CM /* PCIE1 clock mode */ 114f1371048SIlya Yanok SCCR_PCIEXP1CM | 115f1371048SIlya Yanok #endif 116f1371048SIlya Yanok #ifdef CONFIG_SYS_SCCR_PCIEXP2CM /* PCIE2 clock mode */ 117f1371048SIlya Yanok SCCR_PCIEXP2CM | 118f1371048SIlya Yanok #endif 119a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */ 12071bd860cSKim Phillips SCCR_TSECCM | 121a47a12beSStefan Roese #endif 122a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */ 12371bd860cSKim Phillips SCCR_TSEC1CM | 124a47a12beSStefan Roese #endif 125a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */ 12671bd860cSKim Phillips SCCR_TSEC2CM | 127a47a12beSStefan Roese #endif 128a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */ 12971bd860cSKim Phillips SCCR_TSEC1ON | 130a47a12beSStefan Roese #endif 131a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */ 13271bd860cSKim Phillips SCCR_TSEC2ON | 133a47a12beSStefan Roese #endif 134a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */ 13571bd860cSKim Phillips SCCR_USBMPHCM | 136a47a12beSStefan Roese #endif 137a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_USBDRCM /* USB DR clock mode */ 13871bd860cSKim Phillips SCCR_USBDRCM | 139a47a12beSStefan Roese #endif 140a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */ 14171bd860cSKim Phillips SCCR_SATACM | 142a47a12beSStefan Roese #endif 143a47a12beSStefan Roese 0; 144a47a12beSStefan Roese __be32 sccr_val = 145a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_ENCCM /* Encryption clock mode */ 146a47a12beSStefan Roese (CONFIG_SYS_SCCR_ENCCM << SCCR_ENCCM_SHIFT) | 147a47a12beSStefan Roese #endif 148a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_PCICM /* PCI & DMA clock mode */ 149a47a12beSStefan Roese (CONFIG_SYS_SCCR_PCICM << SCCR_PCICM_SHIFT) | 150a47a12beSStefan Roese #endif 151f1371048SIlya Yanok #ifdef CONFIG_SYS_SCCR_PCIEXP1CM /* PCIE1 clock mode */ 152f1371048SIlya Yanok (CONFIG_SYS_SCCR_PCIEXP1CM << SCCR_PCIEXP1CM_SHIFT) | 153f1371048SIlya Yanok #endif 154f1371048SIlya Yanok #ifdef CONFIG_SYS_SCCR_PCIEXP2CM /* PCIE2 clock mode */ 155f1371048SIlya Yanok (CONFIG_SYS_SCCR_PCIEXP2CM << SCCR_PCIEXP2CM_SHIFT) | 156f1371048SIlya Yanok #endif 157a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSECCM /* all TSEC's clock mode */ 158a47a12beSStefan Roese (CONFIG_SYS_SCCR_TSECCM << SCCR_TSECCM_SHIFT) | 159a47a12beSStefan Roese #endif 160a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSEC1CM /* TSEC1 clock mode */ 161a47a12beSStefan Roese (CONFIG_SYS_SCCR_TSEC1CM << SCCR_TSEC1CM_SHIFT) | 162a47a12beSStefan Roese #endif 163a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSEC2CM /* TSEC2 clock mode */ 164a47a12beSStefan Roese (CONFIG_SYS_SCCR_TSEC2CM << SCCR_TSEC2CM_SHIFT) | 165a47a12beSStefan Roese #endif 166a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSEC1ON /* TSEC1 clock switch */ 167a47a12beSStefan Roese (CONFIG_SYS_SCCR_TSEC1ON << SCCR_TSEC1ON_SHIFT) | 168a47a12beSStefan Roese #endif 169a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_TSEC2ON /* TSEC2 clock switch */ 170a47a12beSStefan Roese (CONFIG_SYS_SCCR_TSEC2ON << SCCR_TSEC2ON_SHIFT) | 171a47a12beSStefan Roese #endif 172a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_USBMPHCM /* USB MPH clock mode */ 173a47a12beSStefan Roese (CONFIG_SYS_SCCR_USBMPHCM << SCCR_USBMPHCM_SHIFT) | 174a47a12beSStefan Roese #endif 175a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_USBDRCM /* USB DR clock mode */ 176a47a12beSStefan Roese (CONFIG_SYS_SCCR_USBDRCM << SCCR_USBDRCM_SHIFT) | 177a47a12beSStefan Roese #endif 178a47a12beSStefan Roese #ifdef CONFIG_SYS_SCCR_SATACM /* SATA controller clock mode */ 179a47a12beSStefan Roese (CONFIG_SYS_SCCR_SATACM << SCCR_SATACM_SHIFT) | 180a47a12beSStefan Roese #endif 181a47a12beSStefan Roese 0; 182a47a12beSStefan Roese __be32 lcrr_mask = 183a47a12beSStefan Roese #ifdef CONFIG_SYS_LCRR_DBYP /* PLL bypass */ 184a47a12beSStefan Roese LCRR_DBYP | 185a47a12beSStefan Roese #endif 186a47a12beSStefan Roese #ifdef CONFIG_SYS_LCRR_EADC /* external address delay */ 187a47a12beSStefan Roese LCRR_EADC | 188a47a12beSStefan Roese #endif 189a47a12beSStefan Roese #ifdef CONFIG_SYS_LCRR_CLKDIV /* system clock divider */ 190a47a12beSStefan Roese LCRR_CLKDIV | 191a47a12beSStefan Roese #endif 192a47a12beSStefan Roese 0; 193a47a12beSStefan Roese __be32 lcrr_val = 194a47a12beSStefan Roese #ifdef CONFIG_SYS_LCRR_DBYP /* PLL bypass */ 195a47a12beSStefan Roese CONFIG_SYS_LCRR_DBYP | 196a47a12beSStefan Roese #endif 197a47a12beSStefan Roese #ifdef CONFIG_SYS_LCRR_EADC 198a47a12beSStefan Roese CONFIG_SYS_LCRR_EADC | 199a47a12beSStefan Roese #endif 200a47a12beSStefan Roese #ifdef CONFIG_SYS_LCRR_CLKDIV /* system clock divider */ 201a47a12beSStefan Roese CONFIG_SYS_LCRR_CLKDIV | 202a47a12beSStefan Roese #endif 203a47a12beSStefan Roese 0; 204a47a12beSStefan Roese 205a47a12beSStefan Roese /* Pointer is writable since we allocated a register for it */ 206a47a12beSStefan Roese gd = (gd_t *) (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET); 207a47a12beSStefan Roese 208*dbcb2c0eSmario.six@gdsys.cc /* global data region was cleared in start.S */ 209a47a12beSStefan Roese 210a47a12beSStefan Roese /* system performance tweaking */ 211a47a12beSStefan Roese clrsetbits_be32(&im->arbiter.acr, acr_mask, acr_val); 212a47a12beSStefan Roese 213a47a12beSStefan Roese clrsetbits_be32(&im->sysconf.spcr, spcr_mask, spcr_val); 214a47a12beSStefan Roese 215a47a12beSStefan Roese clrsetbits_be32(&im->clk.sccr, sccr_mask, sccr_val); 216a47a12beSStefan Roese 217a47a12beSStefan Roese /* RSR - Reset Status Register - clear all status (4.6.1.3) */ 2183c4c308cSSimon Glass gd->arch.reset_status = __raw_readl(&im->reset.rsr); 219a47a12beSStefan Roese __raw_writel(~(RSR_RES), &im->reset.rsr); 220a47a12beSStefan Roese 221a47a12beSStefan Roese /* AER - Arbiter Event Register - store status */ 22243e60814SSimon Glass gd->arch.arbiter_event_attributes = __raw_readl(&im->arbiter.aeatr); 22343e60814SSimon Glass gd->arch.arbiter_event_address = __raw_readl(&im->arbiter.aeadr); 224a47a12beSStefan Roese 225a47a12beSStefan Roese /* 226a47a12beSStefan Roese * RMR - Reset Mode Register 227a47a12beSStefan Roese * contains checkstop reset enable (4.6.1.4) 228a47a12beSStefan Roese */ 229a47a12beSStefan Roese __raw_writel(RMR_CSRE & (1<<RMR_CSRE_SHIFT), &im->reset.rmr); 230a47a12beSStefan Roese 231a47a12beSStefan Roese /* LCRR - Clock Ratio Register (10.3.1.16) 232a47a12beSStefan Roese * write, read, and isync per MPC8379ERM rev.1 CLKDEV field description 233a47a12beSStefan Roese */ 234f51cdaf1SBecky Bruce clrsetbits_be32(&im->im_lbc.lcrr, lcrr_mask, lcrr_val); 235f51cdaf1SBecky Bruce __raw_readl(&im->im_lbc.lcrr); 236a47a12beSStefan Roese isync(); 237a47a12beSStefan Roese 238a47a12beSStefan Roese /* Enable Time Base & Decrementer ( so we will have udelay() )*/ 239a47a12beSStefan Roese setbits_be32(&im->sysconf.spcr, SPCR_TBEN); 240a47a12beSStefan Roese 241a47a12beSStefan Roese /* System General Purpose Register */ 242a47a12beSStefan Roese #ifdef CONFIG_SYS_SICRH 243a47a12beSStefan Roese #if defined(CONFIG_MPC834x) || defined(CONFIG_MPC8313) 244a47a12beSStefan Roese /* regarding to MPC34x manual rev.1 bits 28..29 must be preserved */ 245a47a12beSStefan Roese __raw_writel((im->sysconf.sicrh & 0x0000000C) | CONFIG_SYS_SICRH, 246a47a12beSStefan Roese &im->sysconf.sicrh); 247a47a12beSStefan Roese #else 248a47a12beSStefan Roese __raw_writel(CONFIG_SYS_SICRH, &im->sysconf.sicrh); 249a47a12beSStefan Roese #endif 250a47a12beSStefan Roese #endif 251a47a12beSStefan Roese #ifdef CONFIG_SYS_SICRL 252a47a12beSStefan Roese __raw_writel(CONFIG_SYS_SICRL, &im->sysconf.sicrl); 253a47a12beSStefan Roese #endif 254a88731a6SGerlando Falauto #ifdef CONFIG_SYS_GPR1 255a88731a6SGerlando Falauto __raw_writel(CONFIG_SYS_GPR1, &im->sysconf.gpr1); 256a88731a6SGerlando Falauto #endif 257a47a12beSStefan Roese #ifdef CONFIG_SYS_DDRCDR /* DDR control driver register */ 258a47a12beSStefan Roese __raw_writel(CONFIG_SYS_DDRCDR, &im->sysconf.ddrcdr); 259a47a12beSStefan Roese #endif 260a47a12beSStefan Roese #ifdef CONFIG_SYS_OBIR /* Output buffer impedance register */ 261a47a12beSStefan Roese __raw_writel(CONFIG_SYS_OBIR, &im->sysconf.obir); 262a47a12beSStefan Roese #endif 263a47a12beSStefan Roese 264a47a12beSStefan Roese #ifdef CONFIG_QE 265a47a12beSStefan Roese /* Config QE ioports */ 266a47a12beSStefan Roese config_qe_ioports(); 267a47a12beSStefan Roese #endif 268f51cdaf1SBecky Bruce /* Set up preliminary BR/OR regs */ 269f51cdaf1SBecky Bruce init_early_memctl_regs(); 270a47a12beSStefan Roese 271f51cdaf1SBecky Bruce /* Local Access window setup */ 272f51cdaf1SBecky Bruce #if defined(CONFIG_SYS_LBLAWBAR0_PRELIM) && defined(CONFIG_SYS_LBLAWAR0_PRELIM) 273a47a12beSStefan Roese im->sysconf.lblaw[0].bar = CONFIG_SYS_LBLAWBAR0_PRELIM; 274a47a12beSStefan Roese im->sysconf.lblaw[0].ar = CONFIG_SYS_LBLAWAR0_PRELIM; 275a47a12beSStefan Roese #else 276f51cdaf1SBecky Bruce #error CONFIG_SYS_LBLAWBAR0_PRELIM & CONFIG_SYS_LBLAWAR0_PRELIM must be defined 277a47a12beSStefan Roese #endif 278a47a12beSStefan Roese 279a47a12beSStefan Roese #if defined(CONFIG_SYS_LBLAWBAR1_PRELIM) && defined(CONFIG_SYS_LBLAWAR1_PRELIM) 280a47a12beSStefan Roese im->sysconf.lblaw[1].bar = CONFIG_SYS_LBLAWBAR1_PRELIM; 281a47a12beSStefan Roese im->sysconf.lblaw[1].ar = CONFIG_SYS_LBLAWAR1_PRELIM; 282a47a12beSStefan Roese #endif 283a47a12beSStefan Roese #if defined(CONFIG_SYS_LBLAWBAR2_PRELIM) && defined(CONFIG_SYS_LBLAWAR2_PRELIM) 284a47a12beSStefan Roese im->sysconf.lblaw[2].bar = CONFIG_SYS_LBLAWBAR2_PRELIM; 285a47a12beSStefan Roese im->sysconf.lblaw[2].ar = CONFIG_SYS_LBLAWAR2_PRELIM; 286a47a12beSStefan Roese #endif 287a47a12beSStefan Roese #if defined(CONFIG_SYS_LBLAWBAR3_PRELIM) && defined(CONFIG_SYS_LBLAWAR3_PRELIM) 288a47a12beSStefan Roese im->sysconf.lblaw[3].bar = CONFIG_SYS_LBLAWBAR3_PRELIM; 289a47a12beSStefan Roese im->sysconf.lblaw[3].ar = CONFIG_SYS_LBLAWAR3_PRELIM; 290a47a12beSStefan Roese #endif 291a47a12beSStefan Roese #if defined(CONFIG_SYS_LBLAWBAR4_PRELIM) && defined(CONFIG_SYS_LBLAWAR4_PRELIM) 292a47a12beSStefan Roese im->sysconf.lblaw[4].bar = CONFIG_SYS_LBLAWBAR4_PRELIM; 293a47a12beSStefan Roese im->sysconf.lblaw[4].ar = CONFIG_SYS_LBLAWAR4_PRELIM; 294a47a12beSStefan Roese #endif 295a47a12beSStefan Roese #if defined(CONFIG_SYS_LBLAWBAR5_PRELIM) && defined(CONFIG_SYS_LBLAWAR5_PRELIM) 296a47a12beSStefan Roese im->sysconf.lblaw[5].bar = CONFIG_SYS_LBLAWBAR5_PRELIM; 297a47a12beSStefan Roese im->sysconf.lblaw[5].ar = CONFIG_SYS_LBLAWAR5_PRELIM; 298a47a12beSStefan Roese #endif 299a47a12beSStefan Roese #if defined(CONFIG_SYS_LBLAWBAR6_PRELIM) && defined(CONFIG_SYS_LBLAWAR6_PRELIM) 300a47a12beSStefan Roese im->sysconf.lblaw[6].bar = CONFIG_SYS_LBLAWBAR6_PRELIM; 301a47a12beSStefan Roese im->sysconf.lblaw[6].ar = CONFIG_SYS_LBLAWAR6_PRELIM; 302a47a12beSStefan Roese #endif 303a47a12beSStefan Roese #if defined(CONFIG_SYS_LBLAWBAR7_PRELIM) && defined(CONFIG_SYS_LBLAWAR7_PRELIM) 304a47a12beSStefan Roese im->sysconf.lblaw[7].bar = CONFIG_SYS_LBLAWBAR7_PRELIM; 305a47a12beSStefan Roese im->sysconf.lblaw[7].ar = CONFIG_SYS_LBLAWAR7_PRELIM; 306a47a12beSStefan Roese #endif 307a47a12beSStefan Roese #ifdef CONFIG_SYS_GPIO1_PRELIM 308a47a12beSStefan Roese im->gpio[0].dat = CONFIG_SYS_GPIO1_DAT; 309a47a12beSStefan Roese im->gpio[0].dir = CONFIG_SYS_GPIO1_DIR; 310a47a12beSStefan Roese #endif 311a47a12beSStefan Roese #ifdef CONFIG_SYS_GPIO2_PRELIM 312a47a12beSStefan Roese im->gpio[1].dat = CONFIG_SYS_GPIO2_DAT; 313a47a12beSStefan Roese im->gpio[1].dir = CONFIG_SYS_GPIO2_DIR; 314a47a12beSStefan Roese #endif 31584d2e03fSKim Phillips #if defined(CONFIG_USB_EHCI_FSL) && defined(CONFIG_MPC831x) 316a47a12beSStefan Roese uint32_t temp; 31777354e9dSramneek mehresh struct usb_ehci *ehci = (struct usb_ehci *)CONFIG_SYS_FSL_USB1_ADDR; 318a47a12beSStefan Roese 319a47a12beSStefan Roese /* Configure interface. */ 320a47a12beSStefan Roese setbits_be32(&ehci->control, REFSEL_16MHZ | UTMI_PHY_EN); 321a47a12beSStefan Roese 322a47a12beSStefan Roese /* Wait for clock to stabilize */ 323a47a12beSStefan Roese do { 324a47a12beSStefan Roese temp = __raw_readl(&ehci->control); 325a47a12beSStefan Roese udelay(1000); 326a47a12beSStefan Roese } while (!(temp & PHY_CLK_VALID)); 327a47a12beSStefan Roese #endif 328a47a12beSStefan Roese } 329a47a12beSStefan Roese 330a47a12beSStefan Roese int cpu_init_r (void) 331a47a12beSStefan Roese { 332a47a12beSStefan Roese #ifdef CONFIG_QE 333a47a12beSStefan Roese uint qe_base = CONFIG_SYS_IMMR + 0x00100000; /* QE immr base */ 334a47a12beSStefan Roese 335a47a12beSStefan Roese qe_init(qe_base); 336a47a12beSStefan Roese qe_reset(); 337a47a12beSStefan Roese #endif 338a47a12beSStefan Roese return 0; 339a47a12beSStefan Roese } 340a47a12beSStefan Roese 341a47a12beSStefan Roese /* 342a47a12beSStefan Roese * Print out the bus arbiter event 343a47a12beSStefan Roese */ 344a47a12beSStefan Roese #if defined(CONFIG_DISPLAY_AER_FULL) 345a47a12beSStefan Roese static int print_83xx_arb_event(int force) 346a47a12beSStefan Roese { 347a47a12beSStefan Roese static char* event[] = { 348a47a12beSStefan Roese "Address Time Out", 349a47a12beSStefan Roese "Data Time Out", 350a47a12beSStefan Roese "Address Only Transfer Type", 351a47a12beSStefan Roese "External Control Word Transfer Type", 352a47a12beSStefan Roese "Reserved Transfer Type", 353a47a12beSStefan Roese "Transfer Error", 354a47a12beSStefan Roese "reserved", 355a47a12beSStefan Roese "reserved" 356a47a12beSStefan Roese }; 357a47a12beSStefan Roese static char* master[] = { 358a47a12beSStefan Roese "e300 Core Data Transaction", 359a47a12beSStefan Roese "reserved", 360a47a12beSStefan Roese "e300 Core Instruction Fetch", 361a47a12beSStefan Roese "reserved", 362a47a12beSStefan Roese "TSEC1", 363a47a12beSStefan Roese "TSEC2", 364a47a12beSStefan Roese "USB MPH", 365a47a12beSStefan Roese "USB DR", 366a47a12beSStefan Roese "Encryption Core", 367a47a12beSStefan Roese "I2C Boot Sequencer", 368a47a12beSStefan Roese "JTAG", 369a47a12beSStefan Roese "reserved", 370a47a12beSStefan Roese "eSDHC", 371a47a12beSStefan Roese "PCI1", 372a47a12beSStefan Roese "PCI2", 373a47a12beSStefan Roese "DMA", 374a47a12beSStefan Roese "QUICC Engine 00", 375a47a12beSStefan Roese "QUICC Engine 01", 376a47a12beSStefan Roese "QUICC Engine 10", 377a47a12beSStefan Roese "QUICC Engine 11", 378a47a12beSStefan Roese "reserved", 379a47a12beSStefan Roese "reserved", 380a47a12beSStefan Roese "reserved", 381a47a12beSStefan Roese "reserved", 382a47a12beSStefan Roese "SATA1", 383a47a12beSStefan Roese "SATA2", 384a47a12beSStefan Roese "SATA3", 385a47a12beSStefan Roese "SATA4", 386a47a12beSStefan Roese "reserved", 387a47a12beSStefan Roese "PCI Express 1", 388a47a12beSStefan Roese "PCI Express 2", 389a47a12beSStefan Roese "TDM-DMAC" 390a47a12beSStefan Roese }; 391a47a12beSStefan Roese static char *transfer[] = { 392a47a12beSStefan Roese "Address-only, Clean Block", 393a47a12beSStefan Roese "Address-only, lwarx reservation set", 394a47a12beSStefan Roese "Single-beat or Burst write", 395a47a12beSStefan Roese "reserved", 396a47a12beSStefan Roese "Address-only, Flush Block", 397a47a12beSStefan Roese "reserved", 398a47a12beSStefan Roese "Burst write", 399a47a12beSStefan Roese "reserved", 400a47a12beSStefan Roese "Address-only, sync", 401a47a12beSStefan Roese "Address-only, tlbsync", 402a47a12beSStefan Roese "Single-beat or Burst read", 403a47a12beSStefan Roese "Single-beat or Burst read", 404a47a12beSStefan Roese "Address-only, Kill Block", 405a47a12beSStefan Roese "Address-only, icbi", 406a47a12beSStefan Roese "Burst read", 407a47a12beSStefan Roese "reserved", 408a47a12beSStefan Roese "Address-only, eieio", 409a47a12beSStefan Roese "reserved", 410a47a12beSStefan Roese "Single-beat write", 411a47a12beSStefan Roese "reserved", 412a47a12beSStefan Roese "ecowx - Illegal single-beat write", 413a47a12beSStefan Roese "reserved", 414a47a12beSStefan Roese "reserved", 415a47a12beSStefan Roese "reserved", 416a47a12beSStefan Roese "Address-only, TLB Invalidate", 417a47a12beSStefan Roese "reserved", 418a47a12beSStefan Roese "Single-beat or Burst read", 419a47a12beSStefan Roese "reserved", 420a47a12beSStefan Roese "eciwx - Illegal single-beat read", 421a47a12beSStefan Roese "reserved", 422a47a12beSStefan Roese "Burst read", 423a47a12beSStefan Roese "reserved" 424a47a12beSStefan Roese }; 425a47a12beSStefan Roese 42643e60814SSimon Glass int etype = (gd->arch.arbiter_event_attributes & AEATR_EVENT) 427a47a12beSStefan Roese >> AEATR_EVENT_SHIFT; 42843e60814SSimon Glass int mstr_id = (gd->arch.arbiter_event_attributes & AEATR_MSTR_ID) 429a47a12beSStefan Roese >> AEATR_MSTR_ID_SHIFT; 43043e60814SSimon Glass int tbst = (gd->arch.arbiter_event_attributes & AEATR_TBST) 431a47a12beSStefan Roese >> AEATR_TBST_SHIFT; 43243e60814SSimon Glass int tsize = (gd->arch.arbiter_event_attributes & AEATR_TSIZE) 433a47a12beSStefan Roese >> AEATR_TSIZE_SHIFT; 43443e60814SSimon Glass int ttype = (gd->arch.arbiter_event_attributes & AEATR_TTYPE) 435a47a12beSStefan Roese >> AEATR_TTYPE_SHIFT; 436a47a12beSStefan Roese 43743e60814SSimon Glass if (!force && !gd->arch.arbiter_event_address) 438a47a12beSStefan Roese return 0; 439a47a12beSStefan Roese 440a47a12beSStefan Roese puts("Arbiter Event Status:\n"); 44143e60814SSimon Glass printf(" Event Address: 0x%08lX\n", 44243e60814SSimon Glass gd->arch.arbiter_event_address); 443a47a12beSStefan Roese printf(" Event Type: 0x%1x = %s\n", etype, event[etype]); 444a47a12beSStefan Roese printf(" Master ID: 0x%02x = %s\n", mstr_id, master[mstr_id]); 445a47a12beSStefan Roese printf(" Transfer Size: 0x%1x = %d bytes\n", (tbst<<3) | tsize, 446a47a12beSStefan Roese tbst ? (tsize ? tsize : 8) : 16 + 8 * tsize); 447a47a12beSStefan Roese printf(" Transfer Type: 0x%02x = %s\n", ttype, transfer[ttype]); 448a47a12beSStefan Roese 44943e60814SSimon Glass return gd->arch.arbiter_event_address; 450a47a12beSStefan Roese } 451a47a12beSStefan Roese 452a47a12beSStefan Roese #elif defined(CONFIG_DISPLAY_AER_BRIEF) 453a47a12beSStefan Roese 454a47a12beSStefan Roese static int print_83xx_arb_event(int force) 455a47a12beSStefan Roese { 45643e60814SSimon Glass if (!force && !gd->arch.arbiter_event_address) 457a47a12beSStefan Roese return 0; 458a47a12beSStefan Roese 459a47a12beSStefan Roese printf("Arbiter Event Status: AEATR=0x%08lX, AEADR=0x%08lX\n", 46043e60814SSimon Glass gd->arch.arbiter_event_attributes, 46143e60814SSimon Glass gd->arch.arbiter_event_address); 462a47a12beSStefan Roese 46343e60814SSimon Glass return gd->arch.arbiter_event_address; 464a47a12beSStefan Roese } 465a47a12beSStefan Roese #endif /* CONFIG_DISPLAY_AER_xxxx */ 466a47a12beSStefan Roese 467a47a12beSStefan Roese /* 468a47a12beSStefan Roese * Figure out the cause of the reset 469a47a12beSStefan Roese */ 470a47a12beSStefan Roese int prt_83xx_rsr(void) 471a47a12beSStefan Roese { 472a47a12beSStefan Roese static struct { 473a47a12beSStefan Roese ulong mask; 474a47a12beSStefan Roese char *desc; 475a47a12beSStefan Roese } bits[] = { 476a47a12beSStefan Roese { 477a47a12beSStefan Roese RSR_SWSR, "Software Soft"}, { 478a47a12beSStefan Roese RSR_SWHR, "Software Hard"}, { 479a47a12beSStefan Roese RSR_JSRS, "JTAG Soft"}, { 480a47a12beSStefan Roese RSR_CSHR, "Check Stop"}, { 481a47a12beSStefan Roese RSR_SWRS, "Software Watchdog"}, { 482a47a12beSStefan Roese RSR_BMRS, "Bus Monitor"}, { 483a47a12beSStefan Roese RSR_SRS, "External/Internal Soft"}, { 484a47a12beSStefan Roese RSR_HRS, "External/Internal Hard"} 485a47a12beSStefan Roese }; 486b7707b04SRobert P. J. Day static int n = ARRAY_SIZE(bits); 4873c4c308cSSimon Glass ulong rsr = gd->arch.reset_status; 488a47a12beSStefan Roese int i; 489a47a12beSStefan Roese char *sep; 490a47a12beSStefan Roese 491a47a12beSStefan Roese puts("Reset Status:"); 492a47a12beSStefan Roese 493a47a12beSStefan Roese sep = " "; 494a47a12beSStefan Roese for (i = 0; i < n; i++) 495a47a12beSStefan Roese if (rsr & bits[i].mask) { 496a47a12beSStefan Roese printf("%s%s", sep, bits[i].desc); 497a47a12beSStefan Roese sep = ", "; 498a47a12beSStefan Roese } 499a47a12beSStefan Roese puts("\n"); 500a47a12beSStefan Roese 501a47a12beSStefan Roese #if defined(CONFIG_DISPLAY_AER_FULL) || defined(CONFIG_DISPLAY_AER_BRIEF) 502a47a12beSStefan Roese print_83xx_arb_event(rsr & RSR_BMRS); 503a47a12beSStefan Roese #endif 504a47a12beSStefan Roese puts("\n"); 505a47a12beSStefan Roese 506a47a12beSStefan Roese return 0; 507a47a12beSStefan Roese } 508