blob: fd59839b32bdcfc7a8bc21d4050fd102847dd47d [file] [log] [blame]
Jon Loeliger0553fc02007-04-11 16:51:02 -05001/*
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 Swarthout52b98522007-07-27 01:50:51 -050025#include <pci.h>
Jon Loeliger0553fc02007-04-11 16:51:02 -050026#include <asm/processor.h>
Kumar Gala573ad302008-08-26 08:02:30 -050027#include <asm/mmu.h>
Jon Loeliger0553fc02007-04-11 16:51:02 -050028#include <asm/immap_85xx.h>
Kumar Gala9bbd6432009-04-02 13:22:48 -050029#include <asm/fsl_pci.h>
Kumar Gala573ad302008-08-26 08:02:30 -050030#include <asm/fsl_ddr_sdram.h>
Kumar Galae1e870a2007-08-30 16:18:18 -050031#include <asm/io.h>
Jon Loeliger0553fc02007-04-11 16:51:02 -050032#include <miiphy.h>
Kumar Gala67b349b2007-11-26 17:12:24 -060033#include <libfdt.h>
34#include <fdt_support.h>
Andy Flemingafcf7762008-08-31 16:33:29 -050035#include <tsec.h>
Ben Warren65b86232008-08-31 21:41:08 -070036#include <netdev.h>
Jon Loeliger0553fc02007-04-11 16:51:02 -050037
38#include "../common/pixis.h"
Andy Flemingafcf7762008-08-31 16:33:29 -050039#include "../common/sgmii_riser.h"
Jon Loeliger0553fc02007-04-11 16:51:02 -050040
Jon Loeliger0553fc02007-04-11 16:51:02 -050041int checkboard (void)
42{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020043 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 Galae21db032009-07-14 22:42:01 -050046 u8 vboot;
47 u8 *pixis_base = (u8 *)PIXIS_BASE;
Jon Loeliger0553fc02007-04-11 16:51:02 -050048
Wolfgang Denk58c495b2007-05-05 18:23:11 +020049 if ((uint)&gur->porpllsr != 0xe00e0000) {
Wolfgang Denk12cec0a2008-07-11 01:16:00 +020050 printf("immap size error %lx\n",(ulong)&gur->porpllsr);
Jon Loeliger0553fc02007-04-11 16:51:02 -050051 }
Kumar Galae21db032009-07-14 22:42:01 -050052 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 Loeliger0553fc02007-04-11 16:51:02 -050062
Ed Swarthout52b98522007-07-27 01:50:51 -050063 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 Loeliger0553fc02007-04-11 16:51:02 -050068 return 0;
69}
70
Becky Brucebd99ae72008-06-09 16:03:40 -050071phys_size_t
Jon Loeliger0553fc02007-04-11 16:51:02 -050072initdram(int board_type)
73{
74 long dram_size = 0;
75
76 puts("Initializing\n");
77
Kumar Gala573ad302008-08-26 08:02:30 -050078 dram_size = fsl_ddr_sdram();
79
80 dram_size = setup_ddr_tlbs(dram_size / 0x100000);
81
82 dram_size *= 0x100000;
Jon Loeliger0553fc02007-04-11 16:51:02 -050083
Jon Loeliger0553fc02007-04-11 16:51:02 -050084 puts(" DDR: ");
85 return dram_size;
86}
87
Ed Swarthout52b98522007-07-27 01:50:51 -050088#ifdef CONFIG_PCI1
89static struct pci_controller pci1_hose;
90#endif
91
92#ifdef CONFIG_PCIE1
93static struct pci_controller pcie1_hose;
94#endif
95
96#ifdef CONFIG_PCIE2
97static struct pci_controller pcie2_hose;
98#endif
99
100#ifdef CONFIG_PCIE3
101static struct pci_controller pcie3_hose;
102#endif
103
104int first_free_busno=0;
105
106void
107pci_init_board(void)
108{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200109 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Ed Swarthout52b98522007-07-27 01:50:51 -0500110 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-VILLARD03836942008-10-16 15:01:15 +0200126 volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE3_ADDR;
Ed Swarthout52b98522007-07-27 01:50:51 -0500127 struct pci_controller *hose = &pcie3_hose;
Ed Swarthout031003a2008-04-25 01:08:32 -0500128 int pcie_ep = (host_agent == 1);
Roy Zang91423452009-01-09 16:00:55 +0800129 int pcie_configured = io_sel >= 6;
Kumar Galac10a0c42008-10-21 08:28:33 -0500130 struct pci_region *r = hose->regions;
Ed Swarthout52b98522007-07-27 01:50:51 -0500131
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 Galac10a0c42008-10-21 08:28:33 -0500143 r += fsl_pci_setup_inbound_windows(r);
Ed Swarthout52b98522007-07-27 01:50:51 -0500144
145 /* outbound memory */
Kumar Galac10a0c42008-10-21 08:28:33 -0500146 pci_set_region(r++,
Kumar Gala3fe80872008-12-02 16:08:36 -0600147 CONFIG_SYS_PCIE3_MEM_BUS,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200148 CONFIG_SYS_PCIE3_MEM_PHYS,
149 CONFIG_SYS_PCIE3_MEM_SIZE,
Ed Swarthout52b98522007-07-27 01:50:51 -0500150 PCI_REGION_MEM);
151
152 /* outbound io */
Kumar Galac10a0c42008-10-21 08:28:33 -0500153 pci_set_region(r++,
Kumar Gala64bb6d12008-12-02 16:08:37 -0600154 CONFIG_SYS_PCIE3_IO_BUS,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200155 CONFIG_SYS_PCIE3_IO_PHYS,
156 CONFIG_SYS_PCIE3_IO_SIZE,
Ed Swarthout52b98522007-07-27 01:50:51 -0500157 PCI_REGION_IO);
158
Kumar Gala3fe80872008-12-02 16:08:36 -0600159#ifdef CONFIG_SYS_PCIE3_MEM_BUS2
Ed Swarthout52b98522007-07-27 01:50:51 -0500160 /* outbound memory */
Kumar Galac10a0c42008-10-21 08:28:33 -0500161 pci_set_region(r++,
Kumar Gala3fe80872008-12-02 16:08:36 -0600162 CONFIG_SYS_PCIE3_MEM_BUS2,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200163 CONFIG_SYS_PCIE3_MEM_PHYS2,
164 CONFIG_SYS_PCIE3_MEM_SIZE2,
Ed Swarthout52b98522007-07-27 01:50:51 -0500165 PCI_REGION_MEM);
Ed Swarthout52b98522007-07-27 01:50:51 -0500166#endif
Kumar Galac10a0c42008-10-21 08:28:33 -0500167 hose->region_count = r - hose->regions;
Ed Swarthout52b98522007-07-27 01:50:51 -0500168 hose->first_busno=first_free_busno;
169 pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
170
171 fsl_pci_init(hose);
172
173 first_free_busno=hose->last_busno+1;
174 printf (" PCIE3 on bus %02x - %02x\n",
175 hose->first_busno,hose->last_busno);
176
Kumar Galae1e870a2007-08-30 16:18:18 -0500177 /*
178 * Activate ULI1575 legacy chip by performing a fake
179 * memory access. Needed to make ULI RTC work.
180 */
Kumar Gala3fe80872008-12-02 16:08:36 -0600181 in_be32((u32 *)CONFIG_SYS_PCIE3_MEM_BUS);
Ed Swarthout52b98522007-07-27 01:50:51 -0500182 } else {
183 printf (" PCIE3: disabled\n");
184 }
185
186 }
187#else
188 gur->devdisr |= MPC85xx_DEVDISR_PCIE3; /* disable */
189#endif
190
191#ifdef CONFIG_PCIE1
192 {
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200193 volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE1_ADDR;
Ed Swarthout52b98522007-07-27 01:50:51 -0500194 struct pci_controller *hose = &pcie1_hose;
195 int pcie_ep = (host_agent == 5);
Roy Zang994719d2009-01-09 16:02:35 +0800196 int pcie_configured = io_sel >= 2;
Kumar Galac10a0c42008-10-21 08:28:33 -0500197 struct pci_region *r = hose->regions;
Ed Swarthout52b98522007-07-27 01:50:51 -0500198
199 if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
200 printf ("\n PCIE1 connected to Slot2 as %s (base address %x)",
201 pcie_ep ? "End Point" : "Root Complex",
202 (uint)pci);
203 if (pci->pme_msg_det) {
204 pci->pme_msg_det = 0xffffffff;
205 debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det);
206 }
207 printf ("\n");
208
209 /* inbound */
Kumar Galac10a0c42008-10-21 08:28:33 -0500210 r += fsl_pci_setup_inbound_windows(r);
Ed Swarthout52b98522007-07-27 01:50:51 -0500211
212 /* outbound memory */
Kumar Galac10a0c42008-10-21 08:28:33 -0500213 pci_set_region(r++,
Kumar Gala3fe80872008-12-02 16:08:36 -0600214 CONFIG_SYS_PCIE1_MEM_BUS,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200215 CONFIG_SYS_PCIE1_MEM_PHYS,
216 CONFIG_SYS_PCIE1_MEM_SIZE,
Ed Swarthout52b98522007-07-27 01:50:51 -0500217 PCI_REGION_MEM);
218
219 /* outbound io */
Kumar Galac10a0c42008-10-21 08:28:33 -0500220 pci_set_region(r++,
Kumar Gala64bb6d12008-12-02 16:08:37 -0600221 CONFIG_SYS_PCIE1_IO_BUS,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200222 CONFIG_SYS_PCIE1_IO_PHYS,
223 CONFIG_SYS_PCIE1_IO_SIZE,
Ed Swarthout52b98522007-07-27 01:50:51 -0500224 PCI_REGION_IO);
225
Kumar Gala3fe80872008-12-02 16:08:36 -0600226#ifdef CONFIG_SYS_PCIE1_MEM_BUS2
Ed Swarthout52b98522007-07-27 01:50:51 -0500227 /* outbound memory */
Kumar Galac10a0c42008-10-21 08:28:33 -0500228 pci_set_region(r++,
Kumar Gala3fe80872008-12-02 16:08:36 -0600229 CONFIG_SYS_PCIE1_MEM_BUS2,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200230 CONFIG_SYS_PCIE1_MEM_PHYS2,
231 CONFIG_SYS_PCIE1_MEM_SIZE2,
Ed Swarthout52b98522007-07-27 01:50:51 -0500232 PCI_REGION_MEM);
Ed Swarthout52b98522007-07-27 01:50:51 -0500233#endif
Kumar Galac10a0c42008-10-21 08:28:33 -0500234 hose->region_count = r - hose->regions;
Ed Swarthout52b98522007-07-27 01:50:51 -0500235 hose->first_busno=first_free_busno;
236
237 pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
238
239 fsl_pci_init(hose);
240
241 first_free_busno=hose->last_busno+1;
242 printf(" PCIE1 on bus %02x - %02x\n",
243 hose->first_busno,hose->last_busno);
244
245 } else {
246 printf (" PCIE1: disabled\n");
247 }
248
249 }
250#else
251 gur->devdisr |= MPC85xx_DEVDISR_PCIE; /* disable */
252#endif
253
254#ifdef CONFIG_PCIE2
255 {
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200256 volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE2_ADDR;
Ed Swarthout52b98522007-07-27 01:50:51 -0500257 struct pci_controller *hose = &pcie2_hose;
258 int pcie_ep = (host_agent == 3);
Roy Zang994719d2009-01-09 16:02:35 +0800259 int pcie_configured = io_sel >= 4;
Kumar Galac10a0c42008-10-21 08:28:33 -0500260 struct pci_region *r = hose->regions;
Ed Swarthout52b98522007-07-27 01:50:51 -0500261
262 if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
263 printf ("\n PCIE2 connected to Slot 1 as %s (base address %x)",
264 pcie_ep ? "End Point" : "Root Complex",
265 (uint)pci);
266 if (pci->pme_msg_det) {
267 pci->pme_msg_det = 0xffffffff;
268 debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det);
269 }
270 printf ("\n");
271
272 /* inbound */
Kumar Galac10a0c42008-10-21 08:28:33 -0500273 r += fsl_pci_setup_inbound_windows(r);
Ed Swarthout52b98522007-07-27 01:50:51 -0500274
275 /* outbound memory */
Kumar Galac10a0c42008-10-21 08:28:33 -0500276 pci_set_region(r++,
Kumar Gala3fe80872008-12-02 16:08:36 -0600277 CONFIG_SYS_PCIE2_MEM_BUS,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200278 CONFIG_SYS_PCIE2_MEM_PHYS,
279 CONFIG_SYS_PCIE2_MEM_SIZE,
Ed Swarthout52b98522007-07-27 01:50:51 -0500280 PCI_REGION_MEM);
281
282 /* outbound io */
Kumar Galac10a0c42008-10-21 08:28:33 -0500283 pci_set_region(r++,
Kumar Gala64bb6d12008-12-02 16:08:37 -0600284 CONFIG_SYS_PCIE2_IO_BUS,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200285 CONFIG_SYS_PCIE2_IO_PHYS,
286 CONFIG_SYS_PCIE2_IO_SIZE,
Ed Swarthout52b98522007-07-27 01:50:51 -0500287 PCI_REGION_IO);
288
Kumar Gala3fe80872008-12-02 16:08:36 -0600289#ifdef CONFIG_SYS_PCIE2_MEM_BUS2
Ed Swarthout52b98522007-07-27 01:50:51 -0500290 /* outbound memory */
Kumar Galac10a0c42008-10-21 08:28:33 -0500291 pci_set_region(r++,
Kumar Gala3fe80872008-12-02 16:08:36 -0600292 CONFIG_SYS_PCIE2_MEM_BUS2,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200293 CONFIG_SYS_PCIE2_MEM_PHYS2,
294 CONFIG_SYS_PCIE2_MEM_SIZE2,
Ed Swarthout52b98522007-07-27 01:50:51 -0500295 PCI_REGION_MEM);
Ed Swarthout52b98522007-07-27 01:50:51 -0500296#endif
Kumar Galac10a0c42008-10-21 08:28:33 -0500297 hose->region_count = r - hose->regions;
Ed Swarthout52b98522007-07-27 01:50:51 -0500298 hose->first_busno=first_free_busno;
299 pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
300
301 fsl_pci_init(hose);
302 first_free_busno=hose->last_busno+1;
303 printf (" PCIE2 on bus %02x - %02x\n",
304 hose->first_busno,hose->last_busno);
305
306 } else {
307 printf (" PCIE2: disabled\n");
308 }
309
310 }
311#else
312 gur->devdisr |= MPC85xx_DEVDISR_PCIE2; /* disable */
313#endif
314
315
316#ifdef CONFIG_PCI1
317{
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200318 volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCI1_ADDR;
Ed Swarthout52b98522007-07-27 01:50:51 -0500319 struct pci_controller *hose = &pci1_hose;
Kumar Galac10a0c42008-10-21 08:28:33 -0500320 struct pci_region *r = hose->regions;
Ed Swarthout52b98522007-07-27 01:50:51 -0500321
322 uint pci_agent = (host_agent == 6);
323 uint pci_speed = 66666000; /*get_clock_freq (); PCI PSPEED in [4:5] */
324 uint pci_32 = 1;
325 uint pci_arb = gur->pordevsr & MPC85xx_PORDEVSR_PCI1_ARB; /* PORDEVSR[14] */
326 uint pci_clk_sel = gur->porpllsr & MPC85xx_PORDEVSR_PCI1_SPD; /* PORPLLSR[16] */
327
328
329 if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
330 printf ("\n PCI: %d bit, %s MHz, %s, %s, %s (base address %x)\n",
331 (pci_32) ? 32 : 64,
332 (pci_speed == 33333000) ? "33" :
333 (pci_speed == 66666000) ? "66" : "unknown",
334 pci_clk_sel ? "sync" : "async",
335 pci_agent ? "agent" : "host",
336 pci_arb ? "arbiter" : "external-arbiter",
337 (uint)pci
338 );
339
340 /* inbound */
Kumar Galac10a0c42008-10-21 08:28:33 -0500341 r += fsl_pci_setup_inbound_windows(r);
Ed Swarthout52b98522007-07-27 01:50:51 -0500342
343 /* outbound memory */
Kumar Galac10a0c42008-10-21 08:28:33 -0500344 pci_set_region(r++,
Kumar Gala3fe80872008-12-02 16:08:36 -0600345 CONFIG_SYS_PCI1_MEM_BUS,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200346 CONFIG_SYS_PCI1_MEM_PHYS,
347 CONFIG_SYS_PCI1_MEM_SIZE,
Ed Swarthout52b98522007-07-27 01:50:51 -0500348 PCI_REGION_MEM);
349
350 /* outbound io */
Kumar Galac10a0c42008-10-21 08:28:33 -0500351 pci_set_region(r++,
Kumar Gala64bb6d12008-12-02 16:08:37 -0600352 CONFIG_SYS_PCI1_IO_BUS,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200353 CONFIG_SYS_PCI1_IO_PHYS,
354 CONFIG_SYS_PCI1_IO_SIZE,
Ed Swarthout52b98522007-07-27 01:50:51 -0500355 PCI_REGION_IO);
Kumar Galac10a0c42008-10-21 08:28:33 -0500356
Kumar Gala3fe80872008-12-02 16:08:36 -0600357#ifdef CONFIG_SYS_PCIE3_MEM_BUS2
Ed Swarthout52b98522007-07-27 01:50:51 -0500358 /* outbound memory */
Kumar Galac10a0c42008-10-21 08:28:33 -0500359 pci_set_region(r++,
Kumar Gala3fe80872008-12-02 16:08:36 -0600360 CONFIG_SYS_PCIE3_MEM_BUS2,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200361 CONFIG_SYS_PCIE3_MEM_PHYS2,
362 CONFIG_SYS_PCIE3_MEM_SIZE2,
Ed Swarthout52b98522007-07-27 01:50:51 -0500363 PCI_REGION_MEM);
Ed Swarthout52b98522007-07-27 01:50:51 -0500364#endif
Kumar Galac10a0c42008-10-21 08:28:33 -0500365 hose->region_count = r - hose->regions;
Ed Swarthout52b98522007-07-27 01:50:51 -0500366 hose->first_busno=first_free_busno;
367 pci_setup_indirect(hose, (int) &pci->cfg_addr, (int) &pci->cfg_data);
368
369 fsl_pci_init(hose);
370 first_free_busno=hose->last_busno+1;
371 printf ("PCI on bus %02x - %02x\n",
372 hose->first_busno,hose->last_busno);
373 } else {
374 printf (" PCI: disabled\n");
375 }
376}
377#else
378 gur->devdisr |= MPC85xx_DEVDISR_PCI1; /* disable */
Jon Loeliger0553fc02007-04-11 16:51:02 -0500379#endif
Ed Swarthout52b98522007-07-27 01:50:51 -0500380}
381
Jon Loeliger0553fc02007-04-11 16:51:02 -0500382
Jon Loeliger0553fc02007-04-11 16:51:02 -0500383int last_stage_init(void)
384{
385 return 0;
386}
387
388
389unsigned long
390get_board_sys_clk(ulong dummy)
391{
392 u8 i, go_bit, rd_clks;
393 ulong val = 0;
Kumar Gala146c4b22009-07-22 10:12:39 -0500394 u8 *pixis_base = (u8 *)PIXIS_BASE;
Jon Loeliger0553fc02007-04-11 16:51:02 -0500395
Kumar Gala146c4b22009-07-22 10:12:39 -0500396 go_bit = in_8(pixis_base + PIXIS_VCTL);
Jon Loeliger0553fc02007-04-11 16:51:02 -0500397 go_bit &= 0x01;
398
Kumar Gala146c4b22009-07-22 10:12:39 -0500399 rd_clks = in_8(pixis_base + PIXIS_VCFGEN0);
Jon Loeliger0553fc02007-04-11 16:51:02 -0500400 rd_clks &= 0x1C;
401
402 /*
403 * Only if both go bit and the SCLK bit in VCFGEN0 are set
404 * should we be using the AUX register. Remember, we also set the
405 * GO bit to boot from the alternate bank on the on-board flash
406 */
407
408 if (go_bit) {
409 if (rd_clks == 0x1c)
Kumar Gala146c4b22009-07-22 10:12:39 -0500410 i = in_8(pixis_base + PIXIS_AUX);
Jon Loeliger0553fc02007-04-11 16:51:02 -0500411 else
Kumar Gala146c4b22009-07-22 10:12:39 -0500412 i = in_8(pixis_base + PIXIS_SPD);
Jon Loeliger0553fc02007-04-11 16:51:02 -0500413 } else {
Kumar Gala146c4b22009-07-22 10:12:39 -0500414 i = in_8(pixis_base + PIXIS_SPD);
Jon Loeliger0553fc02007-04-11 16:51:02 -0500415 }
416
417 i &= 0x07;
418
419 switch (i) {
420 case 0:
421 val = 33333333;
422 break;
423 case 1:
424 val = 40000000;
425 break;
426 case 2:
427 val = 50000000;
428 break;
429 case 3:
430 val = 66666666;
431 break;
432 case 4:
433 val = 83000000;
434 break;
435 case 5:
436 val = 100000000;
437 break;
438 case 6:
439 val = 133333333;
440 break;
441 case 7:
442 val = 166666666;
443 break;
444 }
445
446 return val;
447}
448
Andy Flemingafcf7762008-08-31 16:33:29 -0500449int board_eth_init(bd_t *bis)
450{
Ben Warren65b86232008-08-31 21:41:08 -0700451#ifdef CONFIG_TSEC_ENET
Andy Flemingafcf7762008-08-31 16:33:29 -0500452 struct tsec_info_struct tsec_info[2];
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200453 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Andy Flemingafcf7762008-08-31 16:33:29 -0500454 uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
455 int num = 0;
456
457#ifdef CONFIG_TSEC1
458 SET_STD_TSEC_INFO(tsec_info[num], 1);
459 if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS))
460 tsec_info[num].flags |= TSEC_SGMII;
461 num++;
462#endif
463#ifdef CONFIG_TSEC3
464 SET_STD_TSEC_INFO(tsec_info[num], 3);
465 if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS))
466 tsec_info[num].flags |= TSEC_SGMII;
467 num++;
468#endif
469
470 if (!num) {
471 printf("No TSECs initialized\n");
472
473 return 0;
474 }
475
476 if (io_sel & 1)
477 fsl_sgmii_riser_init(tsec_info, num);
478
479
480 tsec_eth_init(bis, tsec_info, num);
Andy Flemingafcf7762008-08-31 16:33:29 -0500481#endif
Ben Warren65b86232008-08-31 21:41:08 -0700482 return pci_eth_init(bis);
483}
Andy Flemingafcf7762008-08-31 16:33:29 -0500484
Kumar Gala67b349b2007-11-26 17:12:24 -0600485#if defined(CONFIG_OF_BOARD_SETUP)
Kumar Galac10a0c42008-10-21 08:28:33 -0500486void ft_board_setup(void *blob, bd_t *bd)
Jon Loeliger0553fc02007-04-11 16:51:02 -0500487{
Wolfgang Denk58c495b2007-05-05 18:23:11 +0200488 ft_cpu_setup(blob, bd);
Jon Loeliger0553fc02007-04-11 16:51:02 -0500489
Kumar Galac10a0c42008-10-21 08:28:33 -0500490
Ed Swarthoutf8358402007-08-30 01:58:48 -0500491#ifdef CONFIG_PCI1
Kumar Galac10a0c42008-10-21 08:28:33 -0500492 ft_fsl_pci_setup(blob, "pci0", &pci1_hose);
Ed Swarthout52b98522007-07-27 01:50:51 -0500493#endif
494#ifdef CONFIG_PCIE2
Kumar Galac10a0c42008-10-21 08:28:33 -0500495 ft_fsl_pci_setup(blob, "pci1", &pcie1_hose);
Kumar Gala67b349b2007-11-26 17:12:24 -0600496#endif
497#ifdef CONFIG_PCIE1
Kumar Galac10a0c42008-10-21 08:28:33 -0500498 ft_fsl_pci_setup(blob, "pci2", &pcie3_hose);
Ed Swarthout52b98522007-07-27 01:50:51 -0500499#endif
500#ifdef CONFIG_PCIE3
Kumar Galac10a0c42008-10-21 08:28:33 -0500501 ft_fsl_pci_setup(blob, "pci3", &pcie2_hose);
Ed Swarthout52b98522007-07-27 01:50:51 -0500502#endif
Andy Flemingacaccae2008-12-05 20:10:22 -0600503#ifdef CONFIG_FSL_SGMII_RISER
504 fsl_sgmii_riser_fdt_fixup(blob);
505#endif
Jon Loeliger0553fc02007-04-11 16:51:02 -0500506}
507#endif