125d83d7fSJon Loeliger /* 225d83d7fSJon Loeliger * Copyright 2007 Freescale Semiconductor, Inc. 325d83d7fSJon Loeliger * 425d83d7fSJon Loeliger * See file CREDITS for list of people who contributed to this 525d83d7fSJon Loeliger * project. 625d83d7fSJon Loeliger * 725d83d7fSJon Loeliger * This program is free software; you can redistribute it and/or 825d83d7fSJon Loeliger * modify it under the terms of the GNU General Public License as 925d83d7fSJon Loeliger * published by the Free Software Foundation; either version 2 of 1025d83d7fSJon Loeliger * the License, or (at your option) any later version. 1125d83d7fSJon Loeliger * 1225d83d7fSJon Loeliger * This program is distributed in the hope that it will be useful, 1325d83d7fSJon Loeliger * but WITHOUT ANY WARRANTY; without even the implied warranty of 1425d83d7fSJon Loeliger * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1525d83d7fSJon Loeliger * GNU General Public License for more details. 1625d83d7fSJon Loeliger * 1725d83d7fSJon Loeliger * You should have received a copy of the GNU General Public License 1825d83d7fSJon Loeliger * along with this program; if not, write to the Free Software 1925d83d7fSJon Loeliger * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 2025d83d7fSJon Loeliger * MA 02111-1307 USA 2125d83d7fSJon Loeliger */ 2225d83d7fSJon Loeliger 2325d83d7fSJon Loeliger #include <common.h> 2425d83d7fSJon Loeliger #include <command.h> 25837f1ba0SEd Swarthout #include <pci.h> 2625d83d7fSJon Loeliger #include <asm/processor.h> 271167a2fdSKumar Gala #include <asm/mmu.h> 2825d83d7fSJon Loeliger #include <asm/immap_85xx.h> 29837f1ba0SEd Swarthout #include <asm/immap_fsl_pci.h> 301167a2fdSKumar Gala #include <asm/fsl_ddr_sdram.h> 3156a92705SKumar Gala #include <asm/io.h> 3225d83d7fSJon Loeliger #include <miiphy.h> 33addce57eSKumar Gala #include <libfdt.h> 34addce57eSKumar Gala #include <fdt_support.h> 35216f2a71SAndy Fleming #include <tsec.h> 360b252f50SBen Warren #include <netdev.h> 3725d83d7fSJon Loeliger 3825d83d7fSJon Loeliger #include "../common/pixis.h" 39216f2a71SAndy Fleming #include "../common/sgmii_riser.h" 4025d83d7fSJon Loeliger 4125d83d7fSJon Loeliger #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) 4225d83d7fSJon Loeliger extern void ddr_enable_ecc(unsigned int dram_size); 4325d83d7fSJon Loeliger #endif 4425d83d7fSJon Loeliger 4525d83d7fSJon Loeliger int checkboard (void) 4625d83d7fSJon Loeliger { 476d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); 486d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR); 496d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR); 5025d83d7fSJon Loeliger 5125d83d7fSJon Loeliger if ((uint)&gur->porpllsr != 0xe00e0000) { 529b55a253SWolfgang Denk printf("immap size error %lx\n",(ulong)&gur->porpllsr); 5325d83d7fSJon Loeliger } 54e5852787SKumar Gala printf ("Board: MPC8544DS, System ID: 0x%02x, " 55e5852787SKumar Gala "System Version: 0x%02x, FPGA Version: 0x%02x\n", 56e5852787SKumar Gala in8(PIXIS_BASE + PIXIS_ID), in8(PIXIS_BASE + PIXIS_VER), 57e5852787SKumar Gala in8(PIXIS_BASE + PIXIS_PVER)); 5825d83d7fSJon Loeliger 59837f1ba0SEd Swarthout lbc->ltesr = 0xffffffff; /* Clear LBC error interrupts */ 60837f1ba0SEd Swarthout lbc->lteir = 0xffffffff; /* Enable LBC error interrupts */ 61837f1ba0SEd Swarthout ecm->eedr = 0xffffffff; /* Clear ecm errors */ 62837f1ba0SEd Swarthout ecm->eeer = 0xffffffff; /* Enable ecm errors */ 63837f1ba0SEd Swarthout 6425d83d7fSJon Loeliger return 0; 6525d83d7fSJon Loeliger } 6625d83d7fSJon Loeliger 679973e3c6SBecky Bruce phys_size_t 6825d83d7fSJon Loeliger initdram(int board_type) 6925d83d7fSJon Loeliger { 7025d83d7fSJon Loeliger long dram_size = 0; 7125d83d7fSJon Loeliger 7225d83d7fSJon Loeliger puts("Initializing\n"); 7325d83d7fSJon Loeliger 741167a2fdSKumar Gala dram_size = fsl_ddr_sdram(); 751167a2fdSKumar Gala 761167a2fdSKumar Gala dram_size = setup_ddr_tlbs(dram_size / 0x100000); 771167a2fdSKumar Gala 781167a2fdSKumar Gala dram_size *= 0x100000; 7925d83d7fSJon Loeliger 8025d83d7fSJon Loeliger #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) 8125d83d7fSJon Loeliger /* 8225d83d7fSJon Loeliger * Initialize and enable DDR ECC. 8325d83d7fSJon Loeliger */ 8425d83d7fSJon Loeliger ddr_enable_ecc(dram_size); 8525d83d7fSJon Loeliger #endif 8625d83d7fSJon Loeliger puts(" DDR: "); 8725d83d7fSJon Loeliger return dram_size; 8825d83d7fSJon Loeliger } 8925d83d7fSJon Loeliger 90837f1ba0SEd Swarthout #ifdef CONFIG_PCI1 91837f1ba0SEd Swarthout static struct pci_controller pci1_hose; 92837f1ba0SEd Swarthout #endif 93837f1ba0SEd Swarthout 94837f1ba0SEd Swarthout #ifdef CONFIG_PCIE1 95837f1ba0SEd Swarthout static struct pci_controller pcie1_hose; 96837f1ba0SEd Swarthout #endif 97837f1ba0SEd Swarthout 98837f1ba0SEd Swarthout #ifdef CONFIG_PCIE2 99837f1ba0SEd Swarthout static struct pci_controller pcie2_hose; 100837f1ba0SEd Swarthout #endif 101837f1ba0SEd Swarthout 102837f1ba0SEd Swarthout #ifdef CONFIG_PCIE3 103837f1ba0SEd Swarthout static struct pci_controller pcie3_hose; 104837f1ba0SEd Swarthout #endif 105837f1ba0SEd Swarthout 106*2dba0deaSKumar Gala extern int fsl_pci_setup_inbound_windows(struct pci_region *r); 107*2dba0deaSKumar Gala extern void fsl_pci_init(struct pci_controller *hose); 108*2dba0deaSKumar Gala 109837f1ba0SEd Swarthout int first_free_busno=0; 110837f1ba0SEd Swarthout 111837f1ba0SEd Swarthout void 112837f1ba0SEd Swarthout pci_init_board(void) 113837f1ba0SEd Swarthout { 1146d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); 115837f1ba0SEd Swarthout uint devdisr = gur->devdisr; 116837f1ba0SEd Swarthout uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19; 117837f1ba0SEd Swarthout uint host_agent = (gur->porbmsr & MPC85xx_PORBMSR_HA) >> 16; 118837f1ba0SEd Swarthout 119837f1ba0SEd Swarthout debug (" pci_init_board: devdisr=%x, io_sel=%x, host_agent=%x\n", 120837f1ba0SEd Swarthout devdisr, io_sel, host_agent); 121837f1ba0SEd Swarthout 122837f1ba0SEd Swarthout if (io_sel & 1) { 123837f1ba0SEd Swarthout if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS)) 124837f1ba0SEd Swarthout printf (" eTSEC1 is in sgmii mode.\n"); 125837f1ba0SEd Swarthout if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS)) 126837f1ba0SEd Swarthout printf (" eTSEC3 is in sgmii mode.\n"); 127837f1ba0SEd Swarthout } 128837f1ba0SEd Swarthout 129837f1ba0SEd Swarthout #ifdef CONFIG_PCIE3 130837f1ba0SEd Swarthout { 1316d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE3_ADDR; 132837f1ba0SEd Swarthout struct pci_controller *hose = &pcie3_hose; 133f97abbfbSEd Swarthout int pcie_ep = (host_agent == 1); 134837f1ba0SEd Swarthout int pcie_configured = io_sel >= 1; 135*2dba0deaSKumar Gala struct pci_region *r = hose->regions; 136837f1ba0SEd Swarthout 137837f1ba0SEd Swarthout if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){ 138837f1ba0SEd Swarthout printf ("\n PCIE3 connected to ULI as %s (base address %x)", 139837f1ba0SEd Swarthout pcie_ep ? "End Point" : "Root Complex", 140837f1ba0SEd Swarthout (uint)pci); 141837f1ba0SEd Swarthout if (pci->pme_msg_det) { 142837f1ba0SEd Swarthout pci->pme_msg_det = 0xffffffff; 143837f1ba0SEd Swarthout debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det); 144837f1ba0SEd Swarthout } 145837f1ba0SEd Swarthout printf ("\n"); 146837f1ba0SEd Swarthout 147837f1ba0SEd Swarthout /* inbound */ 148*2dba0deaSKumar Gala r += fsl_pci_setup_inbound_windows(r); 149837f1ba0SEd Swarthout 150837f1ba0SEd Swarthout /* outbound memory */ 151*2dba0deaSKumar Gala pci_set_region(r++, 1526d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE3_MEM_BASE, 1536d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE3_MEM_PHYS, 1546d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE3_MEM_SIZE, 155837f1ba0SEd Swarthout PCI_REGION_MEM); 156837f1ba0SEd Swarthout 157837f1ba0SEd Swarthout /* outbound io */ 158*2dba0deaSKumar Gala pci_set_region(r++, 1596d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE3_IO_BASE, 1606d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE3_IO_PHYS, 1616d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE3_IO_SIZE, 162837f1ba0SEd Swarthout PCI_REGION_IO); 163837f1ba0SEd Swarthout 1646d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #ifdef CONFIG_SYS_PCIE3_MEM_BASE2 165837f1ba0SEd Swarthout /* outbound memory */ 166*2dba0deaSKumar Gala pci_set_region(r++, 1676d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE3_MEM_BASE2, 1686d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE3_MEM_PHYS2, 1696d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE3_MEM_SIZE2, 170837f1ba0SEd Swarthout PCI_REGION_MEM); 171837f1ba0SEd Swarthout #endif 172*2dba0deaSKumar Gala hose->region_count = r - hose->regions; 173837f1ba0SEd Swarthout hose->first_busno=first_free_busno; 174837f1ba0SEd Swarthout pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); 175837f1ba0SEd Swarthout 176837f1ba0SEd Swarthout fsl_pci_init(hose); 177837f1ba0SEd Swarthout 178837f1ba0SEd Swarthout first_free_busno=hose->last_busno+1; 179837f1ba0SEd Swarthout printf (" PCIE3 on bus %02x - %02x\n", 180837f1ba0SEd Swarthout hose->first_busno,hose->last_busno); 181837f1ba0SEd Swarthout 18256a92705SKumar Gala /* 18356a92705SKumar Gala * Activate ULI1575 legacy chip by performing a fake 18456a92705SKumar Gala * memory access. Needed to make ULI RTC work. 18556a92705SKumar Gala */ 1866d0f6bcfSJean-Christophe PLAGNIOL-VILLARD in_be32((u32 *)CONFIG_SYS_PCIE3_MEM_BASE); 187837f1ba0SEd Swarthout } else { 188837f1ba0SEd Swarthout printf (" PCIE3: disabled\n"); 189837f1ba0SEd Swarthout } 190837f1ba0SEd Swarthout 191837f1ba0SEd Swarthout } 192837f1ba0SEd Swarthout #else 193837f1ba0SEd Swarthout gur->devdisr |= MPC85xx_DEVDISR_PCIE3; /* disable */ 194837f1ba0SEd Swarthout #endif 195837f1ba0SEd Swarthout 196837f1ba0SEd Swarthout #ifdef CONFIG_PCIE1 197837f1ba0SEd Swarthout { 1986d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE1_ADDR; 199837f1ba0SEd Swarthout struct pci_controller *hose = &pcie1_hose; 200837f1ba0SEd Swarthout int pcie_ep = (host_agent == 5); 201837f1ba0SEd Swarthout int pcie_configured = io_sel & 6; 202*2dba0deaSKumar Gala struct pci_region *r = hose->regions; 203837f1ba0SEd Swarthout 204837f1ba0SEd Swarthout if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){ 205837f1ba0SEd Swarthout printf ("\n PCIE1 connected to Slot2 as %s (base address %x)", 206837f1ba0SEd Swarthout pcie_ep ? "End Point" : "Root Complex", 207837f1ba0SEd Swarthout (uint)pci); 208837f1ba0SEd Swarthout if (pci->pme_msg_det) { 209837f1ba0SEd Swarthout pci->pme_msg_det = 0xffffffff; 210837f1ba0SEd Swarthout debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det); 211837f1ba0SEd Swarthout } 212837f1ba0SEd Swarthout printf ("\n"); 213837f1ba0SEd Swarthout 214837f1ba0SEd Swarthout /* inbound */ 215*2dba0deaSKumar Gala r += fsl_pci_setup_inbound_windows(r); 216837f1ba0SEd Swarthout 217837f1ba0SEd Swarthout /* outbound memory */ 218*2dba0deaSKumar Gala pci_set_region(r++, 2196d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE1_MEM_BASE, 2206d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE1_MEM_PHYS, 2216d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE1_MEM_SIZE, 222837f1ba0SEd Swarthout PCI_REGION_MEM); 223837f1ba0SEd Swarthout 224837f1ba0SEd Swarthout /* outbound io */ 225*2dba0deaSKumar Gala pci_set_region(r++, 2266d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE1_IO_BASE, 2276d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE1_IO_PHYS, 2286d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE1_IO_SIZE, 229837f1ba0SEd Swarthout PCI_REGION_IO); 230837f1ba0SEd Swarthout 2316d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #ifdef CONFIG_SYS_PCIE1_MEM_BASE2 232837f1ba0SEd Swarthout /* outbound memory */ 233*2dba0deaSKumar Gala pci_set_region(r++, 2346d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE1_MEM_BASE2, 2356d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE1_MEM_PHYS2, 2366d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE1_MEM_SIZE2, 237837f1ba0SEd Swarthout PCI_REGION_MEM); 238837f1ba0SEd Swarthout #endif 239*2dba0deaSKumar Gala hose->region_count = r - hose->regions; 240837f1ba0SEd Swarthout hose->first_busno=first_free_busno; 241837f1ba0SEd Swarthout 242837f1ba0SEd Swarthout pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); 243837f1ba0SEd Swarthout 244837f1ba0SEd Swarthout fsl_pci_init(hose); 245837f1ba0SEd Swarthout 246837f1ba0SEd Swarthout first_free_busno=hose->last_busno+1; 247837f1ba0SEd Swarthout printf(" PCIE1 on bus %02x - %02x\n", 248837f1ba0SEd Swarthout hose->first_busno,hose->last_busno); 249837f1ba0SEd Swarthout 250837f1ba0SEd Swarthout } else { 251837f1ba0SEd Swarthout printf (" PCIE1: disabled\n"); 252837f1ba0SEd Swarthout } 253837f1ba0SEd Swarthout 254837f1ba0SEd Swarthout } 255837f1ba0SEd Swarthout #else 256837f1ba0SEd Swarthout gur->devdisr |= MPC85xx_DEVDISR_PCIE; /* disable */ 257837f1ba0SEd Swarthout #endif 258837f1ba0SEd Swarthout 259837f1ba0SEd Swarthout #ifdef CONFIG_PCIE2 260837f1ba0SEd Swarthout { 2616d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE2_ADDR; 262837f1ba0SEd Swarthout struct pci_controller *hose = &pcie2_hose; 263837f1ba0SEd Swarthout int pcie_ep = (host_agent == 3); 264837f1ba0SEd Swarthout int pcie_configured = io_sel & 4; 265*2dba0deaSKumar Gala struct pci_region *r = hose->regions; 266837f1ba0SEd Swarthout 267837f1ba0SEd Swarthout if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){ 268837f1ba0SEd Swarthout printf ("\n PCIE2 connected to Slot 1 as %s (base address %x)", 269837f1ba0SEd Swarthout pcie_ep ? "End Point" : "Root Complex", 270837f1ba0SEd Swarthout (uint)pci); 271837f1ba0SEd Swarthout if (pci->pme_msg_det) { 272837f1ba0SEd Swarthout pci->pme_msg_det = 0xffffffff; 273837f1ba0SEd Swarthout debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det); 274837f1ba0SEd Swarthout } 275837f1ba0SEd Swarthout printf ("\n"); 276837f1ba0SEd Swarthout 277837f1ba0SEd Swarthout /* inbound */ 278*2dba0deaSKumar Gala r += fsl_pci_setup_inbound_windows(r); 279837f1ba0SEd Swarthout 280837f1ba0SEd Swarthout /* outbound memory */ 281*2dba0deaSKumar Gala pci_set_region(r++, 2826d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE2_MEM_BASE, 2836d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE2_MEM_PHYS, 2846d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE2_MEM_SIZE, 285837f1ba0SEd Swarthout PCI_REGION_MEM); 286837f1ba0SEd Swarthout 287837f1ba0SEd Swarthout /* outbound io */ 288*2dba0deaSKumar Gala pci_set_region(r++, 2896d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE2_IO_BASE, 2906d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE2_IO_PHYS, 2916d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE2_IO_SIZE, 292837f1ba0SEd Swarthout PCI_REGION_IO); 293837f1ba0SEd Swarthout 2946d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #ifdef CONFIG_SYS_PCIE2_MEM_BASE2 295837f1ba0SEd Swarthout /* outbound memory */ 296*2dba0deaSKumar Gala pci_set_region(r++, 2976d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE2_MEM_BASE2, 2986d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE2_MEM_PHYS2, 2996d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE2_MEM_SIZE2, 300837f1ba0SEd Swarthout PCI_REGION_MEM); 301837f1ba0SEd Swarthout #endif 302*2dba0deaSKumar Gala hose->region_count = r - hose->regions; 303837f1ba0SEd Swarthout hose->first_busno=first_free_busno; 304837f1ba0SEd Swarthout pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); 305837f1ba0SEd Swarthout 306837f1ba0SEd Swarthout fsl_pci_init(hose); 307837f1ba0SEd Swarthout first_free_busno=hose->last_busno+1; 308837f1ba0SEd Swarthout printf (" PCIE2 on bus %02x - %02x\n", 309837f1ba0SEd Swarthout hose->first_busno,hose->last_busno); 310837f1ba0SEd Swarthout 311837f1ba0SEd Swarthout } else { 312837f1ba0SEd Swarthout printf (" PCIE2: disabled\n"); 313837f1ba0SEd Swarthout } 314837f1ba0SEd Swarthout 315837f1ba0SEd Swarthout } 316837f1ba0SEd Swarthout #else 317837f1ba0SEd Swarthout gur->devdisr |= MPC85xx_DEVDISR_PCIE2; /* disable */ 318837f1ba0SEd Swarthout #endif 319837f1ba0SEd Swarthout 320837f1ba0SEd Swarthout 321837f1ba0SEd Swarthout #ifdef CONFIG_PCI1 322837f1ba0SEd Swarthout { 3236d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCI1_ADDR; 324837f1ba0SEd Swarthout struct pci_controller *hose = &pci1_hose; 325*2dba0deaSKumar Gala struct pci_region *r = hose->regions; 326837f1ba0SEd Swarthout 327837f1ba0SEd Swarthout uint pci_agent = (host_agent == 6); 328837f1ba0SEd Swarthout uint pci_speed = 66666000; /*get_clock_freq (); PCI PSPEED in [4:5] */ 329837f1ba0SEd Swarthout uint pci_32 = 1; 330837f1ba0SEd Swarthout uint pci_arb = gur->pordevsr & MPC85xx_PORDEVSR_PCI1_ARB; /* PORDEVSR[14] */ 331837f1ba0SEd Swarthout uint pci_clk_sel = gur->porpllsr & MPC85xx_PORDEVSR_PCI1_SPD; /* PORPLLSR[16] */ 332837f1ba0SEd Swarthout 333837f1ba0SEd Swarthout 334837f1ba0SEd Swarthout if (!(devdisr & MPC85xx_DEVDISR_PCI1)) { 335837f1ba0SEd Swarthout printf ("\n PCI: %d bit, %s MHz, %s, %s, %s (base address %x)\n", 336837f1ba0SEd Swarthout (pci_32) ? 32 : 64, 337837f1ba0SEd Swarthout (pci_speed == 33333000) ? "33" : 338837f1ba0SEd Swarthout (pci_speed == 66666000) ? "66" : "unknown", 339837f1ba0SEd Swarthout pci_clk_sel ? "sync" : "async", 340837f1ba0SEd Swarthout pci_agent ? "agent" : "host", 341837f1ba0SEd Swarthout pci_arb ? "arbiter" : "external-arbiter", 342837f1ba0SEd Swarthout (uint)pci 343837f1ba0SEd Swarthout ); 344837f1ba0SEd Swarthout 345837f1ba0SEd Swarthout /* inbound */ 346*2dba0deaSKumar Gala r += fsl_pci_setup_inbound_windows(r); 347837f1ba0SEd Swarthout 348837f1ba0SEd Swarthout /* outbound memory */ 349*2dba0deaSKumar Gala pci_set_region(r++, 3506d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCI1_MEM_BASE, 3516d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCI1_MEM_PHYS, 3526d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCI1_MEM_SIZE, 353837f1ba0SEd Swarthout PCI_REGION_MEM); 354837f1ba0SEd Swarthout 355837f1ba0SEd Swarthout /* outbound io */ 356*2dba0deaSKumar Gala pci_set_region(r++, 3576d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCI1_IO_BASE, 3586d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCI1_IO_PHYS, 3596d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCI1_IO_SIZE, 360837f1ba0SEd Swarthout PCI_REGION_IO); 361*2dba0deaSKumar Gala 3626d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #ifdef CONFIG_SYS_PCIE3_MEM_BASE2 363837f1ba0SEd Swarthout /* outbound memory */ 364*2dba0deaSKumar Gala pci_set_region(r++, 3656d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE3_MEM_BASE2, 3666d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE3_MEM_PHYS2, 3676d0f6bcfSJean-Christophe PLAGNIOL-VILLARD CONFIG_SYS_PCIE3_MEM_SIZE2, 368837f1ba0SEd Swarthout PCI_REGION_MEM); 369837f1ba0SEd Swarthout #endif 370*2dba0deaSKumar Gala hose->region_count = r - hose->regions; 371837f1ba0SEd Swarthout hose->first_busno=first_free_busno; 372837f1ba0SEd Swarthout pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); 373837f1ba0SEd Swarthout 374837f1ba0SEd Swarthout fsl_pci_init(hose); 375837f1ba0SEd Swarthout first_free_busno=hose->last_busno+1; 376837f1ba0SEd Swarthout printf ("PCI on bus %02x - %02x\n", 377837f1ba0SEd Swarthout hose->first_busno,hose->last_busno); 378837f1ba0SEd Swarthout } else { 379837f1ba0SEd Swarthout printf (" PCI: disabled\n"); 380837f1ba0SEd Swarthout } 381837f1ba0SEd Swarthout } 382837f1ba0SEd Swarthout #else 383837f1ba0SEd Swarthout gur->devdisr |= MPC85xx_DEVDISR_PCI1; /* disable */ 384837f1ba0SEd Swarthout #endif 385837f1ba0SEd Swarthout } 386837f1ba0SEd Swarthout 387837f1ba0SEd Swarthout 38825d83d7fSJon Loeliger int last_stage_init(void) 38925d83d7fSJon Loeliger { 39025d83d7fSJon Loeliger return 0; 39125d83d7fSJon Loeliger } 39225d83d7fSJon Loeliger 39325d83d7fSJon Loeliger 39425d83d7fSJon Loeliger unsigned long 39525d83d7fSJon Loeliger get_board_sys_clk(ulong dummy) 39625d83d7fSJon Loeliger { 39725d83d7fSJon Loeliger u8 i, go_bit, rd_clks; 39825d83d7fSJon Loeliger ulong val = 0; 39925d83d7fSJon Loeliger 40025d83d7fSJon Loeliger go_bit = in8(PIXIS_BASE + PIXIS_VCTL); 40125d83d7fSJon Loeliger go_bit &= 0x01; 40225d83d7fSJon Loeliger 40325d83d7fSJon Loeliger rd_clks = in8(PIXIS_BASE + PIXIS_VCFGEN0); 40425d83d7fSJon Loeliger rd_clks &= 0x1C; 40525d83d7fSJon Loeliger 40625d83d7fSJon Loeliger /* 40725d83d7fSJon Loeliger * Only if both go bit and the SCLK bit in VCFGEN0 are set 40825d83d7fSJon Loeliger * should we be using the AUX register. Remember, we also set the 40925d83d7fSJon Loeliger * GO bit to boot from the alternate bank on the on-board flash 41025d83d7fSJon Loeliger */ 41125d83d7fSJon Loeliger 41225d83d7fSJon Loeliger if (go_bit) { 41325d83d7fSJon Loeliger if (rd_clks == 0x1c) 41425d83d7fSJon Loeliger i = in8(PIXIS_BASE + PIXIS_AUX); 41525d83d7fSJon Loeliger else 41625d83d7fSJon Loeliger i = in8(PIXIS_BASE + PIXIS_SPD); 41725d83d7fSJon Loeliger } else { 41825d83d7fSJon Loeliger i = in8(PIXIS_BASE + PIXIS_SPD); 41925d83d7fSJon Loeliger } 42025d83d7fSJon Loeliger 42125d83d7fSJon Loeliger i &= 0x07; 42225d83d7fSJon Loeliger 42325d83d7fSJon Loeliger switch (i) { 42425d83d7fSJon Loeliger case 0: 42525d83d7fSJon Loeliger val = 33333333; 42625d83d7fSJon Loeliger break; 42725d83d7fSJon Loeliger case 1: 42825d83d7fSJon Loeliger val = 40000000; 42925d83d7fSJon Loeliger break; 43025d83d7fSJon Loeliger case 2: 43125d83d7fSJon Loeliger val = 50000000; 43225d83d7fSJon Loeliger break; 43325d83d7fSJon Loeliger case 3: 43425d83d7fSJon Loeliger val = 66666666; 43525d83d7fSJon Loeliger break; 43625d83d7fSJon Loeliger case 4: 43725d83d7fSJon Loeliger val = 83000000; 43825d83d7fSJon Loeliger break; 43925d83d7fSJon Loeliger case 5: 44025d83d7fSJon Loeliger val = 100000000; 44125d83d7fSJon Loeliger break; 44225d83d7fSJon Loeliger case 6: 44325d83d7fSJon Loeliger val = 133333333; 44425d83d7fSJon Loeliger break; 44525d83d7fSJon Loeliger case 7: 44625d83d7fSJon Loeliger val = 166666666; 44725d83d7fSJon Loeliger break; 44825d83d7fSJon Loeliger } 44925d83d7fSJon Loeliger 45025d83d7fSJon Loeliger return val; 45125d83d7fSJon Loeliger } 45225d83d7fSJon Loeliger 453216f2a71SAndy Fleming int board_eth_init(bd_t *bis) 454216f2a71SAndy Fleming { 4550b252f50SBen Warren #ifdef CONFIG_TSEC_ENET 456216f2a71SAndy Fleming struct tsec_info_struct tsec_info[2]; 4576d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); 458216f2a71SAndy Fleming uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19; 459216f2a71SAndy Fleming int num = 0; 460216f2a71SAndy Fleming 461216f2a71SAndy Fleming #ifdef CONFIG_TSEC1 462216f2a71SAndy Fleming SET_STD_TSEC_INFO(tsec_info[num], 1); 463216f2a71SAndy Fleming if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS)) 464216f2a71SAndy Fleming tsec_info[num].flags |= TSEC_SGMII; 465216f2a71SAndy Fleming num++; 466216f2a71SAndy Fleming #endif 467216f2a71SAndy Fleming #ifdef CONFIG_TSEC3 468216f2a71SAndy Fleming SET_STD_TSEC_INFO(tsec_info[num], 3); 469216f2a71SAndy Fleming if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS)) 470216f2a71SAndy Fleming tsec_info[num].flags |= TSEC_SGMII; 471216f2a71SAndy Fleming num++; 472216f2a71SAndy Fleming #endif 473216f2a71SAndy Fleming 474216f2a71SAndy Fleming if (!num) { 475216f2a71SAndy Fleming printf("No TSECs initialized\n"); 476216f2a71SAndy Fleming 477216f2a71SAndy Fleming return 0; 478216f2a71SAndy Fleming } 479216f2a71SAndy Fleming 480216f2a71SAndy Fleming if (io_sel & 1) 481216f2a71SAndy Fleming fsl_sgmii_riser_init(tsec_info, num); 482216f2a71SAndy Fleming 483216f2a71SAndy Fleming 484216f2a71SAndy Fleming tsec_eth_init(bis, tsec_info, num); 485216f2a71SAndy Fleming #endif 4860b252f50SBen Warren return pci_eth_init(bis); 4870b252f50SBen Warren } 488216f2a71SAndy Fleming 489addce57eSKumar Gala #if defined(CONFIG_OF_BOARD_SETUP) 490*2dba0deaSKumar Gala extern void ft_fsl_pci_setup(void *blob, const char *pci_alias, 491*2dba0deaSKumar Gala struct pci_controller *hose); 492addce57eSKumar Gala 493*2dba0deaSKumar Gala void ft_board_setup(void *blob, bd_t *bd) 49425d83d7fSJon Loeliger { 49525d83d7fSJon Loeliger ft_cpu_setup(blob, bd); 49625d83d7fSJon Loeliger 497*2dba0deaSKumar Gala 498f75e89e9SEd Swarthout #ifdef CONFIG_PCI1 499*2dba0deaSKumar Gala ft_fsl_pci_setup(blob, "pci0", &pci1_hose); 500837f1ba0SEd Swarthout #endif 501837f1ba0SEd Swarthout #ifdef CONFIG_PCIE2 502*2dba0deaSKumar Gala ft_fsl_pci_setup(blob, "pci1", &pcie1_hose); 503addce57eSKumar Gala #endif 504addce57eSKumar Gala #ifdef CONFIG_PCIE1 505*2dba0deaSKumar Gala ft_fsl_pci_setup(blob, "pci2", &pcie3_hose); 506837f1ba0SEd Swarthout #endif 507837f1ba0SEd Swarthout #ifdef CONFIG_PCIE3 508*2dba0deaSKumar Gala ft_fsl_pci_setup(blob, "pci3", &pcie2_hose); 509837f1ba0SEd Swarthout #endif 51025d83d7fSJon Loeliger } 51125d83d7fSJon Loeliger #endif 512