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