Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 1 | /* |
Ed Swarthout | f2cff6b | 2007-07-27 01:50:52 -0500 | [diff] [blame] | 2 | * Copyright 2004, 2007 Freescale Semiconductor. |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 3 | * |
| 4 | * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com> |
| 5 | * |
| 6 | * See file CREDITS for list of people who contributed to this |
| 7 | * project. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 22 | * MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | #include <common.h> |
| 26 | #include <pci.h> |
| 27 | #include <asm/processor.h> |
| 28 | #include <asm/immap_85xx.h> |
Ed Swarthout | f2cff6b | 2007-07-27 01:50:52 -0500 | [diff] [blame] | 29 | #include <asm/immap_fsl_pci.h> |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 30 | #include <spd.h> |
Andy Fleming | 09f3e09 | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 31 | #include <miiphy.h> |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 32 | |
| 33 | #include "../common/cadmus.h" |
| 34 | #include "../common/eeprom.h" |
Matthew McClintock | bf1dfff | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 35 | #include "../common/via.h" |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 36 | |
Ed Swarthout | f2cff6b | 2007-07-27 01:50:52 -0500 | [diff] [blame] | 37 | #if defined(CONFIG_OF_FLAT_TREE) |
| 38 | #include <ft_build.h> |
| 39 | #endif |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 40 | #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) |
| 41 | extern void ddr_enable_ecc(unsigned int dram_size); |
| 42 | #endif |
| 43 | |
Ed Swarthout | f2cff6b | 2007-07-27 01:50:52 -0500 | [diff] [blame] | 44 | DECLARE_GLOBAL_DATA_PTR; |
| 45 | |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 46 | extern long int spd_sdram(void); |
| 47 | |
| 48 | void local_bus_init(void); |
| 49 | void sdram_init(void); |
| 50 | |
| 51 | int board_early_init_f (void) |
| 52 | { |
| 53 | return 0; |
| 54 | } |
| 55 | |
| 56 | int checkboard (void) |
| 57 | { |
| 58 | volatile immap_t *immap = (immap_t *) CFG_CCSRBAR; |
| 59 | volatile ccsr_gur_t *gur = &immap->im_gur; |
Zang Roy-r61911 | 7337b23 | 2006-12-15 14:43:31 +0800 | [diff] [blame] | 60 | volatile ccsr_local_ecm_t *ecm = &immap->im_local_ecm; |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 61 | |
| 62 | /* PCI slot in USER bits CSR[6:7] by convention. */ |
| 63 | uint pci_slot = get_pci_slot (); |
| 64 | |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 65 | uint cpu_board_rev = get_cpu_board_revision (); |
| 66 | |
| 67 | printf ("Board: CDS Version 0x%02x, PCI Slot %d\n", |
| 68 | get_board_version (), pci_slot); |
| 69 | |
| 70 | printf ("CPU Board Revision %d.%d (0x%04x)\n", |
| 71 | MPC85XX_CPU_BOARD_MAJOR (cpu_board_rev), |
| 72 | MPC85XX_CPU_BOARD_MINOR (cpu_board_rev), cpu_board_rev); |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 73 | /* |
| 74 | * Initialize local bus. |
| 75 | */ |
| 76 | local_bus_init (); |
| 77 | |
Zang Roy-r61911 | 7337b23 | 2006-12-15 14:43:31 +0800 | [diff] [blame] | 78 | /* |
| 79 | * Fix CPU2 errata: A core hang possible while executing a |
| 80 | * msync instruction and a snoopable transaction from an I/O |
| 81 | * master tagged to make quick forward progress is present. |
| 82 | */ |
| 83 | ecm->eebpcr |= (1 << 16); |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 84 | |
| 85 | /* |
| 86 | * Hack TSEC 3 and 4 IO voltages. |
| 87 | */ |
| 88 | gur->tsec34ioovcr = 0xe7e0; /* 1110 0111 1110 0xxx */ |
| 89 | |
Ed Swarthout | f2cff6b | 2007-07-27 01:50:52 -0500 | [diff] [blame] | 90 | ecm->eedr = 0xffffffff; /* clear ecm errors */ |
| 91 | ecm->eeer = 0xffffffff; /* enable ecm errors */ |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | long int |
| 96 | initdram(int board_type) |
| 97 | { |
| 98 | long dram_size = 0; |
| 99 | volatile immap_t *immap = (immap_t *)CFG_IMMR; |
| 100 | |
| 101 | puts("Initializing\n"); |
| 102 | |
| 103 | #if defined(CONFIG_DDR_DLL) |
| 104 | { |
| 105 | /* |
| 106 | * Work around to stabilize DDR DLL MSYNC_IN. |
| 107 | * Errata DDR9 seems to have been fixed. |
| 108 | * This is now the workaround for Errata DDR11: |
| 109 | * Override DLL = 1, Course Adj = 1, Tap Select = 0 |
| 110 | */ |
| 111 | |
| 112 | volatile ccsr_gur_t *gur= &immap->im_gur; |
| 113 | |
| 114 | gur->ddrdllcr = 0x81000000; |
| 115 | asm("sync;isync;msync"); |
| 116 | udelay(200); |
| 117 | } |
| 118 | #endif |
| 119 | dram_size = spd_sdram(); |
| 120 | |
| 121 | #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) |
| 122 | /* |
| 123 | * Initialize and enable DDR ECC. |
| 124 | */ |
| 125 | ddr_enable_ecc(dram_size); |
| 126 | #endif |
| 127 | /* |
| 128 | * SDRAM Initialization |
| 129 | */ |
| 130 | sdram_init(); |
| 131 | |
| 132 | puts(" DDR: "); |
| 133 | return dram_size; |
| 134 | } |
| 135 | |
| 136 | /* |
| 137 | * Initialize Local Bus |
| 138 | */ |
| 139 | void |
| 140 | local_bus_init(void) |
| 141 | { |
| 142 | volatile immap_t *immap = (immap_t *)CFG_IMMR; |
| 143 | volatile ccsr_gur_t *gur = &immap->im_gur; |
| 144 | volatile ccsr_lbc_t *lbc = &immap->im_lbc; |
| 145 | |
| 146 | uint clkdiv; |
| 147 | uint lbc_hz; |
| 148 | sys_info_t sysinfo; |
| 149 | |
| 150 | get_sys_info(&sysinfo); |
| 151 | clkdiv = (lbc->lcrr & 0x0f) * 2; |
| 152 | lbc_hz = sysinfo.freqSystemBus / 1000000 / clkdiv; |
| 153 | |
| 154 | gur->lbiuiplldcr1 = 0x00078080; |
| 155 | if (clkdiv == 16) { |
| 156 | gur->lbiuiplldcr0 = 0x7c0f1bf0; |
| 157 | } else if (clkdiv == 8) { |
| 158 | gur->lbiuiplldcr0 = 0x6c0f1bf0; |
| 159 | } else if (clkdiv == 4) { |
| 160 | gur->lbiuiplldcr0 = 0x5c0f1bf0; |
| 161 | } |
| 162 | |
| 163 | lbc->lcrr |= 0x00030000; |
| 164 | |
| 165 | asm("sync;isync;msync"); |
Ed Swarthout | f2cff6b | 2007-07-27 01:50:52 -0500 | [diff] [blame] | 166 | |
| 167 | lbc->ltesr = 0xffffffff; /* Clear LBC error interrupts */ |
| 168 | lbc->lteir = 0xffffffff; /* Enable LBC error interrupts */ |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | /* |
| 172 | * Initialize SDRAM memory on the Local Bus. |
| 173 | */ |
| 174 | void |
| 175 | sdram_init(void) |
| 176 | { |
| 177 | #if defined(CFG_OR2_PRELIM) && defined(CFG_BR2_PRELIM) |
| 178 | |
| 179 | uint idx; |
| 180 | volatile immap_t *immap = (immap_t *)CFG_IMMR; |
| 181 | volatile ccsr_lbc_t *lbc = &immap->im_lbc; |
| 182 | uint *sdram_addr = (uint *)CFG_LBC_SDRAM_BASE; |
| 183 | uint cpu_board_rev; |
| 184 | uint lsdmr_common; |
| 185 | |
| 186 | puts(" SDRAM: "); |
| 187 | |
| 188 | print_size (CFG_LBC_SDRAM_SIZE * 1024 * 1024, "\n"); |
| 189 | |
| 190 | /* |
| 191 | * Setup SDRAM Base and Option Registers |
| 192 | */ |
| 193 | lbc->or2 = CFG_OR2_PRELIM; |
| 194 | asm("msync"); |
| 195 | |
| 196 | lbc->br2 = CFG_BR2_PRELIM; |
| 197 | asm("msync"); |
| 198 | |
| 199 | lbc->lbcr = CFG_LBC_LBCR; |
| 200 | asm("msync"); |
| 201 | |
| 202 | |
| 203 | lbc->lsrt = CFG_LBC_LSRT; |
| 204 | lbc->mrtpr = CFG_LBC_MRTPR; |
| 205 | asm("msync"); |
| 206 | |
| 207 | /* |
| 208 | * MPC8548 uses "new" 15-16 style addressing. |
| 209 | */ |
| 210 | cpu_board_rev = get_cpu_board_revision(); |
| 211 | lsdmr_common = CFG_LBC_LSDMR_COMMON; |
| 212 | lsdmr_common |= CFG_LBC_LSDMR_BSMA1516; |
| 213 | |
| 214 | /* |
| 215 | * Issue PRECHARGE ALL command. |
| 216 | */ |
| 217 | lbc->lsdmr = lsdmr_common | CFG_LBC_LSDMR_OP_PCHALL; |
| 218 | asm("sync;msync"); |
| 219 | *sdram_addr = 0xff; |
| 220 | ppcDcbf((unsigned long) sdram_addr); |
| 221 | udelay(100); |
| 222 | |
| 223 | /* |
| 224 | * Issue 8 AUTO REFRESH commands. |
| 225 | */ |
| 226 | for (idx = 0; idx < 8; idx++) { |
| 227 | lbc->lsdmr = lsdmr_common | CFG_LBC_LSDMR_OP_ARFRSH; |
| 228 | asm("sync;msync"); |
| 229 | *sdram_addr = 0xff; |
| 230 | ppcDcbf((unsigned long) sdram_addr); |
| 231 | udelay(100); |
| 232 | } |
| 233 | |
| 234 | /* |
| 235 | * Issue 8 MODE-set command. |
| 236 | */ |
| 237 | lbc->lsdmr = lsdmr_common | CFG_LBC_LSDMR_OP_MRW; |
| 238 | asm("sync;msync"); |
| 239 | *sdram_addr = 0xff; |
| 240 | ppcDcbf((unsigned long) sdram_addr); |
| 241 | udelay(100); |
| 242 | |
| 243 | /* |
| 244 | * Issue NORMAL OP command. |
| 245 | */ |
| 246 | lbc->lsdmr = lsdmr_common | CFG_LBC_LSDMR_OP_NORMAL; |
| 247 | asm("sync;msync"); |
| 248 | *sdram_addr = 0xff; |
| 249 | ppcDcbf((unsigned long) sdram_addr); |
| 250 | udelay(200); /* Overkill. Must wait > 200 bus cycles */ |
| 251 | |
| 252 | #endif /* enable SDRAM init */ |
| 253 | } |
| 254 | |
| 255 | #if defined(CFG_DRAM_TEST) |
| 256 | int |
| 257 | testdram(void) |
| 258 | { |
| 259 | uint *pstart = (uint *) CFG_MEMTEST_START; |
| 260 | uint *pend = (uint *) CFG_MEMTEST_END; |
| 261 | uint *p; |
| 262 | |
| 263 | printf("Testing DRAM from 0x%08x to 0x%08x\n", |
| 264 | CFG_MEMTEST_START, |
| 265 | CFG_MEMTEST_END); |
| 266 | |
| 267 | printf("DRAM test phase 1:\n"); |
| 268 | for (p = pstart; p < pend; p++) |
| 269 | *p = 0xaaaaaaaa; |
| 270 | |
| 271 | for (p = pstart; p < pend; p++) { |
| 272 | if (*p != 0xaaaaaaaa) { |
| 273 | printf ("DRAM test fails at: %08x\n", (uint) p); |
| 274 | return 1; |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | printf("DRAM test phase 2:\n"); |
| 279 | for (p = pstart; p < pend; p++) |
| 280 | *p = 0x55555555; |
| 281 | |
| 282 | for (p = pstart; p < pend; p++) { |
| 283 | if (*p != 0x55555555) { |
| 284 | printf ("DRAM test fails at: %08x\n", (uint) p); |
| 285 | return 1; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | printf("DRAM test passed.\n"); |
| 290 | return 0; |
| 291 | } |
| 292 | #endif |
| 293 | |
Ed Swarthout | f2cff6b | 2007-07-27 01:50:52 -0500 | [diff] [blame] | 294 | #if defined(CONFIG_PCI) || defined(CONFIG_PCI1) |
Matthew McClintock | bf1dfff | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 295 | /* For some reason the Tundra PCI bridge shows up on itself as a |
| 296 | * different device. Work around that by refusing to configure it. |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 297 | */ |
Matthew McClintock | bf1dfff | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 298 | void dummy_func(struct pci_controller* hose, pci_dev_t dev, struct pci_config_table *tab) { } |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 299 | |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 300 | static struct pci_config_table pci_mpc85xxcds_config_table[] = { |
Matthew McClintock | bf1dfff | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 301 | {0x10e3, 0x0513, PCI_ANY_ID, 1, 3, PCI_ANY_ID, dummy_func, {0,0,0}}, |
Randy Vinson | 7f3f2bd | 2007-02-27 19:42:22 -0700 | [diff] [blame] | 302 | {0x1106, 0x0686, PCI_ANY_ID, 1, VIA_ID, 0, mpc85xx_config_via, {0,0,0}}, |
| 303 | {0x1106, 0x0571, PCI_ANY_ID, 1, VIA_ID, 1, |
Andy Fleming | ffa621a | 2007-02-24 01:08:13 -0600 | [diff] [blame] | 304 | mpc85xx_config_via_usbide, {0,0,0}}, |
Randy Vinson | 7f3f2bd | 2007-02-27 19:42:22 -0700 | [diff] [blame] | 305 | {0x1105, 0x3038, PCI_ANY_ID, 1, VIA_ID, 2, |
| 306 | mpc85xx_config_via_usb, {0,0,0}}, |
| 307 | {0x1106, 0x3038, PCI_ANY_ID, 1, VIA_ID, 3, |
| 308 | mpc85xx_config_via_usb2, {0,0,0}}, |
| 309 | {0x1106, 0x3058, PCI_ANY_ID, 1, VIA_ID, 5, |
Andy Fleming | ffa621a | 2007-02-24 01:08:13 -0600 | [diff] [blame] | 310 | mpc85xx_config_via_power, {0,0,0}}, |
Randy Vinson | 7f3f2bd | 2007-02-27 19:42:22 -0700 | [diff] [blame] | 311 | {0x1106, 0x3068, PCI_ANY_ID, 1, VIA_ID, 6, |
| 312 | mpc85xx_config_via_ac97, {0,0,0}}, |
Andy Fleming | ffa621a | 2007-02-24 01:08:13 -0600 | [diff] [blame] | 313 | {}, |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 314 | }; |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 315 | |
Ed Swarthout | f2cff6b | 2007-07-27 01:50:52 -0500 | [diff] [blame] | 316 | static struct pci_controller pci1_hose = { |
| 317 | config_table: pci_mpc85xxcds_config_table}; |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 318 | #endif /* CONFIG_PCI */ |
| 319 | |
Ed Swarthout | f2cff6b | 2007-07-27 01:50:52 -0500 | [diff] [blame] | 320 | #ifdef CONFIG_PCI2 |
| 321 | static struct pci_controller pci2_hose; |
| 322 | #endif /* CONFIG_PCI2 */ |
| 323 | |
| 324 | #ifdef CONFIG_PCIE1 |
| 325 | static struct pci_controller pcie1_hose; |
| 326 | #endif /* CONFIG_PCIE1 */ |
| 327 | |
| 328 | int first_free_busno=0; |
| 329 | |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 330 | void |
| 331 | pci_init_board(void) |
| 332 | { |
Ed Swarthout | f2cff6b | 2007-07-27 01:50:52 -0500 | [diff] [blame] | 333 | volatile immap_t *immap = (immap_t *)CFG_IMMR; |
| 334 | volatile ccsr_gur_t *gur = &immap->im_gur; |
| 335 | uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19; |
| 336 | uint host_agent = (gur->porbmsr & MPC85xx_PORBMSR_HA) >> 16; |
| 337 | |
| 338 | |
| 339 | #ifdef CONFIG_PCI1 |
| 340 | { |
| 341 | volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CFG_PCI1_ADDR; |
| 342 | extern void fsl_pci_init(struct pci_controller *hose); |
| 343 | struct pci_controller *hose = &pci1_hose; |
| 344 | struct pci_config_table *table; |
| 345 | |
| 346 | uint pci_32 = gur->pordevsr & MPC85xx_PORDEVSR_PCI1_PCI32; /* PORDEVSR[15] */ |
| 347 | uint pci_arb = gur->pordevsr & MPC85xx_PORDEVSR_PCI1_ARB; /* PORDEVSR[14] */ |
| 348 | uint pci_clk_sel = gur->porpllsr & MPC85xx_PORDEVSR_PCI1_SPD; /* PORPLLSR[16] */ |
| 349 | |
| 350 | uint pci_agent = (host_agent == 3) || (host_agent == 4 ) || (host_agent == 6); |
| 351 | |
| 352 | uint pci_speed = get_clock_freq (); /* PCI PSPEED in [4:5] */ |
| 353 | |
| 354 | if (!(gur->devdisr & MPC85xx_DEVDISR_PCI1)) { |
| 355 | printf (" PCI: %d bit, %s MHz, %s, %s, %s\n", |
| 356 | (pci_32) ? 32 : 64, |
| 357 | (pci_speed == 33333000) ? "33" : |
| 358 | (pci_speed == 66666000) ? "66" : "unknown", |
| 359 | pci_clk_sel ? "sync" : "async", |
| 360 | pci_agent ? "agent" : "host", |
| 361 | pci_arb ? "arbiter" : "external-arbiter" |
| 362 | ); |
| 363 | |
| 364 | |
Ed Swarthout | 4bf4abb | 2007-08-21 09:38:59 -0500 | [diff] [blame^] | 365 | /* inbound */ |
Ed Swarthout | f2cff6b | 2007-07-27 01:50:52 -0500 | [diff] [blame] | 366 | pci_set_region(hose->regions + 0, |
Ed Swarthout | 4bf4abb | 2007-08-21 09:38:59 -0500 | [diff] [blame^] | 367 | CFG_PCI_MEMORY_BUS, |
| 368 | CFG_PCI_MEMORY_PHYS, |
| 369 | CFG_PCI_MEMORY_SIZE, |
| 370 | PCI_REGION_MEM | PCI_REGION_MEMORY); |
| 371 | |
| 372 | |
| 373 | /* outbound memory */ |
| 374 | pci_set_region(hose->regions + 1, |
Ed Swarthout | f2cff6b | 2007-07-27 01:50:52 -0500 | [diff] [blame] | 375 | CFG_PCI1_MEM_BASE, |
| 376 | CFG_PCI1_MEM_PHYS, |
| 377 | CFG_PCI1_MEM_SIZE, |
| 378 | PCI_REGION_MEM); |
| 379 | |
| 380 | /* outbound io */ |
Ed Swarthout | 4bf4abb | 2007-08-21 09:38:59 -0500 | [diff] [blame^] | 381 | pci_set_region(hose->regions + 2, |
Ed Swarthout | f2cff6b | 2007-07-27 01:50:52 -0500 | [diff] [blame] | 382 | CFG_PCI1_IO_BASE, |
| 383 | CFG_PCI1_IO_PHYS, |
| 384 | CFG_PCI1_IO_SIZE, |
| 385 | PCI_REGION_IO); |
Ed Swarthout | 4bf4abb | 2007-08-21 09:38:59 -0500 | [diff] [blame^] | 386 | hose->region_count = 3; |
Ed Swarthout | f2cff6b | 2007-07-27 01:50:52 -0500 | [diff] [blame] | 387 | |
| 388 | /* relocate config table pointers */ |
| 389 | hose->config_table = \ |
| 390 | (struct pci_config_table *)((uint)hose->config_table + gd->reloc_off); |
| 391 | for (table = hose->config_table; table && table->vendor; table++) |
| 392 | table->config_device += gd->reloc_off; |
| 393 | |
| 394 | hose->first_busno=first_free_busno; |
| 395 | pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); |
| 396 | |
| 397 | fsl_pci_init(hose); |
| 398 | first_free_busno=hose->last_busno+1; |
| 399 | printf ("PCI on bus %02x - %02x\n",hose->first_busno,hose->last_busno); |
| 400 | #ifdef CONFIG_PCIX_CHECK |
| 401 | if (!(gur->pordevsr & PORDEVSR_PCI)) { |
| 402 | /* PCI-X init */ |
| 403 | if (CONFIG_SYS_CLK_FREQ < 66000000) |
| 404 | printf("PCI-X will only work at 66 MHz\n"); |
| 405 | |
| 406 | reg16 = PCI_X_CMD_MAX_SPLIT | PCI_X_CMD_MAX_READ |
| 407 | | PCI_X_CMD_ERO | PCI_X_CMD_DPERR_E; |
| 408 | pci_hose_write_config_word(hose, bus, PCIX_COMMAND, reg16); |
| 409 | } |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 410 | #endif |
Ed Swarthout | f2cff6b | 2007-07-27 01:50:52 -0500 | [diff] [blame] | 411 | } else { |
| 412 | printf (" PCI: disabled\n"); |
| 413 | } |
| 414 | } |
| 415 | #else |
| 416 | gur->devdisr |= MPC85xx_DEVDISR_PCI1; /* disable */ |
| 417 | #endif |
| 418 | |
| 419 | #ifdef CONFIG_PCI2 |
| 420 | { |
| 421 | uint pci2_clk_sel = gur->porpllsr & 0x4000; /* PORPLLSR[17] */ |
| 422 | uint pci_dual = get_pci_dual (); /* PCI DUAL in CM_PCI[3] */ |
| 423 | if (pci_dual) { |
| 424 | printf (" PCI2: 32 bit, 66 MHz, %s\n", |
| 425 | pci2_clk_sel ? "sync" : "async"); |
| 426 | } else { |
| 427 | printf (" PCI2: disabled\n"); |
| 428 | } |
| 429 | } |
| 430 | #else |
| 431 | gur->devdisr |= MPC85xx_DEVDISR_PCI2; /* disable */ |
| 432 | #endif /* CONFIG_PCI2 */ |
| 433 | |
| 434 | #ifdef CONFIG_PCIE1 |
| 435 | { |
| 436 | volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CFG_PCIE1_ADDR; |
| 437 | extern void fsl_pci_init(struct pci_controller *hose); |
| 438 | struct pci_controller *hose = &pcie1_hose; |
| 439 | int pcie_ep = (host_agent == 0) || (host_agent == 2 ) || (host_agent == 3); |
| 440 | |
| 441 | int pcie_configured = io_sel >= 1; |
| 442 | |
| 443 | if (pcie_configured && !(gur->devdisr & MPC85xx_DEVDISR_PCIE)){ |
| 444 | printf ("\n PCIE connected to slot as %s (base address %x)", |
| 445 | pcie_ep ? "End Point" : "Root Complex", |
| 446 | (uint)pci); |
| 447 | |
| 448 | if (pci->pme_msg_det) { |
| 449 | pci->pme_msg_det = 0xffffffff; |
| 450 | debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det); |
| 451 | } |
| 452 | printf ("\n"); |
| 453 | |
| 454 | /* inbound */ |
| 455 | pci_set_region(hose->regions + 0, |
| 456 | CFG_PCI_MEMORY_BUS, |
| 457 | CFG_PCI_MEMORY_PHYS, |
| 458 | CFG_PCI_MEMORY_SIZE, |
| 459 | PCI_REGION_MEM | PCI_REGION_MEMORY); |
| 460 | |
| 461 | /* outbound memory */ |
| 462 | pci_set_region(hose->regions + 1, |
| 463 | CFG_PCIE1_MEM_BASE, |
| 464 | CFG_PCIE1_MEM_PHYS, |
| 465 | CFG_PCIE1_MEM_SIZE, |
| 466 | PCI_REGION_MEM); |
| 467 | |
| 468 | /* outbound io */ |
| 469 | pci_set_region(hose->regions + 2, |
| 470 | CFG_PCIE1_IO_BASE, |
| 471 | CFG_PCIE1_IO_PHYS, |
| 472 | CFG_PCIE1_IO_SIZE, |
| 473 | PCI_REGION_IO); |
| 474 | |
| 475 | hose->region_count = 3; |
| 476 | |
| 477 | hose->first_busno=first_free_busno; |
| 478 | pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); |
| 479 | |
| 480 | fsl_pci_init(hose); |
| 481 | printf ("PCIE on bus %d - %d\n",hose->first_busno,hose->last_busno); |
| 482 | |
| 483 | first_free_busno=hose->last_busno+1; |
| 484 | |
| 485 | } else { |
| 486 | printf (" PCIE: disabled\n"); |
| 487 | } |
| 488 | } |
| 489 | #else |
| 490 | gur->devdisr |= MPC85xx_DEVDISR_PCIE; /* disable */ |
| 491 | #endif |
| 492 | |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 493 | } |
Andy Fleming | 09f3e09 | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 494 | |
| 495 | int last_stage_init(void) |
| 496 | { |
Jon Loeliger | f501282 | 2006-10-20 15:54:34 -0500 | [diff] [blame] | 497 | unsigned short temp; |
Andy Fleming | 09f3e09 | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 498 | |
| 499 | /* Change the resistors for the PHY */ |
| 500 | /* This is needed to get the RGMII working for the 1.3+ |
| 501 | * CDS cards */ |
| 502 | if (get_board_version() == 0x13) { |
Kim Phillips | 255a3577 | 2007-05-16 16:52:19 -0500 | [diff] [blame] | 503 | miiphy_write(CONFIG_TSEC1_NAME, |
Andy Fleming | 09f3e09 | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 504 | TSEC1_PHY_ADDR, 29, 18); |
| 505 | |
Kim Phillips | 255a3577 | 2007-05-16 16:52:19 -0500 | [diff] [blame] | 506 | miiphy_read(CONFIG_TSEC1_NAME, |
Andy Fleming | 09f3e09 | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 507 | TSEC1_PHY_ADDR, 30, &temp); |
| 508 | |
| 509 | temp = (temp & 0xf03f); |
| 510 | temp |= 2 << 9; /* 36 ohm */ |
| 511 | temp |= 2 << 6; /* 39 ohm */ |
| 512 | |
Kim Phillips | 255a3577 | 2007-05-16 16:52:19 -0500 | [diff] [blame] | 513 | miiphy_write(CONFIG_TSEC1_NAME, |
Andy Fleming | 09f3e09 | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 514 | TSEC1_PHY_ADDR, 30, temp); |
| 515 | |
Kim Phillips | 255a3577 | 2007-05-16 16:52:19 -0500 | [diff] [blame] | 516 | miiphy_write(CONFIG_TSEC1_NAME, |
Andy Fleming | 09f3e09 | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 517 | TSEC1_PHY_ADDR, 29, 3); |
| 518 | |
Kim Phillips | 255a3577 | 2007-05-16 16:52:19 -0500 | [diff] [blame] | 519 | miiphy_write(CONFIG_TSEC1_NAME, |
Andy Fleming | 09f3e09 | 2006-09-13 10:34:18 -0500 | [diff] [blame] | 520 | TSEC1_PHY_ADDR, 30, 0x8000); |
| 521 | } |
| 522 | |
| 523 | return 0; |
| 524 | } |
Ed Swarthout | f2cff6b | 2007-07-27 01:50:52 -0500 | [diff] [blame] | 525 | |
| 526 | |
| 527 | #if defined(CONFIG_OF_FLAT_TREE) && defined(CONFIG_OF_BOARD_SETUP) |
| 528 | void |
| 529 | ft_pci_setup(void *blob, bd_t *bd) |
| 530 | { |
| 531 | u32 *p; |
| 532 | int len; |
| 533 | |
| 534 | |
| 535 | #ifdef CONFIG_PCI1 |
| 536 | p = (u32 *)ft_get_prop(blob, "/" OF_SOC "/pci@8000/bus-range", &len); |
| 537 | if (p != NULL) { |
| 538 | p[0] = 0; |
| 539 | p[1] = pci1_hose.last_busno - pci1_hose.first_busno; |
| 540 | debug("PCI@8000 first_busno=%d last_busno=%d\n",p[0],p[1]); |
| 541 | } |
| 542 | #endif |
| 543 | |
| 544 | #ifdef CONFIG_PCIE1 |
| 545 | p = (u32 *)ft_get_prop(blob, "/" OF_SOC "/pci@a000/bus-range", &len); |
| 546 | if (p != NULL) { |
| 547 | p[0] = 0; |
| 548 | p[1] = pcie1_hose.last_busno - pcie1_hose.first_busno; |
| 549 | debug("PCI@a000 first_busno=%d last_busno=%d\n",p[0],p[1]); |
| 550 | } |
| 551 | #endif |
| 552 | } |
| 553 | #endif |