1acbca876SKumar Gala /* 2acbca876SKumar Gala * Copyright 2007 Freescale Semiconductor. 3acbca876SKumar Gala * 4acbca876SKumar Gala * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com> 5acbca876SKumar Gala * 6acbca876SKumar Gala * See file CREDITS for list of people who contributed to this 7acbca876SKumar Gala * project. 8acbca876SKumar Gala * 9acbca876SKumar Gala * This program is free software; you can redistribute it and/or 10acbca876SKumar Gala * modify it under the terms of the GNU General Public License as 11acbca876SKumar Gala * published by the Free Software Foundation; either version 2 of 12acbca876SKumar Gala * the License, or (at your option) any later version. 13acbca876SKumar Gala * 14acbca876SKumar Gala * This program is distributed in the hope that it will be useful, 15acbca876SKumar Gala * but WITHOUT ANY WARRANTY; without even the implied warranty of 16acbca876SKumar Gala * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17acbca876SKumar Gala * GNU General Public License for more details. 18acbca876SKumar Gala * 19acbca876SKumar Gala * You should have received a copy of the GNU General Public License 20acbca876SKumar Gala * along with this program; if not, write to the Free Software 21acbca876SKumar Gala * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 22acbca876SKumar Gala * MA 02111-1307 USA 23acbca876SKumar Gala */ 24acbca876SKumar Gala 25acbca876SKumar Gala #include <common.h> 26acbca876SKumar Gala #include <pci.h> 27acbca876SKumar Gala #include <asm/processor.h> 28e6f5b35bSJon Loeliger #include <asm/mmu.h> 29acbca876SKumar Gala #include <asm/immap_85xx.h> 30acbca876SKumar Gala #include <asm/immap_fsl_pci.h> 31e6f5b35bSJon Loeliger #include <asm/fsl_ddr_sdram.h> 32a30a549aSJon Loeliger #include <spd_sdram.h> 33acbca876SKumar Gala #include <i2c.h> 34acbca876SKumar Gala #include <ioports.h> 35acbca876SKumar Gala #include <libfdt.h> 36acbca876SKumar Gala #include <fdt_support.h> 37acbca876SKumar Gala 38acbca876SKumar Gala #include "bcsr.h" 39acbca876SKumar Gala 40acbca876SKumar Gala const qe_iop_conf_t qe_iop_conf_tab[] = { 41acbca876SKumar Gala /* GETH1 */ 42acbca876SKumar Gala {4, 10, 1, 0, 2}, /* TxD0 */ 43acbca876SKumar Gala {4, 9, 1, 0, 2}, /* TxD1 */ 44acbca876SKumar Gala {4, 8, 1, 0, 2}, /* TxD2 */ 45acbca876SKumar Gala {4, 7, 1, 0, 2}, /* TxD3 */ 46acbca876SKumar Gala {4, 23, 1, 0, 2}, /* TxD4 */ 47acbca876SKumar Gala {4, 22, 1, 0, 2}, /* TxD5 */ 48acbca876SKumar Gala {4, 21, 1, 0, 2}, /* TxD6 */ 49acbca876SKumar Gala {4, 20, 1, 0, 2}, /* TxD7 */ 50acbca876SKumar Gala {4, 15, 2, 0, 2}, /* RxD0 */ 51acbca876SKumar Gala {4, 14, 2, 0, 2}, /* RxD1 */ 52acbca876SKumar Gala {4, 13, 2, 0, 2}, /* RxD2 */ 53acbca876SKumar Gala {4, 12, 2, 0, 2}, /* RxD3 */ 54acbca876SKumar Gala {4, 29, 2, 0, 2}, /* RxD4 */ 55acbca876SKumar Gala {4, 28, 2, 0, 2}, /* RxD5 */ 56acbca876SKumar Gala {4, 27, 2, 0, 2}, /* RxD6 */ 57acbca876SKumar Gala {4, 26, 2, 0, 2}, /* RxD7 */ 58acbca876SKumar Gala {4, 11, 1, 0, 2}, /* TX_EN */ 59acbca876SKumar Gala {4, 24, 1, 0, 2}, /* TX_ER */ 60acbca876SKumar Gala {4, 16, 2, 0, 2}, /* RX_DV */ 61acbca876SKumar Gala {4, 30, 2, 0, 2}, /* RX_ER */ 62acbca876SKumar Gala {4, 17, 2, 0, 2}, /* RX_CLK */ 63acbca876SKumar Gala {4, 19, 1, 0, 2}, /* GTX_CLK */ 64acbca876SKumar Gala {1, 31, 2, 0, 3}, /* GTX125 */ 65acbca876SKumar Gala 66acbca876SKumar Gala /* GETH2 */ 67acbca876SKumar Gala {5, 10, 1, 0, 2}, /* TxD0 */ 68acbca876SKumar Gala {5, 9, 1, 0, 2}, /* TxD1 */ 69acbca876SKumar Gala {5, 8, 1, 0, 2}, /* TxD2 */ 70acbca876SKumar Gala {5, 7, 1, 0, 2}, /* TxD3 */ 71acbca876SKumar Gala {5, 23, 1, 0, 2}, /* TxD4 */ 72acbca876SKumar Gala {5, 22, 1, 0, 2}, /* TxD5 */ 73acbca876SKumar Gala {5, 21, 1, 0, 2}, /* TxD6 */ 74acbca876SKumar Gala {5, 20, 1, 0, 2}, /* TxD7 */ 75acbca876SKumar Gala {5, 15, 2, 0, 2}, /* RxD0 */ 76acbca876SKumar Gala {5, 14, 2, 0, 2}, /* RxD1 */ 77acbca876SKumar Gala {5, 13, 2, 0, 2}, /* RxD2 */ 78acbca876SKumar Gala {5, 12, 2, 0, 2}, /* RxD3 */ 79acbca876SKumar Gala {5, 29, 2, 0, 2}, /* RxD4 */ 80acbca876SKumar Gala {5, 28, 2, 0, 2}, /* RxD5 */ 81acbca876SKumar Gala {5, 27, 2, 0, 3}, /* RxD6 */ 82acbca876SKumar Gala {5, 26, 2, 0, 2}, /* RxD7 */ 83acbca876SKumar Gala {5, 11, 1, 0, 2}, /* TX_EN */ 84acbca876SKumar Gala {5, 24, 1, 0, 2}, /* TX_ER */ 85acbca876SKumar Gala {5, 16, 2, 0, 2}, /* RX_DV */ 86acbca876SKumar Gala {5, 30, 2, 0, 2}, /* RX_ER */ 87acbca876SKumar Gala {5, 17, 2, 0, 2}, /* RX_CLK */ 88acbca876SKumar Gala {5, 19, 1, 0, 2}, /* GTX_CLK */ 89acbca876SKumar Gala {1, 31, 2, 0, 3}, /* GTX125 */ 90acbca876SKumar Gala {4, 6, 3, 0, 2}, /* MDIO */ 91acbca876SKumar Gala {4, 5, 1, 0, 2}, /* MDC */ 9264d4bcb0SAnton Vorontsov 9364d4bcb0SAnton Vorontsov /* UART1 */ 9464d4bcb0SAnton Vorontsov {2, 0, 1, 0, 2}, /* UART_SOUT1 */ 9564d4bcb0SAnton Vorontsov {2, 1, 1, 0, 2}, /* UART_RTS1 */ 9664d4bcb0SAnton Vorontsov {2, 2, 2, 0, 2}, /* UART_CTS1 */ 9764d4bcb0SAnton Vorontsov {2, 3, 2, 0, 2}, /* UART_SIN1 */ 9864d4bcb0SAnton Vorontsov 99acbca876SKumar Gala {0, 0, 0, 0, QE_IOP_TAB_END}, /* END of table */ 100acbca876SKumar Gala }; 101acbca876SKumar Gala 102acbca876SKumar Gala void local_bus_init(void); 103acbca876SKumar Gala void sdram_init(void); 104acbca876SKumar Gala 105acbca876SKumar Gala int board_early_init_f (void) 106acbca876SKumar Gala { 107acbca876SKumar Gala /* 108acbca876SKumar Gala * Initialize local bus. 109acbca876SKumar Gala */ 110acbca876SKumar Gala local_bus_init (); 111acbca876SKumar Gala 112acbca876SKumar Gala enable_8568mds_duart(); 113acbca876SKumar Gala enable_8568mds_flash_write(); 114ad162249SAnton Vorontsov #if defined(CONFIG_UEC_ETH1) || defined(CONFIG_UEC_ETH2) 115ad162249SAnton Vorontsov reset_8568mds_uccs(); 116ad162249SAnton Vorontsov #endif 117acbca876SKumar Gala #if defined(CONFIG_QE) && !defined(CONFIG_eTSEC_MDIO_BUS) 118acbca876SKumar Gala enable_8568mds_qe_mdio(); 119acbca876SKumar Gala #endif 120acbca876SKumar Gala 1216d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #ifdef CONFIG_SYS_I2C2_OFFSET 122acbca876SKumar Gala /* Enable I2C2_SCL and I2C2_SDA */ 123acbca876SKumar Gala volatile struct par_io *port_c; 1246d0f6bcfSJean-Christophe PLAGNIOL-VILLARD port_c = (struct par_io*)(CONFIG_SYS_IMMR + 0xe0140); 125acbca876SKumar Gala port_c->cpdir2 |= 0x0f000000; 126acbca876SKumar Gala port_c->cppar2 &= ~0x0f000000; 127acbca876SKumar Gala port_c->cppar2 |= 0x0a000000; 128acbca876SKumar Gala #endif 129acbca876SKumar Gala 130acbca876SKumar Gala return 0; 131acbca876SKumar Gala } 132acbca876SKumar Gala 133acbca876SKumar Gala int checkboard (void) 134acbca876SKumar Gala { 135acbca876SKumar Gala printf ("Board: 8568 MDS\n"); 136acbca876SKumar Gala 137acbca876SKumar Gala return 0; 138acbca876SKumar Gala } 139acbca876SKumar Gala 1409973e3c6SBecky Bruce phys_size_t 141acbca876SKumar Gala initdram(int board_type) 142acbca876SKumar Gala { 143acbca876SKumar Gala long dram_size = 0; 144acbca876SKumar Gala 145acbca876SKumar Gala puts("Initializing\n"); 146acbca876SKumar Gala 147acbca876SKumar Gala #if defined(CONFIG_DDR_DLL) 148acbca876SKumar Gala { 149acbca876SKumar Gala /* 150acbca876SKumar Gala * Work around to stabilize DDR DLL MSYNC_IN. 151acbca876SKumar Gala * Errata DDR9 seems to have been fixed. 152acbca876SKumar Gala * This is now the workaround for Errata DDR11: 153acbca876SKumar Gala * Override DLL = 1, Course Adj = 1, Tap Select = 0 154acbca876SKumar Gala */ 155acbca876SKumar Gala 1566d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); 157acbca876SKumar Gala 158acbca876SKumar Gala gur->ddrdllcr = 0x81000000; 159acbca876SKumar Gala asm("sync;isync;msync"); 160acbca876SKumar Gala udelay(200); 161acbca876SKumar Gala } 162acbca876SKumar Gala #endif 163e6f5b35bSJon Loeliger 164e6f5b35bSJon Loeliger dram_size = fsl_ddr_sdram(); 165e6f5b35bSJon Loeliger dram_size = setup_ddr_tlbs(dram_size / 0x100000); 166e6f5b35bSJon Loeliger dram_size *= 0x100000; 167acbca876SKumar Gala 168acbca876SKumar Gala /* 169acbca876SKumar Gala * SDRAM Initialization 170acbca876SKumar Gala */ 171acbca876SKumar Gala sdram_init(); 172acbca876SKumar Gala 173acbca876SKumar Gala puts(" DDR: "); 174acbca876SKumar Gala return dram_size; 175acbca876SKumar Gala } 176acbca876SKumar Gala 177acbca876SKumar Gala /* 178acbca876SKumar Gala * Initialize Local Bus 179acbca876SKumar Gala */ 180acbca876SKumar Gala void 181acbca876SKumar Gala local_bus_init(void) 182acbca876SKumar Gala { 1836d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); 1846d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR); 185acbca876SKumar Gala 186acbca876SKumar Gala uint clkdiv; 187acbca876SKumar Gala uint lbc_hz; 188acbca876SKumar Gala sys_info_t sysinfo; 189acbca876SKumar Gala 190acbca876SKumar Gala get_sys_info(&sysinfo); 191*a5d212a2STrent Piepho clkdiv = (lbc->lcrr & LCRR_CLKDIV) * 2; 192acbca876SKumar Gala lbc_hz = sysinfo.freqSystemBus / 1000000 / clkdiv; 193acbca876SKumar Gala 194acbca876SKumar Gala gur->lbiuiplldcr1 = 0x00078080; 195acbca876SKumar Gala if (clkdiv == 16) { 196acbca876SKumar Gala gur->lbiuiplldcr0 = 0x7c0f1bf0; 197acbca876SKumar Gala } else if (clkdiv == 8) { 198acbca876SKumar Gala gur->lbiuiplldcr0 = 0x6c0f1bf0; 199acbca876SKumar Gala } else if (clkdiv == 4) { 200acbca876SKumar Gala gur->lbiuiplldcr0 = 0x5c0f1bf0; 201acbca876SKumar Gala } 202acbca876SKumar Gala 203acbca876SKumar Gala lbc->lcrr |= 0x00030000; 204acbca876SKumar Gala 205acbca876SKumar Gala asm("sync;isync;msync"); 206acbca876SKumar Gala } 207acbca876SKumar Gala 208acbca876SKumar Gala /* 209acbca876SKumar Gala * Initialize SDRAM memory on the Local Bus. 210acbca876SKumar Gala */ 211acbca876SKumar Gala void 212acbca876SKumar Gala sdram_init(void) 213acbca876SKumar Gala { 2146d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM) 215acbca876SKumar Gala 216acbca876SKumar Gala uint idx; 2176d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR); 2186d0f6bcfSJean-Christophe PLAGNIOL-VILLARD uint *sdram_addr = (uint *)CONFIG_SYS_LBC_SDRAM_BASE; 219acbca876SKumar Gala uint lsdmr_common; 220acbca876SKumar Gala 221acbca876SKumar Gala puts(" SDRAM: "); 222acbca876SKumar Gala 2236d0f6bcfSJean-Christophe PLAGNIOL-VILLARD print_size (CONFIG_SYS_LBC_SDRAM_SIZE * 1024 * 1024, "\n"); 224acbca876SKumar Gala 225acbca876SKumar Gala /* 226acbca876SKumar Gala * Setup SDRAM Base and Option Registers 227acbca876SKumar Gala */ 2286d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->or2 = CONFIG_SYS_OR2_PRELIM; 229acbca876SKumar Gala asm("msync"); 230acbca876SKumar Gala 2316d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->br2 = CONFIG_SYS_BR2_PRELIM; 232acbca876SKumar Gala asm("msync"); 233acbca876SKumar Gala 2346d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->lbcr = CONFIG_SYS_LBC_LBCR; 235acbca876SKumar Gala asm("msync"); 236acbca876SKumar Gala 237acbca876SKumar Gala 2386d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->lsrt = CONFIG_SYS_LBC_LSRT; 2396d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->mrtpr = CONFIG_SYS_LBC_MRTPR; 240acbca876SKumar Gala asm("msync"); 241acbca876SKumar Gala 242acbca876SKumar Gala /* 243acbca876SKumar Gala * MPC8568 uses "new" 15-16 style addressing. 244acbca876SKumar Gala */ 2456d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lsdmr_common = CONFIG_SYS_LBC_LSDMR_COMMON; 2466d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lsdmr_common |= CONFIG_SYS_LBC_LSDMR_BSMA1516; 247acbca876SKumar Gala 248acbca876SKumar Gala /* 249acbca876SKumar Gala * Issue PRECHARGE ALL command. 250acbca876SKumar Gala */ 2516d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->lsdmr = lsdmr_common | CONFIG_SYS_LBC_LSDMR_OP_PCHALL; 252acbca876SKumar Gala asm("sync;msync"); 253acbca876SKumar Gala *sdram_addr = 0xff; 254acbca876SKumar Gala ppcDcbf((unsigned long) sdram_addr); 255acbca876SKumar Gala udelay(100); 256acbca876SKumar Gala 257acbca876SKumar Gala /* 258acbca876SKumar Gala * Issue 8 AUTO REFRESH commands. 259acbca876SKumar Gala */ 260acbca876SKumar Gala for (idx = 0; idx < 8; idx++) { 2616d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->lsdmr = lsdmr_common | CONFIG_SYS_LBC_LSDMR_OP_ARFRSH; 262acbca876SKumar Gala asm("sync;msync"); 263acbca876SKumar Gala *sdram_addr = 0xff; 264acbca876SKumar Gala ppcDcbf((unsigned long) sdram_addr); 265acbca876SKumar Gala udelay(100); 266acbca876SKumar Gala } 267acbca876SKumar Gala 268acbca876SKumar Gala /* 269acbca876SKumar Gala * Issue 8 MODE-set command. 270acbca876SKumar Gala */ 2716d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->lsdmr = lsdmr_common | CONFIG_SYS_LBC_LSDMR_OP_MRW; 272acbca876SKumar Gala asm("sync;msync"); 273acbca876SKumar Gala *sdram_addr = 0xff; 274acbca876SKumar Gala ppcDcbf((unsigned long) sdram_addr); 275acbca876SKumar Gala udelay(100); 276acbca876SKumar Gala 277acbca876SKumar Gala /* 278acbca876SKumar Gala * Issue NORMAL OP command. 279acbca876SKumar Gala */ 2806d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->lsdmr = lsdmr_common | CONFIG_SYS_LBC_LSDMR_OP_NORMAL; 281acbca876SKumar Gala asm("sync;msync"); 282acbca876SKumar Gala *sdram_addr = 0xff; 283acbca876SKumar Gala ppcDcbf((unsigned long) sdram_addr); 284acbca876SKumar Gala udelay(200); /* Overkill. Must wait > 200 bus cycles */ 285acbca876SKumar Gala 286acbca876SKumar Gala #endif /* enable SDRAM init */ 287acbca876SKumar Gala } 288acbca876SKumar Gala 289acbca876SKumar Gala #if defined(CONFIG_PCI) 290acbca876SKumar Gala #ifndef CONFIG_PCI_PNP 291acbca876SKumar Gala static struct pci_config_table pci_mpc8568mds_config_table[] = { 292acbca876SKumar Gala { 293acbca876SKumar Gala PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, 294acbca876SKumar Gala pci_cfgfunc_config_device, 295acbca876SKumar Gala {PCI_ENET0_IOADDR, 296acbca876SKumar Gala PCI_ENET0_MEMADDR, 297acbca876SKumar Gala PCI_COMMON_MEMORY | PCI_COMMAND_MASTER} 298acbca876SKumar Gala }, 299acbca876SKumar Gala {} 300acbca876SKumar Gala }; 301acbca876SKumar Gala #endif 302acbca876SKumar Gala 303acbca876SKumar Gala static struct pci_controller pci1_hose = { 304acbca876SKumar Gala #ifndef CONFIG_PCI_PNP 305acbca876SKumar Gala config_table: pci_mpc8568mds_config_table, 306acbca876SKumar Gala #endif 307acbca876SKumar Gala }; 308acbca876SKumar Gala #endif /* CONFIG_PCI */ 309acbca876SKumar Gala 310acbca876SKumar Gala #ifdef CONFIG_PCIE1 311acbca876SKumar Gala static struct pci_controller pcie1_hose; 312acbca876SKumar Gala #endif /* CONFIG_PCIE1 */ 313acbca876SKumar Gala 3142dba0deaSKumar Gala extern int fsl_pci_setup_inbound_windows(struct pci_region *r); 3152dba0deaSKumar Gala extern void fsl_pci_init(struct pci_controller *hose); 3162dba0deaSKumar Gala 317acbca876SKumar Gala int first_free_busno = 0; 318acbca876SKumar Gala 319acbca876SKumar Gala /* 320acbca876SKumar Gala * pib_init() -- Initialize the PCA9555 IO expander on the PIB board 321acbca876SKumar Gala */ 322acbca876SKumar Gala void 323acbca876SKumar Gala pib_init(void) 324acbca876SKumar Gala { 325acbca876SKumar Gala u8 val8, orig_i2c_bus; 326acbca876SKumar Gala /* 327acbca876SKumar Gala * Assign PIB PMC2/3 to PCI bus 328acbca876SKumar Gala */ 329acbca876SKumar Gala 330acbca876SKumar Gala /*switch temporarily to I2C bus #2 */ 331acbca876SKumar Gala orig_i2c_bus = i2c_get_bus_num(); 332acbca876SKumar Gala i2c_set_bus_num(1); 333acbca876SKumar Gala 334acbca876SKumar Gala val8 = 0x00; 335acbca876SKumar Gala i2c_write(0x23, 0x6, 1, &val8, 1); 336acbca876SKumar Gala i2c_write(0x23, 0x7, 1, &val8, 1); 337acbca876SKumar Gala val8 = 0xff; 338acbca876SKumar Gala i2c_write(0x23, 0x2, 1, &val8, 1); 339acbca876SKumar Gala i2c_write(0x23, 0x3, 1, &val8, 1); 340acbca876SKumar Gala 341acbca876SKumar Gala val8 = 0x00; 342acbca876SKumar Gala i2c_write(0x26, 0x6, 1, &val8, 1); 343acbca876SKumar Gala val8 = 0x34; 344acbca876SKumar Gala i2c_write(0x26, 0x7, 1, &val8, 1); 345acbca876SKumar Gala val8 = 0xf9; 346acbca876SKumar Gala i2c_write(0x26, 0x2, 1, &val8, 1); 347acbca876SKumar Gala val8 = 0xff; 348acbca876SKumar Gala i2c_write(0x26, 0x3, 1, &val8, 1); 349acbca876SKumar Gala 350acbca876SKumar Gala val8 = 0x00; 351acbca876SKumar Gala i2c_write(0x27, 0x6, 1, &val8, 1); 352acbca876SKumar Gala i2c_write(0x27, 0x7, 1, &val8, 1); 353acbca876SKumar Gala val8 = 0xff; 354acbca876SKumar Gala i2c_write(0x27, 0x2, 1, &val8, 1); 355acbca876SKumar Gala val8 = 0xef; 356acbca876SKumar Gala i2c_write(0x27, 0x3, 1, &val8, 1); 357acbca876SKumar Gala 358acbca876SKumar Gala asm("eieio"); 359acbca876SKumar Gala } 360acbca876SKumar Gala 361acbca876SKumar Gala #ifdef CONFIG_PCI 362acbca876SKumar Gala void 363acbca876SKumar Gala pci_init_board(void) 364acbca876SKumar Gala { 3656d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); 366acbca876SKumar Gala uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19; 367acbca876SKumar Gala uint host_agent = (gur->porbmsr & MPC85xx_PORBMSR_HA) >> 16; 368acbca876SKumar Gala 369acbca876SKumar Gala #ifdef CONFIG_PCI1 370acbca876SKumar Gala { 371acbca876SKumar Gala pib_init(); 372acbca876SKumar Gala 3736d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCI1_ADDR; 374acbca876SKumar Gala struct pci_controller *hose = &pci1_hose; 3752dba0deaSKumar Gala struct pci_region *r = hose->regions; 376acbca876SKumar Gala 377acbca876SKumar Gala uint pci_32 = 1; /* PORDEVSR[15] */ 378acbca876SKumar Gala uint pci_arb = gur->pordevsr & MPC85xx_PORDEVSR_PCI1_ARB; /* PORDEVSR[14] */ 379acbca876SKumar Gala uint pci_clk_sel = gur->porpllsr & MPC85xx_PORDEVSR_PCI1_SPD; /* PORPLLSR[16] */ 380acbca876SKumar Gala 381acbca876SKumar Gala uint pci_agent = (host_agent == 3) || (host_agent == 4 ) || (host_agent == 6); 382acbca876SKumar Gala 383acbca876SKumar Gala uint pci_speed = 66666000; 384acbca876SKumar Gala 385acbca876SKumar Gala if (!(gur->devdisr & MPC85xx_DEVDISR_PCI1)) { 386acbca876SKumar Gala printf (" PCI: %d bit, %s MHz, %s, %s, %s\n", 387acbca876SKumar Gala (pci_32) ? 32 : 64, 388acbca876SKumar Gala (pci_speed == 33333000) ? "33" : 389acbca876SKumar Gala (pci_speed == 66666000) ? "66" : "unknown", 390acbca876SKumar Gala pci_clk_sel ? "sync" : "async", 391acbca876SKumar Gala pci_agent ? "agent" : "host", 392acbca876SKumar Gala pci_arb ? "arbiter" : "external-arbiter" 393acbca876SKumar Gala ); 394acbca876SKumar Gala 395acbca876SKumar Gala /* inbound */ 3962dba0deaSKumar Gala r += fsl_pci_setup_inbound_windows(r); 397acbca876SKumar Gala 398acbca876SKumar Gala /* outbound memory */ 3992dba0deaSKumar Gala pci_set_region(r++, 4006d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCI1_MEM_BASE, 4016d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCI1_MEM_PHYS, 4026d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCI1_MEM_SIZE, 403acbca876SKumar Gala PCI_REGION_MEM); 404acbca876SKumar Gala 405acbca876SKumar Gala /* outbound io */ 4062dba0deaSKumar Gala pci_set_region(r++, 4076d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCI1_IO_BASE, 4086d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCI1_IO_PHYS, 4096d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCI1_IO_SIZE, 410acbca876SKumar Gala PCI_REGION_IO); 411acbca876SKumar Gala 4122dba0deaSKumar Gala hose->region_count = r - hose->regions; 413acbca876SKumar Gala 414acbca876SKumar Gala hose->first_busno = first_free_busno; 415acbca876SKumar Gala pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); 416acbca876SKumar Gala 417acbca876SKumar Gala fsl_pci_init(hose); 418acbca876SKumar Gala first_free_busno = hose->last_busno+1; 419acbca876SKumar Gala printf ("PCI on bus %02x - %02x\n",hose->first_busno,hose->last_busno); 420acbca876SKumar Gala } else { 421acbca876SKumar Gala printf (" PCI: disabled\n"); 422acbca876SKumar Gala } 423acbca876SKumar Gala } 424acbca876SKumar Gala #else 425acbca876SKumar Gala gur->devdisr |= MPC85xx_DEVDISR_PCI1; /* disable */ 426acbca876SKumar Gala #endif 427acbca876SKumar Gala 428acbca876SKumar Gala #ifdef CONFIG_PCIE1 429acbca876SKumar Gala { 4306d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE1_ADDR; 431acbca876SKumar Gala struct pci_controller *hose = &pcie1_hose; 432acbca876SKumar Gala int pcie_ep = (host_agent == 0) || (host_agent == 2 ) || (host_agent == 3); 4332dba0deaSKumar Gala struct pci_region *r = hose->regions; 434acbca876SKumar Gala 435acbca876SKumar Gala int pcie_configured = io_sel >= 1; 436acbca876SKumar Gala 437acbca876SKumar Gala if (pcie_configured && !(gur->devdisr & MPC85xx_DEVDISR_PCIE)){ 438acbca876SKumar Gala printf ("\n PCIE connected to slot as %s (base address %x)", 439acbca876SKumar Gala pcie_ep ? "End Point" : "Root Complex", 440acbca876SKumar Gala (uint)pci); 441acbca876SKumar Gala 442acbca876SKumar Gala if (pci->pme_msg_det) { 443acbca876SKumar Gala pci->pme_msg_det = 0xffffffff; 444acbca876SKumar Gala debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det); 445acbca876SKumar Gala } 446acbca876SKumar Gala printf ("\n"); 447acbca876SKumar Gala 448acbca876SKumar Gala /* inbound */ 4492dba0deaSKumar Gala r += fsl_pci_setup_inbound_windows(r); 450acbca876SKumar Gala 451acbca876SKumar Gala /* outbound memory */ 4522dba0deaSKumar Gala pci_set_region(r++, 4536d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE1_MEM_BASE, 4546d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE1_MEM_PHYS, 4556d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE1_MEM_SIZE, 456acbca876SKumar Gala PCI_REGION_MEM); 457acbca876SKumar Gala 458acbca876SKumar Gala /* outbound io */ 4592dba0deaSKumar Gala pci_set_region(r++, 4606d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE1_IO_BASE, 4616d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE1_IO_PHYS, 4626d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE1_IO_SIZE, 463acbca876SKumar Gala PCI_REGION_IO); 464acbca876SKumar Gala 4652dba0deaSKumar Gala hose->region_count = r - hose->regions; 466acbca876SKumar Gala 467acbca876SKumar Gala hose->first_busno=first_free_busno; 468acbca876SKumar Gala pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); 469acbca876SKumar Gala 470acbca876SKumar Gala fsl_pci_init(hose); 471acbca876SKumar Gala printf ("PCIE on bus %02x - %02x\n",hose->first_busno,hose->last_busno); 472acbca876SKumar Gala 473acbca876SKumar Gala first_free_busno=hose->last_busno+1; 474acbca876SKumar Gala 475acbca876SKumar Gala } else { 476acbca876SKumar Gala printf (" PCIE: disabled\n"); 477acbca876SKumar Gala } 478acbca876SKumar Gala } 479acbca876SKumar Gala #else 480acbca876SKumar Gala gur->devdisr |= MPC85xx_DEVDISR_PCIE; /* disable */ 481acbca876SKumar Gala #endif 482acbca876SKumar Gala } 483acbca876SKumar Gala #endif /* CONFIG_PCI */ 484acbca876SKumar Gala 485acbca876SKumar Gala #if defined(CONFIG_OF_BOARD_SETUP) 4862dba0deaSKumar Gala extern void ft_fsl_pci_setup(void *blob, const char *pci_alias, 4872dba0deaSKumar Gala struct pci_controller *hose); 488acbca876SKumar Gala 4892dba0deaSKumar Gala void ft_board_setup(void *blob, bd_t *bd) 4902dba0deaSKumar Gala { 491acbca876SKumar Gala ft_cpu_setup(blob, bd); 492acbca876SKumar Gala 493acbca876SKumar Gala #ifdef CONFIG_PCI1 4942dba0deaSKumar Gala ft_fsl_pci_setup(blob, "pci0", &pci1_hose); 495acbca876SKumar Gala #endif 496acbca876SKumar Gala #ifdef CONFIG_PCIE1 4972dba0deaSKumar Gala ft_fsl_pci_setup(blob, "pci1", &pcie1_hose); 498acbca876SKumar Gala #endif 499acbca876SKumar Gala } 500acbca876SKumar Gala #endif 501