1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2013 Freescale Semiconductor, Inc.
6 * Shengzhou Liu <Shengzhou.Liu@freescale.com>
11 #include <fdt_support.h>
15 #include <asm/processor.h>
16 #include <asm/immap_85xx.h>
17 #include <asm/fsl_law.h>
18 #include <asm/fsl_serdes.h>
19 #include <asm/fsl_portals.h>
20 #include <asm/fsl_liodn.h>
26 #include <fsl_dtsec.h>
27 #include <asm/fsl_serdes.h>
29 #include "../common/qixis.h"
30 #include "../common/fman.h"
31 #include "t208xqds_qixis.h"
32 #include <linux/libfdt.h>
34 #define EMI_NONE 0xFFFFFFFF
38 #if defined(CONFIG_TARGET_T2080QDS)
44 #elif defined(CONFIG_TARGET_T2081QDS)
53 #define PCCR1_SGMIIA_KX_MASK 0x00008000
54 #define PCCR1_SGMIIB_KX_MASK 0x00004000
55 #define PCCR1_SGMIIC_KX_MASK 0x00002000
56 #define PCCR1_SGMIID_KX_MASK 0x00001000
57 #define PCCR1_SGMIIE_KX_MASK 0x00000800
58 #define PCCR1_SGMIIF_KX_MASK 0x00000400
59 #define PCCR1_SGMIIG_KX_MASK 0x00000200
60 #define PCCR1_SGMIIH_KX_MASK 0x00000100
62 static int mdio_mux[NUM_FM_PORTS];
64 static const char * const mdio_names[] = {
65 #if defined(CONFIG_TARGET_T2080QDS)
66 "T2080QDS_MDIO_RGMII1",
67 "T2080QDS_MDIO_RGMII2",
68 "T2080QDS_MDIO_SLOT1",
69 "T2080QDS_MDIO_SLOT3",
70 "T2080QDS_MDIO_SLOT4",
71 "T2080QDS_MDIO_SLOT5",
72 "T2080QDS_MDIO_SLOT2",
74 #elif defined(CONFIG_TARGET_T2081QDS)
75 "T2081QDS_MDIO_RGMII1",
76 "T2081QDS_MDIO_RGMII2",
77 "T2081QDS_MDIO_SLOT1",
78 "T2081QDS_MDIO_SLOT2",
79 "T2081QDS_MDIO_SLOT3",
80 "T2081QDS_MDIO_SLOT5",
81 "T2081QDS_MDIO_SLOT6",
82 "T2081QDS_MDIO_SLOT7",
87 /* Map SerDes1 8 lanes to default slot, will be initialized dynamically */
88 #if defined(CONFIG_TARGET_T2080QDS)
89 static u8 lane_to_slot[] = {3, 3, 3, 3, 1, 1, 1, 1};
90 #elif defined(CONFIG_TARGET_T2081QDS)
91 static u8 lane_to_slot[] = {2, 2, 2, 2, 1, 1, 1, 1};
94 static const char *t208xqds_mdio_name_for_muxval(u8 muxval)
96 return mdio_names[muxval];
99 struct mii_dev *mii_dev_for_muxval(u8 muxval)
102 const char *name = t208xqds_mdio_name_for_muxval(muxval);
105 printf("No bus for muxval %x\n", muxval);
109 bus = miiphy_get_dev_by_name(name);
112 printf("No bus by name %s\n", name);
119 struct t208xqds_mdio {
121 struct mii_dev *realbus;
124 static void t208xqds_mux_mdio(u8 muxval)
128 brdcfg4 = QIXIS_READ(brdcfg[4]);
129 brdcfg4 &= ~BRDCFG4_EMISEL_MASK;
130 brdcfg4 |= (muxval << BRDCFG4_EMISEL_SHIFT);
131 QIXIS_WRITE(brdcfg[4], brdcfg4);
135 static int t208xqds_mdio_read(struct mii_dev *bus, int addr, int devad,
138 struct t208xqds_mdio *priv = bus->priv;
140 t208xqds_mux_mdio(priv->muxval);
142 return priv->realbus->read(priv->realbus, addr, devad, regnum);
145 static int t208xqds_mdio_write(struct mii_dev *bus, int addr, int devad,
146 int regnum, u16 value)
148 struct t208xqds_mdio *priv = bus->priv;
150 t208xqds_mux_mdio(priv->muxval);
152 return priv->realbus->write(priv->realbus, addr, devad, regnum, value);
155 static int t208xqds_mdio_reset(struct mii_dev *bus)
157 struct t208xqds_mdio *priv = bus->priv;
159 return priv->realbus->reset(priv->realbus);
162 static int t208xqds_mdio_init(char *realbusname, u8 muxval)
164 struct t208xqds_mdio *pmdio;
165 struct mii_dev *bus = mdio_alloc();
168 printf("Failed to allocate t208xqds MDIO bus\n");
172 pmdio = malloc(sizeof(*pmdio));
174 printf("Failed to allocate t208xqds private data\n");
179 bus->read = t208xqds_mdio_read;
180 bus->write = t208xqds_mdio_write;
181 bus->reset = t208xqds_mdio_reset;
182 strcpy(bus->name, t208xqds_mdio_name_for_muxval(muxval));
184 pmdio->realbus = miiphy_get_dev_by_name(realbusname);
186 if (!pmdio->realbus) {
187 printf("No bus with name %s\n", realbusname);
193 pmdio->muxval = muxval;
195 return mdio_register(bus);
198 void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr,
199 enum fm_port port, int offset)
203 char lane_mode[2][20] = {"1000BASE-KX", "10GBASE-KR"};
204 char buf[32] = "serdes-1,";
205 struct fixed_link f_link;
210 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
211 #ifdef CONFIG_TARGET_T2080QDS
212 serdes_corenet_t *srds_regs =
213 (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR;
214 u32 srds1_pccr1 = in_be32(&srds_regs->srdspccr1);
216 u32 srds_s1 = in_be32(&gur->rcwsr[4]) &
217 FSL_CORENET2_RCWSR4_SRDS1_PRTCL;
219 srds_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT;
221 if (fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_SGMII) {
222 phy = fm_info_get_phy_address(port);
224 #if defined(CONFIG_TARGET_T2080QDS)
226 if (hwconfig_sub("fsl_1gkx", "fm1_1g1")) {
228 fdt_set_phy_handle(fdt, compat, addr,
230 fdt_status_okay_by_alias(fdt, "1gkx_pcs_mdio1");
231 sprintf(buf, "%s%s%s", buf, "lane-c,",
232 (char *)lane_mode[0]);
233 out_be32(&srds_regs->srdspccr1, srds1_pccr1 |
234 PCCR1_SGMIIH_KX_MASK);
238 if (hwconfig_sub("fsl_1gkx", "fm1_1g2")) {
240 fdt_set_phy_handle(fdt, compat, addr,
242 fdt_status_okay_by_alias(fdt, "1gkx_pcs_mdio2");
243 sprintf(buf, "%s%s%s", buf, "lane-d,",
244 (char *)lane_mode[0]);
245 out_be32(&srds_regs->srdspccr1, srds1_pccr1 |
246 PCCR1_SGMIIG_KX_MASK);
250 if (hwconfig_sub("fsl_1gkx", "fm1_1g9")) {
252 fdt_set_phy_handle(fdt, compat, addr,
254 fdt_status_okay_by_alias(fdt, "1gkx_pcs_mdio9");
255 sprintf(buf, "%s%s%s", buf, "lane-a,",
256 (char *)lane_mode[0]);
257 out_be32(&srds_regs->srdspccr1, srds1_pccr1 |
258 PCCR1_SGMIIE_KX_MASK);
262 if (hwconfig_sub("fsl_1gkx", "fm1_1g10")) {
264 fdt_set_phy_handle(fdt, compat, addr,
266 fdt_status_okay_by_alias(fdt,
268 sprintf(buf, "%s%s%s", buf, "lane-b,",
269 (char *)lane_mode[0]);
270 out_be32(&srds_regs->srdspccr1, srds1_pccr1 |
271 PCCR1_SGMIIF_KX_MASK);
274 if (mdio_mux[port] == EMI1_SLOT2) {
275 sprintf(alias, "phy_sgmii_s2_%x", phy);
276 fdt_set_phy_handle(fdt, compat, addr, alias);
277 fdt_status_okay_by_alias(fdt, "emi1_slot2");
278 } else if (mdio_mux[port] == EMI1_SLOT3) {
279 sprintf(alias, "phy_sgmii_s3_%x", phy);
280 fdt_set_phy_handle(fdt, compat, addr, alias);
281 fdt_status_okay_by_alias(fdt, "emi1_slot3");
285 if (hwconfig_sub("fsl_1gkx", "fm1_1g5")) {
287 fdt_set_phy_handle(fdt, compat, addr,
289 fdt_status_okay_by_alias(fdt, "1gkx_pcs_mdio5");
290 sprintf(buf, "%s%s%s", buf, "lane-g,",
291 (char *)lane_mode[0]);
292 out_be32(&srds_regs->srdspccr1, srds1_pccr1 |
293 PCCR1_SGMIIC_KX_MASK);
297 if (hwconfig_sub("fsl_1gkx", "fm1_1g6")) {
299 fdt_set_phy_handle(fdt, compat, addr,
301 fdt_status_okay_by_alias(fdt, "1gkx_pcs_mdio6");
302 sprintf(buf, "%s%s%s", buf, "lane-h,",
303 (char *)lane_mode[0]);
304 out_be32(&srds_regs->srdspccr1, srds1_pccr1 |
305 PCCR1_SGMIID_KX_MASK);
308 if (mdio_mux[port] == EMI1_SLOT1) {
309 sprintf(alias, "phy_sgmii_s1_%x", phy);
310 fdt_set_phy_handle(fdt, compat, addr, alias);
311 fdt_status_okay_by_alias(fdt, "emi1_slot1");
312 } else if (mdio_mux[port] == EMI1_SLOT2) {
313 sprintf(alias, "phy_sgmii_s2_%x", phy);
314 fdt_set_phy_handle(fdt, compat, addr, alias);
315 fdt_status_okay_by_alias(fdt, "emi1_slot2");
318 #elif defined(CONFIG_TARGET_T2081QDS)
325 if (mdio_mux[port] == EMI1_SLOT2) {
326 sprintf(alias, "phy_sgmii_s2_%x", phy);
327 fdt_set_phy_handle(fdt, compat, addr, alias);
328 fdt_status_okay_by_alias(fdt, "emi1_slot2");
329 } else if (mdio_mux[port] == EMI1_SLOT3) {
330 sprintf(alias, "phy_sgmii_s3_%x", phy);
331 fdt_set_phy_handle(fdt, compat, addr, alias);
332 fdt_status_okay_by_alias(fdt, "emi1_slot3");
333 } else if (mdio_mux[port] == EMI1_SLOT5) {
334 sprintf(alias, "phy_sgmii_s5_%x", phy);
335 fdt_set_phy_handle(fdt, compat, addr, alias);
336 fdt_status_okay_by_alias(fdt, "emi1_slot5");
337 } else if (mdio_mux[port] == EMI1_SLOT6) {
338 sprintf(alias, "phy_sgmii_s6_%x", phy);
339 fdt_set_phy_handle(fdt, compat, addr, alias);
340 fdt_status_okay_by_alias(fdt, "emi1_slot6");
341 } else if (mdio_mux[port] == EMI1_SLOT7) {
342 sprintf(alias, "phy_sgmii_s7_%x", phy);
343 fdt_set_phy_handle(fdt, compat, addr, alias);
344 fdt_status_okay_by_alias(fdt, "emi1_slot7");
352 /* set property for 1000BASE-KX in dtb */
353 off = fdt_node_offset_by_compat_reg(fdt,
354 "fsl,fman-memac-mdio", addr + 0x1000);
355 fdt_setprop_string(fdt, off, "lane-instance", buf);
358 } else if (fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_XGMII) {
360 case 0x66: /* XFI interface */
366 * if the 10G is XFI, check hwconfig to see what is the
367 * media type, there are two types, fiber or copper,
368 * fix the dtb accordingly.
372 if (hwconfig_sub("fsl_10gkr_copper", "fm1_10g1")) {
375 fdt_set_phy_handle(fdt, compat, addr,
377 fdt_status_okay_by_alias(fdt, "xfi_pcs_mdio9");
378 sprintf(buf, "%s%s%s", buf, "lane-a,",
379 (char *)lane_mode[1]);
383 if (hwconfig_sub("fsl_10gkr_copper", "fm1_10g2")) {
386 fdt_set_phy_handle(fdt, compat, addr,
388 fdt_status_okay_by_alias(fdt, "xfi_pcs_mdio10");
389 sprintf(buf, "%s%s%s", buf, "lane-b,",
390 (char *)lane_mode[1]);
394 if (hwconfig_sub("fsl_10gkr_copper", "fm1_10g3")) {
397 fdt_set_phy_handle(fdt, compat, addr,
399 fdt_status_okay_by_alias(fdt, "xfi_pcs_mdio1");
400 sprintf(buf, "%s%s%s", buf, "lane-c,",
401 (char *)lane_mode[1]);
405 if (hwconfig_sub("fsl_10gkr_copper", "fm1_10g4")) {
408 fdt_set_phy_handle(fdt, compat, addr,
410 fdt_status_okay_by_alias(fdt, "xfi_pcs_mdio2");
411 sprintf(buf, "%s%s%s", buf, "lane-d,",
412 (char *)lane_mode[1]);
420 phyconn = fdt_getprop(fdt, offset,
421 "phy-connection-type",
423 if (is_backplane_mode(phyconn)) {
424 /* Backplane KR mode: skip fixups */
425 printf("Interface %d in backplane KR mode\n",
428 /* fixed-link for XFI fiber cable */
429 f_link.phy_id = port;
431 f_link.link_speed = 10000;
433 f_link.asym_pause = 0;
434 fdt_delprop(fdt, offset, "phy-handle");
435 fdt_setprop(fdt, offset, "fixed-link",
436 &f_link, sizeof(f_link));
439 /* set property for copper cable */
440 off = fdt_node_offset_by_compat_reg(fdt,
441 "fsl,fman-memac-mdio", addr + 0x1000);
442 fdt_setprop_string(fdt, off,
443 "lane-instance", buf);
452 void fdt_fixup_board_enet(void *fdt)
458 * This function reads RCW to check if Serdes1{A:H} is configured
459 * to slot 1/2/3/4/5/6/7 and update the lane_to_slot[] array accordingly
461 static void initialize_lane_to_slot(void)
463 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
464 u32 srds_s1 = in_be32(&gur->rcwsr[4]) &
465 FSL_CORENET2_RCWSR4_SRDS1_PRTCL;
467 srds_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT;
470 #if defined(CONFIG_TARGET_T2080QDS)
497 #elif defined(CONFIG_TARGET_T2081QDS)
527 int board_eth_init(bd_t *bis)
529 #if defined(CONFIG_FMAN_ENET)
530 int i, idx, lane, slot, interface;
531 struct memac_mdio_info dtsec_mdio_info;
532 struct memac_mdio_info tgec_mdio_info;
533 ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR);
534 u32 rcwsr13 = in_be32(&gur->rcwsr[13]);
537 srds_s1 = in_be32(&gur->rcwsr[4]) &
538 FSL_CORENET2_RCWSR4_SRDS1_PRTCL;
539 srds_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT;
541 initialize_lane_to_slot();
543 /* Initialize the mdio_mux array so we can recognize empty elements */
544 for (i = 0; i < NUM_FM_PORTS; i++)
545 mdio_mux[i] = EMI_NONE;
547 dtsec_mdio_info.regs =
548 (struct memac_mdio_controller *)CONFIG_SYS_FM1_DTSEC_MDIO_ADDR;
550 dtsec_mdio_info.name = DEFAULT_FM_MDIO_NAME;
552 /* Register the 1G MDIO bus */
553 fm_memac_mdio_init(bis, &dtsec_mdio_info);
555 tgec_mdio_info.regs =
556 (struct memac_mdio_controller *)CONFIG_SYS_FM1_TGEC_MDIO_ADDR;
557 tgec_mdio_info.name = DEFAULT_FM_TGEC_MDIO_NAME;
559 /* Register the 10G MDIO bus */
560 fm_memac_mdio_init(bis, &tgec_mdio_info);
562 /* Register the muxing front-ends to the MDIO buses */
563 t208xqds_mdio_init(DEFAULT_FM_MDIO_NAME, EMI1_RGMII1);
564 t208xqds_mdio_init(DEFAULT_FM_MDIO_NAME, EMI1_RGMII2);
565 t208xqds_mdio_init(DEFAULT_FM_MDIO_NAME, EMI1_SLOT1);
566 t208xqds_mdio_init(DEFAULT_FM_MDIO_NAME, EMI1_SLOT2);
567 t208xqds_mdio_init(DEFAULT_FM_MDIO_NAME, EMI1_SLOT3);
568 #if defined(CONFIG_TARGET_T2080QDS)
569 t208xqds_mdio_init(DEFAULT_FM_MDIO_NAME, EMI1_SLOT4);
571 t208xqds_mdio_init(DEFAULT_FM_MDIO_NAME, EMI1_SLOT5);
572 #if defined(CONFIG_TARGET_T2081QDS)
573 t208xqds_mdio_init(DEFAULT_FM_MDIO_NAME, EMI1_SLOT6);
574 t208xqds_mdio_init(DEFAULT_FM_MDIO_NAME, EMI1_SLOT7);
576 t208xqds_mdio_init(DEFAULT_FM_TGEC_MDIO_NAME, EMI2);
578 /* Set the two on-board RGMII PHY address */
579 fm_info_set_phy_address(FM1_DTSEC3, RGMII_PHY1_ADDR);
580 if ((rcwsr13 & FSL_CORENET_RCWSR13_EC2) ==
581 FSL_CORENET_RCWSR13_EC2_DTSEC4_RGMII)
582 fm_info_set_phy_address(FM1_DTSEC4, RGMII_PHY2_ADDR);
584 fm_info_set_phy_address(FM1_DTSEC10, RGMII_PHY2_ADDR);
592 /* T2080QDS: SGMII in Slot3; T2081QDS: SGMII in Slot2 */
593 fm_info_set_phy_address(FM1_DTSEC9, SGMII_CARD_PORT1_PHY_ADDR);
594 fm_info_set_phy_address(FM1_DTSEC10, SGMII_CARD_PORT2_PHY_ADDR);
595 fm_info_set_phy_address(FM1_DTSEC1, SGMII_CARD_PORT3_PHY_ADDR);
596 fm_info_set_phy_address(FM1_DTSEC2, SGMII_CARD_PORT4_PHY_ADDR);
597 /* T2080QDS: SGMII in Slot2; T2081QDS: SGMII in Slot1 */
598 fm_info_set_phy_address(FM1_DTSEC5, SGMII_CARD_PORT3_PHY_ADDR);
599 fm_info_set_phy_address(FM1_DTSEC6, SGMII_CARD_PORT4_PHY_ADDR);
607 /* T2080QDS: XAUI/HiGig in Slot3; T2081QDS: in Slot2 */
608 fm_info_set_phy_address(FM1_10GEC1, FM1_10GEC1_PHY_ADDR);
609 /* T2080QDS: SGMII in Slot2; T2081QDS: in Slot3 */
610 fm_info_set_phy_address(FM1_DTSEC5, SGMII_CARD_PORT3_PHY_ADDR);
611 fm_info_set_phy_address(FM1_DTSEC6, SGMII_CARD_PORT4_PHY_ADDR);
616 * XFI does not need a PHY to work, but to avoid U-Boot use
617 * default PHY address which is zero to a MAC when it found
618 * a MAC has no PHY address, we give a PHY address to XFI
619 * MAC, and should not use a real XAUI PHY address, since
620 * MDIO can access it successfully, and then MDIO thinks
621 * the XAUI card is used for the XFI MAC, which will cause
624 fm_info_set_phy_address(FM1_10GEC1, 4);
625 fm_info_set_phy_address(FM1_10GEC2, 5);
626 fm_info_set_phy_address(FM1_10GEC3, 6);
627 fm_info_set_phy_address(FM1_10GEC4, 7);
631 fm_info_set_phy_address(FM1_10GEC1, 4);
632 fm_info_set_phy_address(FM1_10GEC2, 5);
633 fm_info_set_phy_address(FM1_10GEC3, 6);
634 fm_info_set_phy_address(FM1_10GEC4, 7);
635 /* T2080QDS: SGMII in Slot2; T2081QDS: in Slot3 */
636 fm_info_set_phy_address(FM1_DTSEC5, SGMII_CARD_PORT3_PHY_ADDR);
637 fm_info_set_phy_address(FM1_DTSEC6, SGMII_CARD_PORT2_PHY_ADDR);
641 fm_info_set_phy_address(FM1_10GEC1, 4);
642 fm_info_set_phy_address(FM1_10GEC2, 5);
643 /* T2080QDS: SGMII in Slot3; T2081QDS: in Slot2 */
644 fm_info_set_phy_address(FM1_DTSEC1, SGMII_CARD_PORT3_PHY_ADDR);
645 fm_info_set_phy_address(FM1_DTSEC2, SGMII_CARD_PORT4_PHY_ADDR);
650 fm_info_set_phy_address(FM1_DTSEC1, SGMII_CARD_PORT3_PHY_ADDR);
651 fm_info_set_phy_address(FM1_DTSEC2, SGMII_CARD_PORT4_PHY_ADDR);
653 fm_info_set_phy_address(FM1_DTSEC5, SGMII_CARD_PORT3_PHY_ADDR);
654 fm_info_set_phy_address(FM1_DTSEC6, SGMII_CARD_PORT2_PHY_ADDR);
662 fm_info_set_phy_address(FM1_DTSEC9, SGMII_CARD_PORT1_PHY_ADDR);
663 fm_info_set_phy_address(FM1_DTSEC10, SGMII_CARD_PORT2_PHY_ADDR);
664 fm_info_set_phy_address(FM1_DTSEC1, SGMII_CARD_PORT3_PHY_ADDR);
665 fm_info_set_phy_address(FM1_DTSEC2, SGMII_CARD_PORT4_PHY_ADDR);
667 fm_info_set_phy_address(FM1_DTSEC5, SGMII_CARD_PORT3_PHY_ADDR);
668 fm_info_set_phy_address(FM1_DTSEC6, SGMII_CARD_PORT2_PHY_ADDR);
674 fm_info_set_phy_address(FM1_DTSEC9, SGMII_CARD_PORT1_PHY_ADDR);
675 fm_info_set_phy_address(FM1_DTSEC10, SGMII_CARD_PORT2_PHY_ADDR);
676 fm_info_set_phy_address(FM1_DTSEC1, SGMII_CARD_PORT3_PHY_ADDR);
677 fm_info_set_phy_address(FM1_DTSEC2, SGMII_CARD_PORT4_PHY_ADDR);
679 #if defined(CONFIG_TARGET_T2080QDS)
684 fm_info_set_phy_address(FM1_DTSEC10, SGMII_CARD_PORT2_PHY_ADDR);
685 fm_info_set_phy_address(FM1_DTSEC1, SGMII_CARD_PORT3_PHY_ADDR);
686 fm_info_set_phy_address(FM1_DTSEC2, SGMII_CARD_PORT4_PHY_ADDR);
688 fm_info_set_phy_address(FM1_DTSEC5, SGMII_CARD_PORT3_PHY_ADDR);
689 fm_info_set_phy_address(FM1_DTSEC6, SGMII_CARD_PORT2_PHY_ADDR);
691 #elif defined(CONFIG_TARGET_T2081QDS)
695 fm_info_set_phy_address(FM1_DTSEC5, SGMII_CARD_PORT1_PHY_ADDR);
696 fm_info_set_phy_address(FM1_DTSEC6, SGMII_CARD_PORT2_PHY_ADDR);
698 fm_info_set_phy_address(FM1_DTSEC2, SGMII_CARD_PORT1_PHY_ADDR);
700 fm_info_set_phy_address(FM1_DTSEC1, SGMII_CARD_PORT1_PHY_ADDR);
702 fm_info_set_phy_address(FM1_DTSEC10, SGMII_CARD_PORT3_PHY_ADDR);
706 /* T2080QDS: SGMII in Slot3; T2081QDS: SGMII in Slot7 */
707 fm_info_set_phy_address(FM1_DTSEC1, SGMII_CARD_PORT1_PHY_ADDR);
708 fm_info_set_phy_address(FM1_DTSEC2, SGMII_CARD_PORT2_PHY_ADDR);
709 fm_info_set_phy_address(FM1_DTSEC10, SGMII_CARD_PORT3_PHY_ADDR);
710 fm_info_set_phy_address(FM1_DTSEC6, SGMII_CARD_PORT4_PHY_ADDR);
716 for (i = FM1_DTSEC1; i < FM1_DTSEC1 + CONFIG_SYS_NUM_FM1_DTSEC; i++) {
717 idx = i - FM1_DTSEC1;
718 interface = fm_info_get_enet_if(i);
720 case PHY_INTERFACE_MODE_SGMII:
721 lane = serdes_get_first_lane(FSL_SRDS_1,
722 SGMII_FM1_DTSEC1 + idx);
725 slot = lane_to_slot[lane];
726 debug("FM1@DTSEC%u expects SGMII in slot %u\n",
728 if (QIXIS_READ(present2) & (1 << (slot - 1)))
733 mdio_mux[i] = EMI1_SLOT1;
734 fm_info_set_mdio(i, mii_dev_for_muxval(
738 mdio_mux[i] = EMI1_SLOT2;
739 fm_info_set_mdio(i, mii_dev_for_muxval(
743 mdio_mux[i] = EMI1_SLOT3;
744 fm_info_set_mdio(i, mii_dev_for_muxval(
747 #if defined(CONFIG_TARGET_T2081QDS)
749 mdio_mux[i] = EMI1_SLOT5;
750 fm_info_set_mdio(i, mii_dev_for_muxval(
754 mdio_mux[i] = EMI1_SLOT6;
755 fm_info_set_mdio(i, mii_dev_for_muxval(
759 mdio_mux[i] = EMI1_SLOT7;
760 fm_info_set_mdio(i, mii_dev_for_muxval(
766 case PHY_INTERFACE_MODE_RGMII:
768 mdio_mux[i] = EMI1_RGMII1;
769 else if (i == FM1_DTSEC4 || FM1_DTSEC10)
770 mdio_mux[i] = EMI1_RGMII2;
771 fm_info_set_mdio(i, mii_dev_for_muxval(mdio_mux[i]));
778 for (i = FM1_10GEC1; i < FM1_10GEC1 + CONFIG_SYS_NUM_FM1_10GEC; i++) {
779 idx = i - FM1_10GEC1;
780 switch (fm_info_get_enet_if(i)) {
781 case PHY_INTERFACE_MODE_XGMII:
782 if (srds_s1 == 0x51) {
783 lane = serdes_get_first_lane(FSL_SRDS_1,
784 XAUI_FM1_MAC9 + idx);
785 } else if ((srds_s1 == 0x5f) || (srds_s1 == 0x65)) {
786 lane = serdes_get_first_lane(FSL_SRDS_1,
787 HIGIG_FM1_MAC9 + idx);
789 if (i == FM1_10GEC1 || i == FM1_10GEC2)
790 lane = serdes_get_first_lane(FSL_SRDS_1,
793 lane = serdes_get_first_lane(FSL_SRDS_1,
800 fm_info_set_mdio(i, mii_dev_for_muxval(mdio_mux[i]));
802 if ((srds_s1 == 0x66) || (srds_s1 == 0x6b) ||
803 (srds_s1 == 0x6a) || (srds_s1 == 0x70) ||
804 (srds_s1 == 0x6c) || (srds_s1 == 0x6d) ||
806 /* As XFI is in cage intead of a slot, so
807 * ensure doesn't disable the corresponding port
812 slot = lane_to_slot[lane];
813 if (QIXIS_READ(present2) & (1 << (slot - 1)))
822 #endif /* CONFIG_FMAN_ENET */
824 return pci_eth_init(bis);