robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2007 |
| 3 | * Robert Lazarski, Instituto Atlantico, robertlazarski@gmail.com |
| 4 | * |
| 5 | * Copyright 2007 Freescale Semiconductor, Inc. |
| 6 | * |
| 7 | * See file CREDITS for list of people who contributed to this |
| 8 | * project. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 of |
| 13 | * the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 23 | * MA 02111-1307 USA |
| 24 | */ |
| 25 | |
| 26 | #include <common.h> |
| 27 | #include <command.h> |
| 28 | #include <pci.h> |
| 29 | #include <asm/processor.h> |
| 30 | #include <asm/immap_85xx.h> |
Kumar Gala | c851462 | 2009-04-02 13:22:48 -0500 | [diff] [blame] | 31 | #include <asm/fsl_pci.h> |
Kumar Gala | a947e4c | 2008-08-26 23:14:14 -0500 | [diff] [blame] | 32 | #include <asm/fsl_ddr_sdram.h> |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 33 | #include <asm/io.h> |
Kumar Gala | a947e4c | 2008-08-26 23:14:14 -0500 | [diff] [blame] | 34 | #include <asm/mmu.h> |
Jon Loeliger | a30a549 | 2008-03-04 10:03:03 -0600 | [diff] [blame] | 35 | #include <spd_sdram.h> |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 36 | #include <miiphy.h> |
| 37 | #include <libfdt.h> |
| 38 | #include <fdt_support.h> |
| 39 | |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 40 | long int fixed_sdram(void); |
| 41 | |
| 42 | int board_early_init_f (void) |
| 43 | { |
| 44 | return 0; |
| 45 | } |
| 46 | |
| 47 | int checkboard (void) |
| 48 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 49 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
| 50 | volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR); |
| 51 | volatile ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR); |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 52 | |
| 53 | if ((uint)&gur->porpllsr != 0xe00e0000) { |
Wolfgang Denk | 9b55a25 | 2008-07-11 01:16:00 +0200 | [diff] [blame] | 54 | printf("immap size error %lx\n",(ulong)&gur->porpllsr); |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 55 | } |
| 56 | printf ("Board: ATUM8548\n"); |
| 57 | |
| 58 | lbc->ltesr = 0xffffffff; /* Clear LBC error interrupts */ |
| 59 | lbc->lteir = 0xffffffff; /* Enable LBC error interrupts */ |
| 60 | ecm->eedr = 0xffffffff; /* Clear ecm errors */ |
| 61 | ecm->eeer = 0xffffffff; /* Enable ecm errors */ |
| 62 | |
| 63 | return 0; |
| 64 | } |
| 65 | |
| 66 | #if !defined(CONFIG_SPD_EEPROM) |
| 67 | /************************************************************************* |
| 68 | * fixed sdram init -- doesn't use serial presence detect. |
| 69 | ************************************************************************/ |
| 70 | long int fixed_sdram (void) |
| 71 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 72 | volatile ccsr_ddr_t *ddr= (void *)(CONFIG_SYS_MPC85xx_DDR_ADDR); |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 73 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 74 | ddr->cs0_bnds = CONFIG_SYS_DDR_CS0_BNDS; |
| 75 | ddr->cs0_config = CONFIG_SYS_DDR_CS0_CONFIG; |
| 76 | ddr->timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0; |
| 77 | ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1; |
| 78 | ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2; |
| 79 | ddr->sdram_mode = CONFIG_SYS_DDR_MODE; |
| 80 | ddr->sdram_interval = CONFIG_SYS_DDR_INTERVAL; |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 81 | #if defined (CONFIG_DDR_ECC) |
| 82 | ddr->err_disable = 0x0000000D; |
| 83 | ddr->err_sbe = 0x00ff0000; |
| 84 | #endif |
| 85 | asm("sync;isync;msync"); |
| 86 | udelay(500); |
| 87 | #if defined (CONFIG_DDR_ECC) |
| 88 | /* Enable ECC checking */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 89 | ddr->sdram_cfg = (CONFIG_SYS_DDR_CONTROL | 0x20000000); |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 90 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 91 | ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL; |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 92 | #endif |
| 93 | asm("sync; isync; msync"); |
| 94 | udelay(500); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 95 | return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024; |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 96 | } |
| 97 | #endif /* !defined(CONFIG_SPD_EEPROM) */ |
| 98 | |
Becky Bruce | 9973e3c | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 99 | phys_size_t |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 100 | initdram(int board_type) |
| 101 | { |
| 102 | long dram_size = 0; |
| 103 | |
| 104 | puts("Initializing\n"); |
| 105 | |
| 106 | #if defined(CONFIG_SPD_EEPROM) |
Kumar Gala | a947e4c | 2008-08-26 23:14:14 -0500 | [diff] [blame] | 107 | puts("fsl_ddr_sdram\n"); |
| 108 | dram_size = fsl_ddr_sdram(); |
| 109 | dram_size = setup_ddr_tlbs(dram_size / 0x100000); |
| 110 | dram_size *= 0x100000; |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 111 | #else |
| 112 | puts("fixed_sdram\n"); |
| 113 | dram_size = fixed_sdram (); |
| 114 | #endif |
| 115 | |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 116 | puts(" DDR: "); |
| 117 | return dram_size; |
| 118 | } |
| 119 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 120 | #if defined(CONFIG_SYS_DRAM_TEST) |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 121 | int |
| 122 | testdram(void) |
| 123 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 124 | uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START; |
| 125 | uint *pend = (uint *) CONFIG_SYS_MEMTEST_END; |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 126 | uint *p; |
| 127 | |
| 128 | printf("Testing DRAM from 0x%08x to 0x%08x\n", |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 129 | CONFIG_SYS_MEMTEST_START, |
| 130 | CONFIG_SYS_MEMTEST_END); |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 131 | |
| 132 | printf("DRAM test phase 1:\n"); |
| 133 | for (p = pstart; p < pend; p++) { |
| 134 | printf ("DRAM test attempting to write 0xaaaaaaaa at: %08x\n", (uint) p); |
| 135 | *p = 0xaaaaaaaa; |
Wolfgang Denk | d3a6532 | 2008-01-10 00:55:14 +0100 | [diff] [blame] | 136 | } |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 137 | |
| 138 | for (p = pstart; p < pend; p++) { |
| 139 | if (*p != 0xaaaaaaaa) { |
| 140 | printf ("DRAM test fails at: %08x\n", (uint) p); |
| 141 | return 1; |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | printf("DRAM test phase 2:\n"); |
| 146 | for (p = pstart; p < pend; p++) |
| 147 | *p = 0x55555555; |
| 148 | |
| 149 | for (p = pstart; p < pend; p++) { |
| 150 | if (*p != 0x55555555) { |
| 151 | printf ("DRAM test fails at: %08x\n", (uint) p); |
| 152 | return 1; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | printf("DRAM test passed.\n"); |
| 157 | return 0; |
| 158 | } |
| 159 | #endif |
| 160 | |
| 161 | #ifdef CONFIG_PCI1 |
| 162 | static struct pci_controller pci1_hose; |
| 163 | #endif |
| 164 | |
| 165 | #ifdef CONFIG_PCI2 |
| 166 | static struct pci_controller pci2_hose; |
| 167 | #endif |
| 168 | |
| 169 | #ifdef CONFIG_PCIE1 |
| 170 | static struct pci_controller pcie1_hose; |
| 171 | #endif |
| 172 | |
| 173 | int first_free_busno=0; |
| 174 | |
| 175 | void |
| 176 | pci_init_board(void) |
| 177 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 178 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 179 | |
| 180 | uint devdisr = gur->devdisr; |
| 181 | uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19; |
| 182 | uint host_agent = (gur->porbmsr & MPC85xx_PORBMSR_HA) >> 16; |
| 183 | |
| 184 | debug (" pci_init_board: devdisr=%x, io_sel=%x, host_agent=%x\n", |
| 185 | devdisr, io_sel, host_agent); |
| 186 | |
Wolfgang Denk | d3a6532 | 2008-01-10 00:55:14 +0100 | [diff] [blame] | 187 | /* explicitly set 'Clock out select register' to echo SYSCLK input to our CPLD */ |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 188 | gur->clkocr |= MPC85xx_ATUM_CLKOCR; |
| 189 | |
| 190 | if (io_sel & 1) { |
| 191 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS)) |
| 192 | printf (" eTSEC1 is in sgmii mode.\n"); |
| 193 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII2_DIS)) |
| 194 | printf (" eTSEC2 is in sgmii mode.\n"); |
| 195 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS)) |
| 196 | printf (" eTSEC3 is in sgmii mode.\n"); |
| 197 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII4_DIS)) |
| 198 | printf (" eTSEC4 is in sgmii mode.\n"); |
| 199 | } |
| 200 | |
| 201 | #ifdef CONFIG_PCIE1 |
| 202 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 203 | volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE1_ADDR; |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 204 | struct pci_controller *hose = &pcie1_hose; |
| 205 | int pcie_ep = (host_agent == 5); |
| 206 | int pcie_configured = io_sel & 6; |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 207 | struct pci_region *r = hose->regions; |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 208 | |
| 209 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){ |
| 210 | printf ("\n PCIE1 connected to slot as %s (base address %x)", |
| 211 | pcie_ep ? "End Point" : "Root Complex", |
| 212 | (uint)pci); |
| 213 | if (pci->pme_msg_det) { |
| 214 | pci->pme_msg_det = 0xffffffff; |
| 215 | debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det); |
| 216 | } |
| 217 | printf ("\n"); |
| 218 | |
| 219 | /* inbound */ |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 220 | r += fsl_pci_setup_inbound_windows(r); |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 221 | |
| 222 | /* outbound memory */ |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 223 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 224 | CONFIG_SYS_PCIE1_MEM_BASE, |
| 225 | CONFIG_SYS_PCIE1_MEM_PHYS, |
| 226 | CONFIG_SYS_PCIE1_MEM_SIZE, |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 227 | PCI_REGION_MEM); |
| 228 | |
| 229 | /* outbound io */ |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 230 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 231 | CONFIG_SYS_PCIE1_IO_BASE, |
| 232 | CONFIG_SYS_PCIE1_IO_PHYS, |
| 233 | CONFIG_SYS_PCIE1_IO_SIZE, |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 234 | PCI_REGION_IO); |
| 235 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 236 | #ifdef CONFIG_SYS_PCIE1_MEM_BASE2 |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 237 | /* outbound memory */ |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 238 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 239 | CONFIG_SYS_PCIE1_MEM_BASE2, |
| 240 | CONFIG_SYS_PCIE1_MEM_PHYS2, |
| 241 | CONFIG_SYS_PCIE1_MEM_SIZE2, |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 242 | PCI_REGION_MEM); |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 243 | #endif |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 244 | hose->region_count = r - hose->regions; |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 245 | hose->first_busno=first_free_busno; |
| 246 | |
| 247 | pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); |
| 248 | |
| 249 | fsl_pci_init(hose); |
| 250 | |
| 251 | first_free_busno=hose->last_busno+1; |
| 252 | printf(" PCIE1 on bus %02x - %02x\n", |
| 253 | hose->first_busno,hose->last_busno); |
| 254 | |
| 255 | } else { |
| 256 | printf (" PCIE1: disabled\n"); |
| 257 | } |
| 258 | |
| 259 | } |
| 260 | #else |
| 261 | gur->devdisr |= MPC85xx_DEVDISR_PCIE; /* disable */ |
| 262 | #endif |
| 263 | |
| 264 | #ifdef CONFIG_PCI1 |
| 265 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 266 | volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCI1_ADDR; |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 267 | struct pci_controller *hose = &pci1_hose; |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 268 | struct pci_region *r = hose->regions; |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 269 | |
| 270 | uint pci_agent = (host_agent == 6); |
| 271 | uint pci_speed = 33333000; /*get_clock_freq (); PCI PSPEED in [4:5] */ |
| 272 | uint pci_32 = gur->pordevsr & MPC85xx_PORDEVSR_PCI1_PCI32; /* PORDEVSR[15] */ |
| 273 | uint pci_arb = gur->pordevsr & MPC85xx_PORDEVSR_PCI1_ARB; /* PORDEVSR[14] */ |
| 274 | uint pci_clk_sel = gur->porpllsr & MPC85xx_PORDEVSR_PCI1_SPD; /* PORPLLSR[16] */ |
| 275 | |
| 276 | if (!(devdisr & MPC85xx_DEVDISR_PCI1)) { |
| 277 | printf ("\n PCI1: %d bit, %s MHz, %s, %s, %s (base address %x)\n", |
| 278 | (pci_32) ? 32 : 64, |
| 279 | (pci_speed == 33333000) ? "33" : |
| 280 | (pci_speed == 66666000) ? "66" : "unknown", |
| 281 | pci_clk_sel ? "sync" : "async", |
| 282 | pci_agent ? "agent" : "host", |
| 283 | pci_arb ? "arbiter" : "external-arbiter", |
| 284 | (uint)pci |
| 285 | ); |
| 286 | |
| 287 | /* inbound */ |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 288 | r += fsl_pci_setup_inbound_windows(r); |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 289 | |
| 290 | /* outbound memory */ |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 291 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 292 | CONFIG_SYS_PCI1_MEM_BASE, |
| 293 | CONFIG_SYS_PCI1_MEM_PHYS, |
| 294 | CONFIG_SYS_PCI1_MEM_SIZE, |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 295 | PCI_REGION_MEM); |
| 296 | |
| 297 | /* outbound io */ |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 298 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 299 | CONFIG_SYS_PCI1_IO_BASE, |
| 300 | CONFIG_SYS_PCI1_IO_PHYS, |
| 301 | CONFIG_SYS_PCI1_IO_SIZE, |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 302 | PCI_REGION_IO); |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 303 | hose->region_count = r - hose->regions; |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 304 | hose->first_busno=first_free_busno; |
| 305 | pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); |
| 306 | |
| 307 | fsl_pci_init(hose); |
| 308 | first_free_busno=hose->last_busno+1; |
| 309 | printf ("PCI1 on bus %02x - %02x\n", |
| 310 | hose->first_busno,hose->last_busno); |
| 311 | } else { |
| 312 | printf (" PCI1: disabled\n"); |
| 313 | } |
| 314 | } |
| 315 | #else |
| 316 | gur->devdisr |= MPC85xx_DEVDISR_PCI1; /* disable */ |
| 317 | #endif |
| 318 | |
| 319 | #ifdef CONFIG_PCI2 |
| 320 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 321 | volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCI2_ADDR; |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 322 | struct pci_controller *hose = &pci2_hose; |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 323 | struct pci_region *r = hose->regions; |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 324 | |
| 325 | if (!(devdisr & MPC85xx_DEVDISR_PCI2)) { |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 326 | r += fsl_pci_setup_inbound_windows(r); |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 327 | |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 328 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 329 | CONFIG_SYS_PCI2_MEM_BASE, |
| 330 | CONFIG_SYS_PCI2_MEM_PHYS, |
| 331 | CONFIG_SYS_PCI2_MEM_SIZE, |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 332 | PCI_REGION_MEM); |
| 333 | |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 334 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 335 | CONFIG_SYS_PCI2_IO_BASE, |
| 336 | CONFIG_SYS_PCI2_IO_PHYS, |
| 337 | CONFIG_SYS_PCI2_IO_SIZE, |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 338 | PCI_REGION_IO); |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 339 | hose->region_count = r - hose->regions; |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 340 | hose->first_busno=first_free_busno; |
| 341 | pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); |
| 342 | |
| 343 | fsl_pci_init(hose); |
| 344 | first_free_busno=hose->last_busno+1; |
| 345 | printf ("PCI2 on bus %02x - %02x\n", |
| 346 | hose->first_busno,hose->last_busno); |
| 347 | } else { |
| 348 | printf (" PCI2: disabled\n"); |
| 349 | } |
| 350 | } |
| 351 | #else |
| 352 | gur->devdisr |= MPC85xx_DEVDISR_PCI2; |
| 353 | #endif |
| 354 | } |
| 355 | |
| 356 | |
| 357 | int last_stage_init(void) |
| 358 | { |
Wolfgang Denk | d3a6532 | 2008-01-10 00:55:14 +0100 | [diff] [blame] | 359 | int ic = icache_status (); |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 360 | printf ("icache_status: %d\n", ic); |
| 361 | return 0; |
| 362 | } |
| 363 | |
| 364 | #if defined(CONFIG_OF_BOARD_SETUP) |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 365 | void ft_board_setup(void *blob, bd_t *bd) |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 366 | { |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 367 | ft_cpu_setup(blob, bd); |
| 368 | |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 369 | #ifdef CONFIG_PCI1 |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 370 | ft_fsl_pci_setup(blob, "pci0", &pci1_hose); |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 371 | #endif |
| 372 | #ifdef CONFIG_PCI2 |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 373 | ft_fsl_pci_setup(blob, "pci1", &pci2_hose); |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 374 | #endif |
| 375 | #ifdef CONFIG_PCIE1 |
Kumar Gala | 2dba0de | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 376 | ft_fsl_pci_setup(blob, "pci2", &pcie1_hose); |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 377 | #endif |
robert lazarski | b964e93 | 2007-12-21 10:39:27 -0500 | [diff] [blame] | 378 | } |
| 379 | #endif |