blob: 5a47d0a008e9976982cb5fd59f343b6040a1b70b [file] [log] [blame]
Jon Loeliger25d83d72007-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 Swarthout837f1ba2007-07-27 01:50:51 -050025#include <pci.h>
Jon Loeliger25d83d72007-04-11 16:51:02 -050026#include <asm/processor.h>
Kumar Gala1167a2f2008-08-26 08:02:30 -050027#include <asm/mmu.h>
Jon Loeliger25d83d72007-04-11 16:51:02 -050028#include <asm/immap_85xx.h>
Kumar Galac8514622009-04-02 13:22:48 -050029#include <asm/fsl_pci.h>
Kumar Gala1167a2f2008-08-26 08:02:30 -050030#include <asm/fsl_ddr_sdram.h>
Kumar Gala56a92702007-08-30 16:18:18 -050031#include <asm/io.h>
Jon Loeliger25d83d72007-04-11 16:51:02 -050032#include <miiphy.h>
Kumar Galaaddce572007-11-26 17:12:24 -060033#include <libfdt.h>
34#include <fdt_support.h>
Andy Fleming216f2a72008-08-31 16:33:29 -050035#include <tsec.h>
Ben Warren0b252f52008-08-31 21:41:08 -070036#include <netdev.h>
Jon Loeliger25d83d72007-04-11 16:51:02 -050037
38#include "../common/pixis.h"
Andy Fleming216f2a72008-08-31 16:33:29 -050039#include "../common/sgmii_riser.h"
Jon Loeliger25d83d72007-04-11 16:51:02 -050040
Jon Loeliger25d83d72007-04-11 16:51:02 -050041int checkboard (void)
42{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-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 Gala6bb5b412009-07-14 22:42:01 -050046 u8 vboot;
47 u8 *pixis_base = (u8 *)PIXIS_BASE;
Jon Loeliger25d83d72007-04-11 16:51:02 -050048
Wolfgang Denk2f152782007-05-05 18:23:11 +020049 if ((uint)&gur->porpllsr != 0xe00e0000) {
Wolfgang Denk9b55a252008-07-11 01:16:00 +020050 printf("immap size error %lx\n",(ulong)&gur->porpllsr);
Jon Loeliger25d83d72007-04-11 16:51:02 -050051 }
Kumar Gala6bb5b412009-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 Loeliger25d83d72007-04-11 16:51:02 -050062
Ed Swarthout837f1ba2007-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 Loeliger25d83d72007-04-11 16:51:02 -050068 return 0;
69}
70
Becky Bruce9973e3c2008-06-09 16:03:40 -050071phys_size_t
Jon Loeliger25d83d72007-04-11 16:51:02 -050072initdram(int board_type)
73{
74 long dram_size = 0;
75
76 puts("Initializing\n");
77
Kumar Gala1167a2f2008-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 Loeliger25d83d72007-04-11 16:51:02 -050083
Jon Loeliger25d83d72007-04-11 16:51:02 -050084 puts(" DDR: ");
85 return dram_size;
86}
87
Ed Swarthout837f1ba2007-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-VILLARD6d0f6bc2008-10-16 15:01:15 +0200109 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Ed Swarthout837f1ba2007-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-VILLARD6d0f6bc2008-10-16 15:01:15 +0200126 volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE3_ADDR;
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500127 struct pci_controller *hose = &pcie3_hose;
Ed Swarthoutf97abbf2008-04-25 01:08:32 -0500128 int pcie_ep = (host_agent == 1);
Roy Zang9afc2ef2009-01-09 16:00:55 +0800129 int pcie_configured = io_sel >= 6;
Kumar Gala2dba0de2008-10-21 08:28:33 -0500130 struct pci_region *r = hose->regions;
Ed Swarthout837f1ba2007-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
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500142 /* outbound memory */
Kumar Gala2dba0de2008-10-21 08:28:33 -0500143 pci_set_region(r++,
Kumar Gala10795f42008-12-02 16:08:36 -0600144 CONFIG_SYS_PCIE3_MEM_BUS,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200145 CONFIG_SYS_PCIE3_MEM_PHYS,
146 CONFIG_SYS_PCIE3_MEM_SIZE,
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500147 PCI_REGION_MEM);
148
149 /* outbound io */
Kumar Gala2dba0de2008-10-21 08:28:33 -0500150 pci_set_region(r++,
Kumar Gala5f91ef62008-12-02 16:08:37 -0600151 CONFIG_SYS_PCIE3_IO_BUS,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200152 CONFIG_SYS_PCIE3_IO_PHYS,
153 CONFIG_SYS_PCIE3_IO_SIZE,
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500154 PCI_REGION_IO);
155
Kumar Gala10795f42008-12-02 16:08:36 -0600156#ifdef CONFIG_SYS_PCIE3_MEM_BUS2
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500157 /* outbound memory */
Kumar Gala2dba0de2008-10-21 08:28:33 -0500158 pci_set_region(r++,
Kumar Gala10795f42008-12-02 16:08:36 -0600159 CONFIG_SYS_PCIE3_MEM_BUS2,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200160 CONFIG_SYS_PCIE3_MEM_PHYS2,
161 CONFIG_SYS_PCIE3_MEM_SIZE2,
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500162 PCI_REGION_MEM);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500163#endif
Kumar Gala2dba0de2008-10-21 08:28:33 -0500164 hose->region_count = r - hose->regions;
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500165 hose->first_busno=first_free_busno;
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500166
Kumar Galafb3143b2009-08-03 20:44:55 -0500167 fsl_pci_init(hose, (u32)&pci->cfg_addr, (u32)&pci->cfg_data);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500168
169 first_free_busno=hose->last_busno+1;
170 printf (" PCIE3 on bus %02x - %02x\n",
171 hose->first_busno,hose->last_busno);
172
Kumar Gala56a92702007-08-30 16:18:18 -0500173 /*
174 * Activate ULI1575 legacy chip by performing a fake
175 * memory access. Needed to make ULI RTC work.
176 */
Kumar Gala10795f42008-12-02 16:08:36 -0600177 in_be32((u32 *)CONFIG_SYS_PCIE3_MEM_BUS);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500178 } else {
179 printf (" PCIE3: disabled\n");
180 }
181
182 }
183#else
184 gur->devdisr |= MPC85xx_DEVDISR_PCIE3; /* disable */
185#endif
186
187#ifdef CONFIG_PCIE1
188 {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200189 volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE1_ADDR;
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500190 struct pci_controller *hose = &pcie1_hose;
191 int pcie_ep = (host_agent == 5);
Roy Zang6d3a10f2009-01-09 16:02:35 +0800192 int pcie_configured = io_sel >= 2;
Kumar Gala2dba0de2008-10-21 08:28:33 -0500193 struct pci_region *r = hose->regions;
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500194
195 if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
196 printf ("\n PCIE1 connected to Slot2 as %s (base address %x)",
197 pcie_ep ? "End Point" : "Root Complex",
198 (uint)pci);
199 if (pci->pme_msg_det) {
200 pci->pme_msg_det = 0xffffffff;
201 debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det);
202 }
203 printf ("\n");
204
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500205 /* outbound memory */
Kumar Gala2dba0de2008-10-21 08:28:33 -0500206 pci_set_region(r++,
Kumar Gala10795f42008-12-02 16:08:36 -0600207 CONFIG_SYS_PCIE1_MEM_BUS,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200208 CONFIG_SYS_PCIE1_MEM_PHYS,
209 CONFIG_SYS_PCIE1_MEM_SIZE,
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500210 PCI_REGION_MEM);
211
212 /* outbound io */
Kumar Gala2dba0de2008-10-21 08:28:33 -0500213 pci_set_region(r++,
Kumar Gala5f91ef62008-12-02 16:08:37 -0600214 CONFIG_SYS_PCIE1_IO_BUS,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200215 CONFIG_SYS_PCIE1_IO_PHYS,
216 CONFIG_SYS_PCIE1_IO_SIZE,
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500217 PCI_REGION_IO);
218
Kumar Gala10795f42008-12-02 16:08:36 -0600219#ifdef CONFIG_SYS_PCIE1_MEM_BUS2
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500220 /* outbound memory */
Kumar Gala2dba0de2008-10-21 08:28:33 -0500221 pci_set_region(r++,
Kumar Gala10795f42008-12-02 16:08:36 -0600222 CONFIG_SYS_PCIE1_MEM_BUS2,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200223 CONFIG_SYS_PCIE1_MEM_PHYS2,
224 CONFIG_SYS_PCIE1_MEM_SIZE2,
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500225 PCI_REGION_MEM);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500226#endif
Kumar Gala2dba0de2008-10-21 08:28:33 -0500227 hose->region_count = r - hose->regions;
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500228 hose->first_busno=first_free_busno;
229
Kumar Galafb3143b2009-08-03 20:44:55 -0500230 fsl_pci_init(hose, (u32)&pci->cfg_addr, (u32)&pci->cfg_data);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500231
232 first_free_busno=hose->last_busno+1;
233 printf(" PCIE1 on bus %02x - %02x\n",
234 hose->first_busno,hose->last_busno);
235
236 } else {
237 printf (" PCIE1: disabled\n");
238 }
239
240 }
241#else
242 gur->devdisr |= MPC85xx_DEVDISR_PCIE; /* disable */
243#endif
244
245#ifdef CONFIG_PCIE2
246 {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200247 volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCIE2_ADDR;
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500248 struct pci_controller *hose = &pcie2_hose;
249 int pcie_ep = (host_agent == 3);
Roy Zang6d3a10f2009-01-09 16:02:35 +0800250 int pcie_configured = io_sel >= 4;
Kumar Gala2dba0de2008-10-21 08:28:33 -0500251 struct pci_region *r = hose->regions;
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500252
253 if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)){
254 printf ("\n PCIE2 connected to Slot 1 as %s (base address %x)",
255 pcie_ep ? "End Point" : "Root Complex",
256 (uint)pci);
257 if (pci->pme_msg_det) {
258 pci->pme_msg_det = 0xffffffff;
259 debug (" with errors. Clearing. Now 0x%08x",pci->pme_msg_det);
260 }
261 printf ("\n");
262
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500263 /* outbound memory */
Kumar Gala2dba0de2008-10-21 08:28:33 -0500264 pci_set_region(r++,
Kumar Gala10795f42008-12-02 16:08:36 -0600265 CONFIG_SYS_PCIE2_MEM_BUS,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200266 CONFIG_SYS_PCIE2_MEM_PHYS,
267 CONFIG_SYS_PCIE2_MEM_SIZE,
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500268 PCI_REGION_MEM);
269
270 /* outbound io */
Kumar Gala2dba0de2008-10-21 08:28:33 -0500271 pci_set_region(r++,
Kumar Gala5f91ef62008-12-02 16:08:37 -0600272 CONFIG_SYS_PCIE2_IO_BUS,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200273 CONFIG_SYS_PCIE2_IO_PHYS,
274 CONFIG_SYS_PCIE2_IO_SIZE,
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500275 PCI_REGION_IO);
276
Kumar Gala10795f42008-12-02 16:08:36 -0600277#ifdef CONFIG_SYS_PCIE2_MEM_BUS2
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500278 /* outbound memory */
Kumar Gala2dba0de2008-10-21 08:28:33 -0500279 pci_set_region(r++,
Kumar Gala10795f42008-12-02 16:08:36 -0600280 CONFIG_SYS_PCIE2_MEM_BUS2,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200281 CONFIG_SYS_PCIE2_MEM_PHYS2,
282 CONFIG_SYS_PCIE2_MEM_SIZE2,
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500283 PCI_REGION_MEM);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500284#endif
Kumar Gala2dba0de2008-10-21 08:28:33 -0500285 hose->region_count = r - hose->regions;
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500286 hose->first_busno=first_free_busno;
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500287
Kumar Galafb3143b2009-08-03 20:44:55 -0500288 fsl_pci_init(hose, (u32)&pci->cfg_addr, (u32)&pci->cfg_data);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500289 first_free_busno=hose->last_busno+1;
290 printf (" PCIE2 on bus %02x - %02x\n",
291 hose->first_busno,hose->last_busno);
292
293 } else {
294 printf (" PCIE2: disabled\n");
295 }
296
297 }
298#else
299 gur->devdisr |= MPC85xx_DEVDISR_PCIE2; /* disable */
300#endif
301
302
303#ifdef CONFIG_PCI1
304{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200305 volatile ccsr_fsl_pci_t *pci = (ccsr_fsl_pci_t *) CONFIG_SYS_PCI1_ADDR;
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500306 struct pci_controller *hose = &pci1_hose;
Kumar Gala2dba0de2008-10-21 08:28:33 -0500307 struct pci_region *r = hose->regions;
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500308
309 uint pci_agent = (host_agent == 6);
310 uint pci_speed = 66666000; /*get_clock_freq (); PCI PSPEED in [4:5] */
311 uint pci_32 = 1;
312 uint pci_arb = gur->pordevsr & MPC85xx_PORDEVSR_PCI1_ARB; /* PORDEVSR[14] */
313 uint pci_clk_sel = gur->porpllsr & MPC85xx_PORDEVSR_PCI1_SPD; /* PORPLLSR[16] */
314
315
316 if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
317 printf ("\n PCI: %d bit, %s MHz, %s, %s, %s (base address %x)\n",
318 (pci_32) ? 32 : 64,
319 (pci_speed == 33333000) ? "33" :
320 (pci_speed == 66666000) ? "66" : "unknown",
321 pci_clk_sel ? "sync" : "async",
322 pci_agent ? "agent" : "host",
323 pci_arb ? "arbiter" : "external-arbiter",
324 (uint)pci
325 );
326
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500327 /* outbound memory */
Kumar Gala2dba0de2008-10-21 08:28:33 -0500328 pci_set_region(r++,
Kumar Gala10795f42008-12-02 16:08:36 -0600329 CONFIG_SYS_PCI1_MEM_BUS,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200330 CONFIG_SYS_PCI1_MEM_PHYS,
331 CONFIG_SYS_PCI1_MEM_SIZE,
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500332 PCI_REGION_MEM);
333
334 /* outbound io */
Kumar Gala2dba0de2008-10-21 08:28:33 -0500335 pci_set_region(r++,
Kumar Gala5f91ef62008-12-02 16:08:37 -0600336 CONFIG_SYS_PCI1_IO_BUS,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200337 CONFIG_SYS_PCI1_IO_PHYS,
338 CONFIG_SYS_PCI1_IO_SIZE,
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500339 PCI_REGION_IO);
Kumar Gala2dba0de2008-10-21 08:28:33 -0500340
Kumar Gala10795f42008-12-02 16:08:36 -0600341#ifdef CONFIG_SYS_PCIE3_MEM_BUS2
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500342 /* outbound memory */
Kumar Gala2dba0de2008-10-21 08:28:33 -0500343 pci_set_region(r++,
Kumar Gala10795f42008-12-02 16:08:36 -0600344 CONFIG_SYS_PCIE3_MEM_BUS2,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200345 CONFIG_SYS_PCIE3_MEM_PHYS2,
346 CONFIG_SYS_PCIE3_MEM_SIZE2,
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500347 PCI_REGION_MEM);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500348#endif
Kumar Gala2dba0de2008-10-21 08:28:33 -0500349 hose->region_count = r - hose->regions;
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500350 hose->first_busno=first_free_busno;
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500351
Kumar Galafb3143b2009-08-03 20:44:55 -0500352 fsl_pci_init(hose, (u32)&pci->cfg_addr, (u32)&pci->cfg_data);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500353 first_free_busno=hose->last_busno+1;
354 printf ("PCI on bus %02x - %02x\n",
355 hose->first_busno,hose->last_busno);
356 } else {
357 printf (" PCI: disabled\n");
358 }
359}
360#else
361 gur->devdisr |= MPC85xx_DEVDISR_PCI1; /* disable */
362#endif
363}
364
365
Jon Loeliger25d83d72007-04-11 16:51:02 -0500366int last_stage_init(void)
367{
368 return 0;
369}
370
371
372unsigned long
373get_board_sys_clk(ulong dummy)
374{
375 u8 i, go_bit, rd_clks;
376 ulong val = 0;
Kumar Gala048e7ef2009-07-22 10:12:39 -0500377 u8 *pixis_base = (u8 *)PIXIS_BASE;
Jon Loeliger25d83d72007-04-11 16:51:02 -0500378
Kumar Gala048e7ef2009-07-22 10:12:39 -0500379 go_bit = in_8(pixis_base + PIXIS_VCTL);
Jon Loeliger25d83d72007-04-11 16:51:02 -0500380 go_bit &= 0x01;
381
Kumar Gala048e7ef2009-07-22 10:12:39 -0500382 rd_clks = in_8(pixis_base + PIXIS_VCFGEN0);
Jon Loeliger25d83d72007-04-11 16:51:02 -0500383 rd_clks &= 0x1C;
384
385 /*
386 * Only if both go bit and the SCLK bit in VCFGEN0 are set
387 * should we be using the AUX register. Remember, we also set the
388 * GO bit to boot from the alternate bank on the on-board flash
389 */
390
391 if (go_bit) {
392 if (rd_clks == 0x1c)
Kumar Gala048e7ef2009-07-22 10:12:39 -0500393 i = in_8(pixis_base + PIXIS_AUX);
Jon Loeliger25d83d72007-04-11 16:51:02 -0500394 else
Kumar Gala048e7ef2009-07-22 10:12:39 -0500395 i = in_8(pixis_base + PIXIS_SPD);
Jon Loeliger25d83d72007-04-11 16:51:02 -0500396 } else {
Kumar Gala048e7ef2009-07-22 10:12:39 -0500397 i = in_8(pixis_base + PIXIS_SPD);
Jon Loeliger25d83d72007-04-11 16:51:02 -0500398 }
399
400 i &= 0x07;
401
402 switch (i) {
403 case 0:
404 val = 33333333;
405 break;
406 case 1:
407 val = 40000000;
408 break;
409 case 2:
410 val = 50000000;
411 break;
412 case 3:
413 val = 66666666;
414 break;
415 case 4:
416 val = 83000000;
417 break;
418 case 5:
419 val = 100000000;
420 break;
421 case 6:
422 val = 133333333;
423 break;
424 case 7:
425 val = 166666666;
426 break;
427 }
428
429 return val;
430}
431
Andy Fleming216f2a72008-08-31 16:33:29 -0500432int board_eth_init(bd_t *bis)
433{
Ben Warren0b252f52008-08-31 21:41:08 -0700434#ifdef CONFIG_TSEC_ENET
Andy Fleming216f2a72008-08-31 16:33:29 -0500435 struct tsec_info_struct tsec_info[2];
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200436 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Andy Fleming216f2a72008-08-31 16:33:29 -0500437 uint io_sel = (gur->pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
438 int num = 0;
439
440#ifdef CONFIG_TSEC1
441 SET_STD_TSEC_INFO(tsec_info[num], 1);
442 if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII1_DIS))
443 tsec_info[num].flags |= TSEC_SGMII;
444 num++;
445#endif
446#ifdef CONFIG_TSEC3
447 SET_STD_TSEC_INFO(tsec_info[num], 3);
448 if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS))
449 tsec_info[num].flags |= TSEC_SGMII;
450 num++;
451#endif
452
453 if (!num) {
454 printf("No TSECs initialized\n");
455
456 return 0;
457 }
458
459 if (io_sel & 1)
460 fsl_sgmii_riser_init(tsec_info, num);
461
462
463 tsec_eth_init(bis, tsec_info, num);
Andy Fleming216f2a72008-08-31 16:33:29 -0500464#endif
Ben Warren0b252f52008-08-31 21:41:08 -0700465 return pci_eth_init(bis);
466}
Andy Fleming216f2a72008-08-31 16:33:29 -0500467
Kumar Galaaddce572007-11-26 17:12:24 -0600468#if defined(CONFIG_OF_BOARD_SETUP)
Kumar Gala2dba0de2008-10-21 08:28:33 -0500469void ft_board_setup(void *blob, bd_t *bd)
Jon Loeliger25d83d72007-04-11 16:51:02 -0500470{
Wolfgang Denk2f152782007-05-05 18:23:11 +0200471 ft_cpu_setup(blob, bd);
Jon Loeliger25d83d72007-04-11 16:51:02 -0500472
Kumar Gala2dba0de2008-10-21 08:28:33 -0500473
Ed Swarthoutf75e89e2007-08-30 01:58:48 -0500474#ifdef CONFIG_PCI1
Kumar Gala2dba0de2008-10-21 08:28:33 -0500475 ft_fsl_pci_setup(blob, "pci0", &pci1_hose);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500476#endif
477#ifdef CONFIG_PCIE2
Kumar Gala2dba0de2008-10-21 08:28:33 -0500478 ft_fsl_pci_setup(blob, "pci1", &pcie1_hose);
Kumar Galaaddce572007-11-26 17:12:24 -0600479#endif
480#ifdef CONFIG_PCIE1
Kumar Gala2dba0de2008-10-21 08:28:33 -0500481 ft_fsl_pci_setup(blob, "pci2", &pcie3_hose);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500482#endif
483#ifdef CONFIG_PCIE3
Kumar Gala2dba0de2008-10-21 08:28:33 -0500484 ft_fsl_pci_setup(blob, "pci3", &pcie2_hose);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500485#endif
Andy Flemingfeede8b2008-12-05 20:10:22 -0600486#ifdef CONFIG_FSL_SGMII_RISER
487 fsl_sgmii_riser_fdt_fixup(blob);
488#endif
Jon Loeliger25d83d72007-04-11 16:51:02 -0500489}
490#endif