blob: a48c8155c5086be73a23cea3785ed67fa6727566 [file] [log] [blame]
Jon Loeliger25d83d72007-04-11 16:51:02 -05001/*
Kumar Gala6525d512010-07-08 22:37:44 -05002 * Copyright 2007,2009-2010 Freescale Semiconductor, Inc.
Jon Loeliger25d83d72007-04-11 16:51:02 -05003 *
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 Gala5d27e022010-12-15 04:55:20 -060031#include <asm/fsl_serdes.h>
Kumar Gala56a92702007-08-30 16:18:18 -050032#include <asm/io.h>
Jon Loeliger25d83d72007-04-11 16:51:02 -050033#include <miiphy.h>
Kumar Galaaddce572007-11-26 17:12:24 -060034#include <libfdt.h>
35#include <fdt_support.h>
Andy Fleming216f2a72008-08-31 16:33:29 -050036#include <tsec.h>
Ben Warren0b252f52008-08-31 21:41:08 -070037#include <netdev.h>
Jon Loeliger25d83d72007-04-11 16:51:02 -050038
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);
Becky Brucef51cdaf2010-06-17 11:37:20 -050044 volatile fsl_lbc_t *lbc = LBC_BASE_ADDR;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020045 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
Ed Swarthout837f1ba2007-07-27 01:50:51 -050071#ifdef CONFIG_PCI1
72static struct pci_controller pci1_hose;
73#endif
74
Ed Swarthout837f1ba2007-07-27 01:50:51 -050075#ifdef CONFIG_PCIE3
76static struct pci_controller pcie3_hose;
77#endif
78
Kumar Gala645d5a72009-11-04 10:22:26 -060079void pci_init_board(void)
Ed Swarthout837f1ba2007-07-27 01:50:51 -050080{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020081 volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
Kumar Gala64a16862010-12-17 06:01:24 -060082 struct fsl_pci_info pci_info;
Kumar Gala645d5a72009-11-04 10:22:26 -060083 u32 devdisr, pordevsr, io_sel;
84 u32 porpllsr, pci_agent, pci_speed, pci_32, pci_arb, pci_clk_sel;
85 int first_free_busno = 0;
Ed Swarthout837f1ba2007-07-27 01:50:51 -050086
Kumar Gala645d5a72009-11-04 10:22:26 -060087 int pcie_ep, pcie_configured;
88
89 devdisr = in_be32(&gur->devdisr);
90 pordevsr = in_be32(&gur->pordevsr);
91 porpllsr = in_be32(&gur->porpllsr);
92 io_sel = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19;
93
94 debug (" pci_init_board: devdisr=%x, io_sel=%x\n", devdisr, io_sel);
Ed Swarthout837f1ba2007-07-27 01:50:51 -050095
Kumar Gala645d5a72009-11-04 10:22:26 -060096 puts("\n");
Ed Swarthout837f1ba2007-07-27 01:50:51 -050097
98#ifdef CONFIG_PCIE3
Kumar Gala5d27e022010-12-15 04:55:20 -060099 pcie_configured = is_serdes_configured(PCIE3);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500100
Kumar Gala645d5a72009-11-04 10:22:26 -0600101 if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE3)){
Kumar Gala64a16862010-12-17 06:01:24 -0600102 /* contains both PCIE3 MEM & IO space */
103 set_next_law(CONFIG_SYS_PCIE3_MEM_PHYS, LAW_SIZE_4M,
104 LAW_TRGT_IF_PCIE_3);
105 SET_STD_PCIE_INFO(pci_info, 3);
106 pcie_ep = fsl_setup_hose(&pcie3_hose, pci_info.regs);
107
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500108 /* outbound memory */
Kumar Gala645d5a72009-11-04 10:22:26 -0600109 pci_set_region(&pcie3_hose.regions[0],
Kumar Gala10795f42008-12-02 16:08:36 -0600110 CONFIG_SYS_PCIE3_MEM_BUS2,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200111 CONFIG_SYS_PCIE3_MEM_PHYS2,
112 CONFIG_SYS_PCIE3_MEM_SIZE2,
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500113 PCI_REGION_MEM);
Kumar Gala645d5a72009-11-04 10:22:26 -0600114
115 pcie3_hose.region_count = 1;
Kumar Gala64a16862010-12-17 06:01:24 -0600116
Peter Tyser8ca78f22010-10-29 17:59:24 -0500117 printf("PCIE3: connected to ULI as %s (base addr %lx)\n",
118 pcie_ep ? "Endpoint" : "Root Complex",
Kumar Gala64a16862010-12-17 06:01:24 -0600119 pci_info.regs);
120 first_free_busno = fsl_pci_init_port(&pci_info,
Kumar Gala645d5a72009-11-04 10:22:26 -0600121 &pcie3_hose, first_free_busno);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500122
Kumar Gala56a92702007-08-30 16:18:18 -0500123 /*
124 * Activate ULI1575 legacy chip by performing a fake
125 * memory access. Needed to make ULI RTC work.
126 */
Kumar Gala10795f42008-12-02 16:08:36 -0600127 in_be32((u32 *)CONFIG_SYS_PCIE3_MEM_BUS);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500128 } else {
Peter Tyser8ca78f22010-10-29 17:59:24 -0500129 printf("PCIE3: disabled\n");
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500130 }
Kumar Gala645d5a72009-11-04 10:22:26 -0600131 puts("\n");
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500132#else
Kumar Gala645d5a72009-11-04 10:22:26 -0600133 setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE3); /* disable */
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500134#endif
135
136#ifdef CONFIG_PCIE1
Kumar Gala64a16862010-12-17 06:01:24 -0600137 SET_STD_PCIE_INFO(pci_info, 1);
138 first_free_busno = fsl_pcie_init_ctrl(first_free_busno, devdisr, PCIE1, &pci_info);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500139#else
Kumar Gala64a16862010-12-17 06:01:24 -0600140 setbits_be32(&gur->devdisr, _DEVDISR_PCIE1); /* disable */
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500141#endif
142
143#ifdef CONFIG_PCIE2
Kumar Gala64a16862010-12-17 06:01:24 -0600144 SET_STD_PCIE_INFO(pci_info, 2);
145 first_free_busno = fsl_pcie_init_ctrl(first_free_busno, devdisr, PCIE2, &pci_info);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500146#else
Kumar Gala64a16862010-12-17 06:01:24 -0600147 setbits_be32(&gur->devdisr, _DEVDISR_PCIE2); /* disable */
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500148#endif
149
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500150#ifdef CONFIG_PCI1
Kumar Gala645d5a72009-11-04 10:22:26 -0600151 pci_speed = 66666000;
152 pci_32 = 1;
153 pci_arb = pordevsr & MPC85xx_PORDEVSR_PCI1_ARB;
154 pci_clk_sel = porpllsr & MPC85xx_PORDEVSR_PCI1_SPD;
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500155
156 if (!(devdisr & MPC85xx_DEVDISR_PCI1)) {
Kumar Gala64a16862010-12-17 06:01:24 -0600157 SET_STD_PCI_INFO(pci_info, 1);
158 set_next_law(pci_info.mem_phys,
159 law_size_bits(pci_info.mem_size), pci_info.law);
160 set_next_law(pci_info.io_phys,
161 law_size_bits(pci_info.io_size), pci_info.law);
162
163 pci_agent = fsl_setup_hose(&pci1_hose, pci_info.regs);
Peter Tyser8ca78f22010-10-29 17:59:24 -0500164 printf("PCI: %d bit, %s MHz, %s, %s, %s (base address %lx)\n",
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500165 (pci_32) ? 32 : 64,
166 (pci_speed == 33333000) ? "33" :
167 (pci_speed == 66666000) ? "66" : "unknown",
168 pci_clk_sel ? "sync" : "async",
169 pci_agent ? "agent" : "host",
170 pci_arb ? "arbiter" : "external-arbiter",
Kumar Gala64a16862010-12-17 06:01:24 -0600171 pci_info.regs);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500172
Kumar Gala64a16862010-12-17 06:01:24 -0600173 first_free_busno = fsl_pci_init_port(&pci_info,
Kumar Gala645d5a72009-11-04 10:22:26 -0600174 &pci1_hose, first_free_busno);
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500175 } else {
Peter Tyser8ca78f22010-10-29 17:59:24 -0500176 printf("PCI: disabled\n");
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500177 }
Kumar Gala645d5a72009-11-04 10:22:26 -0600178
179 puts("\n");
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500180#else
Kumar Gala645d5a72009-11-04 10:22:26 -0600181 setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCI1); /* disable */
Ed Swarthout837f1ba2007-07-27 01:50:51 -0500182#endif
183}
184
Jon Loeliger25d83d72007-04-11 16:51:02 -0500185int last_stage_init(void)
186{
187 return 0;
188}
189
190
191unsigned long
192get_board_sys_clk(ulong dummy)
193{
194 u8 i, go_bit, rd_clks;
195 ulong val = 0;
Kumar Gala048e7ef2009-07-22 10:12:39 -0500196 u8 *pixis_base = (u8 *)PIXIS_BASE;
Jon Loeliger25d83d72007-04-11 16:51:02 -0500197
Kumar Gala048e7ef2009-07-22 10:12:39 -0500198 go_bit = in_8(pixis_base + PIXIS_VCTL);
Jon Loeliger25d83d72007-04-11 16:51:02 -0500199 go_bit &= 0x01;
200
Kumar Gala048e7ef2009-07-22 10:12:39 -0500201 rd_clks = in_8(pixis_base + PIXIS_VCFGEN0);
Jon Loeliger25d83d72007-04-11 16:51:02 -0500202 rd_clks &= 0x1C;
203
204 /*
205 * Only if both go bit and the SCLK bit in VCFGEN0 are set
206 * should we be using the AUX register. Remember, we also set the
207 * GO bit to boot from the alternate bank on the on-board flash
208 */
209
210 if (go_bit) {
211 if (rd_clks == 0x1c)
Kumar Gala048e7ef2009-07-22 10:12:39 -0500212 i = in_8(pixis_base + PIXIS_AUX);
Jon Loeliger25d83d72007-04-11 16:51:02 -0500213 else
Kumar Gala048e7ef2009-07-22 10:12:39 -0500214 i = in_8(pixis_base + PIXIS_SPD);
Jon Loeliger25d83d72007-04-11 16:51:02 -0500215 } else {
Kumar Gala048e7ef2009-07-22 10:12:39 -0500216 i = in_8(pixis_base + PIXIS_SPD);
Jon Loeliger25d83d72007-04-11 16:51:02 -0500217 }
218
219 i &= 0x07;
220
221 switch (i) {
222 case 0:
223 val = 33333333;
224 break;
225 case 1:
226 val = 40000000;
227 break;
228 case 2:
229 val = 50000000;
230 break;
231 case 3:
232 val = 66666666;
233 break;
234 case 4:
235 val = 83000000;
236 break;
237 case 5:
238 val = 100000000;
239 break;
240 case 6:
241 val = 133333333;
242 break;
243 case 7:
244 val = 166666666;
245 break;
246 }
247
248 return val;
249}
250
Andy Fleming216f2a72008-08-31 16:33:29 -0500251int board_eth_init(bd_t *bis)
252{
Ben Warren0b252f52008-08-31 21:41:08 -0700253#ifdef CONFIG_TSEC_ENET
Andy Fleming216f2a72008-08-31 16:33:29 -0500254 struct tsec_info_struct tsec_info[2];
Andy Fleming216f2a72008-08-31 16:33:29 -0500255 int num = 0;
256
257#ifdef CONFIG_TSEC1
258 SET_STD_TSEC_INFO(tsec_info[num], 1);
Kumar Gala058d7dc2010-12-16 14:28:06 -0600259 if (is_serdes_configured(SGMII_TSEC1)) {
260 puts("eTSEC1 is in sgmii mode.\n");
Andy Fleming216f2a72008-08-31 16:33:29 -0500261 tsec_info[num].flags |= TSEC_SGMII;
Kumar Gala058d7dc2010-12-16 14:28:06 -0600262 }
Andy Fleming216f2a72008-08-31 16:33:29 -0500263 num++;
264#endif
265#ifdef CONFIG_TSEC3
266 SET_STD_TSEC_INFO(tsec_info[num], 3);
Kumar Gala058d7dc2010-12-16 14:28:06 -0600267 if (is_serdes_configured(SGMII_TSEC3)) {
268 puts("eTSEC3 is in sgmii mode.\n");
Andy Fleming216f2a72008-08-31 16:33:29 -0500269 tsec_info[num].flags |= TSEC_SGMII;
Kumar Gala058d7dc2010-12-16 14:28:06 -0600270 }
Andy Fleming216f2a72008-08-31 16:33:29 -0500271 num++;
272#endif
273
274 if (!num) {
275 printf("No TSECs initialized\n");
276
277 return 0;
278 }
279
Kumar Gala058d7dc2010-12-16 14:28:06 -0600280 if (is_serdes_configured(SGMII_TSEC1) ||
281 is_serdes_configured(SGMII_TSEC3)) {
Andy Fleming216f2a72008-08-31 16:33:29 -0500282 fsl_sgmii_riser_init(tsec_info, num);
Kumar Gala058d7dc2010-12-16 14:28:06 -0600283 }
Andy Fleming216f2a72008-08-31 16:33:29 -0500284
285
286 tsec_eth_init(bis, tsec_info, num);
Andy Fleming216f2a72008-08-31 16:33:29 -0500287#endif
Ben Warren0b252f52008-08-31 21:41:08 -0700288 return pci_eth_init(bis);
289}
Andy Fleming216f2a72008-08-31 16:33:29 -0500290
Kumar Galaaddce572007-11-26 17:12:24 -0600291#if defined(CONFIG_OF_BOARD_SETUP)
Kumar Gala2dba0de2008-10-21 08:28:33 -0500292void ft_board_setup(void *blob, bd_t *bd)
Jon Loeliger25d83d72007-04-11 16:51:02 -0500293{
Wolfgang Denk2f152782007-05-05 18:23:11 +0200294 ft_cpu_setup(blob, bd);
Jon Loeliger25d83d72007-04-11 16:51:02 -0500295
Kumar Gala6525d512010-07-08 22:37:44 -0500296 FT_FSL_PCI_SETUP;
Kumar Gala2dba0de2008-10-21 08:28:33 -0500297
Andy Flemingfeede8b2008-12-05 20:10:22 -0600298#ifdef CONFIG_FSL_SGMII_RISER
299 fsl_sgmii_riser_fdt_fixup(blob);
300#endif
Jon Loeliger25d83d72007-04-11 16:51:02 -0500301}
302#endif