Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2007-2008 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> |
| 25 | #include <pci.h> |
| 26 | #include <asm/processor.h> |
| 27 | #include <asm/mmu.h> |
Kumar Gala | f81f89f | 2008-09-22 14:11:11 -0500 | [diff] [blame] | 28 | #include <asm/cache.h> |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 29 | #include <asm/immap_85xx.h> |
Kumar Gala | 9bbd643 | 2009-04-02 13:22:48 -0500 | [diff] [blame] | 30 | #include <asm/fsl_pci.h> |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 31 | #include <asm/fsl_ddr_sdram.h> |
| 32 | #include <asm/io.h> |
| 33 | #include <miiphy.h> |
| 34 | #include <libfdt.h> |
| 35 | #include <fdt_support.h> |
Liu Yu | c49bce4 | 2008-10-10 11:40:59 +0800 | [diff] [blame] | 36 | #include <tsec.h> |
Kumar Gala | d3b1b66 | 2009-08-08 10:42:30 -0500 | [diff] [blame] | 37 | #include <netdev.h> |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 38 | |
| 39 | #include "../common/pixis.h" |
Liu Yu | c49bce4 | 2008-10-10 11:40:59 +0800 | [diff] [blame] | 40 | #include "../common/sgmii_riser.h" |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 41 | |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 42 | long int fixed_sdram(void); |
| 43 | |
| 44 | int checkboard (void) |
| 45 | { |
Kumar Gala | e21db03 | 2009-07-14 22:42:01 -0500 | [diff] [blame] | 46 | u8 vboot; |
| 47 | u8 *pixis_base = (u8 *)PIXIS_BASE; |
| 48 | |
Kumar Gala | 2cbb2ee | 2009-02-10 17:36:15 -0600 | [diff] [blame] | 49 | puts ("Board: MPC8572DS "); |
| 50 | #ifdef CONFIG_PHYS_64BIT |
| 51 | puts ("(36-bit addrmap) "); |
| 52 | #endif |
| 53 | printf ("Sys ID: 0x%02x, " |
Kumar Gala | e21db03 | 2009-07-14 22:42:01 -0500 | [diff] [blame] | 54 | "Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ", |
| 55 | in_8(pixis_base + PIXIS_ID), in_8(pixis_base + PIXIS_VER), |
| 56 | in_8(pixis_base + PIXIS_PVER)); |
| 57 | |
| 58 | vboot = in_8(pixis_base + PIXIS_VBOOT); |
| 59 | switch ((vboot & PIXIS_VBOOT_LBMAP) >> 6) { |
| 60 | case PIXIS_VBOOT_LBMAP_NOR0: |
| 61 | puts ("vBank: 0\n"); |
| 62 | break; |
| 63 | case PIXIS_VBOOT_LBMAP_PJET: |
| 64 | puts ("Promjet\n"); |
| 65 | break; |
| 66 | case PIXIS_VBOOT_LBMAP_NAND: |
| 67 | puts ("NAND\n"); |
| 68 | break; |
| 69 | case PIXIS_VBOOT_LBMAP_NOR1: |
| 70 | puts ("vBank: 1\n"); |
| 71 | break; |
| 72 | } |
| 73 | |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | phys_size_t initdram(int board_type) |
| 78 | { |
| 79 | phys_size_t dram_size = 0; |
| 80 | |
| 81 | puts("Initializing...."); |
| 82 | |
| 83 | #ifdef CONFIG_SPD_EEPROM |
| 84 | dram_size = fsl_ddr_sdram(); |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 85 | #else |
| 86 | dram_size = fixed_sdram(); |
| 87 | #endif |
Dave Liu | 83d43d2 | 2008-10-28 17:53:45 +0800 | [diff] [blame] | 88 | dram_size = setup_ddr_tlbs(dram_size / 0x100000); |
| 89 | dram_size *= 0x100000; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 90 | |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 91 | puts(" DDR: "); |
| 92 | return dram_size; |
| 93 | } |
| 94 | |
| 95 | #if !defined(CONFIG_SPD_EEPROM) |
| 96 | /* |
| 97 | * Fixed sdram init -- doesn't use serial presence detect. |
| 98 | */ |
| 99 | |
| 100 | phys_size_t fixed_sdram (void) |
| 101 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 102 | volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 103 | volatile ccsr_ddr_t *ddr= &immap->im_ddr; |
| 104 | uint d_init; |
| 105 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 106 | ddr->cs0_bnds = CONFIG_SYS_DDR_CS0_BNDS; |
| 107 | ddr->cs0_config = CONFIG_SYS_DDR_CS0_CONFIG; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 108 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 109 | ddr->timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3; |
| 110 | ddr->timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0; |
| 111 | ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1; |
| 112 | ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2; |
| 113 | ddr->sdram_mode = CONFIG_SYS_DDR_MODE_1; |
| 114 | ddr->sdram_mode_2 = CONFIG_SYS_DDR_MODE_2; |
| 115 | ddr->sdram_interval = CONFIG_SYS_DDR_INTERVAL; |
| 116 | ddr->sdram_data_init = CONFIG_SYS_DDR_DATA_INIT; |
| 117 | ddr->sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CTRL; |
| 118 | ddr->sdram_cfg_2 = CONFIG_SYS_DDR_CONTROL2; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 119 | |
| 120 | #if defined (CONFIG_DDR_ECC) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 121 | ddr->err_int_en = CONFIG_SYS_DDR_ERR_INT_EN; |
| 122 | ddr->err_disable = CONFIG_SYS_DDR_ERR_DIS; |
| 123 | ddr->err_sbe = CONFIG_SYS_DDR_SBE; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 124 | #endif |
| 125 | asm("sync;isync"); |
| 126 | |
| 127 | udelay(500); |
| 128 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 129 | ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 130 | |
| 131 | #if defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) |
| 132 | d_init = 1; |
| 133 | debug("DDR - 1st controller: memory initializing\n"); |
| 134 | /* |
| 135 | * Poll until memory is initialized. |
| 136 | * 512 Meg at 400 might hit this 200 times or so. |
| 137 | */ |
| 138 | while ((ddr->sdram_cfg_2 & (d_init << 4)) != 0) { |
| 139 | udelay(1000); |
| 140 | } |
| 141 | debug("DDR: memory initialized\n\n"); |
| 142 | asm("sync; isync"); |
| 143 | udelay(500); |
| 144 | #endif |
| 145 | |
| 146 | return 512 * 1024 * 1024; |
| 147 | } |
| 148 | |
| 149 | #endif |
| 150 | |
| 151 | #ifdef CONFIG_PCIE1 |
| 152 | static struct pci_controller pcie1_hose; |
| 153 | #endif |
| 154 | |
| 155 | #ifdef CONFIG_PCIE2 |
| 156 | static struct pci_controller pcie2_hose; |
| 157 | #endif |
| 158 | |
| 159 | #ifdef CONFIG_PCIE3 |
| 160 | static struct pci_controller pcie3_hose; |
| 161 | #endif |
| 162 | |
| 163 | int first_free_busno=0; |
| 164 | #ifdef CONFIG_PCI |
| 165 | void pci_init_board(void) |
| 166 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 167 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 168 | uint devdisr = gur->devdisr; |
| 169 | uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19; |
| 170 | uint host_agent = (gur->porbmsr & MPC85xx_PORBMSR_HA) >> 16; |
| 171 | |
| 172 | debug (" pci_init_board: devdisr=%x, io_sel=%x, host_agent=%x\n", |
| 173 | devdisr, io_sel, host_agent); |
| 174 | |
| 175 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS)) |
| 176 | printf (" eTSEC1 is in sgmii mode.\n"); |
| 177 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII2_DIS)) |
| 178 | printf (" eTSEC2 is in sgmii mode.\n"); |
| 179 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS)) |
| 180 | printf (" eTSEC3 is in sgmii mode.\n"); |
| 181 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII4_DIS)) |
| 182 | printf (" eTSEC4 is in sgmii mode.\n"); |
| 183 | |
| 184 | |
| 185 | #ifdef CONFIG_PCIE3 |
| 186 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 187 | volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE3_ADDR; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 188 | struct pci_controller *hose = &pcie3_hose; |
Kumar Gala | 666ced1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 189 | int pcie_ep = is_fsl_pci_agent(LAW_TRGT_IF_PCIE_3, host_agent); |
| 190 | int pcie_configured = is_fsl_pci_cfg(LAW_TRGT_IF_PCIE_3, io_sel); |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 191 | struct pci_region *r = hose->regions; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 192 | u32 temp32; |
| 193 | |
Roy Zang | b302240 | 2009-01-09 16:01:52 +0800 | [diff] [blame] | 194 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE3)){ |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 195 | printf ("\n PCIE3 connected to ULI 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 | |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 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_PCIE3_MEM_BUS, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 207 | CONFIG_SYS_PCIE3_MEM_PHYS, |
| 208 | CONFIG_SYS_PCIE3_MEM_SIZE, |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -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_PCIE3_IO_BUS, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 214 | CONFIG_SYS_PCIE3_IO_PHYS, |
| 215 | CONFIG_SYS_PCIE3_IO_SIZE, |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 216 | PCI_REGION_IO); |
| 217 | |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 218 | hose->region_count = r - hose->regions; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 219 | hose->first_busno=first_free_busno; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 220 | |
Kumar Gala | 65e198d | 2009-08-03 20:44:55 -0500 | [diff] [blame] | 221 | fsl_pci_init(hose, (u32)&pci->cfg_addr, (u32)&pci->cfg_data); |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 222 | |
| 223 | first_free_busno=hose->last_busno+1; |
| 224 | printf (" PCIE3 on bus %02x - %02x\n", |
| 225 | hose->first_busno,hose->last_busno); |
| 226 | |
| 227 | /* |
| 228 | * Activate ULI1575 legacy chip by performing a fake |
| 229 | * memory access. Needed to make ULI RTC work. |
| 230 | * Device 1d has the first on-board memory BAR. |
| 231 | */ |
| 232 | |
| 233 | pci_hose_read_config_dword(hose, PCI_BDF(2, 0x1d, 0 ), |
| 234 | PCI_BASE_ADDRESS_1, &temp32); |
Kumar Gala | ef43b6e | 2008-12-02 16:08:39 -0600 | [diff] [blame] | 235 | if (temp32 >= CONFIG_SYS_PCIE3_MEM_BUS) { |
Kumar Gala | 2275d0e | 2009-02-09 22:03:05 -0600 | [diff] [blame] | 236 | void *p = pci_mem_to_virt(PCI_BDF(2, 0x1d, 0), |
| 237 | temp32, 4, 0); |
| 238 | debug(" uli1572 read to %p\n", p); |
| 239 | in_be32(p); |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 240 | } |
| 241 | } else { |
| 242 | printf (" PCIE3: disabled\n"); |
| 243 | } |
| 244 | |
| 245 | } |
| 246 | #else |
| 247 | gur->devdisr |= MPC85xx_DEVDISR_PCIE3; /* disable */ |
| 248 | #endif |
| 249 | |
| 250 | #ifdef CONFIG_PCIE2 |
| 251 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 252 | volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE2_ADDR; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 253 | struct pci_controller *hose = &pcie2_hose; |
Kumar Gala | 666ced1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 254 | int pcie_ep = is_fsl_pci_agent(LAW_TRGT_IF_PCIE_2, host_agent); |
| 255 | int pcie_configured = is_fsl_pci_cfg(LAW_TRGT_IF_PCIE_2, io_sel); |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 256 | struct pci_region *r = hose->regions; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 257 | |
Roy Zang | b302240 | 2009-01-09 16:01:52 +0800 | [diff] [blame] | 258 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE2)){ |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 259 | printf ("\n PCIE2 connected to Slot 1 as %s (base address %x)", |
| 260 | pcie_ep ? "End Point" : "Root Complex", |
| 261 | (uint)pci); |
| 262 | if (pci->pme_msg_det) { |
| 263 | pci->pme_msg_det = 0xffffffff; |
| 264 | debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det); |
| 265 | } |
| 266 | printf ("\n"); |
| 267 | |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 268 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 269 | pci_set_region(r++, |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 270 | CONFIG_SYS_PCIE2_MEM_BUS, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 271 | CONFIG_SYS_PCIE2_MEM_PHYS, |
| 272 | CONFIG_SYS_PCIE2_MEM_SIZE, |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 273 | PCI_REGION_MEM); |
| 274 | |
| 275 | /* outbound io */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 276 | pci_set_region(r++, |
Kumar Gala | 64bb6d1 | 2008-12-02 16:08:37 -0600 | [diff] [blame] | 277 | CONFIG_SYS_PCIE2_IO_BUS, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 278 | CONFIG_SYS_PCIE2_IO_PHYS, |
| 279 | CONFIG_SYS_PCIE2_IO_SIZE, |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 280 | PCI_REGION_IO); |
| 281 | |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 282 | hose->region_count = r - hose->regions; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 283 | hose->first_busno=first_free_busno; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 284 | |
Kumar Gala | 65e198d | 2009-08-03 20:44:55 -0500 | [diff] [blame] | 285 | fsl_pci_init(hose, (u32)&pci->cfg_addr, (u32)&pci->cfg_data); |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 286 | first_free_busno=hose->last_busno+1; |
| 287 | printf (" PCIE2 on bus %02x - %02x\n", |
| 288 | hose->first_busno,hose->last_busno); |
| 289 | |
| 290 | } else { |
| 291 | printf (" PCIE2: disabled\n"); |
| 292 | } |
| 293 | |
| 294 | } |
| 295 | #else |
| 296 | gur->devdisr |= MPC85xx_DEVDISR_PCIE2; /* disable */ |
| 297 | #endif |
| 298 | #ifdef CONFIG_PCIE1 |
| 299 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 300 | volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE1_ADDR; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 301 | struct pci_controller *hose = &pcie1_hose; |
Kumar Gala | 666ced1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 302 | int pcie_ep = is_fsl_pci_agent(LAW_TRGT_IF_PCIE_1, host_agent); |
| 303 | int pcie_configured = is_fsl_pci_cfg(LAW_TRGT_IF_PCIE_1, io_sel); |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 304 | struct pci_region *r = hose->regions; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 305 | |
| 306 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){ |
| 307 | printf ("\n PCIE1 connected to Slot 2 as %s (base address %x)", |
| 308 | pcie_ep ? "End Point" : "Root Complex", |
| 309 | (uint)pci); |
| 310 | if (pci->pme_msg_det) { |
| 311 | pci->pme_msg_det = 0xffffffff; |
| 312 | debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det); |
| 313 | } |
| 314 | printf ("\n"); |
| 315 | |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 316 | /* outbound memory */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 317 | pci_set_region(r++, |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 318 | CONFIG_SYS_PCIE1_MEM_BUS, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 319 | CONFIG_SYS_PCIE1_MEM_PHYS, |
| 320 | CONFIG_SYS_PCIE1_MEM_SIZE, |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 321 | PCI_REGION_MEM); |
| 322 | |
| 323 | /* outbound io */ |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 324 | pci_set_region(r++, |
Kumar Gala | 64bb6d1 | 2008-12-02 16:08:37 -0600 | [diff] [blame] | 325 | CONFIG_SYS_PCIE1_IO_BUS, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 326 | CONFIG_SYS_PCIE1_IO_PHYS, |
| 327 | CONFIG_SYS_PCIE1_IO_SIZE, |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 328 | PCI_REGION_IO); |
| 329 | |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 330 | hose->region_count = r - hose->regions; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 331 | hose->first_busno=first_free_busno; |
| 332 | |
Kumar Gala | 65e198d | 2009-08-03 20:44:55 -0500 | [diff] [blame] | 333 | fsl_pci_init(hose, (u32)&pci->cfg_addr, (u32)&pci->cfg_data); |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 334 | |
| 335 | first_free_busno=hose->last_busno+1; |
| 336 | printf(" PCIE1 on bus %02x - %02x\n", |
| 337 | hose->first_busno,hose->last_busno); |
| 338 | |
| 339 | } else { |
| 340 | printf (" PCIE1: disabled\n"); |
| 341 | } |
| 342 | |
| 343 | } |
| 344 | #else |
| 345 | gur->devdisr |= MPC85xx_DEVDISR_PCIE; /* disable */ |
| 346 | #endif |
| 347 | } |
| 348 | #endif |
| 349 | |
| 350 | int board_early_init_r(void) |
| 351 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 352 | const unsigned int flashbase = CONFIG_SYS_FLASH_BASE; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 353 | const u8 flash_esel = 2; |
| 354 | |
| 355 | /* |
| 356 | * Remap Boot flash + PROMJET region to caching-inhibited |
| 357 | * so that flash can be erased properly. |
| 358 | */ |
| 359 | |
Kumar Gala | f81f89f | 2008-09-22 14:11:11 -0500 | [diff] [blame] | 360 | /* Flush d-cache and invalidate i-cache of any FLASH data */ |
Wolfgang Denk | 82f15f3 | 2008-11-02 16:14:22 +0100 | [diff] [blame] | 361 | flush_dcache(); |
| 362 | invalidate_icache(); |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 363 | |
| 364 | /* invalidate existing TLB entry for flash + promjet */ |
| 365 | disable_tlb(flash_esel); |
| 366 | |
Kumar Gala | 4be8b57 | 2008-12-02 14:19:34 -0600 | [diff] [blame] | 367 | set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS, /* tlb, epn, rpn */ |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 368 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, /* perms, wimge */ |
| 369 | 0, flash_esel, BOOKE_PAGESZ_256M, 1); /* ts, esel, tsize, iprot */ |
| 370 | |
| 371 | return 0; |
| 372 | } |
| 373 | |
| 374 | #ifdef CONFIG_GET_CLK_FROM_ICS307 |
| 375 | /* decode S[0-2] to Output Divider (OD) */ |
| 376 | static unsigned char ics307_S_to_OD[] = { |
| 377 | 10, 2, 8, 4, 5, 7, 3, 6 |
| 378 | }; |
| 379 | |
| 380 | /* Calculate frequency being generated by ICS307-02 clock chip based upon |
| 381 | * the control bytes being programmed into it. */ |
| 382 | /* XXX: This function should probably go into a common library */ |
| 383 | static unsigned long |
| 384 | ics307_clk_freq (unsigned char cw0, unsigned char cw1, unsigned char cw2) |
| 385 | { |
| 386 | const unsigned long InputFrequency = CONFIG_ICS307_REFCLK_HZ; |
| 387 | unsigned long VDW = ((cw1 << 1) & 0x1FE) + ((cw2 >> 7) & 1); |
| 388 | unsigned long RDW = cw2 & 0x7F; |
| 389 | unsigned long OD = ics307_S_to_OD[cw0 & 0x7]; |
| 390 | unsigned long freq; |
| 391 | |
| 392 | /* CLK1Frequency = InputFrequency * 2 * (VDW + 8) / ((RDW + 2) * OD) */ |
| 393 | |
| 394 | /* cw0: C1 C0 TTL F1 F0 S2 S1 S0 |
| 395 | * cw1: V8 V7 V6 V5 V4 V3 V2 V1 |
| 396 | * cw2: V0 R6 R5 R4 R3 R2 R1 R0 |
| 397 | * |
| 398 | * R6:R0 = Reference Divider Word (RDW) |
| 399 | * V8:V0 = VCO Divider Word (VDW) |
| 400 | * S2:S0 = Output Divider Select (OD) |
| 401 | * F1:F0 = Function of CLK2 Output |
| 402 | * TTL = duty cycle |
| 403 | * C1:C0 = internal load capacitance for cyrstal |
| 404 | */ |
| 405 | |
| 406 | /* Adding 1 to get a "nicely" rounded number, but this needs |
| 407 | * more tweaking to get a "properly" rounded number. */ |
| 408 | |
| 409 | freq = 1 + (InputFrequency * 2 * (VDW + 8) / ((RDW + 2) * OD)); |
| 410 | |
| 411 | debug("ICS307: CW[0-2]: %02X %02X %02X => %u Hz\n", cw0, cw1, cw2, |
| 412 | freq); |
| 413 | return freq; |
| 414 | } |
| 415 | |
| 416 | unsigned long get_board_sys_clk(ulong dummy) |
| 417 | { |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 418 | u8 *pixis_base = (u8 *)PIXIS_BASE; |
| 419 | |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 420 | return ics307_clk_freq ( |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 421 | in_8(pixis_base + PIXIS_VSYSCLK0), |
| 422 | in_8(pixis_base + PIXIS_VSYSCLK1), |
| 423 | in_8(pixis_base + PIXIS_VSYSCLK2) |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 424 | ); |
| 425 | } |
| 426 | |
| 427 | unsigned long get_board_ddr_clk(ulong dummy) |
| 428 | { |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 429 | u8 *pixis_base = (u8 *)PIXIS_BASE; |
| 430 | |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 431 | return ics307_clk_freq ( |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 432 | in_8(pixis_base + PIXIS_VDDRCLK0), |
| 433 | in_8(pixis_base + PIXIS_VDDRCLK1), |
| 434 | in_8(pixis_base + PIXIS_VDDRCLK2) |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 435 | ); |
| 436 | } |
| 437 | #else |
| 438 | unsigned long get_board_sys_clk(ulong dummy) |
| 439 | { |
| 440 | u8 i; |
| 441 | ulong val = 0; |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 442 | u8 *pixis_base = (u8 *)PIXIS_BASE; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 443 | |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 444 | i = in_8(pixis_base + PIXIS_SPD); |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 445 | i &= 0x07; |
| 446 | |
| 447 | switch (i) { |
| 448 | case 0: |
| 449 | val = 33333333; |
| 450 | break; |
| 451 | case 1: |
| 452 | val = 40000000; |
| 453 | break; |
| 454 | case 2: |
| 455 | val = 50000000; |
| 456 | break; |
| 457 | case 3: |
| 458 | val = 66666666; |
| 459 | break; |
| 460 | case 4: |
| 461 | val = 83333333; |
| 462 | break; |
| 463 | case 5: |
| 464 | val = 100000000; |
| 465 | break; |
| 466 | case 6: |
| 467 | val = 133333333; |
| 468 | break; |
| 469 | case 7: |
| 470 | val = 166666666; |
| 471 | break; |
| 472 | } |
| 473 | |
| 474 | return val; |
| 475 | } |
| 476 | |
| 477 | unsigned long get_board_ddr_clk(ulong dummy) |
| 478 | { |
| 479 | u8 i; |
| 480 | ulong val = 0; |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 481 | u8 *pixis_base = (u8 *)PIXIS_BASE; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 482 | |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 483 | i = in_8(pixis_base + PIXIS_SPD); |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 484 | i &= 0x38; |
| 485 | i >>= 3; |
| 486 | |
| 487 | switch (i) { |
| 488 | case 0: |
| 489 | val = 33333333; |
| 490 | break; |
| 491 | case 1: |
| 492 | val = 40000000; |
| 493 | break; |
| 494 | case 2: |
| 495 | val = 50000000; |
| 496 | break; |
| 497 | case 3: |
| 498 | val = 66666666; |
| 499 | break; |
| 500 | case 4: |
| 501 | val = 83333333; |
| 502 | break; |
| 503 | case 5: |
| 504 | val = 100000000; |
| 505 | break; |
| 506 | case 6: |
| 507 | val = 133333333; |
| 508 | break; |
| 509 | case 7: |
| 510 | val = 166666666; |
| 511 | break; |
| 512 | } |
| 513 | return val; |
| 514 | } |
| 515 | #endif |
| 516 | |
Liu Yu | c49bce4 | 2008-10-10 11:40:59 +0800 | [diff] [blame] | 517 | #ifdef CONFIG_TSEC_ENET |
| 518 | int board_eth_init(bd_t *bis) |
| 519 | { |
| 520 | struct tsec_info_struct tsec_info[4]; |
| 521 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
| 522 | int num = 0; |
| 523 | |
| 524 | #ifdef CONFIG_TSEC1 |
| 525 | SET_STD_TSEC_INFO(tsec_info[num], 1); |
| 526 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS)) |
| 527 | tsec_info[num].flags |= TSEC_SGMII; |
| 528 | num++; |
| 529 | #endif |
| 530 | #ifdef CONFIG_TSEC2 |
| 531 | SET_STD_TSEC_INFO(tsec_info[num], 2); |
| 532 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII2_DIS)) |
| 533 | tsec_info[num].flags |= TSEC_SGMII; |
| 534 | num++; |
| 535 | #endif |
| 536 | #ifdef CONFIG_TSEC3 |
| 537 | SET_STD_TSEC_INFO(tsec_info[num], 3); |
| 538 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS)) |
| 539 | tsec_info[num].flags |= TSEC_SGMII; |
| 540 | num++; |
| 541 | #endif |
| 542 | #ifdef CONFIG_TSEC4 |
| 543 | SET_STD_TSEC_INFO(tsec_info[num], 4); |
| 544 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII4_DIS)) |
| 545 | tsec_info[num].flags |= TSEC_SGMII; |
| 546 | num++; |
| 547 | #endif |
| 548 | |
| 549 | if (!num) { |
| 550 | printf("No TSECs initialized\n"); |
| 551 | |
| 552 | return 0; |
| 553 | } |
| 554 | |
Andy Fleming | acaccae | 2008-12-05 20:10:22 -0600 | [diff] [blame] | 555 | #ifdef CONFIG_FSL_SGMII_RISER |
Liu Yu | c49bce4 | 2008-10-10 11:40:59 +0800 | [diff] [blame] | 556 | fsl_sgmii_riser_init(tsec_info, num); |
Andy Fleming | acaccae | 2008-12-05 20:10:22 -0600 | [diff] [blame] | 557 | #endif |
Liu Yu | c49bce4 | 2008-10-10 11:40:59 +0800 | [diff] [blame] | 558 | |
| 559 | tsec_eth_init(bis, tsec_info, num); |
| 560 | |
Kumar Gala | d3b1b66 | 2009-08-08 10:42:30 -0500 | [diff] [blame] | 561 | return pci_eth_init(bis); |
Liu Yu | c49bce4 | 2008-10-10 11:40:59 +0800 | [diff] [blame] | 562 | } |
| 563 | #endif |
| 564 | |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 565 | #if defined(CONFIG_OF_BOARD_SETUP) |
| 566 | void ft_board_setup(void *blob, bd_t *bd) |
| 567 | { |
Kumar Gala | f281c5c | 2009-02-09 22:03:04 -0600 | [diff] [blame] | 568 | phys_addr_t base; |
| 569 | phys_size_t size; |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 570 | |
| 571 | ft_cpu_setup(blob, bd); |
| 572 | |
| 573 | base = getenv_bootm_low(); |
| 574 | size = getenv_bootm_size(); |
| 575 | |
| 576 | fdt_fixup_memory(blob, (u64)base, (u64)size); |
| 577 | |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 578 | #ifdef CONFIG_PCIE3 |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 579 | ft_fsl_pci_setup(blob, "pci0", &pcie3_hose); |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 580 | #endif |
| 581 | #ifdef CONFIG_PCIE2 |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 582 | ft_fsl_pci_setup(blob, "pci1", &pcie2_hose); |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 583 | #endif |
| 584 | #ifdef CONFIG_PCIE1 |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 585 | ft_fsl_pci_setup(blob, "pci2", &pcie1_hose); |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 586 | #endif |
Andy Fleming | acaccae | 2008-12-05 20:10:22 -0600 | [diff] [blame] | 587 | #ifdef CONFIG_FSL_SGMII_RISER |
| 588 | fsl_sgmii_riser_fdt_fixup(blob); |
| 589 | #endif |
Kumar Gala | 3ab0b2d | 2008-08-12 11:13:08 -0500 | [diff] [blame] | 590 | } |
| 591 | #endif |
| 592 | |
| 593 | #ifdef CONFIG_MP |
| 594 | extern void cpu_mp_lmb_reserve(struct lmb *lmb); |
| 595 | |
| 596 | void board_lmb_reserve(struct lmb *lmb) |
| 597 | { |
| 598 | cpu_mp_lmb_reserve(lmb); |
| 599 | } |
| 600 | #endif |