Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 1 | /* |
Kumar Gala | d0f27d3 | 2010-07-08 22:37:44 -0500 | [diff] [blame] | 2 | * Copyright 2007,2009-2010 Freescale Semiconductor, Inc. |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 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 | 3d02038 | 2010-12-15 04:55:20 -0600 | [diff] [blame] | 31 | #include <asm/fsl_serdes.h> |
Kumar Gala | e1e870a | 2007-08-30 16:18:18 -0500 | [diff] [blame] | 32 | #include <asm/io.h> |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 33 | #include <miiphy.h> |
Kumar Gala | 67b349b | 2007-11-26 17:12:24 -0600 | [diff] [blame] | 34 | #include <libfdt.h> |
| 35 | #include <fdt_support.h> |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 36 | #include <tsec.h> |
Ben Warren | 65b8623 | 2008-08-31 21:41:08 -0700 | [diff] [blame] | 37 | #include <netdev.h> |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 38 | |
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); |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 44 | volatile fsl_lbc_t *lbc = LBC_BASE_ADDR; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 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 | |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 104 | void pci_init_board(void) |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 105 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 106 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 107 | struct fsl_pci_info pci_info[4]; |
| 108 | u32 devdisr, pordevsr, io_sel; |
| 109 | u32 porpllsr, pci_agent, pci_speed, pci_32, pci_arb, pci_clk_sel; |
| 110 | int first_free_busno = 0; |
| 111 | int num = 0; |
| 112 | |
| 113 | int pcie_ep, pcie_configured; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 114 | |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 115 | devdisr = in_be32(&gur->devdisr); |
| 116 | pordevsr = in_be32(&gur->pordevsr); |
| 117 | porpllsr = in_be32(&gur->porpllsr); |
| 118 | io_sel = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19; |
| 119 | |
| 120 | debug (" pci_init_board: devdisr=%x, io_sel=%x\n", devdisr, io_sel); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 121 | |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 122 | puts("\n"); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 123 | |
| 124 | #ifdef CONFIG_PCIE3 |
Kumar Gala | 3d02038 | 2010-12-15 04:55:20 -0600 | [diff] [blame] | 125 | pcie_configured = is_serdes_configured(PCIE3); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 126 | |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 127 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE3)){ |
| 128 | SET_STD_PCIE_INFO(pci_info[num], 3); |
| 129 | pcie_ep = fsl_setup_hose(&pcie3_hose, pci_info[num].regs); |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 130 | #ifdef CONFIG_SYS_PCIE3_MEM_BUS2 |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 131 | /* outbound memory */ |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 132 | pci_set_region(&pcie3_hose.regions[0], |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 133 | CONFIG_SYS_PCIE3_MEM_BUS2, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 134 | CONFIG_SYS_PCIE3_MEM_PHYS2, |
| 135 | CONFIG_SYS_PCIE3_MEM_SIZE2, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 136 | PCI_REGION_MEM); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 137 | |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 138 | pcie3_hose.region_count = 1; |
| 139 | #endif |
Peter Tyser | 2b91f71 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 140 | printf("PCIE3: connected to ULI as %s (base addr %lx)\n", |
| 141 | pcie_ep ? "Endpoint" : "Root Complex", |
| 142 | pci_info[num].regs); |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 143 | first_free_busno = fsl_pci_init_port(&pci_info[num++], |
| 144 | &pcie3_hose, first_free_busno); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 145 | |
Kumar Gala | e1e870a | 2007-08-30 16:18:18 -0500 | [diff] [blame] | 146 | /* |
| 147 | * Activate ULI1575 legacy chip by performing a fake |
| 148 | * memory access. Needed to make ULI RTC work. |
| 149 | */ |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 150 | in_be32((u32 *)CONFIG_SYS_PCIE3_MEM_BUS); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 151 | } else { |
Peter Tyser | 2b91f71 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 152 | printf("PCIE3: disabled\n"); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 153 | } |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 154 | puts("\n"); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 155 | #else |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 156 | setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE3); /* disable */ |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 157 | #endif |
| 158 | |
| 159 | #ifdef CONFIG_PCIE1 |
Kumar Gala | 3d02038 | 2010-12-15 04:55:20 -0600 | [diff] [blame] | 160 | pcie_configured = is_serdes_configured(PCIE1); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 161 | |
| 162 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){ |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 163 | SET_STD_PCIE_INFO(pci_info[num], 1); |
| 164 | pcie_ep = fsl_setup_hose(&pcie1_hose, pci_info[num].regs); |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 165 | #ifdef CONFIG_SYS_PCIE1_MEM_BUS2 |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 166 | /* outbound memory */ |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 167 | pci_set_region(&pcie1_hose.regions[0], |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 168 | CONFIG_SYS_PCIE1_MEM_BUS2, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 169 | CONFIG_SYS_PCIE1_MEM_PHYS2, |
| 170 | CONFIG_SYS_PCIE1_MEM_SIZE2, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 171 | PCI_REGION_MEM); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 172 | |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 173 | pcie1_hose.region_count = 1; |
| 174 | #endif |
Peter Tyser | 2b91f71 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 175 | printf("PCIE1: connected to Slot 2 as %s (base addr %lx)\n", |
Peter Tyser | 62825a5 | 2010-01-17 15:38:26 -0600 | [diff] [blame] | 176 | pcie_ep ? "Endpoint" : "Root Complex", |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 177 | pci_info[num].regs); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 178 | |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 179 | first_free_busno = fsl_pci_init_port(&pci_info[num++], |
| 180 | &pcie1_hose, first_free_busno); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 181 | } else { |
Peter Tyser | 2b91f71 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 182 | printf("PCIE1: disabled\n"); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 183 | } |
| 184 | |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 185 | puts("\n"); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 186 | #else |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 187 | setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE); /* disable */ |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 188 | #endif |
| 189 | |
| 190 | #ifdef CONFIG_PCIE2 |
Kumar Gala | 3d02038 | 2010-12-15 04:55:20 -0600 | [diff] [blame] | 191 | pcie_configured = is_serdes_configured(PCIE2); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 192 | |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 193 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE2)){ |
| 194 | SET_STD_PCIE_INFO(pci_info[num], 2); |
| 195 | pcie_ep = fsl_setup_hose(&pcie2_hose, pci_info[num].regs); |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 196 | #ifdef CONFIG_SYS_PCIE2_MEM_BUS2 |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 197 | /* outbound memory */ |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 198 | pci_set_region(&pcie2_hose.regions[0], |
Kumar Gala | 3fe8087 | 2008-12-02 16:08:36 -0600 | [diff] [blame] | 199 | CONFIG_SYS_PCIE2_MEM_BUS2, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 200 | CONFIG_SYS_PCIE2_MEM_PHYS2, |
| 201 | CONFIG_SYS_PCIE2_MEM_SIZE2, |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 202 | PCI_REGION_MEM); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 203 | |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 204 | pcie2_hose.region_count = 1; |
| 205 | #endif |
Peter Tyser | 2b91f71 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 206 | printf("PCIE2: connected to Slot 1 as %s (base addr %lx)\n", |
| 207 | pcie_ep ? "Endpoint" : "Root Complex", |
| 208 | pci_info[num].regs); |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 209 | first_free_busno = fsl_pci_init_port(&pci_info[num++], |
| 210 | &pcie2_hose, first_free_busno); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 211 | } else { |
Peter Tyser | 2b91f71 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 212 | printf("PCIE2: disabled\n"); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 213 | } |
| 214 | |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 215 | puts("\n"); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 216 | #else |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 217 | setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE2); /* disable */ |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 218 | #endif |
| 219 | |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 220 | #ifdef CONFIG_PCI1 |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 221 | pci_speed = 66666000; |
| 222 | pci_32 = 1; |
| 223 | pci_arb = pordevsr & MPC85xx_PORDEVSR_PCI1_ARB; |
| 224 | pci_clk_sel = porpllsr & MPC85xx_PORDEVSR_PCI1_SPD; |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 225 | |
| 226 | if (!(devdisr & MPC85xx_DEVDISR_PCI1)) { |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 227 | SET_STD_PCI_INFO(pci_info[num], 1); |
| 228 | pci_agent = fsl_setup_hose(&pci1_hose, pci_info[num].regs); |
Peter Tyser | 2b91f71 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 229 | printf("PCI: %d bit, %s MHz, %s, %s, %s (base address %lx)\n", |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 230 | (pci_32) ? 32 : 64, |
| 231 | (pci_speed == 33333000) ? "33" : |
| 232 | (pci_speed == 66666000) ? "66" : "unknown", |
| 233 | pci_clk_sel ? "sync" : "async", |
| 234 | pci_agent ? "agent" : "host", |
| 235 | pci_arb ? "arbiter" : "external-arbiter", |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 236 | pci_info[num].regs); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 237 | |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 238 | first_free_busno = fsl_pci_init_port(&pci_info[num++], |
| 239 | &pci1_hose, first_free_busno); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 240 | } else { |
Peter Tyser | 2b91f71 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 241 | printf("PCI: disabled\n"); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 242 | } |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 243 | |
| 244 | puts("\n"); |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 245 | #else |
Kumar Gala | 949ea66 | 2009-11-04 10:22:26 -0600 | [diff] [blame] | 246 | setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1); /* disable */ |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 247 | #endif |
Ed Swarthout | 52b9852 | 2007-07-27 01:50:51 -0500 | [diff] [blame] | 248 | } |
| 249 | |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 250 | |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 251 | int last_stage_init(void) |
| 252 | { |
| 253 | return 0; |
| 254 | } |
| 255 | |
| 256 | |
| 257 | unsigned long |
| 258 | get_board_sys_clk(ulong dummy) |
| 259 | { |
| 260 | u8 i, go_bit, rd_clks; |
| 261 | ulong val = 0; |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 262 | u8 *pixis_base = (u8 *)PIXIS_BASE; |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 263 | |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 264 | go_bit = in_8(pixis_base + PIXIS_VCTL); |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 265 | go_bit &= 0x01; |
| 266 | |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 267 | rd_clks = in_8(pixis_base + PIXIS_VCFGEN0); |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 268 | rd_clks &= 0x1C; |
| 269 | |
| 270 | /* |
| 271 | * Only if both go bit and the SCLK bit in VCFGEN0 are set |
| 272 | * should we be using the AUX register. Remember, we also set the |
| 273 | * GO bit to boot from the alternate bank on the on-board flash |
| 274 | */ |
| 275 | |
| 276 | if (go_bit) { |
| 277 | if (rd_clks == 0x1c) |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 278 | i = in_8(pixis_base + PIXIS_AUX); |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 279 | else |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 280 | i = in_8(pixis_base + PIXIS_SPD); |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 281 | } else { |
Kumar Gala | 146c4b2 | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 282 | i = in_8(pixis_base + PIXIS_SPD); |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | i &= 0x07; |
| 286 | |
| 287 | switch (i) { |
| 288 | case 0: |
| 289 | val = 33333333; |
| 290 | break; |
| 291 | case 1: |
| 292 | val = 40000000; |
| 293 | break; |
| 294 | case 2: |
| 295 | val = 50000000; |
| 296 | break; |
| 297 | case 3: |
| 298 | val = 66666666; |
| 299 | break; |
| 300 | case 4: |
| 301 | val = 83000000; |
| 302 | break; |
| 303 | case 5: |
| 304 | val = 100000000; |
| 305 | break; |
| 306 | case 6: |
| 307 | val = 133333333; |
| 308 | break; |
| 309 | case 7: |
| 310 | val = 166666666; |
| 311 | break; |
| 312 | } |
| 313 | |
| 314 | return val; |
| 315 | } |
| 316 | |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 317 | int board_eth_init(bd_t *bis) |
| 318 | { |
Ben Warren | 65b8623 | 2008-08-31 21:41:08 -0700 | [diff] [blame] | 319 | #ifdef CONFIG_TSEC_ENET |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 320 | struct tsec_info_struct tsec_info[2]; |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 321 | int num = 0; |
| 322 | |
| 323 | #ifdef CONFIG_TSEC1 |
| 324 | SET_STD_TSEC_INFO(tsec_info[num], 1); |
Kumar Gala | e6dc484 | 2010-12-16 14:28:06 -0600 | [diff] [blame^] | 325 | if (is_serdes_configured(SGMII_TSEC1)) { |
| 326 | puts("eTSEC1 is in sgmii mode.\n"); |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 327 | tsec_info[num].flags |= TSEC_SGMII; |
Kumar Gala | e6dc484 | 2010-12-16 14:28:06 -0600 | [diff] [blame^] | 328 | } |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 329 | num++; |
| 330 | #endif |
| 331 | #ifdef CONFIG_TSEC3 |
| 332 | SET_STD_TSEC_INFO(tsec_info[num], 3); |
Kumar Gala | e6dc484 | 2010-12-16 14:28:06 -0600 | [diff] [blame^] | 333 | if (is_serdes_configured(SGMII_TSEC3)) { |
| 334 | puts("eTSEC3 is in sgmii mode.\n"); |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 335 | tsec_info[num].flags |= TSEC_SGMII; |
Kumar Gala | e6dc484 | 2010-12-16 14:28:06 -0600 | [diff] [blame^] | 336 | } |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 337 | num++; |
| 338 | #endif |
| 339 | |
| 340 | if (!num) { |
| 341 | printf("No TSECs initialized\n"); |
| 342 | |
| 343 | return 0; |
| 344 | } |
| 345 | |
Kumar Gala | e6dc484 | 2010-12-16 14:28:06 -0600 | [diff] [blame^] | 346 | if (is_serdes_configured(SGMII_TSEC1) || |
| 347 | is_serdes_configured(SGMII_TSEC3)) { |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 348 | fsl_sgmii_riser_init(tsec_info, num); |
Kumar Gala | e6dc484 | 2010-12-16 14:28:06 -0600 | [diff] [blame^] | 349 | } |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 350 | |
| 351 | |
| 352 | tsec_eth_init(bis, tsec_info, num); |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 353 | #endif |
Ben Warren | 65b8623 | 2008-08-31 21:41:08 -0700 | [diff] [blame] | 354 | return pci_eth_init(bis); |
| 355 | } |
Andy Fleming | afcf776 | 2008-08-31 16:33:29 -0500 | [diff] [blame] | 356 | |
Kumar Gala | 67b349b | 2007-11-26 17:12:24 -0600 | [diff] [blame] | 357 | #if defined(CONFIG_OF_BOARD_SETUP) |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 358 | void ft_board_setup(void *blob, bd_t *bd) |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 359 | { |
Wolfgang Denk | 58c495b | 2007-05-05 18:23:11 +0200 | [diff] [blame] | 360 | ft_cpu_setup(blob, bd); |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 361 | |
Kumar Gala | d0f27d3 | 2010-07-08 22:37:44 -0500 | [diff] [blame] | 362 | FT_FSL_PCI_SETUP; |
Kumar Gala | c10a0c4 | 2008-10-21 08:28:33 -0500 | [diff] [blame] | 363 | |
Andy Fleming | acaccae | 2008-12-05 20:10:22 -0600 | [diff] [blame] | 364 | #ifdef CONFIG_FSL_SGMII_RISER |
| 365 | fsl_sgmii_riser_fdt_fixup(blob); |
| 366 | #endif |
Jon Loeliger | 0553fc0 | 2007-04-11 16:51:02 -0500 | [diff] [blame] | 367 | } |
| 368 | #endif |