xref: /openbmc/u-boot/board/freescale/b4860qds/eth_b4860qds.c (revision 83d290c56fab2d38cd1ab4c4cc7099559c1d5046)
1*83d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
2b5b06fb7SYork Sun /*
3b5b06fb7SYork Sun  * Copyright 2012 Freescale Semiconductor, Inc.
4b5b06fb7SYork Sun  * Author: Sandeep Kumar Singh <sandeep@freescale.com>
5b5b06fb7SYork Sun  */
6b5b06fb7SYork Sun 
7b5b06fb7SYork Sun /* This file is based on board/freescale/corenet_ds/eth_superhydra.c */
8b5b06fb7SYork Sun 
9b5b06fb7SYork Sun /*
10b5b06fb7SYork Sun  * This file handles the board muxing between the Fman Ethernet MACs and
11b5b06fb7SYork Sun  * the RGMII/SGMII/XGMII PHYs on a Freescale B4860 "Centaur". The SGMII
12b5b06fb7SYork Sun  * PHYs are the two on-board 1Gb ports. There are no RGMII PHY on board.
13b5b06fb7SYork Sun  * The 10Gb XGMII PHY is provided via the XAUI riser card. There is only
14b5b06fb7SYork Sun  * one Fman device on B4860. The SERDES configuration is used to determine
15b5b06fb7SYork Sun  * where the SGMII and XAUI cards exist, and also which Fman MACs are routed
16b5b06fb7SYork Sun  * to which PHYs. So for a given Fman MAC, there is one and only PHY it
17b5b06fb7SYork Sun  * connects to. MACs cannot be routed to PHYs dynamically. This configuration
18b5b06fb7SYork Sun  * is done at boot time by reading SERDES protocol from RCW.
19b5b06fb7SYork Sun  */
20b5b06fb7SYork Sun 
21b5b06fb7SYork Sun #include <common.h>
22b5b06fb7SYork Sun #include <netdev.h>
23b5b06fb7SYork Sun #include <asm/fsl_serdes.h>
24b5b06fb7SYork Sun #include <fm_eth.h>
25b5b06fb7SYork Sun #include <fsl_mdio.h>
26b5b06fb7SYork Sun #include <malloc.h>
27b5b06fb7SYork Sun #include <fdt_support.h>
288225b2fdSShaohui Xie #include <fsl_dtsec.h>
29b5b06fb7SYork Sun 
30b5b06fb7SYork Sun #include "../common/ngpixis.h"
31b5b06fb7SYork Sun #include "../common/fman.h"
32b5b06fb7SYork Sun #include "../common/qixis.h"
33b5b06fb7SYork Sun #include "b4860qds_qixis.h"
34b5b06fb7SYork Sun 
35b5b06fb7SYork Sun #define EMI_NONE       0xFFFFFFFF
36b5b06fb7SYork Sun 
37b5b06fb7SYork Sun #ifdef CONFIG_FMAN_ENET
38b5b06fb7SYork Sun 
39b5b06fb7SYork Sun /*
40b5b06fb7SYork Sun  * Mapping of all 16 SERDES lanes to board slots. A value n(>0) will mean that
41b5b06fb7SYork Sun  * lane at index is mapped to slot number n. A value of '0' will mean
42b5b06fb7SYork Sun  * that the mapping must be determined dynamically, or that the lane maps to
43b5b06fb7SYork Sun  * something other than a board slot
44b5b06fb7SYork Sun  */
45b5b06fb7SYork Sun static u8 lane_to_slot[] = {
46b5b06fb7SYork Sun 	0, 0, 0, 0,
47b5b06fb7SYork Sun 	0, 0, 0, 0,
48b5b06fb7SYork Sun 	1, 1, 1, 1,
49b5b06fb7SYork Sun 	0, 0, 0, 0
50b5b06fb7SYork Sun };
51b5b06fb7SYork Sun 
52b5b06fb7SYork Sun /*
53b5b06fb7SYork Sun  * This function initializes the lane_to_slot[] array. It reads RCW to check
54b5b06fb7SYork Sun  * if Serdes2{E,F,G,H} is configured as slot 2 or as SFP and initializes
55b5b06fb7SYork Sun  * lane_to_slot[] accordingly
56b5b06fb7SYork Sun  */
initialize_lane_to_slot(void)57b5b06fb7SYork Sun static void initialize_lane_to_slot(void)
58b5b06fb7SYork Sun {
59b5b06fb7SYork Sun 	unsigned int  serdes2_prtcl;
60b5b06fb7SYork Sun 	ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
61b5b06fb7SYork Sun 	serdes2_prtcl = in_be32(&gur->rcwsr[4]) &
62b5b06fb7SYork Sun 		FSL_CORENET2_RCWSR4_SRDS2_PRTCL;
63b5b06fb7SYork Sun 	serdes2_prtcl >>= FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT;
64b5b06fb7SYork Sun 	debug("Initializing lane to slot: Serdes2 protocol: %x\n",
65b5b06fb7SYork Sun 			serdes2_prtcl);
66b5b06fb7SYork Sun 
67b5b06fb7SYork Sun 	switch (serdes2_prtcl) {
68c7d506d4Spoonam aggrwal 	case 0x17:
69b5b06fb7SYork Sun 	case 0x18:
70b5b06fb7SYork Sun 		/*
71b5b06fb7SYork Sun 		 * Configuration:
72b5b06fb7SYork Sun 		 * SERDES: 2
73b5b06fb7SYork Sun 		 * Lanes: A,B,C,D: SGMII
74b5b06fb7SYork Sun 		 * Lanes: E,F: Aur
75b5b06fb7SYork Sun 		 * Lanes: G,H: SRIO
76b5b06fb7SYork Sun 		 */
77b5b06fb7SYork Sun 	case 0x91:
78b5b06fb7SYork Sun 		/*
79b5b06fb7SYork Sun 		 * Configuration:
80b5b06fb7SYork Sun 		 * SERDES: 2
81b5b06fb7SYork Sun 		 * Lanes: A,B: SGMII
82b5b06fb7SYork Sun 		 * Lanes: C,D: SRIO2
83b5b06fb7SYork Sun 		 * Lanes: E,F,G,H: XAUI2
84b5b06fb7SYork Sun 		 */
85b5b06fb7SYork Sun 	case 0x93:
86b5b06fb7SYork Sun 		/*
87b5b06fb7SYork Sun 		 * Configuration:
88b5b06fb7SYork Sun 		 * SERDES: 2
89b5b06fb7SYork Sun 		 * Lanes: A,B,C,D: SGMII
90b5b06fb7SYork Sun 		 * Lanes: E,F,G,H: XAUI2
91b5b06fb7SYork Sun 		 */
92b5b06fb7SYork Sun 	case 0x98:
93b5b06fb7SYork Sun 		/*
94b5b06fb7SYork Sun 		 * Configuration:
95b5b06fb7SYork Sun 		 * SERDES: 2
96b5b06fb7SYork Sun 		 * Lanes: A,B,C,D: XAUI2
97b5b06fb7SYork Sun 		 * Lanes: E,F,G,H: XAUI2
98b5b06fb7SYork Sun 		 */
99b5b06fb7SYork Sun 	case 0x9a:
100b5b06fb7SYork Sun 		/*
101b5b06fb7SYork Sun 		 * Configuration:
102b5b06fb7SYork Sun 		 * SERDES: 2
103b5b06fb7SYork Sun 		 * Lanes: A,B: PCI
104b5b06fb7SYork Sun 		 * Lanes: C,D: SGMII
105b5b06fb7SYork Sun 		 * Lanes: E,F,G,H: XAUI2
106b5b06fb7SYork Sun 		 */
107b5b06fb7SYork Sun 	case 0x9e:
108b5b06fb7SYork Sun 		/*
109b5b06fb7SYork Sun 		 * Configuration:
110b5b06fb7SYork Sun 		 * SERDES: 2
111b5b06fb7SYork Sun 		 * Lanes: A,B,C,D: PCI
112b5b06fb7SYork Sun 		 * Lanes: E,F,G,H: XAUI2
113b5b06fb7SYork Sun 		 */
114f1d8074cSShaveta Leekha 	case 0xb1:
115b5b06fb7SYork Sun 	case 0xb2:
116f1d8074cSShaveta Leekha 	case 0x8c:
117f1d8074cSShaveta Leekha 	case 0x8d:
118b5b06fb7SYork Sun 		/*
119b5b06fb7SYork Sun 		 * Configuration:
120b5b06fb7SYork Sun 		 * SERDES: 2
121b5b06fb7SYork Sun 		 * Lanes: A,B,C,D: PCI
122b5b06fb7SYork Sun 		 * Lanes: E,F: SGMII 3&4
123b5b06fb7SYork Sun 		 * Lanes: G,H: XFI
124b5b06fb7SYork Sun 		 */
125b5b06fb7SYork Sun 	case 0xc2:
126b5b06fb7SYork Sun 		/*
127b5b06fb7SYork Sun 		 * Configuration:
128b5b06fb7SYork Sun 		 * SERDES: 2
129b5b06fb7SYork Sun 		 * Lanes: A,B: SGMII
130b5b06fb7SYork Sun 		 * Lanes: C,D: SRIO2
131b5b06fb7SYork Sun 		 * Lanes: E,F,G,H: XAUI2
132b5b06fb7SYork Sun 		 */
133b5b06fb7SYork Sun 		lane_to_slot[12] = 2;
134b5b06fb7SYork Sun 		lane_to_slot[13] = lane_to_slot[12];
135b5b06fb7SYork Sun 		lane_to_slot[14] = lane_to_slot[12];
136b5b06fb7SYork Sun 		lane_to_slot[15] = lane_to_slot[12];
137b5b06fb7SYork Sun 		break;
138b5b06fb7SYork Sun 
139b5b06fb7SYork Sun 	default:
140b5b06fb7SYork Sun 		printf("Fman: Unsupported SerDes2 Protocol 0x%02x\n",
141b5b06fb7SYork Sun 				serdes2_prtcl);
142b5b06fb7SYork Sun 			break;
143b5b06fb7SYork Sun 	}
144b5b06fb7SYork Sun 	return;
145b5b06fb7SYork Sun }
146b5b06fb7SYork Sun 
147b5b06fb7SYork Sun #endif /* #ifdef CONFIG_FMAN_ENET */
148b5b06fb7SYork Sun 
board_eth_init(bd_t * bis)149b5b06fb7SYork Sun int board_eth_init(bd_t *bis)
150b5b06fb7SYork Sun {
151b5b06fb7SYork Sun #ifdef CONFIG_FMAN_ENET
152b5b06fb7SYork Sun 	struct memac_mdio_info memac_mdio_info;
153b5b06fb7SYork Sun 	struct memac_mdio_info tg_memac_mdio_info;
154b5b06fb7SYork Sun 	unsigned int i;
155b5b06fb7SYork Sun 	unsigned int  serdes1_prtcl, serdes2_prtcl;
156ffee1ddeSZhao Qiang 	int qsgmii;
157ffee1ddeSZhao Qiang 	struct mii_dev *bus;
158b5b06fb7SYork Sun 	ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
159b5b06fb7SYork Sun 	serdes1_prtcl = in_be32(&gur->rcwsr[4]) &
160b5b06fb7SYork Sun 		FSL_CORENET2_RCWSR4_SRDS1_PRTCL;
161b5b06fb7SYork Sun 	if (!serdes1_prtcl) {
162b5b06fb7SYork Sun 		printf("SERDES1 is not enabled\n");
163b5b06fb7SYork Sun 		return 0;
164b5b06fb7SYork Sun 	}
165b5b06fb7SYork Sun 	serdes1_prtcl >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT;
166b5b06fb7SYork Sun 	debug("Using SERDES1 Protocol: 0x%x:\n", serdes1_prtcl);
167b5b06fb7SYork Sun 
168b5b06fb7SYork Sun 	serdes2_prtcl = in_be32(&gur->rcwsr[4]) &
169b5b06fb7SYork Sun 		FSL_CORENET2_RCWSR4_SRDS2_PRTCL;
170b5b06fb7SYork Sun 	if (!serdes2_prtcl) {
171b5b06fb7SYork Sun 		printf("SERDES2 is not enabled\n");
172b5b06fb7SYork Sun 		return 0;
173b5b06fb7SYork Sun 	}
174b5b06fb7SYork Sun 	serdes2_prtcl >>= FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT;
175b5b06fb7SYork Sun 	debug("Using SERDES2 Protocol: 0x%x:\n", serdes2_prtcl);
176b5b06fb7SYork Sun 
177b5b06fb7SYork Sun 	printf("Initializing Fman\n");
178b5b06fb7SYork Sun 
179b5b06fb7SYork Sun 	initialize_lane_to_slot();
180b5b06fb7SYork Sun 
181b5b06fb7SYork Sun 	memac_mdio_info.regs =
182b5b06fb7SYork Sun 		(struct memac_mdio_controller *)CONFIG_SYS_FM1_DTSEC_MDIO_ADDR;
183b5b06fb7SYork Sun 	memac_mdio_info.name = DEFAULT_FM_MDIO_NAME;
184b5b06fb7SYork Sun 
185b5b06fb7SYork Sun 	/* Register the real 1G MDIO bus */
186b5b06fb7SYork Sun 	fm_memac_mdio_init(bis, &memac_mdio_info);
187b5b06fb7SYork Sun 
188b5b06fb7SYork Sun 	tg_memac_mdio_info.regs =
189b5b06fb7SYork Sun 		(struct memac_mdio_controller *)CONFIG_SYS_FM1_TGEC_MDIO_ADDR;
190b5b06fb7SYork Sun 	tg_memac_mdio_info.name = DEFAULT_FM_TGEC_MDIO_NAME;
191b5b06fb7SYork Sun 
192b5b06fb7SYork Sun 	/* Register the real 10G MDIO bus */
193b5b06fb7SYork Sun 	fm_memac_mdio_init(bis, &tg_memac_mdio_info);
194b5b06fb7SYork Sun 
195b5b06fb7SYork Sun 	/*
196b5b06fb7SYork Sun 	 * Program the two on board DTSEC PHY addresses assuming that they are
197b5b06fb7SYork Sun 	 * all SGMII. RGMII is not supported on this board. Setting SGMII 5 and
198b5b06fb7SYork Sun 	 * 6 to on board SGMII phys
199b5b06fb7SYork Sun 	 */
200f1d8074cSShaveta Leekha 	fm_info_set_phy_address(FM1_DTSEC5, CONFIG_SYS_FM1_ONBOARD_PHY1_ADDR);
201f1d8074cSShaveta Leekha 	fm_info_set_phy_address(FM1_DTSEC6, CONFIG_SYS_FM1_ONBOARD_PHY2_ADDR);
202b5b06fb7SYork Sun 
203b5b06fb7SYork Sun 	switch (serdes1_prtcl) {
204c7d506d4Spoonam aggrwal 	case 0x29:
205b5b06fb7SYork Sun 	case 0x2a:
206b5b06fb7SYork Sun 		/* Serdes 1: A-B SGMII, Configuring DTSEC 5 and 6 */
207f1d8074cSShaveta Leekha 		debug("Set phy addresses for FM1_DTSEC5:%x, FM1_DTSEC6:%x\n",
208f1d8074cSShaveta Leekha 		      CONFIG_SYS_FM1_ONBOARD_PHY1_ADDR,
209f1d8074cSShaveta Leekha 		      CONFIG_SYS_FM1_ONBOARD_PHY2_ADDR);
210b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC5,
211f1d8074cSShaveta Leekha 				CONFIG_SYS_FM1_ONBOARD_PHY1_ADDR);
212b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC6,
213f1d8074cSShaveta Leekha 				CONFIG_SYS_FM1_ONBOARD_PHY2_ADDR);
214b5b06fb7SYork Sun 		break;
215b41f192bSYork Sun #ifdef CONFIG_ARCH_B4420
216c7d506d4Spoonam aggrwal 	case 0x17:
217b5b06fb7SYork Sun 	case 0x18:
218b5b06fb7SYork Sun 		/* Serdes 1: A-D SGMII, Configuring on board dual SGMII Phy */
219f1d8074cSShaveta Leekha 		debug("Set phy addresses for FM1_DTSEC3:%x, FM1_DTSEC4:%x\n",
220f1d8074cSShaveta Leekha 		      CONFIG_SYS_FM1_ONBOARD_PHY1_ADDR,
221f1d8074cSShaveta Leekha 		      CONFIG_SYS_FM1_ONBOARD_PHY2_ADDR);
222b5b06fb7SYork Sun 		/* Fixing Serdes clock by programming FPGA register */
223b5b06fb7SYork Sun 		QIXIS_WRITE(brdcfg[4], QIXIS_SRDS1CLK_125);
224b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC3,
225f1d8074cSShaveta Leekha 				CONFIG_SYS_FM1_ONBOARD_PHY1_ADDR);
226b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC4,
227f1d8074cSShaveta Leekha 				CONFIG_SYS_FM1_ONBOARD_PHY2_ADDR);
228b5b06fb7SYork Sun 		break;
229b5b06fb7SYork Sun #endif
230b5b06fb7SYork Sun 	default:
231b5b06fb7SYork Sun 		printf("Fman:  Unsupported SerDes1 Protocol 0x%02x\n",
232b5b06fb7SYork Sun 				serdes1_prtcl);
233b5b06fb7SYork Sun 		break;
234b5b06fb7SYork Sun 	}
235b5b06fb7SYork Sun 	switch (serdes2_prtcl) {
236c7d506d4Spoonam aggrwal 	case 0x17:
237b5b06fb7SYork Sun 	case 0x18:
238f1d8074cSShaveta Leekha 		debug("Set phy address on SGMII Riser for FM1_DTSEC1:%x\n",
239f1d8074cSShaveta Leekha 		      CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR);
240b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC1,
241b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR);
242b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC2,
243b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC2_RISER_PHY_ADDR);
244b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC3,
245b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC3_RISER_PHY_ADDR);
246b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC4,
247b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC4_RISER_PHY_ADDR);
248b5b06fb7SYork Sun 		break;
249c7d506d4Spoonam aggrwal 	case 0x48:
250b5b06fb7SYork Sun 	case 0x49:
251f1d8074cSShaveta Leekha 		debug("Set phy address on SGMII Riser for FM1_DTSEC1:%x\n",
252f1d8074cSShaveta Leekha 		      CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR);
253b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC1,
254b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR);
255b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC2,
256b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC2_RISER_PHY_ADDR);
257b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC3,
258b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC3_RISER_PHY_ADDR);
259b5b06fb7SYork Sun 		break;
260f1d8074cSShaveta Leekha 	case 0xb1:
261b5b06fb7SYork Sun 	case 0xb2:
262f1d8074cSShaveta Leekha 	case 0x8c:
263f1d8074cSShaveta Leekha 	case 0x8d:
264f1d8074cSShaveta Leekha 		debug("Set phy addresses on SGMII Riser for FM1_DTSEC1:%x\n",
265f1d8074cSShaveta Leekha 		      CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR);
266b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC3,
267b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR);
268b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC4,
269b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC2_RISER_PHY_ADDR);
27089b94d85SShaohui Xie 		/*
271a187559eSBin Meng 		 * XFI does not need a PHY to work, but to make U-Boot
27289b94d85SShaohui Xie 		 * happy, assign a fake PHY address for a XFI port.
27389b94d85SShaohui Xie 		 */
27489b94d85SShaohui Xie 		fm_info_set_phy_address(FM1_10GEC1, 0);
27589b94d85SShaohui Xie 		fm_info_set_phy_address(FM1_10GEC2, 1);
276b5b06fb7SYork Sun 		break;
27716d88f41SSuresh Gupta 	case 0x98:
27816d88f41SSuresh Gupta 		/* XAUI in Slot1 and Slot2 */
279f1d8074cSShaveta Leekha 		debug("Set phy address of AMC2PEX-2S for FM1_10GEC1:%x\n",
28016d88f41SSuresh Gupta 		      CONFIG_SYS_FM1_10GEC1_PHY_ADDR);
28116d88f41SSuresh Gupta 		fm_info_set_phy_address(FM1_10GEC1,
28216d88f41SSuresh Gupta 					CONFIG_SYS_FM1_10GEC1_PHY_ADDR);
283f1d8074cSShaveta Leekha 		debug("Set phy address of AMC2PEX-2S for FM1_10GEC2:%x\n",
28416d88f41SSuresh Gupta 		      CONFIG_SYS_FM1_10GEC2_PHY_ADDR);
28516d88f41SSuresh Gupta 		fm_info_set_phy_address(FM1_10GEC2,
28616d88f41SSuresh Gupta 					CONFIG_SYS_FM1_10GEC2_PHY_ADDR);
28716d88f41SSuresh Gupta 		break;
28816d88f41SSuresh Gupta 	case 0x9E:
28916d88f41SSuresh Gupta 		/* XAUI in Slot2 */
290f1d8074cSShaveta Leekha 		debug("Sett phy address of AMC2PEX-2S for FM1_10GEC2:%x\n",
29116d88f41SSuresh Gupta 		      CONFIG_SYS_FM1_10GEC2_PHY_ADDR);
29216d88f41SSuresh Gupta 		fm_info_set_phy_address(FM1_10GEC2,
29316d88f41SSuresh Gupta 					CONFIG_SYS_FM1_10GEC2_PHY_ADDR);
29416d88f41SSuresh Gupta 		break;
295b5b06fb7SYork Sun 	default:
296b5b06fb7SYork Sun 		printf("Fman:  Unsupported SerDes2 Protocol 0x%02x\n",
297b5b06fb7SYork Sun 				serdes2_prtcl);
298b5b06fb7SYork Sun 		break;
299b5b06fb7SYork Sun 	}
300b5b06fb7SYork Sun 
301ffee1ddeSZhao Qiang 	/*set PHY address for QSGMII Riser Card on slot2*/
302ffee1ddeSZhao Qiang 	bus = miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME);
303ffee1ddeSZhao Qiang 	qsgmii = is_qsgmii_riser_card(bus, PHY_BASE_ADDR, PORT_NUM, REGNUM);
304ffee1ddeSZhao Qiang 
305ffee1ddeSZhao Qiang 	if (qsgmii) {
306ffee1ddeSZhao Qiang 		switch (serdes2_prtcl) {
307ffee1ddeSZhao Qiang 		case 0xb2:
308ffee1ddeSZhao Qiang 		case 0x8d:
309ffee1ddeSZhao Qiang 			fm_info_set_phy_address(FM1_DTSEC3, PHY_BASE_ADDR);
310ffee1ddeSZhao Qiang 			fm_info_set_phy_address(FM1_DTSEC4, PHY_BASE_ADDR + 1);
311ffee1ddeSZhao Qiang 			break;
312ffee1ddeSZhao Qiang 		default:
313ffee1ddeSZhao Qiang 			break;
314ffee1ddeSZhao Qiang 		}
315ffee1ddeSZhao Qiang 	}
316ffee1ddeSZhao Qiang 
317b5b06fb7SYork Sun 	for (i = FM1_DTSEC1; i < FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) {
318b5b06fb7SYork Sun 		int idx = i - FM1_DTSEC1;
319b5b06fb7SYork Sun 
320b5b06fb7SYork Sun 		switch (fm_info_get_enet_if(i)) {
321b5b06fb7SYork Sun 		case PHY_INTERFACE_MODE_SGMII:
322b5b06fb7SYork Sun 			fm_info_set_mdio(i,
323b5b06fb7SYork Sun 				miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
324b5b06fb7SYork Sun 			break;
325b5b06fb7SYork Sun 		case PHY_INTERFACE_MODE_NONE:
326b5b06fb7SYork Sun 			fm_info_set_phy_address(i, 0);
327b5b06fb7SYork Sun 			break;
328b5b06fb7SYork Sun 		default:
329b5b06fb7SYork Sun 			printf("Fman1: DTSEC%u set to unknown interface %i\n",
330b5b06fb7SYork Sun 					idx + 1, fm_info_get_enet_if(i));
331b5b06fb7SYork Sun 			fm_info_set_phy_address(i, 0);
332b5b06fb7SYork Sun 			break;
333b5b06fb7SYork Sun 		}
334b5b06fb7SYork Sun 	}
335b5b06fb7SYork Sun 
33616d88f41SSuresh Gupta 	for (i = FM1_10GEC1; i < FM1_10GEC1 + CONFIG_SYS_NUM_FM1_10GEC; i++) {
33716d88f41SSuresh Gupta 		int idx = i - FM1_10GEC1;
33816d88f41SSuresh Gupta 
33916d88f41SSuresh Gupta 		switch (fm_info_get_enet_if(i)) {
34016d88f41SSuresh Gupta 		case PHY_INTERFACE_MODE_XGMII:
34116d88f41SSuresh Gupta 			fm_info_set_mdio(i,
342f1d8074cSShaveta Leekha 					 miiphy_get_dev_by_name
343f1d8074cSShaveta Leekha 					 (DEFAULT_FM_TGEC_MDIO_NAME));
344f1d8074cSShaveta Leekha 			break;
345f1d8074cSShaveta Leekha 		case PHY_INTERFACE_MODE_NONE:
346f1d8074cSShaveta Leekha 			fm_info_set_phy_address(i, 0);
34716d88f41SSuresh Gupta 			break;
34816d88f41SSuresh Gupta 		default:
349f1d8074cSShaveta Leekha 			printf("Fman1: TGEC%u set to unknown interface %i\n",
35016d88f41SSuresh Gupta 			       idx + 1, fm_info_get_enet_if(i));
35116d88f41SSuresh Gupta 			fm_info_set_phy_address(i, 0);
35216d88f41SSuresh Gupta 			break;
35316d88f41SSuresh Gupta 		}
35416d88f41SSuresh Gupta 	}
35516d88f41SSuresh Gupta 
356b5b06fb7SYork Sun 	cpu_eth_init(bis);
357b5b06fb7SYork Sun #endif
358b5b06fb7SYork Sun 
359b5b06fb7SYork Sun 	return pci_eth_init(bis);
360b5b06fb7SYork Sun }
361b5b06fb7SYork Sun 
board_ft_fman_fixup_port(void * fdt,char * compat,phys_addr_t addr,enum fm_port port,int offset)362b5b06fb7SYork Sun void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr,
363b5b06fb7SYork Sun 			      enum fm_port port, int offset)
364b5b06fb7SYork Sun {
365b5b06fb7SYork Sun 	int phy;
366b5b06fb7SYork Sun 	char alias[32];
36790e80dc6SShaohui Xie 	struct fixed_link f_link;
36890e80dc6SShaohui Xie 	ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
36990e80dc6SShaohui Xie 	u32 prtcl2 = in_be32(&gur->rcwsr[4]) & FSL_CORENET2_RCWSR4_SRDS2_PRTCL;
37090e80dc6SShaohui Xie 
37190e80dc6SShaohui Xie 	prtcl2 >>= FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT;
372b5b06fb7SYork Sun 
373b5b06fb7SYork Sun 	if (fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_SGMII) {
374b5b06fb7SYork Sun 		phy = fm_info_get_phy_address(port);
375b5b06fb7SYork Sun 
376b5b06fb7SYork Sun 		sprintf(alias, "phy_sgmii_%x", phy);
377b5b06fb7SYork Sun 		fdt_set_phy_handle(fdt, compat, addr, alias);
378f1d8074cSShaveta Leekha 		fdt_status_okay_by_alias(fdt, alias);
37990e80dc6SShaohui Xie 	} else if (fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_XGMII) {
38090e80dc6SShaohui Xie 		/* check if it's XFI interface for 10g */
38190e80dc6SShaohui Xie 		switch (prtcl2) {
38290e80dc6SShaohui Xie 		case 0x80:
38390e80dc6SShaohui Xie 		case 0x81:
38490e80dc6SShaohui Xie 		case 0x82:
38590e80dc6SShaohui Xie 		case 0x83:
38690e80dc6SShaohui Xie 		case 0x84:
38790e80dc6SShaohui Xie 		case 0x85:
38890e80dc6SShaohui Xie 		case 0x86:
38990e80dc6SShaohui Xie 		case 0x87:
39090e80dc6SShaohui Xie 		case 0x88:
39190e80dc6SShaohui Xie 		case 0x89:
39290e80dc6SShaohui Xie 		case 0x8a:
39390e80dc6SShaohui Xie 		case 0x8b:
39490e80dc6SShaohui Xie 		case 0x8c:
39590e80dc6SShaohui Xie 		case 0x8d:
39690e80dc6SShaohui Xie 		case 0x8e:
39790e80dc6SShaohui Xie 		case 0xb1:
39890e80dc6SShaohui Xie 		case 0xb2:
39990e80dc6SShaohui Xie 			f_link.phy_id = port;
40090e80dc6SShaohui Xie 			f_link.duplex = 1;
40190e80dc6SShaohui Xie 			f_link.link_speed = 10000;
40290e80dc6SShaohui Xie 			f_link.pause = 0;
40390e80dc6SShaohui Xie 			f_link.asym_pause = 0;
40490e80dc6SShaohui Xie 
40590e80dc6SShaohui Xie 			fdt_delprop(fdt, offset, "phy-handle");
40690e80dc6SShaohui Xie 			fdt_setprop(fdt, offset, "fixed-link", &f_link,
40790e80dc6SShaohui Xie 				    sizeof(f_link));
40890e80dc6SShaohui Xie 			break;
409e2544e7aSSuresh Gupta 		case 0x98: /* XAUI interface */
410192bc694SBen Whitten 			strcpy(alias, "phy_xaui_slot1");
411e2544e7aSSuresh Gupta 			fdt_status_okay_by_alias(fdt, alias);
412e2544e7aSSuresh Gupta 
413192bc694SBen Whitten 			strcpy(alias, "phy_xaui_slot2");
414e2544e7aSSuresh Gupta 			fdt_status_okay_by_alias(fdt, alias);
415e2544e7aSSuresh Gupta 			break;
416e2544e7aSSuresh Gupta 		case 0x9e: /* XAUI interface */
417e2544e7aSSuresh Gupta 		case 0x9a:
418e2544e7aSSuresh Gupta 		case 0x93:
419e2544e7aSSuresh Gupta 		case 0x91:
420192bc694SBen Whitten 			strcpy(alias, "phy_xaui_slot1");
421e2544e7aSSuresh Gupta 			fdt_status_okay_by_alias(fdt, alias);
422e2544e7aSSuresh Gupta 			break;
423e2544e7aSSuresh Gupta 		case 0x97: /* XAUI interface */
424e2544e7aSSuresh Gupta 		case 0xc3:
425192bc694SBen Whitten 			strcpy(alias, "phy_xaui_slot2");
426e2544e7aSSuresh Gupta 			fdt_status_okay_by_alias(fdt, alias);
427e2544e7aSSuresh Gupta 			break;
42890e80dc6SShaohui Xie 		default:
42990e80dc6SShaohui Xie 			break;
43090e80dc6SShaohui Xie 		}
431b5b06fb7SYork Sun 	}
432b5b06fb7SYork Sun }
433b5b06fb7SYork Sun 
434f1d8074cSShaveta Leekha /*
435f1d8074cSShaveta Leekha  * Set status to disabled for unused ethernet node
436f1d8074cSShaveta Leekha  */
fdt_fixup_board_enet(void * fdt)437b5b06fb7SYork Sun void fdt_fixup_board_enet(void *fdt)
438b5b06fb7SYork Sun {
439b5b06fb7SYork Sun 	int i;
440b5b06fb7SYork Sun 	char alias[32];
441b5b06fb7SYork Sun 
442f1d8074cSShaveta Leekha 	for (i = FM1_DTSEC1; i <= FM1_10GEC2; i++) {
443b5b06fb7SYork Sun 		switch (fm_info_get_enet_if(i)) {
444b5b06fb7SYork Sun 		case PHY_INTERFACE_MODE_NONE:
445b5b06fb7SYork Sun 			sprintf(alias, "ethernet%u", i);
446b5b06fb7SYork Sun 			fdt_status_disabled_by_alias(fdt, alias);
447b5b06fb7SYork Sun 			break;
448b5b06fb7SYork Sun 		default:
449b5b06fb7SYork Sun 			break;
450b5b06fb7SYork Sun 		}
451b5b06fb7SYork Sun 	}
452b5b06fb7SYork Sun }
453