blob: bdd12933433467deb23ad83004cc7a4df0cd0bda [file] [log] [blame]
Dave Liu5f820432006-11-03 19:33:44 -06001/*
Jerry Huangd37be072011-11-03 14:46:12 +08002 * Copyright (C) 2006,2010-2011 Freescale Semiconductor, Inc.
Dave Liu5f820432006-11-03 19:33:44 -06003 * Dave Liu <daveliu@freescale.com>
Dave Liu5f820432006-11-03 19:33:44 -06004 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
12 */
13
14#include <common.h>
15#include <ioports.h>
16#include <mpc83xx.h>
17#include <i2c.h>
Dave Liu5f820432006-11-03 19:33:44 -060018#include <miiphy.h>
Andy Fleming865ff852011-04-13 00:37:12 -050019#include <phy.h>
Dave Liu5f820432006-11-03 19:33:44 -060020#if defined(CONFIG_PCI)
21#include <pci.h>
22#endif
Dave Liu5f820432006-11-03 19:33:44 -060023#include <spd_sdram.h>
Dave Liu5f820432006-11-03 19:33:44 -060024#include <asm/mmu.h>
Anton Vorontsov89da44c2009-09-16 23:21:59 +040025#include <asm/io.h>
Kumar Galaa1964ea2010-09-30 09:15:03 -050026#include <asm/fsl_enet.h>
Jerry Huangd37be072011-11-03 14:46:12 +080027#include <asm/mmu.h>
Kim Phillipsb3458d22007-12-20 15:57:28 -060028#if defined(CONFIG_OF_LIBFDT)
Gerald Van Baren213bf8c2007-03-31 12:23:51 -040029#include <libfdt.h>
Gerald Van Baren213bf8c2007-03-31 12:23:51 -040030#endif
Anton Vorontsovda6eea02009-09-16 23:22:08 +040031#include <hwconfig.h>
32#include <fdt_support.h>
Tony Li14778582007-08-17 10:35:59 +080033#if defined(CONFIG_PQ_MDS_PIB)
Kim Phillipse58fe952007-08-16 22:53:09 -050034#include "../common/pq-mds-pib.h"
Tony Li14778582007-08-17 10:35:59 +080035#endif
Anton Vorontsov89da44c2009-09-16 23:21:59 +040036#include "../../../drivers/qe/uec.h"
Dave Liu5f820432006-11-03 19:33:44 -060037
Dave Liu7737d5c2006-11-03 12:11:15 -060038const qe_iop_conf_t qe_iop_conf_tab[] = {
39 /* GETH1 */
40 {0, 3, 1, 0, 1}, /* TxD0 */
41 {0, 4, 1, 0, 1}, /* TxD1 */
42 {0, 5, 1, 0, 1}, /* TxD2 */
43 {0, 6, 1, 0, 1}, /* TxD3 */
44 {1, 6, 1, 0, 3}, /* TxD4 */
45 {1, 7, 1, 0, 1}, /* TxD5 */
46 {1, 9, 1, 0, 2}, /* TxD6 */
47 {1, 10, 1, 0, 2}, /* TxD7 */
48 {0, 9, 2, 0, 1}, /* RxD0 */
49 {0, 10, 2, 0, 1}, /* RxD1 */
50 {0, 11, 2, 0, 1}, /* RxD2 */
51 {0, 12, 2, 0, 1}, /* RxD3 */
52 {0, 13, 2, 0, 1}, /* RxD4 */
53 {1, 1, 2, 0, 2}, /* RxD5 */
54 {1, 0, 2, 0, 2}, /* RxD6 */
55 {1, 4, 2, 0, 2}, /* RxD7 */
56 {0, 7, 1, 0, 1}, /* TX_EN */
57 {0, 8, 1, 0, 1}, /* TX_ER */
58 {0, 15, 2, 0, 1}, /* RX_DV */
59 {0, 16, 2, 0, 1}, /* RX_ER */
60 {0, 0, 2, 0, 1}, /* RX_CLK */
61 {2, 9, 1, 0, 3}, /* GTX_CLK - CLK10 */
62 {2, 8, 2, 0, 1}, /* GTX125 - CLK9 */
63 /* GETH2 */
64 {0, 17, 1, 0, 1}, /* TxD0 */
65 {0, 18, 1, 0, 1}, /* TxD1 */
66 {0, 19, 1, 0, 1}, /* TxD2 */
67 {0, 20, 1, 0, 1}, /* TxD3 */
68 {1, 2, 1, 0, 1}, /* TxD4 */
69 {1, 3, 1, 0, 2}, /* TxD5 */
70 {1, 5, 1, 0, 3}, /* TxD6 */
71 {1, 8, 1, 0, 3}, /* TxD7 */
72 {0, 23, 2, 0, 1}, /* RxD0 */
73 {0, 24, 2, 0, 1}, /* RxD1 */
74 {0, 25, 2, 0, 1}, /* RxD2 */
75 {0, 26, 2, 0, 1}, /* RxD3 */
76 {0, 27, 2, 0, 1}, /* RxD4 */
77 {1, 12, 2, 0, 2}, /* RxD5 */
78 {1, 13, 2, 0, 3}, /* RxD6 */
79 {1, 11, 2, 0, 2}, /* RxD7 */
80 {0, 21, 1, 0, 1}, /* TX_EN */
81 {0, 22, 1, 0, 1}, /* TX_ER */
82 {0, 29, 2, 0, 1}, /* RX_DV */
83 {0, 30, 2, 0, 1}, /* RX_ER */
84 {0, 31, 2, 0, 1}, /* RX_CLK */
85 {2, 2, 1, 0, 2}, /* GTX_CLK = CLK10 */
86 {2, 3, 2, 0, 1}, /* GTX125 - CLK4 */
87
88 {0, 1, 3, 0, 2}, /* MDIO */
89 {0, 2, 1, 0, 1}, /* MDC */
90
Anton Vorontsov651d96f2007-11-14 18:54:53 +030091 {5, 0, 1, 0, 2}, /* UART2_SOUT */
92 {5, 1, 2, 0, 3}, /* UART2_CTS */
93 {5, 2, 1, 0, 1}, /* UART2_RTS */
94 {5, 3, 2, 0, 2}, /* UART2_SIN */
95
Dave Liu7737d5c2006-11-03 12:11:15 -060096 {0, 0, 0, 0, QE_IOP_TAB_END}, /* END of table */
97};
98
Anton Vorontsov89da44c2009-09-16 23:21:59 +040099/* Handle "mpc8360ea rev.2.1 erratum 2: RGMII Timing"? */
100static int board_handle_erratum2(void)
101{
102 const immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
103
104 return REVID_MAJOR(immr->sysconf.spridr) == 2 &&
105 REVID_MINOR(immr->sysconf.spridr) == 1;
106}
107
Dave Liu5f820432006-11-03 19:33:44 -0600108int board_early_init_f(void)
109{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200110 const immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
Anton Vorontsov89da44c2009-09-16 23:21:59 +0400111 u8 *bcsr = (u8 *)CONFIG_SYS_BCSR;
Dave Liu5f820432006-11-03 19:33:44 -0600112
113 /* Enable flash write */
114 bcsr[0xa] &= ~0x04;
115
Kim Phillipse5c4ade2008-03-28 10:19:07 -0500116 /* Disable G1TXCLK, G2TXCLK h/w buffers (rev.2.x h/w bug workaround) */
117 if (REVID_MAJOR(immr->sysconf.spridr) == 2)
Kim Phillips3fc0bd12007-02-14 19:50:53 -0600118 bcsr[0xe] = 0x30;
119
Anton Vorontsov651d96f2007-11-14 18:54:53 +0300120 /* Enable second UART */
121 bcsr[0x9] &= ~0x01;
122
Anton Vorontsov89da44c2009-09-16 23:21:59 +0400123 if (board_handle_erratum2()) {
124 void *immap = (immap_t *)(CONFIG_SYS_IMMR + 0x14a8);
125
126 /*
127 * IMMR + 0x14A8[4:5] = 11 (clk delay for UCC 2)
128 * IMMR + 0x14A8[18:19] = 11 (clk delay for UCC 1)
129 */
130 setbits_be32(immap, 0x0c003000);
131
132 /*
133 * IMMR + 0x14AC[20:27] = 10101010
134 * (data delay for both UCC's)
135 */
136 clrsetbits_be32(immap + 4, 0xff0, 0xaa0);
137 }
Dave Liu5f820432006-11-03 19:33:44 -0600138 return 0;
139}
140
Tony Li14778582007-08-17 10:35:59 +0800141int board_early_init_r(void)
142{
Jerry Huangd37be072011-11-03 14:46:12 +0800143 gd_t *gd;
Tony Li14778582007-08-17 10:35:59 +0800144#ifdef CONFIG_PQ_MDS_PIB
145 pib_init();
146#endif
Jerry Huangd37be072011-11-03 14:46:12 +0800147 /*
148 * BAT6 is used for SDRAM when DDR size is 512MB or larger than 256MB
149 * So re-setup PCI MEM space used BAT5 after relocated to DDR
150 */
151 gd = (gd_t *)(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
152 if (gd->ram_size > CONFIG_MAX_MEM_MAPPED) {
153 write_bat(DBAT5, CONFIG_SYS_DBAT6U, CONFIG_SYS_DBAT6L);
154 write_bat(IBAT5, CONFIG_SYS_IBAT6U, CONFIG_SYS_IBAT6L);
155 }
156
Tony Li14778582007-08-17 10:35:59 +0800157 return 0;
158}
159
Anton Vorontsov89da44c2009-09-16 23:21:59 +0400160#ifdef CONFIG_UEC_ETH
161static uec_info_t uec_info[] = {
162#ifdef CONFIG_UEC_ETH1
163 STD_UEC_INFO(1),
164#endif
165#ifdef CONFIG_UEC_ETH2
166 STD_UEC_INFO(2),
167#endif
168};
169
170int board_eth_init(bd_t *bd)
171{
172 if (board_handle_erratum2()) {
173 int i;
174
Kim Phillipsb86c7702011-11-15 22:59:52 +0000175 for (i = 0; i < ARRAY_SIZE(uec_info); i++) {
Andy Fleming865ff852011-04-13 00:37:12 -0500176 uec_info[i].enet_interface_type =
177 PHY_INTERFACE_MODE_RGMII_RXID;
178 uec_info[i].speed = SPEED_1000;
Kim Phillipsb86c7702011-11-15 22:59:52 +0000179 }
Anton Vorontsov89da44c2009-09-16 23:21:59 +0400180 }
181 return uec_eth_init(bd, uec_info, ARRAY_SIZE(uec_info));
182}
183#endif /* CONFIG_UEC_ETH */
184
Peter Tyser9adda542009-06-30 17:15:50 -0500185#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
Dave Liu5f820432006-11-03 19:33:44 -0600186extern void ddr_enable_ecc(unsigned int dram_size);
187#endif
188int fixed_sdram(void);
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400189static int sdram_init(unsigned int base);
Dave Liu5f820432006-11-03 19:33:44 -0600190
Becky Bruce9973e3c2008-06-09 16:03:40 -0500191phys_size_t initdram(int board_type)
Dave Liu5f820432006-11-03 19:33:44 -0600192{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200193 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
Dave Liu5f820432006-11-03 19:33:44 -0600194 u32 msize = 0;
Anton Vorontsov034477b2009-09-16 23:21:57 +0400195 u32 lbc_sdram_size;
Dave Liu5f820432006-11-03 19:33:44 -0600196
197 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
198 return -1;
199
200 /* DDR SDRAM - Main SODIMM */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200201 im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
Dave Liu5f820432006-11-03 19:33:44 -0600202#if defined(CONFIG_SPD_EEPROM)
203 msize = spd_sdram();
204#else
205 msize = fixed_sdram();
206#endif
207
Peter Tyser9adda542009-06-30 17:15:50 -0500208#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
Dave Liu5f820432006-11-03 19:33:44 -0600209 /*
210 * Initialize DDR ECC byte
211 */
212 ddr_enable_ecc(msize * 1024 * 1024);
213#endif
214 /*
215 * Initialize SDRAM if it is on local bus.
216 */
Anton Vorontsov034477b2009-09-16 23:21:57 +0400217 lbc_sdram_size = sdram_init(msize * 1024 * 1024);
218 if (!msize)
219 msize = lbc_sdram_size;
Kim Phillipsbbea46f2007-08-16 22:52:48 -0500220
Dave Liu5f820432006-11-03 19:33:44 -0600221 /* return total bus SDRAM size(bytes) -- DDR */
222 return (msize * 1024 * 1024);
223}
224
225#if !defined(CONFIG_SPD_EEPROM)
226/*************************************************************************
227 * fixed sdram init -- doesn't use serial presence detect.
228 ************************************************************************/
229int fixed_sdram(void)
230{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200231 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
Joe Hershberger2e651b22011-10-11 23:57:31 -0500232 u32 msize = CONFIG_SYS_DDR_SIZE;
233 u32 ddr_size = msize << 20;
234 u32 ddr_size_log2 = __ilog2(ddr_size);
235 u32 half_ddr_size = ddr_size >> 1;
Dave Liu5f820432006-11-03 19:33:44 -0600236
Joe Hershberger2e651b22011-10-11 23:57:31 -0500237 im->sysconf.ddrlaw[0].bar =
238 CONFIG_SYS_DDR_SDRAM_BASE & 0xfffff000;
Dave Liu5f820432006-11-03 19:33:44 -0600239 im->sysconf.ddrlaw[0].ar =
Joe Hershberger2e651b22011-10-11 23:57:31 -0500240 LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200241#if (CONFIG_SYS_DDR_SIZE != 256)
Dave Liu5f820432006-11-03 19:33:44 -0600242#warning Currenly any ddr size other than 256 is not supported
243#endif
Xie Xiaobod61853c2007-02-14 18:27:17 +0800244#ifdef CONFIG_DDR_II
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200245 im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
246 im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
247 im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
248 im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
249 im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
250 im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
251 im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
252 im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
253 im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
254 im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
255 im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
256 im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL;
Xie Xiaobod61853c2007-02-14 18:27:17 +0800257#else
Dave Liu5f820432006-11-03 19:33:44 -0600258
Joe Hershberger2e651b22011-10-11 23:57:31 -0500259#if ((CONFIG_SYS_DDR_SDRAM_BASE & 0x00FFFFFF) != 0)
260#warning Chip select bounds is only configurable in 16MB increments
261#endif
262 im->ddr.csbnds[0].csbnds =
263 ((CONFIG_SYS_DDR_SDRAM_BASE >> CSBNDS_SA_SHIFT) & CSBNDS_SA) |
264 (((CONFIG_SYS_DDR_SDRAM_BASE + half_ddr_size - 1) >>
265 CSBNDS_EA_SHIFT) & CSBNDS_EA);
266 im->ddr.csbnds[1].csbnds =
267 (((CONFIG_SYS_DDR_SDRAM_BASE + half_ddr_size) >>
268 CSBNDS_SA_SHIFT) & CSBNDS_SA) |
269 (((CONFIG_SYS_DDR_SDRAM_BASE + ddr_size - 1) >>
270 CSBNDS_EA_SHIFT) & CSBNDS_EA);
271
272 im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
273 im->ddr.cs_config[1] = CONFIG_SYS_DDR_CS1_CONFIG;
274
275 im->ddr.cs_config[2] = 0;
276 im->ddr.cs_config[3] = 0;
Dave Liu5f820432006-11-03 19:33:44 -0600277
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200278 im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
279 im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
280 im->ddr.sdram_cfg = CONFIG_SYS_DDR_CONTROL;
Dave Liu5f820432006-11-03 19:33:44 -0600281
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200282 im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
283 im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
Xie Xiaobod61853c2007-02-14 18:27:17 +0800284#endif
Dave Liu5f820432006-11-03 19:33:44 -0600285 udelay(200);
286 im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
287
288 return msize;
289}
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200290#endif /*!CONFIG_SYS_SPD_EEPROM */
Dave Liu5f820432006-11-03 19:33:44 -0600291
292int checkboard(void)
293{
294 puts("Board: Freescale MPC8360EMDS\n");
295 return 0;
296}
297
298/*
299 * if MPC8360EMDS is soldered with SDRAM
300 */
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400301#ifdef CONFIG_SYS_LB_SDRAM
Dave Liu5f820432006-11-03 19:33:44 -0600302/*
303 * Initialize SDRAM memory on the Local Bus.
304 */
305
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400306static int sdram_init(unsigned int base)
Dave Liu5f820432006-11-03 19:33:44 -0600307{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200308 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
Becky Brucef51cdaf2010-06-17 11:37:20 -0500309 fsl_lbc_t *lbc = LBC_BASE_ADDR;
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400310 const int sdram_size = CONFIG_SYS_LBC_SDRAM_SIZE * 1024 * 1024;
311 int rem = base % sdram_size;
312 uint *sdram_addr;
Dave Liu5f820432006-11-03 19:33:44 -0600313
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400314 /* window base address should be aligned to the window size */
315 if (rem)
316 base = base - rem + sdram_size;
317
Jerry Huangd37be072011-11-03 14:46:12 +0800318 /*
319 * Setup BAT6 for SDRAM when DDR size is 512MB or larger than 256MB
320 * After relocated to DDR, reuse BAT5 for PCI MEM space
321 */
322 if (base > CONFIG_MAX_MEM_MAPPED) {
323 unsigned long batl = base | BATL_PP_10 | BATL_MEMCOHERENCE;
324 unsigned long batu = base | BATU_BL_64M | BATU_VS | BATU_VP;
325
326 /* Setup the BAT6 for SDRAM */
327 write_bat(DBAT6, batu, batl);
328 write_bat(IBAT6, batu, batl);
329 }
330
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400331 sdram_addr = (uint *)base;
Dave Liu5f820432006-11-03 19:33:44 -0600332 /*
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400333 * Setup SDRAM Base and Option Registers
Dave Liu5f820432006-11-03 19:33:44 -0600334 */
Becky Brucef51cdaf2010-06-17 11:37:20 -0500335 set_lbc_br(2, base | CONFIG_SYS_BR2);
336 set_lbc_or(2, CONFIG_SYS_OR2);
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400337 immap->sysconf.lblaw[2].bar = base;
338 immap->sysconf.lblaw[2].ar = CONFIG_SYS_LBLAWAR2;
339
Dave Liu5f820432006-11-03 19:33:44 -0600340 /*setup mtrpt, lsrt and lbcr for LB bus */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200341 lbc->lbcr = CONFIG_SYS_LBC_LBCR;
342 lbc->mrtpr = CONFIG_SYS_LBC_MRTPR;
343 lbc->lsrt = CONFIG_SYS_LBC_LSRT;
Dave Liu5f820432006-11-03 19:33:44 -0600344 asm("sync");
345
346 /*
347 * Configure the SDRAM controller Machine Mode Register.
348 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200349 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_5; /* Normal Operation */
350 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_1; /* Precharge All Banks */
Dave Liu5f820432006-11-03 19:33:44 -0600351 asm("sync");
352 *sdram_addr = 0xff;
353 udelay(100);
354
355 /*
356 * We need do 8 times auto refresh operation.
357 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200358 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_2;
Dave Liu5f820432006-11-03 19:33:44 -0600359 asm("sync");
360 *sdram_addr = 0xff; /* 1 times */
361 udelay(100);
362 *sdram_addr = 0xff; /* 2 times */
363 udelay(100);
364 *sdram_addr = 0xff; /* 3 times */
365 udelay(100);
366 *sdram_addr = 0xff; /* 4 times */
367 udelay(100);
368 *sdram_addr = 0xff; /* 5 times */
369 udelay(100);
370 *sdram_addr = 0xff; /* 6 times */
371 udelay(100);
372 *sdram_addr = 0xff; /* 7 times */
373 udelay(100);
374 *sdram_addr = 0xff; /* 8 times */
375 udelay(100);
376
377 /* Mode register write operation */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200378 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_4;
Dave Liu5f820432006-11-03 19:33:44 -0600379 asm("sync");
380 *(sdram_addr + 0xcc) = 0xff;
381 udelay(100);
382
383 /* Normal operation */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200384 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_5 | 0x40000000;
Dave Liu5f820432006-11-03 19:33:44 -0600385 asm("sync");
386 *sdram_addr = 0xff;
387 udelay(100);
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400388
389 /*
390 * In non-aligned case we don't [normally] use that memory because
391 * there is a hole.
392 */
393 if (rem)
394 return 0;
395 return CONFIG_SYS_LBC_SDRAM_SIZE;
Dave Liu5f820432006-11-03 19:33:44 -0600396}
397#else
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400398static int sdram_init(unsigned int base) { return 0; }
Dave Liu5f820432006-11-03 19:33:44 -0600399#endif
400
Kim Phillips3fde9e82007-08-15 22:30:33 -0500401#if defined(CONFIG_OF_BOARD_SETUP)
Anton Vorontsovda6eea02009-09-16 23:22:08 +0400402static void ft_board_fixup_qe_usb(void *blob, bd_t *bd)
403{
404 if (!hwconfig_subarg_cmp("qe_usb", "mode", "peripheral"))
405 return;
406
407 do_fixup_by_compat(blob, "fsl,mpc8323-qe-usb", "mode",
408 "peripheral", sizeof("peripheral"), 1);
409}
410
Kim Phillips3fde9e82007-08-15 22:30:33 -0500411void ft_board_setup(void *blob, bd_t *bd)
Kim Phillipsbf0b5422006-11-01 00:10:40 -0600412{
Kim Phillips3fde9e82007-08-15 22:30:33 -0500413 ft_cpu_setup(blob, bd);
Gerald Van Baren213bf8c2007-03-31 12:23:51 -0400414#ifdef CONFIG_PCI
415 ft_pci_setup(blob, bd);
416#endif
Anton Vorontsovda6eea02009-09-16 23:22:08 +0400417 ft_board_fixup_qe_usb(blob, bd);
Kim Phillips24f86842007-11-09 14:28:08 -0600418 /*
419 * mpc8360ea pb mds errata 2: RGMII timing
420 * if on mpc8360ea rev. 2.1,
421 * change both ucc phy-connection-types from rgmii-id to rgmii-rxid
422 */
Anton Vorontsov89da44c2009-09-16 23:21:59 +0400423 if (board_handle_erratum2()) {
Kim Phillips24f86842007-11-09 14:28:08 -0600424 int nodeoffset;
Kim Phillipsf6020822007-12-10 14:16:22 -0600425 const char *prop;
Kim Phillips363eea92008-01-15 09:51:12 -0600426 int path;
Kim Phillips24f86842007-11-09 14:28:08 -0600427
Kim Phillipsf09880e2008-01-14 16:14:46 -0600428 nodeoffset = fdt_path_offset(blob, "/aliases");
Kim Phillips24f86842007-11-09 14:28:08 -0600429 if (nodeoffset >= 0) {
Kim Phillips5b8bc602007-12-20 14:09:22 -0600430#if defined(CONFIG_HAS_ETH0)
431 /* fixup UCC 1 if using rgmii-id mode */
Kim Phillips363eea92008-01-15 09:51:12 -0600432 prop = fdt_getprop(blob, nodeoffset, "ethernet0", NULL);
433 if (prop) {
434 path = fdt_path_offset(blob, prop);
Kim Phillipsf09880e2008-01-14 16:14:46 -0600435 prop = fdt_getprop(blob, path,
436 "phy-connection-type", 0);
Kim Phillips5b8bc602007-12-20 14:09:22 -0600437 if (prop && (strcmp(prop, "rgmii-id") == 0))
Kumar Galaa1964ea2010-09-30 09:15:03 -0500438 fdt_fixup_phy_connection(blob, path,
Andy Fleming865ff852011-04-13 00:37:12 -0500439 PHY_INTERFACE_MODE_RGMII_RXID);
Kim Phillips5b8bc602007-12-20 14:09:22 -0600440 }
441#endif
442#if defined(CONFIG_HAS_ETH1)
443 /* fixup UCC 2 if using rgmii-id mode */
Kim Phillips363eea92008-01-15 09:51:12 -0600444 prop = fdt_getprop(blob, nodeoffset, "ethernet1", NULL);
445 if (prop) {
446 path = fdt_path_offset(blob, prop);
Kim Phillipsf09880e2008-01-14 16:14:46 -0600447 prop = fdt_getprop(blob, path,
448 "phy-connection-type", 0);
Kim Phillips5b8bc602007-12-20 14:09:22 -0600449 if (prop && (strcmp(prop, "rgmii-id") == 0))
Kumar Galaa1964ea2010-09-30 09:15:03 -0500450 fdt_fixup_phy_connection(blob, path,
Andy Fleming865ff852011-04-13 00:37:12 -0500451 PHY_INTERFACE_MODE_RGMII_RXID);
Kim Phillips5b8bc602007-12-20 14:09:22 -0600452 }
453#endif
Kim Phillips24f86842007-11-09 14:28:08 -0600454 }
455 }
Kim Phillipsbf0b5422006-11-01 00:10:40 -0600456}
Kim Phillips3fde9e82007-08-15 22:30:33 -0500457#endif