1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2015 Freescale Semiconductor, Inc.
10 #include <asm/arch/fsl_serdes.h>
17 #include <fsl-mc/fsl_mc.h>
18 #include <fsl-mc/ldpaa_wriop.h>
20 #include "../common/qixis.h"
22 #include "ls2080aqds_qixis.h"
24 #define MC_BOOT_ENV_VAR "mcinitcmd"
26 #if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
27 /* - In LS2080A there are only 16 SERDES lanes, spread across 2 SERDES banks.
28 * Bank 1 -> Lanes A, B, C, D, E, F, G, H
29 * Bank 2 -> Lanes A,B, C, D, E, F, G, H
32 /* Mapping of 16 SERDES lanes to LS2080A QDS board slots. A value of '0' here
33 * means that the mapping must be determined dynamically, or that the lane
34 * maps to something other than a board slot.
37 static u8 lane_to_slot_fsm1[] = {
38 0, 0, 0, 0, 0, 0, 0, 0
41 static u8 lane_to_slot_fsm2[] = {
42 0, 0, 0, 0, 0, 0, 0, 0
45 /* On the Vitesse VSC8234XHG SGMII riser card there are 4 SGMII PHYs
49 static int xqsgii_riser_phy_addr[] = {
50 XQSGMII_CARD_PHY1_PORT0_ADDR,
51 XQSGMII_CARD_PHY2_PORT0_ADDR,
52 XQSGMII_CARD_PHY3_PORT0_ADDR,
53 XQSGMII_CARD_PHY4_PORT0_ADDR,
54 XQSGMII_CARD_PHY3_PORT2_ADDR,
55 XQSGMII_CARD_PHY1_PORT2_ADDR,
56 XQSGMII_CARD_PHY4_PORT2_ADDR,
57 XQSGMII_CARD_PHY2_PORT2_ADDR,
60 static int sgmii_riser_phy_addr[] = {
61 SGMII_CARD_PORT1_PHY_ADDR,
62 SGMII_CARD_PORT2_PHY_ADDR,
63 SGMII_CARD_PORT3_PHY_ADDR,
64 SGMII_CARD_PORT4_PHY_ADDR,
67 /* Slot2 does not have EMI connections */
78 static const char * const mdio_names[] = {
85 DEFAULT_WRIOP_MDIO2_NAME,
88 struct ls2080a_qds_mdio {
90 struct mii_dev *realbus;
93 static void sgmii_configure_repeater(int serdes_port)
98 int dpmac_id = 0, dpmac, mii_bus = 0;
100 char dev[2][20] = {"LS2080A_QDS_MDIO0", "LS2080A_QDS_MDIO3"};
101 uint8_t i2c_addr[] = {0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5f, 0x60};
103 uint8_t ch_a_eq[] = {0x1, 0x2, 0x3, 0x7};
104 uint8_t ch_a_ctl2[] = {0x81, 0x82, 0x83, 0x84};
105 uint8_t ch_b_eq[] = {0x1, 0x2, 0x3, 0x7};
106 uint8_t ch_b_ctl2[] = {0x81, 0x82, 0x83, 0x84};
108 int *riser_phy_addr = &xqsgii_riser_phy_addr[0];
110 /* Set I2c to Slot 1 */
111 i2c_write(0x77, 0, 0, &a, 1);
113 for (dpmac = 0; dpmac < 8; dpmac++) {
114 /* Check the PHY status */
115 switch (serdes_port) {
118 dpmac_id = dpmac + 1;
122 dpmac_id = dpmac + 9;
124 i2c_write(0x76, 0, 0, &a, 1);
128 ret = miiphy_set_current_dev(dev[mii_bus]);
132 bus = mdio_get_current_dev();
133 debug("Reading from bus %s\n", bus->name);
135 ret = miiphy_write(dev[mii_bus], riser_phy_addr[dpmac], 0x1f,
141 ret = miiphy_read(dev[mii_bus], riser_phy_addr[dpmac], 0x11,
148 if ((value & 0xfff) == 0x401) {
149 printf("DPMAC %d:PHY is ..... Configured\n", dpmac_id);
150 miiphy_write(dev[mii_bus], riser_phy_addr[dpmac],
155 for (i = 0; i < 4; i++) {
156 for (j = 0; j < 4; j++) {
158 i2c_write(i2c_addr[dpmac], 6, 1, &a, 1);
160 i2c_write(i2c_addr[dpmac], 4, 1, &a, 1);
162 i2c_write(i2c_addr[dpmac], 8, 1, &a, 1);
164 i2c_write(i2c_addr[dpmac], 0xf, 1,
166 i2c_write(i2c_addr[dpmac], 0x11, 1,
169 i2c_write(i2c_addr[dpmac], 0x16, 1,
171 i2c_write(i2c_addr[dpmac], 0x18, 1,
175 i2c_write(i2c_addr[dpmac], 0x23, 1, &a, 1);
177 i2c_write(i2c_addr[dpmac], 0x2d, 1, &a, 1);
179 i2c_write(i2c_addr[dpmac], 4, 1, &a, 1);
181 ret = miiphy_read(dev[mii_bus],
182 riser_phy_addr[dpmac],
188 ret = miiphy_read(dev[mii_bus],
189 riser_phy_addr[dpmac],
194 if ((value & 0xfff) == 0x401) {
195 printf("DPMAC %d :PHY is configured ",
197 printf("after setting repeater 0x%x\n",
202 printf("DPMAC %d :PHY is failed to ",
204 printf("configure the repeater 0x%x\n",
209 miiphy_write(dev[mii_bus], riser_phy_addr[dpmac], 0x1f, 0);
213 printf("DPMAC %d ..... FAILED to configure PHY\n", dpmac_id);
217 static void qsgmii_configure_repeater(int dpmac)
221 int i2c_phy_addr = 0;
223 int i2c_addr[] = {0x58, 0x59, 0x5a, 0x5b};
225 uint8_t ch_a_eq[] = {0x1, 0x2, 0x3, 0x7};
226 uint8_t ch_a_ctl2[] = {0x81, 0x82, 0x83, 0x84};
227 uint8_t ch_b_eq[] = {0x1, 0x2, 0x3, 0x7};
228 uint8_t ch_b_ctl2[] = {0x81, 0x82, 0x83, 0x84};
230 const char *dev = "LS2080A_QDS_MDIO0";
232 unsigned short value;
234 /* Set I2c to Slot 1 */
235 i2c_write(0x77, 0, 0, &a, 1);
242 i2c_phy_addr = i2c_addr[0];
250 i2c_phy_addr = i2c_addr[1];
258 i2c_phy_addr = i2c_addr[2];
266 i2c_phy_addr = i2c_addr[3];
271 /* Check the PHY status */
272 ret = miiphy_set_current_dev(dev);
273 ret = miiphy_write(dev, phy_addr, 0x1f, 3);
275 ret = miiphy_read(dev, phy_addr, 0x11, &value);
277 ret = miiphy_read(dev, phy_addr, 0x11, &value);
279 if ((value & 0xf) == 0xf) {
280 printf("DPMAC %d :PHY is ..... Configured\n", dpmac);
284 for (i = 0; i < 4; i++) {
285 for (j = 0; j < 4; j++) {
287 i2c_write(i2c_phy_addr, 6, 1, &a, 1);
289 i2c_write(i2c_phy_addr, 4, 1, &a, 1);
291 i2c_write(i2c_phy_addr, 8, 1, &a, 1);
293 i2c_write(i2c_phy_addr, 0xf, 1, &ch_a_eq[i], 1);
294 i2c_write(i2c_phy_addr, 0x11, 1, &ch_a_ctl2[j], 1);
296 i2c_write(i2c_phy_addr, 0x16, 1, &ch_b_eq[i], 1);
297 i2c_write(i2c_phy_addr, 0x18, 1, &ch_b_ctl2[j], 1);
300 i2c_write(i2c_phy_addr, 0x23, 1, &a, 1);
302 i2c_write(i2c_phy_addr, 0x2d, 1, &a, 1);
304 i2c_write(i2c_phy_addr, 4, 1, &a, 1);
306 ret = miiphy_read(dev, phy_addr, 0x11, &value);
310 ret = miiphy_read(dev, phy_addr, 0x11, &value);
314 if ((value & 0xf) == 0xf) {
315 printf("DPMAC %d :PHY is ..... Configured\n",
322 printf("DPMAC %d :PHY ..... FAILED to configure PHY\n", dpmac);
326 static const char *ls2080a_qds_mdio_name_for_muxval(u8 muxval)
328 return mdio_names[muxval];
331 struct mii_dev *mii_dev_for_muxval(u8 muxval)
334 const char *name = ls2080a_qds_mdio_name_for_muxval(muxval);
337 printf("No bus for muxval %x\n", muxval);
341 bus = miiphy_get_dev_by_name(name);
344 printf("No bus by name %s\n", name);
351 static void ls2080a_qds_enable_SFP_TX(u8 muxval)
355 brdcfg9 = QIXIS_READ(brdcfg[9]);
356 brdcfg9 &= ~BRDCFG9_SFPTX_MASK;
357 brdcfg9 |= (muxval << BRDCFG9_SFPTX_SHIFT);
358 QIXIS_WRITE(brdcfg[9], brdcfg9);
361 static void ls2080a_qds_mux_mdio(u8 muxval)
366 brdcfg4 = QIXIS_READ(brdcfg[4]);
367 brdcfg4 &= ~BRDCFG4_EMISEL_MASK;
368 brdcfg4 |= (muxval << BRDCFG4_EMISEL_SHIFT);
369 QIXIS_WRITE(brdcfg[4], brdcfg4);
373 static int ls2080a_qds_mdio_read(struct mii_dev *bus, int addr,
374 int devad, int regnum)
376 struct ls2080a_qds_mdio *priv = bus->priv;
378 ls2080a_qds_mux_mdio(priv->muxval);
380 return priv->realbus->read(priv->realbus, addr, devad, regnum);
383 static int ls2080a_qds_mdio_write(struct mii_dev *bus, int addr, int devad,
384 int regnum, u16 value)
386 struct ls2080a_qds_mdio *priv = bus->priv;
388 ls2080a_qds_mux_mdio(priv->muxval);
390 return priv->realbus->write(priv->realbus, addr, devad, regnum, value);
393 static int ls2080a_qds_mdio_reset(struct mii_dev *bus)
395 struct ls2080a_qds_mdio *priv = bus->priv;
397 return priv->realbus->reset(priv->realbus);
400 static int ls2080a_qds_mdio_init(char *realbusname, u8 muxval)
402 struct ls2080a_qds_mdio *pmdio;
403 struct mii_dev *bus = mdio_alloc();
406 printf("Failed to allocate ls2080a_qds MDIO bus\n");
410 pmdio = malloc(sizeof(*pmdio));
412 printf("Failed to allocate ls2080a_qds private data\n");
417 bus->read = ls2080a_qds_mdio_read;
418 bus->write = ls2080a_qds_mdio_write;
419 bus->reset = ls2080a_qds_mdio_reset;
420 strcpy(bus->name, ls2080a_qds_mdio_name_for_muxval(muxval));
422 pmdio->realbus = miiphy_get_dev_by_name(realbusname);
424 if (!pmdio->realbus) {
425 printf("No bus with name %s\n", realbusname);
431 pmdio->muxval = muxval;
434 return mdio_register(bus);
438 * Initialize the dpmac_info array.
441 static void initialize_dpmac_to_slot(void)
443 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
444 int serdes1_prtcl = (in_le32(&gur->rcwsr[28]) &
445 FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_MASK)
446 >> FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_SHIFT;
447 int serdes2_prtcl = (in_le32(&gur->rcwsr[28]) &
448 FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_MASK)
449 >> FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_SHIFT;
452 env_hwconfig = env_get("hwconfig");
454 switch (serdes1_prtcl) {
458 printf("qds: WRIOP: Supported SerDes1 Protocol 0x%02x\n",
460 lane_to_slot_fsm1[0] = EMI1_SLOT1;
461 lane_to_slot_fsm1[1] = EMI1_SLOT1;
462 lane_to_slot_fsm1[2] = EMI1_SLOT1;
463 lane_to_slot_fsm1[3] = EMI1_SLOT1;
464 if (hwconfig_f("xqsgmii", env_hwconfig)) {
465 lane_to_slot_fsm1[4] = EMI1_SLOT1;
466 lane_to_slot_fsm1[5] = EMI1_SLOT1;
467 lane_to_slot_fsm1[6] = EMI1_SLOT1;
468 lane_to_slot_fsm1[7] = EMI1_SLOT1;
470 lane_to_slot_fsm1[4] = EMI1_SLOT2;
471 lane_to_slot_fsm1[5] = EMI1_SLOT2;
472 lane_to_slot_fsm1[6] = EMI1_SLOT2;
473 lane_to_slot_fsm1[7] = EMI1_SLOT2;
478 printf("qds: WRIOP: Supported SerDes1 Protocol 0x%02x\n",
480 if (hwconfig_f("xqsgmii", env_hwconfig)) {
481 lane_to_slot_fsm1[0] = EMI1_SLOT3;
482 lane_to_slot_fsm1[1] = EMI1_SLOT3;
483 lane_to_slot_fsm1[2] = EMI1_SLOT3;
484 lane_to_slot_fsm1[3] = EMI_NONE;
486 lane_to_slot_fsm1[0] = EMI_NONE;
487 lane_to_slot_fsm1[1] = EMI_NONE;
488 lane_to_slot_fsm1[2] = EMI_NONE;
489 lane_to_slot_fsm1[3] = EMI_NONE;
491 lane_to_slot_fsm1[4] = EMI1_SLOT3;
492 lane_to_slot_fsm1[5] = EMI1_SLOT3;
493 lane_to_slot_fsm1[6] = EMI1_SLOT3;
494 lane_to_slot_fsm1[7] = EMI_NONE;
498 printf("qds: WRIOP: Supported SerDes1 Protocol 0x%02x\n",
500 if (hwconfig_f("xqsgmii", env_hwconfig)) {
501 lane_to_slot_fsm1[0] = EMI1_SLOT3;
502 lane_to_slot_fsm1[1] = EMI1_SLOT3;
503 lane_to_slot_fsm1[2] = EMI_NONE;
504 lane_to_slot_fsm1[3] = EMI_NONE;
506 lane_to_slot_fsm1[0] = EMI_NONE;
507 lane_to_slot_fsm1[1] = EMI_NONE;
508 lane_to_slot_fsm1[2] = EMI_NONE;
509 lane_to_slot_fsm1[3] = EMI_NONE;
511 lane_to_slot_fsm1[4] = EMI1_SLOT3;
512 lane_to_slot_fsm1[5] = EMI1_SLOT3;
513 lane_to_slot_fsm1[6] = EMI_NONE;
514 lane_to_slot_fsm1[7] = EMI_NONE;
520 printf("qds: WRIOP: Supported SerDes1 Protocol 0x%02x\n",
524 printf("%s qds: WRIOP: Unsupported SerDes1 Protocol 0x%02x\n",
525 __func__, serdes1_prtcl);
529 switch (serdes2_prtcl) {
534 printf("qds: WRIOP: Supported SerDes2 Protocol 0x%02x\n",
536 lane_to_slot_fsm2[0] = EMI1_SLOT4;
537 lane_to_slot_fsm2[1] = EMI1_SLOT4;
538 lane_to_slot_fsm2[2] = EMI1_SLOT4;
539 lane_to_slot_fsm2[3] = EMI1_SLOT4;
541 if (hwconfig_f("xqsgmii", env_hwconfig)) {
542 lane_to_slot_fsm2[4] = EMI1_SLOT4;
543 lane_to_slot_fsm2[5] = EMI1_SLOT4;
544 lane_to_slot_fsm2[6] = EMI1_SLOT4;
545 lane_to_slot_fsm2[7] = EMI1_SLOT4;
547 /* No MDIO physical connection */
548 lane_to_slot_fsm2[4] = EMI1_SLOT6;
549 lane_to_slot_fsm2[5] = EMI1_SLOT6;
550 lane_to_slot_fsm2[6] = EMI1_SLOT6;
551 lane_to_slot_fsm2[7] = EMI1_SLOT6;
556 printf("qds: WRIOP: Supported SerDes2 Protocol 0x%02x\n",
558 lane_to_slot_fsm2[0] = EMI_NONE;
559 lane_to_slot_fsm2[1] = EMI1_SLOT5;
560 lane_to_slot_fsm2[2] = EMI1_SLOT5;
561 lane_to_slot_fsm2[3] = EMI1_SLOT5;
563 if (hwconfig_f("xqsgmii", env_hwconfig)) {
564 lane_to_slot_fsm2[4] = EMI_NONE;
565 lane_to_slot_fsm2[5] = EMI1_SLOT5;
566 lane_to_slot_fsm2[6] = EMI1_SLOT5;
567 lane_to_slot_fsm2[7] = EMI1_SLOT5;
572 printf("qds: WRIOP: Supported SerDes2 Protocol 0x%02x\n",
574 if (hwconfig_f("xqsgmii", env_hwconfig)) {
575 lane_to_slot_fsm2[0] = EMI_NONE;
576 lane_to_slot_fsm2[1] = EMI_NONE;
577 lane_to_slot_fsm2[2] = EMI_NONE;
578 lane_to_slot_fsm2[3] = EMI_NONE;
580 lane_to_slot_fsm2[4] = EMI_NONE;
581 lane_to_slot_fsm2[5] = EMI_NONE;
582 lane_to_slot_fsm2[6] = EMI1_SLOT5;
583 lane_to_slot_fsm2[7] = EMI1_SLOT5;
587 printf(" %s qds: WRIOP: Unsupported SerDes2 Protocol 0x%02x\n",
588 __func__ , serdes2_prtcl);
593 void ls2080a_handle_phy_interface_sgmii(int dpmac_id)
597 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
598 int serdes1_prtcl = (in_le32(&gur->rcwsr[28]) &
599 FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_MASK)
600 >> FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_SHIFT;
601 int serdes2_prtcl = (in_le32(&gur->rcwsr[28]) &
602 FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_MASK)
603 >> FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_SHIFT;
606 char *env_hwconfig = env_get("hwconfig");
608 if (hwconfig_f("xqsgmii", env_hwconfig))
609 riser_phy_addr = &xqsgii_riser_phy_addr[0];
611 riser_phy_addr = &sgmii_riser_phy_addr[0];
613 if (dpmac_id > WRIOP1_DPMAC9)
616 switch (serdes1_prtcl) {
620 lane = serdes_get_first_lane(FSL_SRDS_1, SGMII1 + dpmac_id - 1);
622 slot = lane_to_slot_fsm1[lane];
626 /* Slot housing a SGMII riser card? */
627 wriop_set_phy_address(dpmac_id, 0,
628 riser_phy_addr[dpmac_id - 1]);
629 dpmac_info[dpmac_id].board_mux = EMI1_SLOT1;
630 bus = mii_dev_for_muxval(EMI1_SLOT1);
631 wriop_set_mdio(dpmac_id, bus);
634 /* Slot housing a SGMII riser card? */
635 wriop_set_phy_address(dpmac_id, 0,
636 riser_phy_addr[dpmac_id - 1]);
637 dpmac_info[dpmac_id].board_mux = EMI1_SLOT2;
638 bus = mii_dev_for_muxval(EMI1_SLOT2);
639 wriop_set_mdio(dpmac_id, bus);
642 if (slot == EMI_NONE)
644 if (serdes1_prtcl == 0x39) {
645 wriop_set_phy_address(dpmac_id, 0,
646 riser_phy_addr[dpmac_id - 2]);
647 if (dpmac_id >= 6 && hwconfig_f("xqsgmii",
649 wriop_set_phy_address(dpmac_id, 0,
650 riser_phy_addr[dpmac_id - 3]);
652 wriop_set_phy_address(dpmac_id, 0,
653 riser_phy_addr[dpmac_id - 2]);
654 if (dpmac_id >= 7 && hwconfig_f("xqsgmii",
656 wriop_set_phy_address(dpmac_id, 0,
657 riser_phy_addr[dpmac_id - 3]);
659 dpmac_info[dpmac_id].board_mux = EMI1_SLOT3;
660 bus = mii_dev_for_muxval(EMI1_SLOT3);
661 wriop_set_mdio(dpmac_id, bus);
672 printf("%s qds: WRIOP: Unsupported SerDes1 Protocol 0x%02x\n",
673 __func__ , serdes1_prtcl);
678 switch (serdes2_prtcl) {
684 lane = serdes_get_first_lane(FSL_SRDS_2, SGMII9 +
686 slot = lane_to_slot_fsm2[lane];
694 /* Slot housing a SGMII riser card? */
695 wriop_set_phy_address(dpmac_id, 0,
696 riser_phy_addr[dpmac_id - 9]);
697 dpmac_info[dpmac_id].board_mux = EMI1_SLOT4;
698 bus = mii_dev_for_muxval(EMI1_SLOT4);
699 wriop_set_mdio(dpmac_id, bus);
702 if (slot == EMI_NONE)
704 if (serdes2_prtcl == 0x47) {
705 wriop_set_phy_address(dpmac_id, 0,
706 riser_phy_addr[dpmac_id - 10]);
707 if (dpmac_id >= 14 && hwconfig_f("xqsgmii",
709 wriop_set_phy_address(dpmac_id, 0,
710 riser_phy_addr[dpmac_id - 11]);
712 wriop_set_phy_address(dpmac_id, 0,
713 riser_phy_addr[dpmac_id - 11]);
715 dpmac_info[dpmac_id].board_mux = EMI1_SLOT5;
716 bus = mii_dev_for_muxval(EMI1_SLOT5);
717 wriop_set_mdio(dpmac_id, bus);
720 /* Slot housing a SGMII riser card? */
721 wriop_set_phy_address(dpmac_id, 0,
722 riser_phy_addr[dpmac_id - 13]);
723 dpmac_info[dpmac_id].board_mux = EMI1_SLOT6;
724 bus = mii_dev_for_muxval(EMI1_SLOT6);
725 wriop_set_mdio(dpmac_id, bus);
730 printf("%s qds: WRIOP: Unsupported SerDes2 Protocol 0x%02x\n",
731 __func__, serdes2_prtcl);
736 void ls2080a_handle_phy_interface_qsgmii(int dpmac_id)
740 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
741 int serdes1_prtcl = (in_le32(&gur->rcwsr[28]) &
742 FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_MASK)
743 >> FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_SHIFT;
745 switch (serdes1_prtcl) {
752 lane = serdes_get_first_lane(FSL_SRDS_1, QSGMII_A);
758 lane = serdes_get_first_lane(FSL_SRDS_1, QSGMII_B);
764 lane = serdes_get_first_lane(FSL_SRDS_1, QSGMII_C);
770 lane = serdes_get_first_lane(FSL_SRDS_1, QSGMII_D);
774 slot = lane_to_slot_fsm1[lane];
778 /* Slot housing a QSGMII riser card? */
779 wriop_set_phy_address(dpmac_id, 0, dpmac_id - 1);
780 dpmac_info[dpmac_id].board_mux = EMI1_SLOT1;
781 bus = mii_dev_for_muxval(EMI1_SLOT1);
782 wriop_set_mdio(dpmac_id, bus);
795 printf("qds: WRIOP: Unsupported SerDes Protocol 0x%02x\n",
800 qsgmii_configure_repeater(dpmac_id);
803 void ls2080a_handle_phy_interface_xsgmii(int i)
805 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
806 int serdes1_prtcl = (in_le32(&gur->rcwsr[28]) &
807 FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_MASK)
808 >> FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_SHIFT;
810 switch (serdes1_prtcl) {
815 * XFI does not need a PHY to work, but to avoid U-Boot use
816 * default PHY address which is zero to a MAC when it found
817 * a MAC has no PHY address, we give a PHY address to XFI
818 * MAC, and should not use a real XAUI PHY address, since
819 * MDIO can access it successfully, and then MDIO thinks
820 * the XAUI card is used for the XFI MAC, which will cause
823 wriop_set_phy_address(i, 0, i + 4);
824 ls2080a_qds_enable_SFP_TX(SFP_TX);
828 printf("qds: WRIOP: Unsupported SerDes Protocol 0x%02x\n",
835 int board_eth_init(bd_t *bis)
838 #if defined(CONFIG_FSL_MC_ENET) && !defined(CONFIG_SPL_BUILD)
839 struct ccsr_gur __iomem *gur = (void *)CONFIG_SYS_FSL_GUTS_ADDR;
840 int serdes1_prtcl = (in_le32(&gur->rcwsr[28]) &
841 FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_MASK)
842 >> FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_SHIFT;
843 int serdes2_prtcl = (in_le32(&gur->rcwsr[28]) &
844 FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_MASK)
845 >> FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_SHIFT;
847 struct memac_mdio_info *memac_mdio0_info;
848 struct memac_mdio_info *memac_mdio1_info;
852 env_hwconfig = env_get("hwconfig");
854 initialize_dpmac_to_slot();
856 memac_mdio0_info = (struct memac_mdio_info *)malloc(
857 sizeof(struct memac_mdio_info));
858 memac_mdio0_info->regs =
859 (struct memac_mdio_controller *)
860 CONFIG_SYS_FSL_WRIOP1_MDIO1;
861 memac_mdio0_info->name = DEFAULT_WRIOP_MDIO1_NAME;
863 /* Register the real MDIO1 bus */
864 fm_memac_mdio_init(bis, memac_mdio0_info);
866 memac_mdio1_info = (struct memac_mdio_info *)malloc(
867 sizeof(struct memac_mdio_info));
868 memac_mdio1_info->regs =
869 (struct memac_mdio_controller *)
870 CONFIG_SYS_FSL_WRIOP1_MDIO2;
871 memac_mdio1_info->name = DEFAULT_WRIOP_MDIO2_NAME;
873 /* Register the real MDIO2 bus */
874 fm_memac_mdio_init(bis, memac_mdio1_info);
876 /* Register the muxing front-ends to the MDIO buses */
877 ls2080a_qds_mdio_init(DEFAULT_WRIOP_MDIO1_NAME, EMI1_SLOT1);
878 ls2080a_qds_mdio_init(DEFAULT_WRIOP_MDIO1_NAME, EMI1_SLOT2);
879 ls2080a_qds_mdio_init(DEFAULT_WRIOP_MDIO1_NAME, EMI1_SLOT3);
880 ls2080a_qds_mdio_init(DEFAULT_WRIOP_MDIO1_NAME, EMI1_SLOT4);
881 ls2080a_qds_mdio_init(DEFAULT_WRIOP_MDIO1_NAME, EMI1_SLOT5);
882 ls2080a_qds_mdio_init(DEFAULT_WRIOP_MDIO1_NAME, EMI1_SLOT6);
884 ls2080a_qds_mdio_init(DEFAULT_WRIOP_MDIO2_NAME, EMI2);
886 for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++) {
887 switch (wriop_get_enet_if(i)) {
888 case PHY_INTERFACE_MODE_QSGMII:
889 ls2080a_handle_phy_interface_qsgmii(i);
891 case PHY_INTERFACE_MODE_SGMII:
892 ls2080a_handle_phy_interface_sgmii(i);
894 case PHY_INTERFACE_MODE_XGMII:
895 ls2080a_handle_phy_interface_xsgmii(i);
905 error = cpu_eth_init(bis);
907 if (hwconfig_f("xqsgmii", env_hwconfig)) {
908 if (serdes1_prtcl == 0x7)
909 sgmii_configure_repeater(1);
910 if (serdes2_prtcl == 0x7 || serdes2_prtcl == 0x8 ||
911 serdes2_prtcl == 0x49)
912 sgmii_configure_repeater(2);
915 error = pci_eth_init(bis);
919 #if defined(CONFIG_RESET_PHY_R)
924 #endif /* CONFIG_RESET_PHY_R */