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> |
Kumar Gala | 9bbd643 | 2009-04-02 13:22:48 -0500 | [diff] [blame] | 29 | #include <asm/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 | |
| 96 | int first_free_busno=0; |
| 97 | |
| 98 | void |
| 99 | pci_init_board(void) |
| 100 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 101 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 102 | uint devdisr = gur->devdisr; |
| 103 | uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19; |
| 104 | uint host_agent = (gur->porbmsr & MPC85xx_PORBMSR_HA) >> 16; |
| 105 | |
| 106 | debug (" pci_init_board: devdisr=%x, io_sel=%x, host_agent=%x\n", |
| 107 | devdisr, io_sel, host_agent); |
| 108 | |
| 109 | if (io_sel & 1) { |
| 110 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS)) |
| 111 | printf (" eTSEC1 is in sgmii mode.\n"); |
| 112 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS)) |
| 113 | printf (" eTSEC3 is in sgmii mode.\n"); |
| 114 | } |
| 115 | |
| 116 | #ifdef CONFIG_PCIE3 |
| 117 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 118 | 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] | 119 | struct pci_controller *hose = &pcie3_hose; |
Ed Swarthout | 031003a | 2008-04-25 01:08:32 -0500 | [diff] [blame] | 120 | int pcie_ep = (host_agent == 1); |
Roy Zang | 9142345 | 2009-01-09 16:00:55 +0800 | [diff] [blame] | 121 | int pcie_configured = io_sel >= 6; |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 122 | struct pci_region *r = hose->regions; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 123 | |
| 124 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){ |
| 125 | printf ("\n PCIE3 connected to ULI as %s (base address %x)", |
| 126 | pcie_ep ? "End Point" : "Root Complex", |
| 127 | (uint)pci); |
| 128 | if (pci->pme_msg_det) { |
| 129 | pci->pme_msg_det = 0xffffffff; |
| 130 | debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det); |
| 131 | } |
| 132 | printf ("\n"); |
| 133 | |
| 134 | /* inbound */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 135 | r += fsl_pci_setup_inbound_windows(r); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 136 | |
| 137 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 138 | pci_set_region(r++, |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 139 | CONFIG_SYS_PCIE3_MEM_BUS, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 140 | CONFIG_SYS_PCIE3_MEM_PHYS, |
| 141 | CONFIG_SYS_PCIE3_MEM_SIZE, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 142 | PCI_REGION_MEM); |
| 143 | |
| 144 | /* outbound io */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 145 | pci_set_region(r++, |
Kumar Gala | 64bb6d1 | 2008-12-02 16:08:37 -0600 | [diff] [blame] | 146 | CONFIG_SYS_PCIE3_IO_BUS, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 147 | CONFIG_SYS_PCIE3_IO_PHYS, |
| 148 | CONFIG_SYS_PCIE3_IO_SIZE, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 149 | PCI_REGION_IO); |
| 150 | |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 151 | #ifdef CONFIG_SYS_PCIE3_MEM_BUS2 |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 152 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 153 | pci_set_region(r++, |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 154 | CONFIG_SYS_PCIE3_MEM_BUS2, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 155 | CONFIG_SYS_PCIE3_MEM_PHYS2, |
| 156 | CONFIG_SYS_PCIE3_MEM_SIZE2, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 157 | PCI_REGION_MEM); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 158 | #endif |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 159 | hose->region_count = r - hose->regions; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 160 | hose->first_busno=first_free_busno; |
| 161 | pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); |
| 162 | |
| 163 | fsl_pci_init(hose); |
| 164 | |
| 165 | first_free_busno=hose->last_busno+1; |
| 166 | printf (" PCIE3 on bus %02x - %02x\n", |
| 167 | hose->first_busno,hose->last_busno); |
| 168 | |
Kumar Gala | e1e870a | 2007-08-30 16:18:18 -0500 | [diff] [blame] | 169 | /* |
| 170 | * Activate ULI1575 legacy chip by performing a fake |
| 171 | * memory access. Needed to make ULI RTC work. |
| 172 | */ |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 173 | in_be32((u32 *)CONFIG_SYS_PCIE3_MEM_BUS); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 174 | } else { |
| 175 | printf (" PCIE3: disabled\n"); |
| 176 | } |
| 177 | |
| 178 | } |
| 179 | #else |
| 180 | gur->devdisr |= MPC85xx_DEVDISR_PCIE3; /* disable */ |
| 181 | #endif |
| 182 | |
| 183 | #ifdef CONFIG_PCIE1 |
| 184 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 185 | 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] | 186 | struct pci_controller *hose = &pcie1_hose; |
| 187 | int pcie_ep = (host_agent == 5); |
Roy Zang | 994719d | 2009-01-09 16:02:35 +0800 | [diff] [blame] | 188 | int pcie_configured = io_sel >= 2; |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 189 | struct pci_region *r = hose->regions; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 190 | |
| 191 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){ |
| 192 | printf ("\n PCIE1 connected to Slot2 as %s (base address %x)", |
| 193 | pcie_ep ? "End Point" : "Root Complex", |
| 194 | (uint)pci); |
| 195 | if (pci->pme_msg_det) { |
| 196 | pci->pme_msg_det = 0xffffffff; |
| 197 | debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det); |
| 198 | } |
| 199 | printf ("\n"); |
| 200 | |
| 201 | /* inbound */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 202 | r += fsl_pci_setup_inbound_windows(r); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 203 | |
| 204 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 205 | pci_set_region(r++, |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 206 | CONFIG_SYS_PCIE1_MEM_BUS, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 207 | CONFIG_SYS_PCIE1_MEM_PHYS, |
| 208 | CONFIG_SYS_PCIE1_MEM_SIZE, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 209 | PCI_REGION_MEM); |
| 210 | |
| 211 | /* outbound io */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 212 | pci_set_region(r++, |
Kumar Gala | 64bb6d1 | 2008-12-02 16:08:37 -0600 | [diff] [blame] | 213 | CONFIG_SYS_PCIE1_IO_BUS, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 214 | CONFIG_SYS_PCIE1_IO_PHYS, |
| 215 | CONFIG_SYS_PCIE1_IO_SIZE, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 216 | PCI_REGION_IO); |
| 217 | |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 218 | #ifdef CONFIG_SYS_PCIE1_MEM_BUS2 |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 219 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 220 | pci_set_region(r++, |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 221 | CONFIG_SYS_PCIE1_MEM_BUS2, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 222 | CONFIG_SYS_PCIE1_MEM_PHYS2, |
| 223 | CONFIG_SYS_PCIE1_MEM_SIZE2, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 224 | PCI_REGION_MEM); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 225 | #endif |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 226 | hose->region_count = r - hose->regions; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 227 | hose->first_busno=first_free_busno; |
| 228 | |
| 229 | pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); |
| 230 | |
| 231 | fsl_pci_init(hose); |
| 232 | |
| 233 | first_free_busno=hose->last_busno+1; |
| 234 | printf(" PCIE1 on bus %02x - %02x\n", |
| 235 | hose->first_busno,hose->last_busno); |
| 236 | |
| 237 | } else { |
| 238 | printf (" PCIE1: disabled\n"); |
| 239 | } |
| 240 | |
| 241 | } |
| 242 | #else |
| 243 | gur->devdisr |= MPC85xx_DEVDISR_PCIE; /* disable */ |
| 244 | #endif |
| 245 | |
| 246 | #ifdef CONFIG_PCIE2 |
| 247 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 248 | 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] | 249 | struct pci_controller *hose = &pcie2_hose; |
| 250 | int pcie_ep = (host_agent == 3); |
Roy Zang | 994719d | 2009-01-09 16:02:35 +0800 | [diff] [blame] | 251 | int pcie_configured = io_sel >= 4; |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 252 | struct pci_region *r = hose->regions; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 253 | |
| 254 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){ |
| 255 | printf ("\n PCIE2 connected to Slot 1 as %s (base address %x)", |
| 256 | pcie_ep ? "End Point" : "Root Complex", |
| 257 | (uint)pci); |
| 258 | if (pci->pme_msg_det) { |
| 259 | pci->pme_msg_det = 0xffffffff; |
| 260 | debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det); |
| 261 | } |
| 262 | printf ("\n"); |
| 263 | |
| 264 | /* inbound */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 265 | r += fsl_pci_setup_inbound_windows(r); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 266 | |
| 267 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 268 | pci_set_region(r++, |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 269 | CONFIG_SYS_PCIE2_MEM_BUS, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 270 | CONFIG_SYS_PCIE2_MEM_PHYS, |
| 271 | CONFIG_SYS_PCIE2_MEM_SIZE, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 272 | PCI_REGION_MEM); |
| 273 | |
| 274 | /* outbound io */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 275 | pci_set_region(r++, |
Kumar Gala | 64bb6d1 | 2008-12-02 16:08:37 -0600 | [diff] [blame] | 276 | CONFIG_SYS_PCIE2_IO_BUS, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 277 | CONFIG_SYS_PCIE2_IO_PHYS, |
| 278 | CONFIG_SYS_PCIE2_IO_SIZE, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 279 | PCI_REGION_IO); |
| 280 | |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 281 | #ifdef CONFIG_SYS_PCIE2_MEM_BUS2 |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 282 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 283 | pci_set_region(r++, |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 284 | CONFIG_SYS_PCIE2_MEM_BUS2, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 285 | CONFIG_SYS_PCIE2_MEM_PHYS2, |
| 286 | CONFIG_SYS_PCIE2_MEM_SIZE2, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 287 | PCI_REGION_MEM); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 288 | #endif |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 289 | hose->region_count = r - hose->regions; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 290 | hose->first_busno=first_free_busno; |
| 291 | pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); |
| 292 | |
| 293 | fsl_pci_init(hose); |
| 294 | first_free_busno=hose->last_busno+1; |
| 295 | printf (" PCIE2 on bus %02x - %02x\n", |
| 296 | hose->first_busno,hose->last_busno); |
| 297 | |
| 298 | } else { |
| 299 | printf (" PCIE2: disabled\n"); |
| 300 | } |
| 301 | |
| 302 | } |
| 303 | #else |
| 304 | gur->devdisr |= MPC85xx_DEVDISR_PCIE2; /* disable */ |
| 305 | #endif |
| 306 | |
| 307 | |
| 308 | #ifdef CONFIG_PCI1 |
| 309 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 310 | 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] | 311 | struct pci_controller *hose = &pci1_hose; |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 312 | struct pci_region *r = hose->regions; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 313 | |
| 314 | uint pci_agent = (host_agent == 6); |
| 315 | uint pci_speed = 66666000; /*get_clock_freq (); PCI PSPEED in [4:5] */ |
| 316 | uint pci_32 = 1; |
| 317 | uint pci_arb = gur->pordevsr & MPC85xx_PORDEVSR_PCI1_ARB; /* PORDEVSR[14] */ |
| 318 | uint pci_clk_sel = gur->porpllsr & MPC85xx_PORDEVSR_PCI1_SPD; /* PORPLLSR[16] */ |
| 319 | |
| 320 | |
| 321 | if (!(devdisr & MPC85xx_DEVDISR_PCI1)) { |
| 322 | printf ("\n PCI: %d bit, %s MHz, %s, %s, %s (base address %x)\n", |
| 323 | (pci_32) ? 32 : 64, |
| 324 | (pci_speed == 33333000) ? "33" : |
| 325 | (pci_speed == 66666000) ? "66" : "unknown", |
| 326 | pci_clk_sel ? "sync" : "async", |
| 327 | pci_agent ? "agent" : "host", |
| 328 | pci_arb ? "arbiter" : "external-arbiter", |
| 329 | (uint)pci |
| 330 | ); |
| 331 | |
| 332 | /* inbound */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 333 | r += fsl_pci_setup_inbound_windows(r); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 334 | |
| 335 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 336 | pci_set_region(r++, |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 337 | CONFIG_SYS_PCI1_MEM_BUS, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 338 | CONFIG_SYS_PCI1_MEM_PHYS, |
| 339 | CONFIG_SYS_PCI1_MEM_SIZE, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 340 | PCI_REGION_MEM); |
| 341 | |
| 342 | /* outbound io */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 343 | pci_set_region(r++, |
Kumar Gala | 64bb6d1 | 2008-12-02 16:08:37 -0600 | [diff] [blame] | 344 | CONFIG_SYS_PCI1_IO_BUS, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 345 | CONFIG_SYS_PCI1_IO_PHYS, |
| 346 | CONFIG_SYS_PCI1_IO_SIZE, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 347 | PCI_REGION_IO); |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 348 | |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 349 | #ifdef CONFIG_SYS_PCIE3_MEM_BUS2 |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 350 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 351 | pci_set_region(r++, |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 352 | CONFIG_SYS_PCIE3_MEM_BUS2, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 353 | CONFIG_SYS_PCIE3_MEM_PHYS2, |
| 354 | CONFIG_SYS_PCIE3_MEM_SIZE2, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 355 | PCI_REGION_MEM); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 356 | #endif |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 357 | hose->region_count = r - hose->regions; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 358 | hose->first_busno=first_free_busno; |
| 359 | pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data); |
| 360 | |
| 361 | fsl_pci_init(hose); |
| 362 | first_free_busno=hose->last_busno+1; |
| 363 | printf ("PCI on bus %02x - %02x\n", |
| 364 | hose->first_busno,hose->last_busno); |
| 365 | } else { |
| 366 | printf (" PCI: disabled\n"); |
| 367 | } |
| 368 | } |
| 369 | #else |
| 370 | gur->devdisr |= MPC85xx_DEVDISR_PCI1; /* disable */ |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 371 | #endif |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 372 | } |
| 373 | |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 374 | |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 375 | int last_stage_init(void) |
| 376 | { |
| 377 | return 0; |
| 378 | } |
| 379 | |
| 380 | |
| 381 | unsigned long |
| 382 | get_board_sys_clk(ulong dummy) |
| 383 | { |
| 384 | u8 i, go_bit, rd_clks; |
| 385 | ulong val = 0; |
| 386 | |
| 387 | go_bit = in8(PIXIS_BASE + PIXIS_VCTL); |
| 388 | go_bit &= 0x01; |
| 389 | |
| 390 | rd_clks = in8(PIXIS_BASE + PIXIS_VCFGEN0); |
| 391 | rd_clks &= 0x1C; |
| 392 | |
| 393 | /* |
| 394 | * Only if both go bit and the SCLK bit in VCFGEN0 are set |
| 395 | * should we be using the AUX register. Remember, we also set the |
| 396 | * GO bit to boot from the alternate bank on the on-board flash |
| 397 | */ |
| 398 | |
| 399 | if (go_bit) { |
| 400 | if (rd_clks == 0x1c) |
| 401 | i = in8(PIXIS_BASE + PIXIS_AUX); |
| 402 | else |
| 403 | i = in8(PIXIS_BASE + PIXIS_SPD); |
| 404 | } else { |
| 405 | i = in8(PIXIS_BASE + PIXIS_SPD); |
| 406 | } |
| 407 | |
| 408 | i &= 0x07; |
| 409 | |
| 410 | switch (i) { |
| 411 | case 0: |
| 412 | val = 33333333; |
| 413 | break; |
| 414 | case 1: |
| 415 | val = 40000000; |
| 416 | break; |
| 417 | case 2: |
| 418 | val = 50000000; |
| 419 | break; |
| 420 | case 3: |
| 421 | val = 66666666; |
| 422 | break; |
| 423 | case 4: |
| 424 | val = 83000000; |
| 425 | break; |
| 426 | case 5: |
| 427 | val = 100000000; |
| 428 | break; |
| 429 | case 6: |
| 430 | val = 133333333; |
| 431 | break; |
| 432 | case 7: |
| 433 | val = 166666666; |
| 434 | break; |
| 435 | } |
| 436 | |
| 437 | return val; |
| 438 | } |
| 439 | |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 440 | int board_eth_init(bd_t *bis) |
| 441 | { |
Ben Warren | 65b8623 | 2008-08-31 21:41:08 -0700 | [diff] [blame] | 442 | #ifdef CONFIG_TSEC_ENET |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 443 | struct tsec_info_struct tsec_info[2]; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 444 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 445 | uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19; |
| 446 | int num = 0; |
| 447 | |
| 448 | #ifdef CONFIG_TSEC1 |
| 449 | SET_STD_TSEC_INFO(tsec_info[num], 1); |
| 450 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS)) |
| 451 | tsec_info[num].flags |= TSEC_SGMII; |
| 452 | num++; |
| 453 | #endif |
| 454 | #ifdef CONFIG_TSEC3 |
| 455 | SET_STD_TSEC_INFO(tsec_info[num], 3); |
| 456 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS)) |
| 457 | tsec_info[num].flags |= TSEC_SGMII; |
| 458 | num++; |
| 459 | #endif |
| 460 | |
| 461 | if (!num) { |
| 462 | printf("No TSECs initialized\n"); |
| 463 | |
| 464 | return 0; |
| 465 | } |
| 466 | |
| 467 | if (io_sel & 1) |
| 468 | fsl_sgmii_riser_init(tsec_info, num); |
| 469 | |
| 470 | |
| 471 | tsec_eth_init(bis, tsec_info, num); |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 472 | #endif |
Ben Warren | 65b8623 | 2008-08-31 21:41:08 -0700 | [diff] [blame] | 473 | return pci_eth_init(bis); |
| 474 | } |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 475 | |
Kumar Gala | 67b349b | 2007-11-26 17:12:24 -0600 | [diff] [blame] | 476 | #if defined(CONFIG_OF_BOARD_SETUP) |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 477 | void ft_board_setup(void *blob, bd_t *bd) |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 478 | { |
Wolfgang Denk | 58c495b | 2007-05-05 18:23:11 +0200 | [diff] [blame] | 479 | ft_cpu_setup(blob, bd); |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 480 | |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 481 | |
Ed Swarthout | f835840 | 2007-08-30 01:58:48 -0500 | [diff] [blame] | 482 | #ifdef CONFIG_PCI1 |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 483 | ft_fsl_pci_setup(blob, "pci0", &pci1_hose); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 484 | #endif |
| 485 | #ifdef CONFIG_PCIE2 |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 486 | ft_fsl_pci_setup(blob, "pci1", &pcie1_hose); |
Kumar Gala | 67b349b | 2007-11-26 17:12:24 -0600 | [diff] [blame] | 487 | #endif |
| 488 | #ifdef CONFIG_PCIE1 |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 489 | ft_fsl_pci_setup(blob, "pci2", &pcie3_hose); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 490 | #endif |
| 491 | #ifdef CONFIG_PCIE3 |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 492 | ft_fsl_pci_setup(blob, "pci3", &pcie2_hose); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 493 | #endif |
Andy Fleming | acaccae | 2008-12-05 20:10:22 -0600 | [diff] [blame] | 494 | #ifdef CONFIG_FSL_SGMII_RISER |
| 495 | fsl_sgmii_riser_fdt_fixup(blob); |
| 496 | #endif |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 497 | } |
| 498 | #endif |