2 * Copyright 2009-2011 Freescale Semiconductor, Inc.
3 * Author: Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
5 * SPDX-License-Identifier: GPL-2.0+
9 * This file handles the board muxing between the Fman Ethernet MACs and
10 * the RGMII/SGMII/XGMII PHYs on a Freescale P5040 "Super Hydra" reference
11 * board. The RGMII PHYs are the two on-board 1Gb ports. The SGMII PHYs are
12 * provided by the standard Freescale four-port SGMII riser card. The 10Gb
13 * XGMII PHYs are provided via the XAUI riser card. The P5040 has 2 FMans
14 * and 5 1G interfaces and 10G interface per FMan. Based on the options in
15 * the RCW, we could have upto 3 SGMII cards and 1 XAUI card at a time.
17 * Muxing is handled via the PIXIS BRDCFG1 register. The EMI1 bits control
18 * muxing among the RGMII PHYs and the SGMII PHYs. The value for RGMII is
19 * always the same (0). The value for SGMII depends on which slot the riser is
20 * inserted in. The EMI2 bits control muxing for the the XGMII. Like SGMII,
21 * the value is based on which slot the XAUI is inserted in.
23 * The SERDES configuration is used to determine where the SGMII and XAUI cards
24 * exist, and also which Fman's MACs are routed to which PHYs. So for a given
25 * Fman MAC, there is one and only PHY it connects to. MACs cannot be routed
26 * to PHYs dynamically.
29 * This file also updates the device tree in three ways:
31 * 1) The status of each virtual MDIO node that is referenced by an Ethernet
32 * node is set to "okay".
34 * 2) The phy-handle property of each active Ethernet MAC node is set to the
35 * appropriate PHY node.
37 * 3) The "mux value" for each virtual MDIO node is set to the correct value,
38 * if necessary. Some virtual MDIO nodes do not have configurable mux
39 * values, so those values are hard-coded in the DTS. On the HYDRA board,
40 * the virtual MDIO node for the SGMII card needs to be updated.
42 * For all this to work, the device tree needs to have the following:
44 * 1) An alias for each PHY node that an Ethernet node could be routed to.
46 * 2) An alias for each real and virtual MDIO node that is disabled by default
47 * and might need to be enabled, and also might need to have its mux-value
53 #include <asm/fsl_serdes.h>
57 #include <fdt_support.h>
58 #include <asm/fsl_dtsec.h>
60 #include "../common/ngpixis.h"
61 #include "../common/fman.h"
63 #ifdef CONFIG_FMAN_ENET
65 #define BRDCFG1_EMI1_SEL_MASK 0x70
66 #define BRDCFG1_EMI1_SEL_SLOT1 0x10
67 #define BRDCFG1_EMI1_SEL_SLOT2 0x20
68 #define BRDCFG1_EMI1_SEL_SLOT5 0x30
69 #define BRDCFG1_EMI1_SEL_SLOT6 0x40
70 #define BRDCFG1_EMI1_SEL_SLOT7 0x50
71 #define BRDCFG1_EMI1_SEL_SLOT3 0x60
72 #define BRDCFG1_EMI1_SEL_RGMII 0x00
73 #define BRDCFG1_EMI1_EN 0x08
74 #define BRDCFG1_EMI2_SEL_MASK 0x06
75 #define BRDCFG1_EMI2_SEL_SLOT1 0x00
76 #define BRDCFG1_EMI2_SEL_SLOT2 0x02
78 #define BRDCFG2_REG_GPIO_SEL 0x20
81 #define PHY_BASE_ADDR 0x00
83 #define PORT_NUM_FM1 0x04
84 #define PORT_NUM_FM2 0x02
87 * BRDCFG1 mask and value for each MAC
89 * This array contains the BRDCFG1 values (in mask/val format) that route the
90 * MDIO bus to a particular RGMII or SGMII PHY.
95 } mdio_mux
[NUM_FM_PORTS
];
98 * Mapping of all 18 SERDES lanes to board slots. A value of '0' here means
99 * that the mapping must be determined dynamically, or that the lane maps to
100 * something other than a board slot
102 static u8 lane_to_slot
[] = {
103 7, 7, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 1, 1, 0, 0, 0, 0
107 * Set the board muxing for a given MAC
109 * The MDIO layer calls this function every time it wants to talk to a PHY.
111 void super_hydra_mux_mdio(u8 mask
, u8 val
)
113 clrsetbits_8(&pixis
->brdcfg1
, mask
, val
);
116 struct super_hydra_mdio
{
119 struct mii_dev
*realbus
;
122 static int super_hydra_mdio_read(struct mii_dev
*bus
, int addr
, int devad
,
125 struct super_hydra_mdio
*priv
= bus
->priv
;
127 super_hydra_mux_mdio(priv
->mask
, priv
->val
);
129 return priv
->realbus
->read(priv
->realbus
, addr
, devad
, regnum
);
132 static int super_hydra_mdio_write(struct mii_dev
*bus
, int addr
, int devad
,
133 int regnum
, u16 value
)
135 struct super_hydra_mdio
*priv
= bus
->priv
;
137 super_hydra_mux_mdio(priv
->mask
, priv
->val
);
139 return priv
->realbus
->write(priv
->realbus
, addr
, devad
, regnum
, value
);
142 static int super_hydra_mdio_reset(struct mii_dev
*bus
)
144 struct super_hydra_mdio
*priv
= bus
->priv
;
146 return priv
->realbus
->reset(priv
->realbus
);
149 static void super_hydra_mdio_set_mux(char *name
, u8 mask
, u8 val
)
151 struct mii_dev
*bus
= miiphy_get_dev_by_name(name
);
152 struct super_hydra_mdio
*priv
= bus
->priv
;
158 static int super_hydra_mdio_init(char *realbusname
, char *fakebusname
)
160 struct super_hydra_mdio
*hmdio
;
161 struct mii_dev
*bus
= mdio_alloc();
164 printf("Failed to allocate Hydra MDIO bus\n");
168 hmdio
= malloc(sizeof(*hmdio
));
170 printf("Failed to allocate Hydra private data\n");
175 bus
->read
= super_hydra_mdio_read
;
176 bus
->write
= super_hydra_mdio_write
;
177 bus
->reset
= super_hydra_mdio_reset
;
178 sprintf(bus
->name
, fakebusname
);
180 hmdio
->realbus
= miiphy_get_dev_by_name(realbusname
);
182 if (!hmdio
->realbus
) {
183 printf("No bus with name %s\n", realbusname
);
191 return mdio_register(bus
);
195 * Given the following ...
197 * 1) A pointer to an Fman Ethernet node (as identified by the 'compat'
198 * compatible string and 'addr' physical address)
202 * ... update the phy-handle property of the Ethernet node to point to the
203 * right PHY. This assumes that we already know the PHY for each port. That
204 * information is stored in mdio_mux[].
206 * The offset of the Fman Ethernet node is also passed in for convenience, but
209 * Note that what we call "Fman ports" (enum fm_port) is really an Fman MAC.
210 * Inside the Fman, "ports" are things that connect to MACs. We only call them
211 * ports in U-Boot because on previous Ethernet devices (e.g. Gianfar), MACs
212 * and ports are the same thing.
214 void board_ft_fman_fixup_port(void *fdt
, char *compat
, phys_addr_t addr
,
215 enum fm_port port
, int offset
)
217 enum srds_prtcl device
;
221 /* RGMII and XGMII are already mapped correctly in the DTS */
223 if (fm_info_get_enet_if(port
) == PHY_INTERFACE_MODE_SGMII
) {
224 device
= serdes_device_from_fm_port(port
);
225 lane
= serdes_get_first_lane(device
);
226 slot
= lane_to_slot
[lane
];
227 phy
= fm_info_get_phy_address(port
);
229 sprintf(alias
, "phy_sgmii_slot%u_%x", slot
, phy
);
230 fdt_set_phy_handle(fdt
, compat
, addr
, alias
);
234 #define PIXIS_SW2_LANE_23_SEL 0x80
235 #define PIXIS_SW2_LANE_45_SEL 0x40
236 #define PIXIS_SW2_LANE_67_SEL_MASK 0x30
237 #define PIXIS_SW2_LANE_67_SEL_5 0x00
238 #define PIXIS_SW2_LANE_67_SEL_6 0x20
239 #define PIXIS_SW2_LANE_67_SEL_7 0x10
240 #define PIXIS_SW2_LANE_8_SEL 0x08
241 #define PIXIS_SW2_LANE_1617_SEL 0x04
242 #define PIXIS_SW11_LANE_9_SEL 0x04
244 * Initialize the lane_to_slot[] array.
246 * On the P4080DS "Expedition" board, the mapping of SERDES lanes to board
247 * slots is hard-coded. On the Hydra board, however, the mapping is controlled
248 * by board switch SW2, so the lane_to_slot[] array needs to be dynamically
251 static void initialize_lane_to_slot(void)
253 u8 sw2
= in_8(&PIXIS_SW(2));
254 /* SW11 appears in the programming model as SW9 */
255 u8 sw11
= in_8(&PIXIS_SW(9));
257 lane_to_slot
[2] = (sw2
& PIXIS_SW2_LANE_23_SEL
) ? 7 : 4;
258 lane_to_slot
[3] = lane_to_slot
[2];
260 lane_to_slot
[4] = (sw2
& PIXIS_SW2_LANE_45_SEL
) ? 7 : 6;
261 lane_to_slot
[5] = lane_to_slot
[4];
263 switch (sw2
& PIXIS_SW2_LANE_67_SEL_MASK
) {
264 case PIXIS_SW2_LANE_67_SEL_5
:
267 case PIXIS_SW2_LANE_67_SEL_6
:
270 case PIXIS_SW2_LANE_67_SEL_7
:
274 lane_to_slot
[7] = lane_to_slot
[6];
276 lane_to_slot
[8] = (sw2
& PIXIS_SW2_LANE_8_SEL
) ? 3 : 0;
277 lane_to_slot
[9] = (sw11
& PIXIS_SW11_LANE_9_SEL
) ? 0 : 3;
279 lane_to_slot
[16] = (sw2
& PIXIS_SW2_LANE_1617_SEL
) ? 1 : 0;
280 lane_to_slot
[17] = lane_to_slot
[16];
283 #endif /* #ifdef CONFIG_FMAN_ENET */
286 * Configure the status for the virtual MDIO nodes
288 * Rather than create the virtual MDIO nodes from scratch for each active
289 * virtual MDIO, we expect the DTS to have the nodes defined already, and we
290 * only enable the ones that are actually active.
292 * We assume that the DTS already hard-codes the status for all the
293 * virtual MDIO nodes to "disabled", so all we need to do is enable the
296 void fdt_fixup_board_enet(void *fdt
)
298 #ifdef CONFIG_FMAN_ENET
302 for (i
= FM1_DTSEC1
; i
< FM1_DTSEC1
+ CONFIG_SYS_NUM_FM1_DTSEC
; i
++) {
303 int idx
= i
- FM1_DTSEC1
;
305 switch (fm_info_get_enet_if(i
)) {
306 case PHY_INTERFACE_MODE_SGMII
:
307 lane
= serdes_get_first_lane(SGMII_FM1_DTSEC1
+ idx
);
311 slot
= lane_to_slot
[lane
];
312 sprintf(alias
, "hydra_sg_slot%u", slot
);
313 fdt_status_okay_by_alias(fdt
, alias
);
314 debug("Enabled MDIO node %s (slot %i)\n",
318 case PHY_INTERFACE_MODE_RGMII
:
319 fdt_status_okay_by_alias(fdt
, "hydra_rg");
320 debug("Enabled MDIO node hydra_rg\n");
327 lane
= serdes_get_first_lane(XAUI_FM1
);
331 slot
= lane_to_slot
[lane
];
332 sprintf(alias
, "hydra_xg_slot%u", slot
);
333 fdt_status_okay_by_alias(fdt
, alias
);
334 debug("Enabled MDIO node %s (slot %i)\n", alias
, slot
);
337 #if CONFIG_SYS_NUM_FMAN == 2
338 for (i
= FM2_DTSEC1
; i
< FM2_DTSEC1
+ CONFIG_SYS_NUM_FM2_DTSEC
; i
++) {
339 int idx
= i
- FM2_DTSEC1
;
341 switch (fm_info_get_enet_if(i
)) {
342 case PHY_INTERFACE_MODE_SGMII
:
343 lane
= serdes_get_first_lane(SGMII_FM2_DTSEC1
+ idx
);
347 slot
= lane_to_slot
[lane
];
348 sprintf(alias
, "hydra_sg_slot%u", slot
);
349 fdt_status_okay_by_alias(fdt
, alias
);
350 debug("Enabled MDIO node %s (slot %i)\n",
354 case PHY_INTERFACE_MODE_RGMII
:
355 fdt_status_okay_by_alias(fdt
, "hydra_rg");
356 debug("Enabled MDIO node hydra_rg\n");
363 lane
= serdes_get_first_lane(XAUI_FM2
);
367 slot
= lane_to_slot
[lane
];
368 sprintf(alias
, "hydra_xg_slot%u", slot
);
369 fdt_status_okay_by_alias(fdt
, alias
);
370 debug("Enabled MDIO node %s (slot %i)\n", alias
, slot
);
372 #endif /* CONFIG_SYS_NUM_FMAN == 2 */
373 #endif /* CONFIG_FMAN_ENET */
377 * Mapping of SerDes Protocol to MDIO MUX value and PHY address.
380 * DTSEC1 | DTSEC2 | DTSEC3 | DTSEC4
381 * Mux Phy | Mux Phy | Mux Phy | Mux Phy
382 * Value Addr | Value Addr | Value Addr | Value Addr
383 * 0x00 2 1c | 2 1d | 2 1e | 2 1f
385 * 0x02 | | 3 1c | 3 1d
386 * 0x03 2 1c | 2 1d | 2 1e | 2 1f
387 * 0x04 2 1c | 2 1d | 2 1e | 2 1f
388 * 0x05 | | 3 1c | 3 1d
389 * 0x06 2 1c | 2 1d | 2 1e | 2 1f
391 * 0x11 2 1c | 2 1d | 2 1e | 2 1f
392 * 0x2a 2 | | 2 1e | 2 1f
393 * 0x34 6 1c | 6 1d | 4 1e | 4 1f
394 * 0x35 | | 3 1c | 3 1d
395 * 0x36 6 1c | 6 1d | 4 1e | 4 1f
398 * DTSEC1 | DTSEC2 | DTSEC3 | DTSEC4
399 * EMI1 | EMI1 | EMI1 | EMI1
400 * Mux Phy | Mux Phy | Mux Phy | Mux Phy
401 * Value Addr | Value Addr | Value Addr | Value Addr
402 * 0x00 | | 6 1c | 6 1d
404 * 0x02 | | 6 1c | 6 1d
405 * 0x03 3 1c | 3 1d | 6 1c | 6 1d
406 * 0x04 3 1c | 3 1d | 6 1c | 6 1d
407 * 0x05 | | 6 1c | 6 1d
408 * 0x06 | | 6 1c | 6 1d
417 int board_eth_init(bd_t
*bis
)
419 #ifdef CONFIG_FMAN_ENET
420 struct fsl_pq_mdio_info dtsec_mdio_info
;
421 struct tgec_mdio_info tgec_mdio_info
;
422 unsigned int i
, slot
;
427 ccsr_gur_t
*gur
= (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR
);
428 int srds_prtcl
= (in_be32(&gur
->rcwsr
[4]) &
429 FSL_CORENET_RCWSR4_SRDS_PRTCL
) >> 26;
431 printf("Initializing Fman\n");
433 initialize_lane_to_slot();
435 /* We want to use the PIXIS to configure MUX routing, not GPIOs. */
436 setbits_8(&pixis
->brdcfg2
, BRDCFG2_REG_GPIO_SEL
);
438 memset(mdio_mux
, 0, sizeof(mdio_mux
));
440 dtsec_mdio_info
.regs
=
441 (struct tsec_mii_mng
*)CONFIG_SYS_FM1_DTSEC1_MDIO_ADDR
;
442 dtsec_mdio_info
.name
= DEFAULT_FM_MDIO_NAME
;
444 /* Register the real 1G MDIO bus */
445 fsl_pq_mdio_init(bis
, &dtsec_mdio_info
);
447 tgec_mdio_info
.regs
=
448 (struct tgec_mdio_controller
*)CONFIG_SYS_FM1_TGEC_MDIO_ADDR
;
449 tgec_mdio_info
.name
= DEFAULT_FM_TGEC_MDIO_NAME
;
451 /* Register the real 10G MDIO bus */
452 fm_tgec_mdio_init(bis
, &tgec_mdio_info
);
454 /* Register the three virtual MDIO front-ends */
455 super_hydra_mdio_init(DEFAULT_FM_MDIO_NAME
,
456 "SUPER_HYDRA_RGMII_MDIO");
457 super_hydra_mdio_init(DEFAULT_FM_MDIO_NAME
,
458 "SUPER_HYDRA_FM1_SGMII_MDIO");
459 super_hydra_mdio_init(DEFAULT_FM_MDIO_NAME
,
460 "SUPER_HYDRA_FM2_SGMII_MDIO");
461 super_hydra_mdio_init(DEFAULT_FM_MDIO_NAME
,
462 "SUPER_HYDRA_FM3_SGMII_MDIO");
463 super_hydra_mdio_init(DEFAULT_FM_TGEC_MDIO_NAME
,
464 "SUPER_HYDRA_FM1_TGEC_MDIO");
465 super_hydra_mdio_init(DEFAULT_FM_TGEC_MDIO_NAME
,
466 "SUPER_HYDRA_FM2_TGEC_MDIO");
469 * Program the DTSEC PHY addresses assuming that they are all SGMII.
470 * For any DTSEC that's RGMII, we'll override its PHY address later.
471 * We assume that DTSEC5 is only used for RGMII.
473 fm_info_set_phy_address(FM1_DTSEC1
, CONFIG_SYS_FM1_DTSEC1_PHY_ADDR
);
474 fm_info_set_phy_address(FM1_DTSEC2
, CONFIG_SYS_FM1_DTSEC2_PHY_ADDR
);
475 fm_info_set_phy_address(FM1_10GEC1
, CONFIG_SYS_FM2_10GEC1_PHY_ADDR
);
477 #if (CONFIG_SYS_NUM_FMAN == 2)
478 fm_info_set_phy_address(FM2_DTSEC1
, CONFIG_SYS_FM2_DTSEC1_PHY_ADDR
);
479 fm_info_set_phy_address(FM2_DTSEC2
, CONFIG_SYS_FM2_DTSEC2_PHY_ADDR
);
480 fm_info_set_phy_address(FM2_DTSEC3
, CONFIG_SYS_FM2_DTSEC1_PHY_ADDR
);
481 fm_info_set_phy_address(FM2_DTSEC4
, CONFIG_SYS_FM2_DTSEC2_PHY_ADDR
);
482 fm_info_set_phy_address(FM2_10GEC1
, CONFIG_SYS_FM1_10GEC1_PHY_ADDR
);
485 switch (srds_prtcl
) {
494 fm_info_set_phy_address(FM1_DTSEC3
,
495 CONFIG_SYS_FM1_DTSEC3_PHY_ADDR
);
496 fm_info_set_phy_address(FM1_DTSEC4
,
497 CONFIG_SYS_FM1_DTSEC4_PHY_ADDR
);
504 fm_info_set_phy_address(FM1_DTSEC3
,
505 CONFIG_SYS_FM1_DTSEC1_PHY_ADDR
);
506 fm_info_set_phy_address(FM1_DTSEC4
,
507 CONFIG_SYS_FM1_DTSEC2_PHY_ADDR
);
510 printf("Fman: Unsupport SerDes Protocol 0x%02x\n", srds_prtcl
);
514 for (i
= FM1_DTSEC1
; i
< FM1_DTSEC1
+ CONFIG_SYS_NUM_FM1_DTSEC
; i
++) {
515 int idx
= i
- FM1_DTSEC1
;
517 switch (fm_info_get_enet_if(i
)) {
518 case PHY_INTERFACE_MODE_SGMII
:
519 lane
= serdes_get_first_lane(SGMII_FM1_DTSEC1
+ idx
);
522 slot
= lane_to_slot
[lane
];
523 mdio_mux
[i
].mask
= BRDCFG1_EMI1_SEL_MASK
;
524 debug("FM1@DTSEC%u expects SGMII in slot %u\n",
528 mdio_mux
[i
].val
= BRDCFG1_EMI1_SEL_SLOT1
|
532 mdio_mux
[i
].val
= BRDCFG1_EMI1_SEL_SLOT2
|
536 mdio_mux
[i
].val
= BRDCFG1_EMI1_SEL_SLOT3
|
540 mdio_mux
[i
].val
= BRDCFG1_EMI1_SEL_SLOT5
|
544 mdio_mux
[i
].val
= BRDCFG1_EMI1_SEL_SLOT6
|
548 mdio_mux
[i
].val
= BRDCFG1_EMI1_SEL_SLOT7
|
553 super_hydra_mdio_set_mux("SUPER_HYDRA_FM1_SGMII_MDIO",
554 mdio_mux
[i
].mask
, mdio_mux
[i
].val
);
556 miiphy_get_dev_by_name("SUPER_HYDRA_FM1_SGMII_MDIO"));
558 case PHY_INTERFACE_MODE_RGMII
:
560 * FM1 DTSEC5 is routed via EC1 to the first on-board
561 * RGMII port. FM2 DTSEC5 is routed via EC2 to the
562 * second on-board RGMII port. The other DTSECs cannot
563 * be routed to RGMII.
565 debug("FM1@DTSEC%u is RGMII at address %u\n",
567 fm_info_set_phy_address(i
, 0);
568 mdio_mux
[i
].mask
= BRDCFG1_EMI1_SEL_MASK
;
569 mdio_mux
[i
].val
= BRDCFG1_EMI1_SEL_RGMII
|
571 super_hydra_mdio_set_mux("SUPER_HYDRA_RGMII_MDIO",
572 mdio_mux
[i
].mask
, mdio_mux
[i
].val
);
574 miiphy_get_dev_by_name("SUPER_HYDRA_RGMII_MDIO"));
576 case PHY_INTERFACE_MODE_NONE
:
577 fm_info_set_phy_address(i
, 0);
580 printf("Fman1: DTSEC%u set to unknown interface %i\n",
581 idx
+ 1, fm_info_get_enet_if(i
));
582 fm_info_set_phy_address(i
, 0);
587 bus
= miiphy_get_dev_by_name("SUPER_HYDRA_FM1_SGMII_MDIO");
588 qsgmii
= is_qsgmii_riser_card(bus
, PHY_BASE_ADDR
, PORT_NUM_FM1
, REGNUM
);
591 for (i
= FM1_DTSEC1
; i
< FM1_DTSEC1
+ PORT_NUM_FM1
; i
++) {
592 if (fm_info_get_enet_if(i
) ==
593 PHY_INTERFACE_MODE_SGMII
) {
594 phy_real_addr
= PHY_BASE_ADDR
+ i
- FM1_DTSEC1
;
595 fm_info_set_phy_address(i
, phy_real_addr
);
598 switch (srds_prtcl
) {
607 fm_info_set_phy_address(FM1_DTSEC3
, PHY_BASE_ADDR
+ 2);
608 fm_info_set_phy_address(FM1_DTSEC4
, PHY_BASE_ADDR
+ 3);
615 fm_info_set_phy_address(FM1_DTSEC3
, PHY_BASE_ADDR
+ 0);
616 fm_info_set_phy_address(FM1_DTSEC4
, PHY_BASE_ADDR
+ 1);
624 * For 10G, we only support one XAUI card per Fman. If present, then we
625 * force its routing and never touch those bits again, which removes the
626 * need for Linux to do any muxing. This works because of the way
627 * BRDCFG1 is defined, but it's a bit hackish.
629 * The PHY address for the XAUI card depends on which slot it's in. The
630 * macros we use imply that the PHY address is based on which FM, but
631 * that's not true. On the P4080DS, FM1 could only use XAUI in slot 5,
632 * and FM2 could only use a XAUI in slot 4. On the Hydra board, we
633 * check the actual slot and just use the macros as-is, even though
634 * the P3041 and P5020 only have one Fman.
636 lane
= serdes_get_first_lane(XAUI_FM1
);
638 debug("FM1@TGEC1 expects XAUI in slot %u\n", lane_to_slot
[lane
]);
639 mdio_mux
[i
].mask
= BRDCFG1_EMI2_SEL_MASK
;
640 mdio_mux
[i
].val
= BRDCFG1_EMI2_SEL_SLOT2
;
641 super_hydra_mdio_set_mux("SUPER_HYDRA_FM1_TGEC_MDIO",
642 mdio_mux
[i
].mask
, mdio_mux
[i
].val
);
645 fm_info_set_mdio(FM1_10GEC1
,
646 miiphy_get_dev_by_name("SUPER_HYDRA_FM1_TGEC_MDIO"));
648 #if (CONFIG_SYS_NUM_FMAN == 2)
649 for (i
= FM2_DTSEC1
; i
< FM2_DTSEC1
+ CONFIG_SYS_NUM_FM2_DTSEC
; i
++) {
650 int idx
= i
- FM2_DTSEC1
;
652 switch (fm_info_get_enet_if(i
)) {
653 case PHY_INTERFACE_MODE_SGMII
:
654 lane
= serdes_get_first_lane(SGMII_FM2_DTSEC1
+ idx
);
657 slot
= lane_to_slot
[lane
];
658 mdio_mux
[i
].mask
= BRDCFG1_EMI1_SEL_MASK
;
659 debug("FM2@DTSEC%u expects SGMII in slot %u\n",
663 mdio_mux
[i
].val
= BRDCFG1_EMI1_SEL_SLOT1
|
667 mdio_mux
[i
].val
= BRDCFG1_EMI1_SEL_SLOT2
|
671 mdio_mux
[i
].val
= BRDCFG1_EMI1_SEL_SLOT3
|
675 mdio_mux
[i
].val
= BRDCFG1_EMI1_SEL_SLOT5
|
679 mdio_mux
[i
].val
= BRDCFG1_EMI1_SEL_SLOT6
|
683 mdio_mux
[i
].val
= BRDCFG1_EMI1_SEL_SLOT7
|
688 if (i
== FM2_DTSEC1
|| i
== FM2_DTSEC2
) {
689 super_hydra_mdio_set_mux(
690 "SUPER_HYDRA_FM3_SGMII_MDIO",
693 fm_info_set_mdio(i
, miiphy_get_dev_by_name(
694 "SUPER_HYDRA_FM3_SGMII_MDIO"));
696 super_hydra_mdio_set_mux(
697 "SUPER_HYDRA_FM2_SGMII_MDIO",
700 fm_info_set_mdio(i
, miiphy_get_dev_by_name(
701 "SUPER_HYDRA_FM2_SGMII_MDIO"));
705 case PHY_INTERFACE_MODE_RGMII
:
707 * FM1 DTSEC5 is routed via EC1 to the first on-board
708 * RGMII port. FM2 DTSEC5 is routed via EC2 to the
709 * second on-board RGMII port. The other DTSECs cannot
710 * be routed to RGMII.
712 debug("FM2@DTSEC%u is RGMII at address %u\n",
714 fm_info_set_phy_address(i
, 1);
715 mdio_mux
[i
].mask
= BRDCFG1_EMI1_SEL_MASK
;
716 mdio_mux
[i
].val
= BRDCFG1_EMI1_SEL_RGMII
|
718 super_hydra_mdio_set_mux("SUPER_HYDRA_RGMII_MDIO",
719 mdio_mux
[i
].mask
, mdio_mux
[i
].val
);
721 miiphy_get_dev_by_name("SUPER_HYDRA_RGMII_MDIO"));
723 case PHY_INTERFACE_MODE_NONE
:
724 fm_info_set_phy_address(i
, 0);
727 printf("Fman2: DTSEC%u set to unknown interface %i\n",
728 idx
+ 1, fm_info_get_enet_if(i
));
729 fm_info_set_phy_address(i
, 0);
734 bus
= miiphy_get_dev_by_name("SUPER_HYDRA_FM2_SGMII_MDIO");
735 set_sgmii_phy(bus
, FM2_DTSEC3
, PORT_NUM_FM2
, PHY_BASE_ADDR
);
736 bus
= miiphy_get_dev_by_name("SUPER_HYDRA_FM3_SGMII_MDIO");
737 set_sgmii_phy(bus
, FM2_DTSEC1
, PORT_NUM_FM2
, PHY_BASE_ADDR
);
740 * For 10G, we only support one XAUI card per Fman. If present, then we
741 * force its routing and never touch those bits again, which removes the
742 * need for Linux to do any muxing. This works because of the way
743 * BRDCFG1 is defined, but it's a bit hackish.
745 * The PHY address for the XAUI card depends on which slot it's in. The
746 * macros we use imply that the PHY address is based on which FM, but
747 * that's not true. On the P4080DS, FM1 could only use XAUI in slot 5,
748 * and FM2 could only use a XAUI in slot 4. On the Hydra board, we
749 * check the actual slot and just use the macros as-is, even though
750 * the P3041 and P5020 only have one Fman.
752 lane
= serdes_get_first_lane(XAUI_FM2
);
754 debug("FM2@TGEC1 expects XAUI in slot %u\n", lane_to_slot
[lane
]);
755 mdio_mux
[i
].mask
= BRDCFG1_EMI2_SEL_MASK
;
756 mdio_mux
[i
].val
= BRDCFG1_EMI2_SEL_SLOT1
;
757 super_hydra_mdio_set_mux("SUPER_HYDRA_FM2_TGEC_MDIO",
758 mdio_mux
[i
].mask
, mdio_mux
[i
].val
);
761 fm_info_set_mdio(FM2_10GEC1
,
762 miiphy_get_dev_by_name("SUPER_HYDRA_FM2_TGEC_MDIO"));
769 return pci_eth_init(bis
);