Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2007 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 20 | * MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #include <common.h> |
| 24 | #include <command.h> |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 25 | #include <pci.h> |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 26 | #include <asm/processor.h> |
Kumar Gala | 573ad30 | 2008-08-26 08:02:30 -0500 | [diff] [blame] | 27 | #include <asm/mmu.h> |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 28 | #include <asm/immap_85xx.h> |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 29 | #include <asm/immap_fsl_pci.h> |
Kumar Gala | 573ad30 | 2008-08-26 08:02:30 -0500 | [diff] [blame] | 30 | #include <asm/fsl_ddr_sdram.h> |
Kumar Gala | e1e870a | 2007-08-30 16:18:18 -0500 | [diff] [blame] | 31 | #include <asm/io.h> |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 32 | #include <miiphy.h> |
Kumar Gala | 67b349b | 2007-11-26 17:12:24 -0600 | [diff] [blame] | 33 | #include <libfdt.h> |
| 34 | #include <fdt_support.h> |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 35 | #include <tsec.h> |
Ben Warren | 65b8623 | 2008-08-31 21:41:08 -0700 | [diff] [blame] | 36 | #include <netdev.h> |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 37 | |
| 38 | #include "../common/pixis.h" |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 39 | #include "../common/sgmii_riser.h" |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 40 | |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 41 | int checkboard (void) |
| 42 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 43 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
| 44 | volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR); |
| 45 | volatile ccsr_local_ecm_t *ecm = (void *)(CONFIG_SYS_MPC85xx_ECM_ADDR); |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 46 | |
Wolfgang Denk | 58c495b | 2007-05-05 18:23:11 +0200 | [diff] [blame] | 47 | if ((uint)&gur->porpllsr != 0xe00e0000) { |
Wolfgang Denk | 12cec0a | 2008-07-11 01:16:00 +0200 | [diff] [blame] | 48 | printf("immap size error %lx\n",(ulong)&gur->porpllsr); |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 49 | } |
Kumar Gala | fda2f3a | 2008-07-14 14:07:01 -0500 | [diff] [blame] | 50 | printf ("Board: MPC8544DS, System ID: 0x%02x, " |
| 51 | "System Version: 0x%02x, FPGA Version: 0x%02x\n", |
| 52 | in8(PIXIS_BASE + PIXIS_ID), in8(PIXIS_BASE + PIXIS_VER), |
| 53 | in8(PIXIS_BASE + PIXIS_PVER)); |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 54 | |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 55 | lbc->ltesr = 0xffffffff; /* Clear LBC error interrupts */ |
| 56 | lbc->lteir = 0xffffffff; /* Enable LBC error interrupts */ |
| 57 | ecm->eedr = 0xffffffff; /* Clear ecm errors */ |
| 58 | ecm->eeer = 0xffffffff; /* Enable ecm errors */ |
| 59 | |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 60 | return 0; |
| 61 | } |
| 62 | |
Becky Bruce | bd99ae7 | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 63 | phys_size_t |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 64 | initdram(int board_type) |
| 65 | { |
| 66 | long dram_size = 0; |
| 67 | |
| 68 | puts("Initializing\n"); |
| 69 | |
Kumar Gala | 573ad30 | 2008-08-26 08:02:30 -0500 | [diff] [blame] | 70 | dram_size = fsl_ddr_sdram(); |
| 71 | |
| 72 | dram_size = setup_ddr_tlbs(dram_size / 0x100000); |
| 73 | |
| 74 | dram_size *= 0x100000; |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 75 | |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 76 | puts(" DDR: "); |
| 77 | return dram_size; |
| 78 | } |
| 79 | |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 80 | #ifdef CONFIG_PCI1 |
| 81 | static struct pci_controller pci1_hose; |
| 82 | #endif |
| 83 | |
| 84 | #ifdef CONFIG_PCIE1 |
| 85 | static struct pci_controller pcie1_hose; |
| 86 | #endif |
| 87 | |
| 88 | #ifdef CONFIG_PCIE2 |
| 89 | static struct pci_controller pcie2_hose; |
| 90 | #endif |
| 91 | |
| 92 | #ifdef CONFIG_PCIE3 |
| 93 | static struct pci_controller pcie3_hose; |
| 94 | #endif |
| 95 | |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 96 | extern int fsl_pci_setup_inbound_windows(struct pci_region *r); |
| 97 | extern void fsl_pci_init(struct pci_controller *hose); |
| 98 | |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 99 | int first_free_busno=0; |
| 100 | |
| 101 | void |
| 102 | pci_init_board(void) |
| 103 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 104 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 105 | uint devdisr = gur->devdisr; |
| 106 | uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19; |
| 107 | uint host_agent = (gur->porbmsr & MPC85xx_PORBMSR_HA) >> 16; |
| 108 | |
| 109 | debug (" pci_init_board: devdisr=%x, io_sel=%x, host_agent=%x\n", |
| 110 | devdisr, io_sel, host_agent); |
| 111 | |
| 112 | if (io_sel & 1) { |
| 113 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS)) |
| 114 | printf (" eTSEC1 is in sgmii mode.\n"); |
| 115 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS)) |
| 116 | printf (" eTSEC3 is in sgmii mode.\n"); |
| 117 | } |
| 118 | |
| 119 | #ifdef CONFIG_PCIE3 |
| 120 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 121 | volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE3_ADDR; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 122 | struct pci_controller *hose = &pcie3_hose; |
Ed Swarthout | 031003a | 2008-04-25 01:08:32 -0500 | [diff] [blame] | 123 | int pcie_ep = (host_agent == 1); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 124 | int pcie_configured = io_sel >= 1; |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 125 | struct pci_region *r = hose->regions; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 126 | |
| 127 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){ |
| 128 | printf ("\n PCIE3 connected to ULI as %s (base address %x)", |
| 129 | pcie_ep ? "End Point" : "Root Complex", |
| 130 | (uint)pci); |
| 131 | if (pci->pme_msg_det) { |
| 132 | pci->pme_msg_det = 0xffffffff; |
| 133 | debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det); |
| 134 | } |
| 135 | printf ("\n"); |
| 136 | |
| 137 | /* inbound */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 138 | r += fsl_pci_setup_inbound_windows(r); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 139 | |
| 140 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 141 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 142 | CONFIG_SYS_PCIE3_MEM_BASE, |
| 143 | CONFIG_SYS_PCIE3_MEM_PHYS, |
| 144 | CONFIG_SYS_PCIE3_MEM_SIZE, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 145 | PCI_REGION_MEM); |
| 146 | |
| 147 | /* outbound io */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 148 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 149 | CONFIG_SYS_PCIE3_IO_BASE, |
| 150 | CONFIG_SYS_PCIE3_IO_PHYS, |
| 151 | CONFIG_SYS_PCIE3_IO_SIZE, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 152 | PCI_REGION_IO); |
| 153 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 154 | #ifdef CONFIG_SYS_PCIE3_MEM_BASE2 |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 155 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 156 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 157 | CONFIG_SYS_PCIE3_MEM_BASE2, |
| 158 | CONFIG_SYS_PCIE3_MEM_PHYS2, |
| 159 | CONFIG_SYS_PCIE3_MEM_SIZE2, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 160 | PCI_REGION_MEM); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 161 | #endif |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 162 | hose->region_count = r - hose->regions; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 163 | hose->first_busno=first_free_busno; |
| 164 | pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); |
| 165 | |
| 166 | fsl_pci_init(hose); |
| 167 | |
| 168 | first_free_busno=hose->last_busno+1; |
| 169 | printf (" PCIE3 on bus %02x - %02x\n", |
| 170 | hose->first_busno,hose->last_busno); |
| 171 | |
Kumar Gala | e1e870a | 2007-08-30 16:18:18 -0500 | [diff] [blame] | 172 | /* |
| 173 | * Activate ULI1575 legacy chip by performing a fake |
| 174 | * memory access. Needed to make ULI RTC work. |
| 175 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 176 | in_be32((u32 *)CONFIG_SYS_PCIE3_MEM_BASE); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 177 | } else { |
| 178 | printf (" PCIE3: disabled\n"); |
| 179 | } |
| 180 | |
| 181 | } |
| 182 | #else |
| 183 | gur->devdisr |= MPC85xx_DEVDISR_PCIE3; /* disable */ |
| 184 | #endif |
| 185 | |
| 186 | #ifdef CONFIG_PCIE1 |
| 187 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 188 | volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE1_ADDR; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 189 | struct pci_controller *hose = &pcie1_hose; |
| 190 | int pcie_ep = (host_agent == 5); |
| 191 | int pcie_configured = io_sel & 6; |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 192 | struct pci_region *r = hose->regions; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 193 | |
| 194 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){ |
| 195 | printf ("\n PCIE1 connected to Slot2 as %s (base address %x)", |
| 196 | pcie_ep ? "End Point" : "Root Complex", |
| 197 | (uint)pci); |
| 198 | if (pci->pme_msg_det) { |
| 199 | pci->pme_msg_det = 0xffffffff; |
| 200 | debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det); |
| 201 | } |
| 202 | printf ("\n"); |
| 203 | |
| 204 | /* inbound */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 205 | r += fsl_pci_setup_inbound_windows(r); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 206 | |
| 207 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 208 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 209 | CONFIG_SYS_PCIE1_MEM_BASE, |
| 210 | CONFIG_SYS_PCIE1_MEM_PHYS, |
| 211 | CONFIG_SYS_PCIE1_MEM_SIZE, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 212 | PCI_REGION_MEM); |
| 213 | |
| 214 | /* outbound io */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 215 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 216 | CONFIG_SYS_PCIE1_IO_BASE, |
| 217 | CONFIG_SYS_PCIE1_IO_PHYS, |
| 218 | CONFIG_SYS_PCIE1_IO_SIZE, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 219 | PCI_REGION_IO); |
| 220 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 221 | #ifdef CONFIG_SYS_PCIE1_MEM_BASE2 |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 222 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 223 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 224 | CONFIG_SYS_PCIE1_MEM_BASE2, |
| 225 | CONFIG_SYS_PCIE1_MEM_PHYS2, |
| 226 | CONFIG_SYS_PCIE1_MEM_SIZE2, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 227 | PCI_REGION_MEM); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 228 | #endif |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 229 | hose->region_count = r - hose->regions; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 230 | hose->first_busno=first_free_busno; |
| 231 | |
| 232 | pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); |
| 233 | |
| 234 | fsl_pci_init(hose); |
| 235 | |
| 236 | first_free_busno=hose->last_busno+1; |
| 237 | printf(" PCIE1 on bus %02x - %02x\n", |
| 238 | hose->first_busno,hose->last_busno); |
| 239 | |
| 240 | } else { |
| 241 | printf (" PCIE1: disabled\n"); |
| 242 | } |
| 243 | |
| 244 | } |
| 245 | #else |
| 246 | gur->devdisr |= MPC85xx_DEVDISR_PCIE; /* disable */ |
| 247 | #endif |
| 248 | |
| 249 | #ifdef CONFIG_PCIE2 |
| 250 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 251 | volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE2_ADDR; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 252 | struct pci_controller *hose = &pcie2_hose; |
| 253 | int pcie_ep = (host_agent == 3); |
| 254 | int pcie_configured = io_sel & 4; |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 255 | struct pci_region *r = hose->regions; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 256 | |
| 257 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){ |
| 258 | printf ("\n PCIE2 connected to Slot 1 as %s (base address %x)", |
| 259 | pcie_ep ? "End Point" : "Root Complex", |
| 260 | (uint)pci); |
| 261 | if (pci->pme_msg_det) { |
| 262 | pci->pme_msg_det = 0xffffffff; |
| 263 | debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det); |
| 264 | } |
| 265 | printf ("\n"); |
| 266 | |
| 267 | /* inbound */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 268 | r += fsl_pci_setup_inbound_windows(r); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 269 | |
| 270 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 271 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 272 | CONFIG_SYS_PCIE2_MEM_BASE, |
| 273 | CONFIG_SYS_PCIE2_MEM_PHYS, |
| 274 | CONFIG_SYS_PCIE2_MEM_SIZE, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 275 | PCI_REGION_MEM); |
| 276 | |
| 277 | /* outbound io */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 278 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 279 | CONFIG_SYS_PCIE2_IO_BASE, |
| 280 | CONFIG_SYS_PCIE2_IO_PHYS, |
| 281 | CONFIG_SYS_PCIE2_IO_SIZE, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 282 | PCI_REGION_IO); |
| 283 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 284 | #ifdef CONFIG_SYS_PCIE2_MEM_BASE2 |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 285 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 286 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 287 | CONFIG_SYS_PCIE2_MEM_BASE2, |
| 288 | CONFIG_SYS_PCIE2_MEM_PHYS2, |
| 289 | CONFIG_SYS_PCIE2_MEM_SIZE2, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 290 | PCI_REGION_MEM); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 291 | #endif |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 292 | hose->region_count = r - hose->regions; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 293 | hose->first_busno=first_free_busno; |
| 294 | pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); |
| 295 | |
| 296 | fsl_pci_init(hose); |
| 297 | first_free_busno=hose->last_busno+1; |
| 298 | printf (" PCIE2 on bus %02x - %02x\n", |
| 299 | hose->first_busno,hose->last_busno); |
| 300 | |
| 301 | } else { |
| 302 | printf (" PCIE2: disabled\n"); |
| 303 | } |
| 304 | |
| 305 | } |
| 306 | #else |
| 307 | gur->devdisr |= MPC85xx_DEVDISR_PCIE2; /* disable */ |
| 308 | #endif |
| 309 | |
| 310 | |
| 311 | #ifdef CONFIG_PCI1 |
| 312 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 313 | volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCI1_ADDR; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 314 | struct pci_controller *hose = &pci1_hose; |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 315 | struct pci_region *r = hose->regions; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 316 | |
| 317 | uint pci_agent = (host_agent == 6); |
| 318 | uint pci_speed = 66666000; /*get_clock_freq (); PCI PSPEED in [4:5] */ |
| 319 | uint pci_32 = 1; |
| 320 | uint pci_arb = gur->pordevsr & MPC85xx_PORDEVSR_PCI1_ARB; /* PORDEVSR[14] */ |
| 321 | uint pci_clk_sel = gur->porpllsr & MPC85xx_PORDEVSR_PCI1_SPD; /* PORPLLSR[16] */ |
| 322 | |
| 323 | |
| 324 | if (!(devdisr & MPC85xx_DEVDISR_PCI1)) { |
| 325 | printf ("\n PCI: %d bit, %s MHz, %s, %s, %s (base address %x)\n", |
| 326 | (pci_32) ? 32 : 64, |
| 327 | (pci_speed == 33333000) ? "33" : |
| 328 | (pci_speed == 66666000) ? "66" : "unknown", |
| 329 | pci_clk_sel ? "sync" : "async", |
| 330 | pci_agent ? "agent" : "host", |
| 331 | pci_arb ? "arbiter" : "external-arbiter", |
| 332 | (uint)pci |
| 333 | ); |
| 334 | |
| 335 | /* inbound */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 336 | r += fsl_pci_setup_inbound_windows(r); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 337 | |
| 338 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 339 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 340 | CONFIG_SYS_PCI1_MEM_BASE, |
| 341 | CONFIG_SYS_PCI1_MEM_PHYS, |
| 342 | CONFIG_SYS_PCI1_MEM_SIZE, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 343 | PCI_REGION_MEM); |
| 344 | |
| 345 | /* outbound io */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 346 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 347 | CONFIG_SYS_PCI1_IO_BASE, |
| 348 | CONFIG_SYS_PCI1_IO_PHYS, |
| 349 | CONFIG_SYS_PCI1_IO_SIZE, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 350 | PCI_REGION_IO); |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 351 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 352 | #ifdef CONFIG_SYS_PCIE3_MEM_BASE2 |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 353 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 354 | pci_set_region(r++, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 355 | CONFIG_SYS_PCIE3_MEM_BASE2, |
| 356 | CONFIG_SYS_PCIE3_MEM_PHYS2, |
| 357 | CONFIG_SYS_PCIE3_MEM_SIZE2, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 358 | PCI_REGION_MEM); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 359 | #endif |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 360 | hose->region_count = r - hose->regions; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 361 | hose->first_busno=first_free_busno; |
| 362 | pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); |
| 363 | |
| 364 | fsl_pci_init(hose); |
| 365 | first_free_busno=hose->last_busno+1; |
| 366 | printf ("PCI on bus %02x - %02x\n", |
| 367 | hose->first_busno,hose->last_busno); |
| 368 | } else { |
| 369 | printf (" PCI: disabled\n"); |
| 370 | } |
| 371 | } |
| 372 | #else |
| 373 | gur->devdisr |= MPC85xx_DEVDISR_PCI1; /* disable */ |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 374 | #endif |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 375 | } |
| 376 | |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 377 | |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 378 | int last_stage_init(void) |
| 379 | { |
| 380 | return 0; |
| 381 | } |
| 382 | |
| 383 | |
| 384 | unsigned long |
| 385 | get_board_sys_clk(ulong dummy) |
| 386 | { |
| 387 | u8 i, go_bit, rd_clks; |
| 388 | ulong val = 0; |
| 389 | |
| 390 | go_bit = in8(PIXIS_BASE + PIXIS_VCTL); |
| 391 | go_bit &= 0x01; |
| 392 | |
| 393 | rd_clks = in8(PIXIS_BASE + PIXIS_VCFGEN0); |
| 394 | rd_clks &= 0x1C; |
| 395 | |
| 396 | /* |
| 397 | * Only if both go bit and the SCLK bit in VCFGEN0 are set |
| 398 | * should we be using the AUX register. Remember, we also set the |
| 399 | * GO bit to boot from the alternate bank on the on-board flash |
| 400 | */ |
| 401 | |
| 402 | if (go_bit) { |
| 403 | if (rd_clks == 0x1c) |
| 404 | i = in8(PIXIS_BASE + PIXIS_AUX); |
| 405 | else |
| 406 | i = in8(PIXIS_BASE + PIXIS_SPD); |
| 407 | } else { |
| 408 | i = in8(PIXIS_BASE + PIXIS_SPD); |
| 409 | } |
| 410 | |
| 411 | i &= 0x07; |
| 412 | |
| 413 | switch (i) { |
| 414 | case 0: |
| 415 | val = 33333333; |
| 416 | break; |
| 417 | case 1: |
| 418 | val = 40000000; |
| 419 | break; |
| 420 | case 2: |
| 421 | val = 50000000; |
| 422 | break; |
| 423 | case 3: |
| 424 | val = 66666666; |
| 425 | break; |
| 426 | case 4: |
| 427 | val = 83000000; |
| 428 | break; |
| 429 | case 5: |
| 430 | val = 100000000; |
| 431 | break; |
| 432 | case 6: |
| 433 | val = 133333333; |
| 434 | break; |
| 435 | case 7: |
| 436 | val = 166666666; |
| 437 | break; |
| 438 | } |
| 439 | |
| 440 | return val; |
| 441 | } |
| 442 | |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 443 | int board_eth_init(bd_t *bis) |
| 444 | { |
Ben Warren | 65b8623 | 2008-08-31 21:41:08 -0700 | [diff] [blame] | 445 | #ifdef CONFIG_TSEC_ENET |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 446 | struct tsec_info_struct tsec_info[2]; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 447 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 448 | uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19; |
| 449 | int num = 0; |
| 450 | |
| 451 | #ifdef CONFIG_TSEC1 |
| 452 | SET_STD_TSEC_INFO(tsec_info[num], 1); |
| 453 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS)) |
| 454 | tsec_info[num].flags |= TSEC_SGMII; |
| 455 | num++; |
| 456 | #endif |
| 457 | #ifdef CONFIG_TSEC3 |
| 458 | SET_STD_TSEC_INFO(tsec_info[num], 3); |
| 459 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS)) |
| 460 | tsec_info[num].flags |= TSEC_SGMII; |
| 461 | num++; |
| 462 | #endif |
| 463 | |
| 464 | if (!num) { |
| 465 | printf("No TSECs initialized\n"); |
| 466 | |
| 467 | return 0; |
| 468 | } |
| 469 | |
| 470 | if (io_sel & 1) |
| 471 | fsl_sgmii_riser_init(tsec_info, num); |
| 472 | |
| 473 | |
| 474 | tsec_eth_init(bis, tsec_info, num); |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 475 | #endif |
Ben Warren | 65b8623 | 2008-08-31 21:41:08 -0700 | [diff] [blame] | 476 | return pci_eth_init(bis); |
| 477 | } |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 478 | |
Kumar Gala | 67b349b | 2007-11-26 17:12:24 -0600 | [diff] [blame] | 479 | #if defined(CONFIG_OF_BOARD_SETUP) |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 480 | extern void ft_fsl_pci_setup(void *blob, const char *pci_alias, |
Wolfgang Denk | 82f15f3 | 2008-11-02 16:14:22 +0100 | [diff] [blame] | 481 | struct pci_controller *hose); |
Kumar Gala | 67b349b | 2007-11-26 17:12:24 -0600 | [diff] [blame] | 482 | |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 483 | void ft_board_setup(void *blob, bd_t *bd) |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 484 | { |
Wolfgang Denk | 58c495b | 2007-05-05 18:23:11 +0200 | [diff] [blame] | 485 | ft_cpu_setup(blob, bd); |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 486 | |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 487 | |
Ed Swarthout | f835840 | 2007-08-30 01:58:48 -0500 | [diff] [blame] | 488 | #ifdef CONFIG_PCI1 |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 489 | ft_fsl_pci_setup(blob, "pci0", &pci1_hose); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 490 | #endif |
| 491 | #ifdef CONFIG_PCIE2 |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 492 | ft_fsl_pci_setup(blob, "pci1", &pcie1_hose); |
Kumar Gala | 67b349b | 2007-11-26 17:12:24 -0600 | [diff] [blame] | 493 | #endif |
| 494 | #ifdef CONFIG_PCIE1 |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 495 | ft_fsl_pci_setup(blob, "pci2", &pcie3_hose); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 496 | #endif |
| 497 | #ifdef CONFIG_PCIE3 |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 498 | ft_fsl_pci_setup(blob, "pci3", &pcie2_hose); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 499 | #endif |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 500 | } |
| 501 | #endif |