blob: 51d8035203fec240e0e247e28fdbea977f47dd65 [file] [log] [blame]
Dave Liu5f820432006-11-03 19:33:44 -06001/*
Kumar Galaa1964ea2010-09-30 09:15:03 -05002 * Copyright (C) 2006,2010 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>
Kim Phillipsb3458d22007-12-20 15:57:28 -060027#if defined(CONFIG_OF_LIBFDT)
Gerald Van Baren213bf8c2007-03-31 12:23:51 -040028#include <libfdt.h>
Gerald Van Baren213bf8c2007-03-31 12:23:51 -040029#endif
Anton Vorontsovda6eea02009-09-16 23:22:08 +040030#include <hwconfig.h>
31#include <fdt_support.h>
Tony Li14778582007-08-17 10:35:59 +080032#if defined(CONFIG_PQ_MDS_PIB)
Kim Phillipse58fe952007-08-16 22:53:09 -050033#include "../common/pq-mds-pib.h"
Tony Li14778582007-08-17 10:35:59 +080034#endif
Anton Vorontsov89da44c2009-09-16 23:21:59 +040035#include "../../../drivers/qe/uec.h"
Dave Liu5f820432006-11-03 19:33:44 -060036
Dave Liu7737d5c2006-11-03 12:11:15 -060037const qe_iop_conf_t qe_iop_conf_tab[] = {
38 /* GETH1 */
39 {0, 3, 1, 0, 1}, /* TxD0 */
40 {0, 4, 1, 0, 1}, /* TxD1 */
41 {0, 5, 1, 0, 1}, /* TxD2 */
42 {0, 6, 1, 0, 1}, /* TxD3 */
43 {1, 6, 1, 0, 3}, /* TxD4 */
44 {1, 7, 1, 0, 1}, /* TxD5 */
45 {1, 9, 1, 0, 2}, /* TxD6 */
46 {1, 10, 1, 0, 2}, /* TxD7 */
47 {0, 9, 2, 0, 1}, /* RxD0 */
48 {0, 10, 2, 0, 1}, /* RxD1 */
49 {0, 11, 2, 0, 1}, /* RxD2 */
50 {0, 12, 2, 0, 1}, /* RxD3 */
51 {0, 13, 2, 0, 1}, /* RxD4 */
52 {1, 1, 2, 0, 2}, /* RxD5 */
53 {1, 0, 2, 0, 2}, /* RxD6 */
54 {1, 4, 2, 0, 2}, /* RxD7 */
55 {0, 7, 1, 0, 1}, /* TX_EN */
56 {0, 8, 1, 0, 1}, /* TX_ER */
57 {0, 15, 2, 0, 1}, /* RX_DV */
58 {0, 16, 2, 0, 1}, /* RX_ER */
59 {0, 0, 2, 0, 1}, /* RX_CLK */
60 {2, 9, 1, 0, 3}, /* GTX_CLK - CLK10 */
61 {2, 8, 2, 0, 1}, /* GTX125 - CLK9 */
62 /* GETH2 */
63 {0, 17, 1, 0, 1}, /* TxD0 */
64 {0, 18, 1, 0, 1}, /* TxD1 */
65 {0, 19, 1, 0, 1}, /* TxD2 */
66 {0, 20, 1, 0, 1}, /* TxD3 */
67 {1, 2, 1, 0, 1}, /* TxD4 */
68 {1, 3, 1, 0, 2}, /* TxD5 */
69 {1, 5, 1, 0, 3}, /* TxD6 */
70 {1, 8, 1, 0, 3}, /* TxD7 */
71 {0, 23, 2, 0, 1}, /* RxD0 */
72 {0, 24, 2, 0, 1}, /* RxD1 */
73 {0, 25, 2, 0, 1}, /* RxD2 */
74 {0, 26, 2, 0, 1}, /* RxD3 */
75 {0, 27, 2, 0, 1}, /* RxD4 */
76 {1, 12, 2, 0, 2}, /* RxD5 */
77 {1, 13, 2, 0, 3}, /* RxD6 */
78 {1, 11, 2, 0, 2}, /* RxD7 */
79 {0, 21, 1, 0, 1}, /* TX_EN */
80 {0, 22, 1, 0, 1}, /* TX_ER */
81 {0, 29, 2, 0, 1}, /* RX_DV */
82 {0, 30, 2, 0, 1}, /* RX_ER */
83 {0, 31, 2, 0, 1}, /* RX_CLK */
84 {2, 2, 1, 0, 2}, /* GTX_CLK = CLK10 */
85 {2, 3, 2, 0, 1}, /* GTX125 - CLK4 */
86
87 {0, 1, 3, 0, 2}, /* MDIO */
88 {0, 2, 1, 0, 1}, /* MDC */
89
Anton Vorontsov651d96f2007-11-14 18:54:53 +030090 {5, 0, 1, 0, 2}, /* UART2_SOUT */
91 {5, 1, 2, 0, 3}, /* UART2_CTS */
92 {5, 2, 1, 0, 1}, /* UART2_RTS */
93 {5, 3, 2, 0, 2}, /* UART2_SIN */
94
Dave Liu7737d5c2006-11-03 12:11:15 -060095 {0, 0, 0, 0, QE_IOP_TAB_END}, /* END of table */
96};
97
Anton Vorontsov89da44c2009-09-16 23:21:59 +040098/* Handle "mpc8360ea rev.2.1 erratum 2: RGMII Timing"? */
99static int board_handle_erratum2(void)
100{
101 const immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
102
103 return REVID_MAJOR(immr->sysconf.spridr) == 2 &&
104 REVID_MINOR(immr->sysconf.spridr) == 1;
105}
106
Dave Liu5f820432006-11-03 19:33:44 -0600107int board_early_init_f(void)
108{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200109 const immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
Anton Vorontsov89da44c2009-09-16 23:21:59 +0400110 u8 *bcsr = (u8 *)CONFIG_SYS_BCSR;
Dave Liu5f820432006-11-03 19:33:44 -0600111
112 /* Enable flash write */
113 bcsr[0xa] &= ~0x04;
114
Kim Phillipse5c4ade2008-03-28 10:19:07 -0500115 /* Disable G1TXCLK, G2TXCLK h/w buffers (rev.2.x h/w bug workaround) */
116 if (REVID_MAJOR(immr->sysconf.spridr) == 2)
Kim Phillips3fc0bd12007-02-14 19:50:53 -0600117 bcsr[0xe] = 0x30;
118
Anton Vorontsov651d96f2007-11-14 18:54:53 +0300119 /* Enable second UART */
120 bcsr[0x9] &= ~0x01;
121
Anton Vorontsov89da44c2009-09-16 23:21:59 +0400122 if (board_handle_erratum2()) {
123 void *immap = (immap_t *)(CONFIG_SYS_IMMR + 0x14a8);
124
125 /*
126 * IMMR + 0x14A8[4:5] = 11 (clk delay for UCC 2)
127 * IMMR + 0x14A8[18:19] = 11 (clk delay for UCC 1)
128 */
129 setbits_be32(immap, 0x0c003000);
130
131 /*
132 * IMMR + 0x14AC[20:27] = 10101010
133 * (data delay for both UCC's)
134 */
135 clrsetbits_be32(immap + 4, 0xff0, 0xaa0);
136 }
Dave Liu5f820432006-11-03 19:33:44 -0600137 return 0;
138}
139
Tony Li14778582007-08-17 10:35:59 +0800140int board_early_init_r(void)
141{
142#ifdef CONFIG_PQ_MDS_PIB
143 pib_init();
144#endif
145 return 0;
146}
147
Anton Vorontsov89da44c2009-09-16 23:21:59 +0400148#ifdef CONFIG_UEC_ETH
149static uec_info_t uec_info[] = {
150#ifdef CONFIG_UEC_ETH1
151 STD_UEC_INFO(1),
152#endif
153#ifdef CONFIG_UEC_ETH2
154 STD_UEC_INFO(2),
155#endif
156};
157
158int board_eth_init(bd_t *bd)
159{
160 if (board_handle_erratum2()) {
161 int i;
162
163 for (i = 0; i < ARRAY_SIZE(uec_info); i++)
Andy Fleming865ff852011-04-13 00:37:12 -0500164 uec_info[i].enet_interface_type =
165 PHY_INTERFACE_MODE_RGMII_RXID;
166 uec_info[i].speed = SPEED_1000;
Anton Vorontsov89da44c2009-09-16 23:21:59 +0400167 }
168 return uec_eth_init(bd, uec_info, ARRAY_SIZE(uec_info));
169}
170#endif /* CONFIG_UEC_ETH */
171
Peter Tyser9adda542009-06-30 17:15:50 -0500172#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
Dave Liu5f820432006-11-03 19:33:44 -0600173extern void ddr_enable_ecc(unsigned int dram_size);
174#endif
175int fixed_sdram(void);
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400176static int sdram_init(unsigned int base);
Dave Liu5f820432006-11-03 19:33:44 -0600177
Becky Bruce9973e3c2008-06-09 16:03:40 -0500178phys_size_t initdram(int board_type)
Dave Liu5f820432006-11-03 19:33:44 -0600179{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200180 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
Dave Liu5f820432006-11-03 19:33:44 -0600181 u32 msize = 0;
Anton Vorontsov034477b2009-09-16 23:21:57 +0400182 u32 lbc_sdram_size;
Dave Liu5f820432006-11-03 19:33:44 -0600183
184 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im)
185 return -1;
186
187 /* DDR SDRAM - Main SODIMM */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200188 im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
Dave Liu5f820432006-11-03 19:33:44 -0600189#if defined(CONFIG_SPD_EEPROM)
190 msize = spd_sdram();
191#else
192 msize = fixed_sdram();
193#endif
194
Peter Tyser9adda542009-06-30 17:15:50 -0500195#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
Dave Liu5f820432006-11-03 19:33:44 -0600196 /*
197 * Initialize DDR ECC byte
198 */
199 ddr_enable_ecc(msize * 1024 * 1024);
200#endif
201 /*
202 * Initialize SDRAM if it is on local bus.
203 */
Anton Vorontsov034477b2009-09-16 23:21:57 +0400204 lbc_sdram_size = sdram_init(msize * 1024 * 1024);
205 if (!msize)
206 msize = lbc_sdram_size;
Kim Phillipsbbea46f2007-08-16 22:52:48 -0500207
Dave Liu5f820432006-11-03 19:33:44 -0600208 /* return total bus SDRAM size(bytes) -- DDR */
209 return (msize * 1024 * 1024);
210}
211
212#if !defined(CONFIG_SPD_EEPROM)
213/*************************************************************************
214 * fixed sdram init -- doesn't use serial presence detect.
215 ************************************************************************/
216int fixed_sdram(void)
217{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200218 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
Dave Liu5f820432006-11-03 19:33:44 -0600219 u32 msize = 0;
220 u32 ddr_size;
221 u32 ddr_size_log2;
222
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200223 msize = CONFIG_SYS_DDR_SIZE;
Dave Liu5f820432006-11-03 19:33:44 -0600224 for (ddr_size = msize << 20, ddr_size_log2 = 0;
225 (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
226 if (ddr_size & 1) {
227 return -1;
228 }
229 }
230 im->sysconf.ddrlaw[0].ar =
231 LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200232#if (CONFIG_SYS_DDR_SIZE != 256)
Dave Liu5f820432006-11-03 19:33:44 -0600233#warning Currenly any ddr size other than 256 is not supported
234#endif
Xie Xiaobod61853c2007-02-14 18:27:17 +0800235#ifdef CONFIG_DDR_II
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200236 im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
237 im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
238 im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
239 im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
240 im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
241 im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
242 im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
243 im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
244 im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
245 im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
246 im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
247 im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL;
Xie Xiaobod61853c2007-02-14 18:27:17 +0800248#else
Dave Liu5f820432006-11-03 19:33:44 -0600249 im->ddr.csbnds[0].csbnds = 0x00000007;
250 im->ddr.csbnds[1].csbnds = 0x0008000f;
251
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200252 im->ddr.cs_config[0] = CONFIG_SYS_DDR_CONFIG;
253 im->ddr.cs_config[1] = CONFIG_SYS_DDR_CONFIG;
Dave Liu5f820432006-11-03 19:33:44 -0600254
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200255 im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
256 im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
257 im->ddr.sdram_cfg = CONFIG_SYS_DDR_CONTROL;
Dave Liu5f820432006-11-03 19:33:44 -0600258
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200259 im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
260 im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
Xie Xiaobod61853c2007-02-14 18:27:17 +0800261#endif
Dave Liu5f820432006-11-03 19:33:44 -0600262 udelay(200);
263 im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
264
265 return msize;
266}
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200267#endif /*!CONFIG_SYS_SPD_EEPROM */
Dave Liu5f820432006-11-03 19:33:44 -0600268
269int checkboard(void)
270{
271 puts("Board: Freescale MPC8360EMDS\n");
272 return 0;
273}
274
275/*
276 * if MPC8360EMDS is soldered with SDRAM
277 */
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400278#ifdef CONFIG_SYS_LB_SDRAM
Dave Liu5f820432006-11-03 19:33:44 -0600279/*
280 * Initialize SDRAM memory on the Local Bus.
281 */
282
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400283static int sdram_init(unsigned int base)
Dave Liu5f820432006-11-03 19:33:44 -0600284{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200285 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
Becky Brucef51cdaf2010-06-17 11:37:20 -0500286 fsl_lbc_t *lbc = LBC_BASE_ADDR;
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400287 const int sdram_size = CONFIG_SYS_LBC_SDRAM_SIZE * 1024 * 1024;
288 int rem = base % sdram_size;
289 uint *sdram_addr;
Dave Liu5f820432006-11-03 19:33:44 -0600290
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400291 /* window base address should be aligned to the window size */
292 if (rem)
293 base = base - rem + sdram_size;
294
295 sdram_addr = (uint *)base;
Dave Liu5f820432006-11-03 19:33:44 -0600296 /*
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400297 * Setup SDRAM Base and Option Registers
Dave Liu5f820432006-11-03 19:33:44 -0600298 */
Becky Brucef51cdaf2010-06-17 11:37:20 -0500299 set_lbc_br(2, base | CONFIG_SYS_BR2);
300 set_lbc_or(2, CONFIG_SYS_OR2);
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400301 immap->sysconf.lblaw[2].bar = base;
302 immap->sysconf.lblaw[2].ar = CONFIG_SYS_LBLAWAR2;
303
Dave Liu5f820432006-11-03 19:33:44 -0600304 /*setup mtrpt, lsrt and lbcr for LB bus */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200305 lbc->lbcr = CONFIG_SYS_LBC_LBCR;
306 lbc->mrtpr = CONFIG_SYS_LBC_MRTPR;
307 lbc->lsrt = CONFIG_SYS_LBC_LSRT;
Dave Liu5f820432006-11-03 19:33:44 -0600308 asm("sync");
309
310 /*
311 * Configure the SDRAM controller Machine Mode Register.
312 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200313 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_5; /* Normal Operation */
314 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_1; /* Precharge All Banks */
Dave Liu5f820432006-11-03 19:33:44 -0600315 asm("sync");
316 *sdram_addr = 0xff;
317 udelay(100);
318
319 /*
320 * We need do 8 times auto refresh operation.
321 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200322 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_2;
Dave Liu5f820432006-11-03 19:33:44 -0600323 asm("sync");
324 *sdram_addr = 0xff; /* 1 times */
325 udelay(100);
326 *sdram_addr = 0xff; /* 2 times */
327 udelay(100);
328 *sdram_addr = 0xff; /* 3 times */
329 udelay(100);
330 *sdram_addr = 0xff; /* 4 times */
331 udelay(100);
332 *sdram_addr = 0xff; /* 5 times */
333 udelay(100);
334 *sdram_addr = 0xff; /* 6 times */
335 udelay(100);
336 *sdram_addr = 0xff; /* 7 times */
337 udelay(100);
338 *sdram_addr = 0xff; /* 8 times */
339 udelay(100);
340
341 /* Mode register write operation */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200342 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_4;
Dave Liu5f820432006-11-03 19:33:44 -0600343 asm("sync");
344 *(sdram_addr + 0xcc) = 0xff;
345 udelay(100);
346
347 /* Normal operation */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200348 lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_5 | 0x40000000;
Dave Liu5f820432006-11-03 19:33:44 -0600349 asm("sync");
350 *sdram_addr = 0xff;
351 udelay(100);
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400352
353 /*
354 * In non-aligned case we don't [normally] use that memory because
355 * there is a hole.
356 */
357 if (rem)
358 return 0;
359 return CONFIG_SYS_LBC_SDRAM_SIZE;
Dave Liu5f820432006-11-03 19:33:44 -0600360}
361#else
Anton Vorontsov5c2ff322008-09-10 18:12:37 +0400362static int sdram_init(unsigned int base) { return 0; }
Dave Liu5f820432006-11-03 19:33:44 -0600363#endif
364
Kim Phillips3fde9e82007-08-15 22:30:33 -0500365#if defined(CONFIG_OF_BOARD_SETUP)
Anton Vorontsovda6eea02009-09-16 23:22:08 +0400366static void ft_board_fixup_qe_usb(void *blob, bd_t *bd)
367{
368 if (!hwconfig_subarg_cmp("qe_usb", "mode", "peripheral"))
369 return;
370
371 do_fixup_by_compat(blob, "fsl,mpc8323-qe-usb", "mode",
372 "peripheral", sizeof("peripheral"), 1);
373}
374
Kim Phillips3fde9e82007-08-15 22:30:33 -0500375void ft_board_setup(void *blob, bd_t *bd)
Kim Phillipsbf0b5422006-11-01 00:10:40 -0600376{
Kim Phillips3fde9e82007-08-15 22:30:33 -0500377 ft_cpu_setup(blob, bd);
Gerald Van Baren213bf8c2007-03-31 12:23:51 -0400378#ifdef CONFIG_PCI
379 ft_pci_setup(blob, bd);
380#endif
Anton Vorontsovda6eea02009-09-16 23:22:08 +0400381 ft_board_fixup_qe_usb(blob, bd);
Kim Phillips24f86842007-11-09 14:28:08 -0600382 /*
383 * mpc8360ea pb mds errata 2: RGMII timing
384 * if on mpc8360ea rev. 2.1,
385 * change both ucc phy-connection-types from rgmii-id to rgmii-rxid
386 */
Anton Vorontsov89da44c2009-09-16 23:21:59 +0400387 if (board_handle_erratum2()) {
Kim Phillips24f86842007-11-09 14:28:08 -0600388 int nodeoffset;
Kim Phillipsf6020822007-12-10 14:16:22 -0600389 const char *prop;
Kim Phillips363eea92008-01-15 09:51:12 -0600390 int path;
Kim Phillips24f86842007-11-09 14:28:08 -0600391
Kim Phillipsf09880e2008-01-14 16:14:46 -0600392 nodeoffset = fdt_path_offset(blob, "/aliases");
Kim Phillips24f86842007-11-09 14:28:08 -0600393 if (nodeoffset >= 0) {
Kim Phillips5b8bc602007-12-20 14:09:22 -0600394#if defined(CONFIG_HAS_ETH0)
395 /* fixup UCC 1 if using rgmii-id mode */
Kim Phillips363eea92008-01-15 09:51:12 -0600396 prop = fdt_getprop(blob, nodeoffset, "ethernet0", NULL);
397 if (prop) {
398 path = fdt_path_offset(blob, prop);
Kim Phillipsf09880e2008-01-14 16:14:46 -0600399 prop = fdt_getprop(blob, path,
400 "phy-connection-type", 0);
Kim Phillips5b8bc602007-12-20 14:09:22 -0600401 if (prop && (strcmp(prop, "rgmii-id") == 0))
Kumar Galaa1964ea2010-09-30 09:15:03 -0500402 fdt_fixup_phy_connection(blob, path,
Andy Fleming865ff852011-04-13 00:37:12 -0500403 PHY_INTERFACE_MODE_RGMII_RXID);
Kim Phillips5b8bc602007-12-20 14:09:22 -0600404 }
405#endif
406#if defined(CONFIG_HAS_ETH1)
407 /* fixup UCC 2 if using rgmii-id mode */
Kim Phillips363eea92008-01-15 09:51:12 -0600408 prop = fdt_getprop(blob, nodeoffset, "ethernet1", NULL);
409 if (prop) {
410 path = fdt_path_offset(blob, prop);
Kim Phillipsf09880e2008-01-14 16:14:46 -0600411 prop = fdt_getprop(blob, path,
412 "phy-connection-type", 0);
Kim Phillips5b8bc602007-12-20 14:09:22 -0600413 if (prop && (strcmp(prop, "rgmii-id") == 0))
Kumar Galaa1964ea2010-09-30 09:15:03 -0500414 fdt_fixup_phy_connection(blob, path,
Andy Fleming865ff852011-04-13 00:37:12 -0500415 PHY_INTERFACE_MODE_RGMII_RXID);
Kim Phillips5b8bc602007-12-20 14:09:22 -0600416 }
417#endif
Kim Phillips24f86842007-11-09 14:28:08 -0600418 }
419 }
Kim Phillipsbf0b5422006-11-01 00:10:40 -0600420}
Kim Phillips3fde9e82007-08-15 22:30:33 -0500421#endif