2 * Copyright 2012 Freescale Semiconductor, Inc.
5 * See file CREDITS for list of people who contributed to this
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.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 /* This file is based on board/freescale/corenet_ds/eth_superhydra.c */
27 * This file handles the board muxing between the Fman Ethernet MACs and
28 * the RGMII/SGMII/XGMII PHYs on a Freescale B4860 "Centaur". The SGMII
29 * PHYs are the two on-board 1Gb ports. There are no RGMII PHY on board.
30 * The 10Gb XGMII PHY is provided via the XAUI riser card. There is only
31 * one Fman device on B4860. The SERDES configuration is used to determine
32 * where the SGMII and XAUI cards exist, and also which Fman MACs are routed
33 * to which PHYs. So for a given Fman MAC, there is one and only PHY it
34 * connects to. MACs cannot be routed to PHYs dynamically. This configuration
35 * is done at boot time by reading SERDES protocol from RCW.
40 #include <asm/fsl_serdes.h>
44 #include <fdt_support.h>
45 #include <asm/fsl_dtsec.h>
47 #include "../common/ngpixis.h"
48 #include "../common/fman.h"
49 #include "../common/qixis.h"
50 #include "b4860qds_qixis.h"
52 #define EMI_NONE 0xFFFFFFFF
54 #ifdef CONFIG_FMAN_ENET
57 * Mapping of all 16 SERDES lanes to board slots. A value n(>0) will mean that
58 * lane at index is mapped to slot number n. A value of '0' will mean
59 * that the mapping must be determined dynamically, or that the lane maps to
60 * something other than a board slot
62 static u8 lane_to_slot[] = {
70 * This function initializes the lane_to_slot[] array. It reads RCW to check
71 * if Serdes2{E,F,G,H} is configured as slot 2 or as SFP and initializes
72 * lane_to_slot[] accordingly
74 static void initialize_lane_to_slot(void)
76 unsigned int serdes2_prtcl;
77 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
78 serdes2_prtcl = in_be32(&gur->rcwsr[4]) &
79 FSL_CORENET2_RCWSR4_SRDS2_PRTCL;
80 serdes2_prtcl >>= FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT;
81 debug("Initializing lane to slot: Serdes2 protocol: %x\n",
84 switch (serdes2_prtcl) {
89 * Lanes: A,B,C,D: SGMII
99 * Lanes: E,F,G,H: XAUI2
105 * Lanes: A,B,C,D: SGMII
106 * Lanes: E,F,G,H: XAUI2
112 * Lanes: A,B,C,D: XAUI2
113 * Lanes: E,F,G,H: XAUI2
121 * Lanes: E,F,G,H: XAUI2
127 * Lanes: A,B,C,D: PCI
128 * Lanes: E,F,G,H: XAUI2
134 * Lanes: A,B,C,D: PCI
135 * Lanes: E,F: SGMII 3&4
144 * Lanes: E,F,G,H: XAUI2
146 lane_to_slot[12] = 2;
147 lane_to_slot[13] = lane_to_slot[12];
148 lane_to_slot[14] = lane_to_slot[12];
149 lane_to_slot[15] = lane_to_slot[12];
153 printf("Fman: Unsupported SerDes2 Protocol 0x%02x\n",
160 #endif /* #ifdef CONFIG_FMAN_ENET */
162 int board_eth_init(bd_t *bis)
164 #ifdef CONFIG_FMAN_ENET
165 struct memac_mdio_info memac_mdio_info;
166 struct memac_mdio_info tg_memac_mdio_info;
168 unsigned int serdes1_prtcl, serdes2_prtcl;
169 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
170 serdes1_prtcl = in_be32(&gur->rcwsr[4]) &
171 FSL_CORENET2_RCWSR4_SRDS1_PRTCL;
172 if (!serdes1_prtcl) {
173 printf("SERDES1 is not enabled\n");
176 serdes1_prtcl >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT;
177 debug("Using SERDES1 Protocol: 0x%x:\n", serdes1_prtcl);
179 serdes2_prtcl = in_be32(&gur->rcwsr[4]) &
180 FSL_CORENET2_RCWSR4_SRDS2_PRTCL;
181 if (!serdes2_prtcl) {
182 printf("SERDES2 is not enabled\n");
185 serdes2_prtcl >>= FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT;
186 debug("Using SERDES2 Protocol: 0x%x:\n", serdes2_prtcl);
188 printf("Initializing Fman\n");
190 initialize_lane_to_slot();
192 memac_mdio_info.regs =
193 (struct memac_mdio_controller *)CONFIG_SYS_FM1_DTSEC_MDIO_ADDR;
194 memac_mdio_info.name = DEFAULT_FM_MDIO_NAME;
196 /* Register the real 1G MDIO bus */
197 fm_memac_mdio_init(bis, &memac_mdio_info);
199 tg_memac_mdio_info.regs =
200 (struct memac_mdio_controller *)CONFIG_SYS_FM1_TGEC_MDIO_ADDR;
201 tg_memac_mdio_info.name = DEFAULT_FM_TGEC_MDIO_NAME;
203 /* Register the real 10G MDIO bus */
204 fm_memac_mdio_init(bis, &tg_memac_mdio_info);
207 * Program the two on board DTSEC PHY addresses assuming that they are
208 * all SGMII. RGMII is not supported on this board. Setting SGMII 5 and
209 * 6 to on board SGMII phys
211 fm_info_set_phy_address(FM1_DTSEC5, CONFIG_SYS_FM1_DTSEC5_PHY_ADDR);
212 fm_info_set_phy_address(FM1_DTSEC6, CONFIG_SYS_FM1_DTSEC6_PHY_ADDR);
214 switch (serdes1_prtcl) {
216 /* Serdes 1: A-B SGMII, Configuring DTSEC 5 and 6 */
217 debug("Setting phy addresses for FM1_DTSEC5: %x and"
218 "FM1_DTSEC6: %x\n", CONFIG_SYS_FM1_DTSEC5_PHY_ADDR,
219 CONFIG_SYS_FM1_DTSEC6_PHY_ADDR);
220 /* Fixing Serdes clock by programming FPGA register */
221 QIXIS_WRITE(brdcfg[4], QIXIS_SRDS1CLK_125);
222 fm_info_set_phy_address(FM1_DTSEC5,
223 CONFIG_SYS_FM1_DTSEC5_PHY_ADDR);
224 fm_info_set_phy_address(FM1_DTSEC6,
225 CONFIG_SYS_FM1_DTSEC6_PHY_ADDR);
227 #ifdef CONFIG_PPC_B4420
229 /* Serdes 1: A-D SGMII, Configuring on board dual SGMII Phy */
230 debug("Setting phy addresses for FM1_DTSEC3: %x and"
231 "FM1_DTSEC4: %x\n", CONFIG_SYS_FM1_DTSEC5_PHY_ADDR,
232 CONFIG_SYS_FM1_DTSEC6_PHY_ADDR);
233 /* Fixing Serdes clock by programming FPGA register */
234 QIXIS_WRITE(brdcfg[4], QIXIS_SRDS1CLK_125);
235 fm_info_set_phy_address(FM1_DTSEC3,
236 CONFIG_SYS_FM1_DTSEC5_PHY_ADDR);
237 fm_info_set_phy_address(FM1_DTSEC4,
238 CONFIG_SYS_FM1_DTSEC6_PHY_ADDR);
242 printf("Fman: Unsupported SerDes1 Protocol 0x%02x\n",
246 switch (serdes2_prtcl) {
248 debug("Setting phy addresses on SGMII Riser card for"
249 "FM1_DTSEC ports: \n");
250 fm_info_set_phy_address(FM1_DTSEC1,
251 CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR);
252 fm_info_set_phy_address(FM1_DTSEC2,
253 CONFIG_SYS_FM1_DTSEC2_RISER_PHY_ADDR);
254 fm_info_set_phy_address(FM1_DTSEC3,
255 CONFIG_SYS_FM1_DTSEC3_RISER_PHY_ADDR);
256 fm_info_set_phy_address(FM1_DTSEC4,
257 CONFIG_SYS_FM1_DTSEC4_RISER_PHY_ADDR);
260 debug("Setting phy addresses on SGMII Riser card for"
261 "FM1_DTSEC ports: \n");
262 fm_info_set_phy_address(FM1_DTSEC1,
263 CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR);
264 fm_info_set_phy_address(FM1_DTSEC2,
265 CONFIG_SYS_FM1_DTSEC2_RISER_PHY_ADDR);
266 fm_info_set_phy_address(FM1_DTSEC3,
267 CONFIG_SYS_FM1_DTSEC3_RISER_PHY_ADDR);
271 debug("Setting phy addresses on SGMII Riser card for"
272 "FM1_DTSEC ports: \n");
273 fm_info_set_phy_address(FM1_DTSEC3,
274 CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR);
275 fm_info_set_phy_address(FM1_DTSEC4,
276 CONFIG_SYS_FM1_DTSEC2_RISER_PHY_ADDR);
279 printf("Fman: Unsupported SerDes2 Protocol 0x%02x\n",
284 for (i = FM1_DTSEC1; i < FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) {
285 int idx = i - FM1_DTSEC1;
287 switch (fm_info_get_enet_if(i)) {
288 case PHY_INTERFACE_MODE_SGMII:
290 miiphy_get_dev_by_name(DEFAULT_FM_MDIO_NAME));
292 case PHY_INTERFACE_MODE_NONE:
293 fm_info_set_phy_address(i, 0);
296 printf("Fman1: DTSEC%u set to unknown interface %i\n",
297 idx + 1, fm_info_get_enet_if(i));
298 fm_info_set_phy_address(i, 0);
306 return pci_eth_init(bis);
309 void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr,
310 enum fm_port port, int offset)
315 if (fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_SGMII) {
316 phy = fm_info_get_phy_address(port);
318 sprintf(alias, "phy_sgmii_%x", phy);
319 fdt_set_phy_handle(fdt, compat, addr, alias);
323 void fdt_fixup_board_enet(void *fdt)
328 for (i = FM1_DTSEC1; i < FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) {
329 switch (fm_info_get_enet_if(i)) {
330 case PHY_INTERFACE_MODE_NONE:
331 sprintf(alias, "ethernet%u", i);
332 fdt_status_disabled_by_alias(fdt, alias);