xref: /openbmc/u-boot/board/freescale/b4860qds/eth_b4860qds.c (revision b5b06fb7b04a93ea48638d4d2ba1932051a28f64)
1*b5b06fb7SYork Sun /*
2*b5b06fb7SYork Sun  * Copyright 2012 Freescale Semiconductor, Inc.
3*b5b06fb7SYork Sun  * Author: Sandeep Kumar Singh <sandeep@freescale.com>
4*b5b06fb7SYork Sun  *
5*b5b06fb7SYork Sun  * See file CREDITS for list of people who contributed to this
6*b5b06fb7SYork Sun  * project.
7*b5b06fb7SYork Sun  *
8*b5b06fb7SYork Sun  * This program is free software; you can redistribute it and/or
9*b5b06fb7SYork Sun  * modify it under the terms of the GNU General Public License as
10*b5b06fb7SYork Sun  * published by the Free Software Foundation; either version 2 of
11*b5b06fb7SYork Sun  * the License, or (at your option) any later version.
12*b5b06fb7SYork Sun  *
13*b5b06fb7SYork Sun  * This program is distributed in the hope that it will be useful,
14*b5b06fb7SYork Sun  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15*b5b06fb7SYork Sun  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16*b5b06fb7SYork Sun  * GNU General Public License for more details.
17*b5b06fb7SYork Sun  *
18*b5b06fb7SYork Sun  * You should have received a copy of the GNU General Public License
19*b5b06fb7SYork Sun  * along with this program; if not, write to the Free Software
20*b5b06fb7SYork Sun  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21*b5b06fb7SYork Sun  * MA 02111-1307 USA
22*b5b06fb7SYork Sun  */
23*b5b06fb7SYork Sun 
24*b5b06fb7SYork Sun /* This file is based on board/freescale/corenet_ds/eth_superhydra.c */
25*b5b06fb7SYork Sun 
26*b5b06fb7SYork Sun /*
27*b5b06fb7SYork Sun  * This file handles the board muxing between the Fman Ethernet MACs and
28*b5b06fb7SYork Sun  * the RGMII/SGMII/XGMII PHYs on a Freescale B4860 "Centaur". The SGMII
29*b5b06fb7SYork Sun  * PHYs are the two on-board 1Gb ports. There are no RGMII PHY on board.
30*b5b06fb7SYork Sun  * The 10Gb XGMII PHY is provided via the XAUI riser card. There is only
31*b5b06fb7SYork Sun  * one Fman device on B4860. The SERDES configuration is used to determine
32*b5b06fb7SYork Sun  * where the SGMII and XAUI cards exist, and also which Fman MACs are routed
33*b5b06fb7SYork Sun  * to which PHYs. So for a given Fman MAC, there is one and only PHY it
34*b5b06fb7SYork Sun  * connects to. MACs cannot be routed to PHYs dynamically. This configuration
35*b5b06fb7SYork Sun  * is done at boot time by reading SERDES protocol from RCW.
36*b5b06fb7SYork Sun  */
37*b5b06fb7SYork Sun 
38*b5b06fb7SYork Sun #include <common.h>
39*b5b06fb7SYork Sun #include <netdev.h>
40*b5b06fb7SYork Sun #include <asm/fsl_serdes.h>
41*b5b06fb7SYork Sun #include <fm_eth.h>
42*b5b06fb7SYork Sun #include <fsl_mdio.h>
43*b5b06fb7SYork Sun #include <malloc.h>
44*b5b06fb7SYork Sun #include <fdt_support.h>
45*b5b06fb7SYork Sun #include <asm/fsl_dtsec.h>
46*b5b06fb7SYork Sun 
47*b5b06fb7SYork Sun #include "../common/ngpixis.h"
48*b5b06fb7SYork Sun #include "../common/fman.h"
49*b5b06fb7SYork Sun #include "../common/qixis.h"
50*b5b06fb7SYork Sun #include "b4860qds_qixis.h"
51*b5b06fb7SYork Sun 
52*b5b06fb7SYork Sun #define EMI_NONE       0xFFFFFFFF
53*b5b06fb7SYork Sun 
54*b5b06fb7SYork Sun #ifdef CONFIG_FMAN_ENET
55*b5b06fb7SYork Sun 
56*b5b06fb7SYork Sun /*
57*b5b06fb7SYork Sun  * Mapping of all 16 SERDES lanes to board slots. A value n(>0) will mean that
58*b5b06fb7SYork Sun  * lane at index is mapped to slot number n. A value of '0' will mean
59*b5b06fb7SYork Sun  * that the mapping must be determined dynamically, or that the lane maps to
60*b5b06fb7SYork Sun  * something other than a board slot
61*b5b06fb7SYork Sun  */
62*b5b06fb7SYork Sun static u8 lane_to_slot[] = {
63*b5b06fb7SYork Sun 	0, 0, 0, 0,
64*b5b06fb7SYork Sun 	0, 0, 0, 0,
65*b5b06fb7SYork Sun 	1, 1, 1, 1,
66*b5b06fb7SYork Sun 	0, 0, 0, 0
67*b5b06fb7SYork Sun };
68*b5b06fb7SYork Sun 
69*b5b06fb7SYork Sun /*
70*b5b06fb7SYork Sun  * This function initializes the lane_to_slot[] array. It reads RCW to check
71*b5b06fb7SYork Sun  * if Serdes2{E,F,G,H} is configured as slot 2 or as SFP and initializes
72*b5b06fb7SYork Sun  * lane_to_slot[] accordingly
73*b5b06fb7SYork Sun  */
74*b5b06fb7SYork Sun static void initialize_lane_to_slot(void)
75*b5b06fb7SYork Sun {
76*b5b06fb7SYork Sun 	unsigned int  serdes2_prtcl;
77*b5b06fb7SYork Sun 	ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
78*b5b06fb7SYork Sun 	serdes2_prtcl = in_be32(&gur->rcwsr[4]) &
79*b5b06fb7SYork Sun 		FSL_CORENET2_RCWSR4_SRDS2_PRTCL;
80*b5b06fb7SYork Sun 	serdes2_prtcl >>= FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT;
81*b5b06fb7SYork Sun 	debug("Initializing lane to slot: Serdes2 protocol: %x\n",
82*b5b06fb7SYork Sun 			serdes2_prtcl);
83*b5b06fb7SYork Sun 
84*b5b06fb7SYork Sun 	switch (serdes2_prtcl) {
85*b5b06fb7SYork Sun 	case 0x18:
86*b5b06fb7SYork Sun 		/*
87*b5b06fb7SYork Sun 		 * Configuration:
88*b5b06fb7SYork Sun 		 * SERDES: 2
89*b5b06fb7SYork Sun 		 * Lanes: A,B,C,D: SGMII
90*b5b06fb7SYork Sun 		 * Lanes: E,F: Aur
91*b5b06fb7SYork Sun 		 * Lanes: G,H: SRIO
92*b5b06fb7SYork Sun 		 */
93*b5b06fb7SYork Sun 	case 0x91:
94*b5b06fb7SYork Sun 		/*
95*b5b06fb7SYork Sun 		 * Configuration:
96*b5b06fb7SYork Sun 		 * SERDES: 2
97*b5b06fb7SYork Sun 		 * Lanes: A,B: SGMII
98*b5b06fb7SYork Sun 		 * Lanes: C,D: SRIO2
99*b5b06fb7SYork Sun 		 * Lanes: E,F,G,H: XAUI2
100*b5b06fb7SYork Sun 		 */
101*b5b06fb7SYork Sun 	case 0x93:
102*b5b06fb7SYork Sun 		/*
103*b5b06fb7SYork Sun 		 * Configuration:
104*b5b06fb7SYork Sun 		 * SERDES: 2
105*b5b06fb7SYork Sun 		 * Lanes: A,B,C,D: SGMII
106*b5b06fb7SYork Sun 		 * Lanes: E,F,G,H: XAUI2
107*b5b06fb7SYork Sun 		 */
108*b5b06fb7SYork Sun 	case 0x98:
109*b5b06fb7SYork Sun 		/*
110*b5b06fb7SYork Sun 		 * Configuration:
111*b5b06fb7SYork Sun 		 * SERDES: 2
112*b5b06fb7SYork Sun 		 * Lanes: A,B,C,D: XAUI2
113*b5b06fb7SYork Sun 		 * Lanes: E,F,G,H: XAUI2
114*b5b06fb7SYork Sun 		 */
115*b5b06fb7SYork Sun 	case 0x9a:
116*b5b06fb7SYork Sun 		/*
117*b5b06fb7SYork Sun 		 * Configuration:
118*b5b06fb7SYork Sun 		 * SERDES: 2
119*b5b06fb7SYork Sun 		 * Lanes: A,B: PCI
120*b5b06fb7SYork Sun 		 * Lanes: C,D: SGMII
121*b5b06fb7SYork Sun 		 * Lanes: E,F,G,H: XAUI2
122*b5b06fb7SYork Sun 		 */
123*b5b06fb7SYork Sun 	case 0x9e:
124*b5b06fb7SYork Sun 		/*
125*b5b06fb7SYork Sun 		 * Configuration:
126*b5b06fb7SYork Sun 		 * SERDES: 2
127*b5b06fb7SYork Sun 		 * Lanes: A,B,C,D: PCI
128*b5b06fb7SYork Sun 		 * Lanes: E,F,G,H: XAUI2
129*b5b06fb7SYork Sun 		 */
130*b5b06fb7SYork Sun 	case 0xb2:
131*b5b06fb7SYork Sun 		/*
132*b5b06fb7SYork Sun 		 * Configuration:
133*b5b06fb7SYork Sun 		 * SERDES: 2
134*b5b06fb7SYork Sun 		 * Lanes: A,B,C,D: PCI
135*b5b06fb7SYork Sun 		 * Lanes: E,F: SGMII 3&4
136*b5b06fb7SYork Sun 		 * Lanes: G,H: XFI
137*b5b06fb7SYork Sun 		 */
138*b5b06fb7SYork Sun 	case 0xc2:
139*b5b06fb7SYork Sun 		/*
140*b5b06fb7SYork Sun 		 * Configuration:
141*b5b06fb7SYork Sun 		 * SERDES: 2
142*b5b06fb7SYork Sun 		 * Lanes: A,B: SGMII
143*b5b06fb7SYork Sun 		 * Lanes: C,D: SRIO2
144*b5b06fb7SYork Sun 		 * Lanes: E,F,G,H: XAUI2
145*b5b06fb7SYork Sun 		 */
146*b5b06fb7SYork Sun 		lane_to_slot[12] = 2;
147*b5b06fb7SYork Sun 		lane_to_slot[13] = lane_to_slot[12];
148*b5b06fb7SYork Sun 		lane_to_slot[14] = lane_to_slot[12];
149*b5b06fb7SYork Sun 		lane_to_slot[15] = lane_to_slot[12];
150*b5b06fb7SYork Sun 		break;
151*b5b06fb7SYork Sun 
152*b5b06fb7SYork Sun 	default:
153*b5b06fb7SYork Sun 		printf("Fman: Unsupported SerDes2 Protocol 0x%02x\n",
154*b5b06fb7SYork Sun 				serdes2_prtcl);
155*b5b06fb7SYork Sun 			break;
156*b5b06fb7SYork Sun 	}
157*b5b06fb7SYork Sun 	return;
158*b5b06fb7SYork Sun }
159*b5b06fb7SYork Sun 
160*b5b06fb7SYork Sun #endif /* #ifdef CONFIG_FMAN_ENET */
161*b5b06fb7SYork Sun 
162*b5b06fb7SYork Sun int board_eth_init(bd_t *bis)
163*b5b06fb7SYork Sun {
164*b5b06fb7SYork Sun #ifdef CONFIG_FMAN_ENET
165*b5b06fb7SYork Sun 	struct memac_mdio_info memac_mdio_info;
166*b5b06fb7SYork Sun 	struct memac_mdio_info tg_memac_mdio_info;
167*b5b06fb7SYork Sun 	unsigned int i;
168*b5b06fb7SYork Sun 	unsigned int  serdes1_prtcl, serdes2_prtcl;
169*b5b06fb7SYork Sun 	ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
170*b5b06fb7SYork Sun 	serdes1_prtcl = in_be32(&gur->rcwsr[4]) &
171*b5b06fb7SYork Sun 		FSL_CORENET2_RCWSR4_SRDS1_PRTCL;
172*b5b06fb7SYork Sun 	if (!serdes1_prtcl) {
173*b5b06fb7SYork Sun 		printf("SERDES1 is not enabled\n");
174*b5b06fb7SYork Sun 		return 0;
175*b5b06fb7SYork Sun 	}
176*b5b06fb7SYork Sun 	serdes1_prtcl >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT;
177*b5b06fb7SYork Sun 	debug("Using SERDES1 Protocol: 0x%x:\n", serdes1_prtcl);
178*b5b06fb7SYork Sun 
179*b5b06fb7SYork Sun 	serdes2_prtcl = in_be32(&gur->rcwsr[4]) &
180*b5b06fb7SYork Sun 		FSL_CORENET2_RCWSR4_SRDS2_PRTCL;
181*b5b06fb7SYork Sun 	if (!serdes2_prtcl) {
182*b5b06fb7SYork Sun 		printf("SERDES2 is not enabled\n");
183*b5b06fb7SYork Sun 		return 0;
184*b5b06fb7SYork Sun 	}
185*b5b06fb7SYork Sun 	serdes2_prtcl >>= FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT;
186*b5b06fb7SYork Sun 	debug("Using SERDES2 Protocol: 0x%x:\n", serdes2_prtcl);
187*b5b06fb7SYork Sun 
188*b5b06fb7SYork Sun 	printf("Initializing Fman\n");
189*b5b06fb7SYork Sun 
190*b5b06fb7SYork Sun 	initialize_lane_to_slot();
191*b5b06fb7SYork Sun 
192*b5b06fb7SYork Sun 	memac_mdio_info.regs =
193*b5b06fb7SYork Sun 		(struct memac_mdio_controller *)CONFIG_SYS_FM1_DTSEC_MDIO_ADDR;
194*b5b06fb7SYork Sun 	memac_mdio_info.name = DEFAULT_FM_MDIO_NAME;
195*b5b06fb7SYork Sun 
196*b5b06fb7SYork Sun 	/* Register the real 1G MDIO bus */
197*b5b06fb7SYork Sun 	fm_memac_mdio_init(bis, &memac_mdio_info);
198*b5b06fb7SYork Sun 
199*b5b06fb7SYork Sun 	tg_memac_mdio_info.regs =
200*b5b06fb7SYork Sun 		(struct memac_mdio_controller *)CONFIG_SYS_FM1_TGEC_MDIO_ADDR;
201*b5b06fb7SYork Sun 	tg_memac_mdio_info.name = DEFAULT_FM_TGEC_MDIO_NAME;
202*b5b06fb7SYork Sun 
203*b5b06fb7SYork Sun 	/* Register the real 10G MDIO bus */
204*b5b06fb7SYork Sun 	fm_memac_mdio_init(bis, &tg_memac_mdio_info);
205*b5b06fb7SYork Sun 
206*b5b06fb7SYork Sun 	/*
207*b5b06fb7SYork Sun 	 * Program the two on board DTSEC PHY addresses assuming that they are
208*b5b06fb7SYork Sun 	 * all SGMII. RGMII is not supported on this board. Setting SGMII 5 and
209*b5b06fb7SYork Sun 	 * 6 to on board SGMII phys
210*b5b06fb7SYork Sun 	 */
211*b5b06fb7SYork Sun 	fm_info_set_phy_address(FM1_DTSEC5, CONFIG_SYS_FM1_DTSEC5_PHY_ADDR);
212*b5b06fb7SYork Sun 	fm_info_set_phy_address(FM1_DTSEC6, CONFIG_SYS_FM1_DTSEC6_PHY_ADDR);
213*b5b06fb7SYork Sun 
214*b5b06fb7SYork Sun 	switch (serdes1_prtcl) {
215*b5b06fb7SYork Sun 	case 0x2a:
216*b5b06fb7SYork Sun 		/* Serdes 1: A-B SGMII, Configuring DTSEC 5 and 6 */
217*b5b06fb7SYork Sun 		debug("Setting phy addresses for FM1_DTSEC5: %x and"
218*b5b06fb7SYork Sun 			"FM1_DTSEC6: %x\n", CONFIG_SYS_FM1_DTSEC5_PHY_ADDR,
219*b5b06fb7SYork Sun 			CONFIG_SYS_FM1_DTSEC6_PHY_ADDR);
220*b5b06fb7SYork Sun 		/* Fixing Serdes clock by programming FPGA register */
221*b5b06fb7SYork Sun 		QIXIS_WRITE(brdcfg[4], QIXIS_SRDS1CLK_125);
222*b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC5,
223*b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC5_PHY_ADDR);
224*b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC6,
225*b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC6_PHY_ADDR);
226*b5b06fb7SYork Sun 		break;
227*b5b06fb7SYork Sun #ifdef CONFIG_PPC_B4420
228*b5b06fb7SYork Sun 	case 0x18:
229*b5b06fb7SYork Sun 		/* Serdes 1: A-D SGMII, Configuring on board dual SGMII Phy */
230*b5b06fb7SYork Sun 		debug("Setting phy addresses for FM1_DTSEC3: %x and"
231*b5b06fb7SYork Sun 			"FM1_DTSEC4: %x\n", CONFIG_SYS_FM1_DTSEC5_PHY_ADDR,
232*b5b06fb7SYork Sun 			CONFIG_SYS_FM1_DTSEC6_PHY_ADDR);
233*b5b06fb7SYork Sun 		/* Fixing Serdes clock by programming FPGA register */
234*b5b06fb7SYork Sun 		QIXIS_WRITE(brdcfg[4], QIXIS_SRDS1CLK_125);
235*b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC3,
236*b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC5_PHY_ADDR);
237*b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC4,
238*b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC6_PHY_ADDR);
239*b5b06fb7SYork Sun 		break;
240*b5b06fb7SYork Sun #endif
241*b5b06fb7SYork Sun 	default:
242*b5b06fb7SYork Sun 		printf("Fman:  Unsupported SerDes1 Protocol 0x%02x\n",
243*b5b06fb7SYork Sun 				serdes1_prtcl);
244*b5b06fb7SYork Sun 		break;
245*b5b06fb7SYork Sun 	}
246*b5b06fb7SYork Sun 	switch (serdes2_prtcl) {
247*b5b06fb7SYork Sun 	case 0x18:
248*b5b06fb7SYork Sun 		debug("Setting phy addresses on SGMII Riser card for"
249*b5b06fb7SYork Sun 				"FM1_DTSEC ports: \n");
250*b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC1,
251*b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR);
252*b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC2,
253*b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC2_RISER_PHY_ADDR);
254*b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC3,
255*b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC3_RISER_PHY_ADDR);
256*b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC4,
257*b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC4_RISER_PHY_ADDR);
258*b5b06fb7SYork Sun 		break;
259*b5b06fb7SYork Sun 	case 0x49:
260*b5b06fb7SYork Sun 		debug("Setting phy addresses on SGMII Riser card for"
261*b5b06fb7SYork Sun 				"FM1_DTSEC ports: \n");
262*b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC1,
263*b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR);
264*b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC2,
265*b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC2_RISER_PHY_ADDR);
266*b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC3,
267*b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC3_RISER_PHY_ADDR);
268*b5b06fb7SYork Sun 		break;
269*b5b06fb7SYork Sun 	case 0x8d:
270*b5b06fb7SYork Sun 	case 0xb2:
271*b5b06fb7SYork Sun 		debug("Setting phy addresses on SGMII Riser card for"
272*b5b06fb7SYork Sun 				"FM1_DTSEC ports: \n");
273*b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC3,
274*b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR);
275*b5b06fb7SYork Sun 		fm_info_set_phy_address(FM1_DTSEC4,
276*b5b06fb7SYork Sun 				CONFIG_SYS_FM1_DTSEC2_RISER_PHY_ADDR);
277*b5b06fb7SYork Sun 		break;
278*b5b06fb7SYork Sun 	default:
279*b5b06fb7SYork Sun 		printf("Fman:  Unsupported SerDes2 Protocol 0x%02x\n",
280*b5b06fb7SYork Sun 				serdes2_prtcl);
281*b5b06fb7SYork Sun 		break;
282*b5b06fb7SYork Sun 	}
283*b5b06fb7SYork Sun 
284*b5b06fb7SYork Sun 	for (i = FM1_DTSEC1; i < FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) {
285*b5b06fb7SYork Sun 		int idx = i - FM1_DTSEC1;
286*b5b06fb7SYork Sun 
287*b5b06fb7SYork Sun 		switch (fm_info_get_enet_if(i)) {
288*b5b06fb7SYork Sun 		case PHY_INTERFACE_MODE_SGMII:
289*b5b06fb7SYork Sun 			fm_info_set_mdio(i,
290*b5b06fb7SYork Sun 				miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
291*b5b06fb7SYork Sun 			break;
292*b5b06fb7SYork Sun 		case PHY_INTERFACE_MODE_NONE:
293*b5b06fb7SYork Sun 			fm_info_set_phy_address(i, 0);
294*b5b06fb7SYork Sun 			break;
295*b5b06fb7SYork Sun 		default:
296*b5b06fb7SYork Sun 			printf("Fman1: DTSEC%u set to unknown interface %i\n",
297*b5b06fb7SYork Sun 					idx + 1, fm_info_get_enet_if(i));
298*b5b06fb7SYork Sun 			fm_info_set_phy_address(i, 0);
299*b5b06fb7SYork Sun 			break;
300*b5b06fb7SYork Sun 		}
301*b5b06fb7SYork Sun 	}
302*b5b06fb7SYork Sun 
303*b5b06fb7SYork Sun 	cpu_eth_init(bis);
304*b5b06fb7SYork Sun #endif
305*b5b06fb7SYork Sun 
306*b5b06fb7SYork Sun 	return pci_eth_init(bis);
307*b5b06fb7SYork Sun }
308*b5b06fb7SYork Sun 
309*b5b06fb7SYork Sun void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr,
310*b5b06fb7SYork Sun 			      enum fm_port port, int offset)
311*b5b06fb7SYork Sun {
312*b5b06fb7SYork Sun 	int phy;
313*b5b06fb7SYork Sun 	char alias[32];
314*b5b06fb7SYork Sun 
315*b5b06fb7SYork Sun 	if (fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_SGMII) {
316*b5b06fb7SYork Sun 		phy = fm_info_get_phy_address(port);
317*b5b06fb7SYork Sun 
318*b5b06fb7SYork Sun 		sprintf(alias, "phy_sgmii_%x", phy);
319*b5b06fb7SYork Sun 		fdt_set_phy_handle(fdt, compat, addr, alias);
320*b5b06fb7SYork Sun 	}
321*b5b06fb7SYork Sun }
322*b5b06fb7SYork Sun 
323*b5b06fb7SYork Sun void fdt_fixup_board_enet(void *fdt)
324*b5b06fb7SYork Sun {
325*b5b06fb7SYork Sun 	int i;
326*b5b06fb7SYork Sun 	char alias[32];
327*b5b06fb7SYork Sun 
328*b5b06fb7SYork Sun 	for (i = FM1_DTSEC1; i < FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) {
329*b5b06fb7SYork Sun 		switch (fm_info_get_enet_if(i)) {
330*b5b06fb7SYork Sun 		case PHY_INTERFACE_MODE_NONE:
331*b5b06fb7SYork Sun 			sprintf(alias, "ethernet%u", i);
332*b5b06fb7SYork Sun 			fdt_status_disabled_by_alias(fdt, alias);
333*b5b06fb7SYork Sun 			break;
334*b5b06fb7SYork Sun 		default:
335*b5b06fb7SYork Sun 			break;
336*b5b06fb7SYork Sun 		}
337*b5b06fb7SYork Sun 	}
338*b5b06fb7SYork Sun }
339