1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2018-2019 NXP
19 #include <asm/arch/fsl_serdes.h>
20 #include <fsl-mc/fsl_mc.h>
21 #include <fsl-mc/ldpaa_wriop.h>
23 #include "../common/qixis.h"
25 DECLARE_GLOBAL_DATA_PTR;
28 #define EMI1 1 /* Mdio Bus 1 */
29 #define EMI2 2 /* Mdio Bus 2 */
31 #if defined(CONFIG_FSL_MC_ENET)
47 struct lx2160a_qds_mdio {
48 enum io_slot ioslot : 4;
50 struct mii_dev *realbus;
53 /* structure explaining the phy configuration on 8 lanes of a serdes*/
54 struct serdes_phy_config {
55 u8 serdes; /* serdes protocol */
58 /* -1 terminated array */
59 int phy_address[WRIOP_MAX_PHY_NUM + 1];
62 } phy_config[SRDS_MAX_LANES];
65 /* Table defining the phy configuration on 8 lanes of a serdes.
66 * Various assumptions have been made while defining this table.
67 * e.g. for serdes1 protocol 19 it is being assumed that X-M11-USXGMII
68 * card is being used for dpmac 3-4. (X-M12-XFI could also have been used)
69 * And also that this card is connected to IO Slot 1 (could have been connected
70 * to any of the 8 IO slots (IO slot 1 - IO slot 8)).
71 * similarly, it is also being assumed that MDIO 1 is selected on X-M7-40G card
72 * used in serdes1 protocol 19 (could have selected MDIO 2)
73 * To override these settings "dpmac" environment variable can be used after
74 * defining "dpmac_override" in hwconfig environment variable.
75 * This table has limited serdes protocol entries. It can be expanded as per
78 static const struct serdes_phy_config serdes1_phy_config[] = {
79 {3, {{WRIOP1_DPMAC3, {AQ_PHY_ADDR1, -1},
81 {WRIOP1_DPMAC4, {AQ_PHY_ADDR2, -1},
83 {WRIOP1_DPMAC5, {AQ_PHY_ADDR3, -1},
85 {WRIOP1_DPMAC6, {AQ_PHY_ADDR4, -1},
87 {7, {{WRIOP1_DPMAC3, {AQ_PHY_ADDR1, -1},
89 {WRIOP1_DPMAC4, {AQ_PHY_ADDR2, -1},
91 {WRIOP1_DPMAC5, {AQ_PHY_ADDR3, -1},
93 {WRIOP1_DPMAC6, {AQ_PHY_ADDR4, -1},
95 {WRIOP1_DPMAC7, {SGMII_CARD_PORT1_PHY_ADDR, -1},
97 {WRIOP1_DPMAC8, {SGMII_CARD_PORT2_PHY_ADDR, -1},
99 {WRIOP1_DPMAC9, {SGMII_CARD_PORT3_PHY_ADDR, -1},
101 {WRIOP1_DPMAC10, {SGMII_CARD_PORT4_PHY_ADDR, -1},
102 EMI1, IO_SLOT_2} } },
104 {13, {{WRIOP1_DPMAC1, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
106 {WRIOP1_DPMAC2, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
107 EMI1, IO_SLOT_2} } },
108 {15, {{WRIOP1_DPMAC1, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
110 {WRIOP1_DPMAC2, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
111 EMI1, IO_SLOT_1} } },
112 {17, {{WRIOP1_DPMAC3, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
114 {WRIOP1_DPMAC4, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
116 {WRIOP1_DPMAC5, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
118 {WRIOP1_DPMAC6, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
119 EMI1, IO_SLOT_1} } },
120 {19, {{WRIOP1_DPMAC2, {CORTINA_PHY_ADDR1, -1},
122 {WRIOP1_DPMAC3, {AQ_PHY_ADDR1, -1},
124 {WRIOP1_DPMAC4, {AQ_PHY_ADDR2, -1},
126 {WRIOP1_DPMAC5, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
128 {WRIOP1_DPMAC6, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
129 EMI1, IO_SLOT_6} } },
130 {20, {{WRIOP1_DPMAC1, {CORTINA_PHY_ADDR1, -1},
132 {WRIOP1_DPMAC2, {CORTINA_PHY_ADDR1, -1},
136 static const struct serdes_phy_config serdes2_phy_config[] = {
140 {11, {{WRIOP1_DPMAC12, {SGMII_CARD_PORT2_PHY_ADDR, -1},
142 {WRIOP1_DPMAC17, {SGMII_CARD_PORT3_PHY_ADDR, -1},
144 {WRIOP1_DPMAC18, {SGMII_CARD_PORT4_PHY_ADDR, -1},
146 {WRIOP1_DPMAC16, {SGMII_CARD_PORT2_PHY_ADDR, -1},
148 {WRIOP1_DPMAC13, {SGMII_CARD_PORT3_PHY_ADDR, -1},
150 {WRIOP1_DPMAC14, {SGMII_CARD_PORT4_PHY_ADDR, -1},
151 EMI1, IO_SLOT_8} } },
154 static const struct serdes_phy_config serdes3_phy_config[] = {
160 const struct phy_config *get_phy_config(u8 serdes,
161 const struct serdes_phy_config *table,
166 for (i = 0; i < table_size; i++) {
167 if (table[i].serdes == serdes)
168 return table[i].phy_config;
174 /* BRDCFG4 controls EMI routing for the board.
176 * 7-6 EMI Interface #1 Primary Routing (CFG_MUX1_EMI1) (1.8V):
177 * EMI1 00= On-board PHY #1
178 * 01= On-board PHY #2
180 * 11= Slots 1..8 multiplexer and translator.
181 * 5-3 EMI Interface #1 Secondary Routing (CFG_MUX2_EMI1) (2.5V):
190 * 2-0 EMI Interface #2 Routing (CFG_MUX_EMI2):
191 * EMI2 000= Slot #1 (secondary EMI)
192 * 001= Slot #2 (secondary EMI)
193 * 010= Slot #3 (secondary EMI)
194 * 011= Slot #4 (secondary EMI)
195 * 100= Slot #5 (secondary EMI)
196 * 101= Slot #6 (secondary EMI)
197 * 110= Slot #7 (secondary EMI)
198 * 111= Slot #8 (secondary EMI)
200 static int lx2160a_qds_get_mdio_mux_val(u8 realbusnum, enum io_slot ioslot)
202 switch (realbusnum) {
210 return (((ioslot - 1) << BRDCFG4_EMI1SEL_SHIFT) | 0xC0);
214 return ((ioslot - 1) << BRDCFG4_EMI2SEL_SHIFT);
220 static void lx2160a_qds_mux_mdio(struct lx2160a_qds_mdio *priv)
222 u8 brdcfg4, mux_val, reg;
224 brdcfg4 = QIXIS_READ(brdcfg[4]);
226 mux_val = lx2160a_qds_get_mdio_mux_val(priv->realbusnum, priv->ioslot);
228 switch (priv->realbusnum) {
230 brdcfg4 &= ~BRDCFG4_EMI1SEL_MASK;
234 brdcfg4 &= ~BRDCFG4_EMI2SEL_MASK;
240 QIXIS_WRITE(brdcfg[4], brdcfg4);
243 static int lx2160a_qds_mdio_read(struct mii_dev *bus, int addr,
244 int devad, int regnum)
246 struct lx2160a_qds_mdio *priv = bus->priv;
248 lx2160a_qds_mux_mdio(priv);
250 return priv->realbus->read(priv->realbus, addr, devad, regnum);
253 static int lx2160a_qds_mdio_write(struct mii_dev *bus, int addr, int devad,
254 int regnum, u16 value)
256 struct lx2160a_qds_mdio *priv = bus->priv;
258 lx2160a_qds_mux_mdio(priv);
260 return priv->realbus->write(priv->realbus, addr, devad, regnum, value);
263 static int lx2160a_qds_mdio_reset(struct mii_dev *bus)
265 struct lx2160a_qds_mdio *priv = bus->priv;
267 return priv->realbus->reset(priv->realbus);
270 static struct mii_dev *lx2160a_qds_mdio_init(u8 realbusnum, enum io_slot ioslot)
272 struct lx2160a_qds_mdio *pmdio;
274 /*should be within MDIO_NAME_LEN*/
275 char dummy_mdio_name[] = "LX2160A_QDS_MDIO1_IOSLOT1";
277 if (realbusnum == EMI2) {
278 if (ioslot < IO_SLOT_1 || ioslot > IO_SLOT_8) {
279 printf("invalid ioslot %d\n", ioslot);
282 } else if (realbusnum == EMI1) {
283 if (ioslot < IO_SLOT_1 || ioslot > EMI1_RGMII2) {
284 printf("invalid ioslot %d\n", ioslot);
288 printf("not supported real mdio bus %d\n", realbusnum);
292 if (ioslot == EMI1_RGMII1)
293 strcpy(dummy_mdio_name, "LX2160A_QDS_MDIO1_RGMII1");
294 else if (ioslot == EMI1_RGMII2)
295 strcpy(dummy_mdio_name, "LX2160A_QDS_MDIO1_RGMII2");
297 sprintf(dummy_mdio_name, "LX2160A_QDS_MDIO%d_IOSLOT%d",
299 bus = miiphy_get_dev_by_name(dummy_mdio_name);
306 printf("Failed to allocate %s bus\n", dummy_mdio_name);
310 pmdio = malloc(sizeof(*pmdio));
312 printf("Failed to allocate %s private data\n", dummy_mdio_name);
317 switch (realbusnum) {
320 miiphy_get_dev_by_name(DEFAULT_WRIOP_MDIO1_NAME);
324 miiphy_get_dev_by_name(DEFAULT_WRIOP_MDIO2_NAME);
328 if (!pmdio->realbus) {
329 printf("No real mdio bus num %d found\n", realbusnum);
335 pmdio->realbusnum = realbusnum;
336 pmdio->ioslot = ioslot;
337 bus->read = lx2160a_qds_mdio_read;
338 bus->write = lx2160a_qds_mdio_write;
339 bus->reset = lx2160a_qds_mdio_reset;
340 strcpy(bus->name, dummy_mdio_name);
343 if (!mdio_register(bus))
346 printf("No bus with name %s\n", dummy_mdio_name);
352 static inline void do_phy_config(const struct phy_config *phy_config)
355 int i, phy_num, phy_address;
357 for (i = 0; i < SRDS_MAX_LANES; i++) {
358 if (!phy_config[i].dpmacid)
362 phy_num < ARRAY_SIZE(phy_config[i].phy_address);
364 phy_address = phy_config[i].phy_address[phy_num];
365 if (phy_address == -1)
367 wriop_set_phy_address(phy_config[i].dpmacid,
368 phy_num, phy_address);
370 /*Register the muxing front-ends to the MDIO buses*/
371 bus = lx2160a_qds_mdio_init(phy_config[i].mdio_bus,
372 phy_config[i].ioslot);
374 printf("could not get bus for mdio %d ioslot %d\n",
375 phy_config[i].mdio_bus,
376 phy_config[i].ioslot);
378 wriop_set_mdio(phy_config[i].dpmacid, bus);
382 static inline void do_dpmac_config(int dpmac, const char *arg_dpmacid,
387 u8 realbusnum, ioslot;
390 char *phystr = "phy00";
392 /*search phy in dpmac arg*/
393 for (phy_num = 0; phy_num < WRIOP_MAX_PHY_NUM; phy_num++) {
394 sprintf(phystr, "phy%d", phy_num + 1);
395 ret = hwconfig_subarg_f(arg_dpmacid, phystr, &len, env_dpmac);
397 /*look for phy instead of phy1*/
399 ret = hwconfig_subarg_f(arg_dpmacid, "phy",
405 if (len != 4 || strncmp(ret, "0x", 2))
406 printf("invalid phy format in %s variable.\n"
407 "specify phy%d for %s in hex format e.g. 0x12\n",
408 env_dpmac, phy_num + 1, arg_dpmacid);
410 wriop_set_phy_address(dpmac, phy_num,
411 simple_strtoul(ret, NULL, 16));
414 /*search mdio in dpmac arg*/
415 ret = hwconfig_subarg_f(arg_dpmacid, "mdio", &len, env_dpmac);
417 realbusnum = *ret - '0';
419 realbusnum = EMI_NONE;
422 /*search io in dpmac arg*/
423 ret = hwconfig_subarg_f(arg_dpmacid, "io", &len, env_dpmac);
427 ioslot = IO_SLOT_NONE;
428 /*Register the muxing front-ends to the MDIO buses*/
429 bus = lx2160a_qds_mdio_init(realbusnum, ioslot);
431 printf("could not get bus for mdio %d ioslot %d\n",
434 wriop_set_mdio(dpmac, bus);
440 int board_eth_init(bd_t *bis)
442 #if defined(CONFIG_FSL_MC_ENET)
443 struct memac_mdio_info mdio_info;
444 struct memac_mdio_controller *regs;
448 char dpmacid[] = "dpmac00", srds[] = "00_00_00";
451 const struct phy_config *phy_config;
452 struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
453 u32 srds_s1, srds_s2, srds_s3;
455 srds_s1 = in_le32(&gur->rcwsr[28]) &
456 FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_MASK;
457 srds_s1 >>= FSL_CHASSIS3_RCWSR28_SRDS1_PRTCL_SHIFT;
459 srds_s2 = in_le32(&gur->rcwsr[28]) &
460 FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_MASK;
461 srds_s2 >>= FSL_CHASSIS3_RCWSR28_SRDS2_PRTCL_SHIFT;
463 srds_s3 = in_le32(&gur->rcwsr[28]) &
464 FSL_CHASSIS3_RCWSR28_SRDS3_PRTCL_MASK;
465 srds_s3 >>= FSL_CHASSIS3_RCWSR28_SRDS3_PRTCL_SHIFT;
467 sprintf(srds, "%d_%d_%d", srds_s1, srds_s2, srds_s3);
469 regs = (struct memac_mdio_controller *)CONFIG_SYS_FSL_WRIOP1_MDIO1;
470 mdio_info.regs = regs;
471 mdio_info.name = DEFAULT_WRIOP_MDIO1_NAME;
473 /*Register the EMI 1*/
474 fm_memac_mdio_init(bis, &mdio_info);
476 regs = (struct memac_mdio_controller *)CONFIG_SYS_FSL_WRIOP1_MDIO2;
477 mdio_info.regs = regs;
478 mdio_info.name = DEFAULT_WRIOP_MDIO2_NAME;
480 /*Register the EMI 2*/
481 fm_memac_mdio_init(bis, &mdio_info);
483 /* "dpmac" environment variable can be used after
484 * defining "dpmac_override" in hwconfig environment variable.
486 if (hwconfig("dpmac_override")) {
487 env_dpmac = env_get("dpmac");
489 ret = hwconfig_arg_f("srds", &len, env_dpmac);
491 if (strncmp(ret, srds, strlen(srds))) {
492 printf("SERDES configuration changed.\n"
493 "previous: %.*s, current: %s.\n"
494 "update dpmac variable.\n",
495 (int)len, ret, srds);
498 printf("SERDES configuration not found.\n"
499 "Please add srds:%s in dpmac variable\n",
503 for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++) {
504 /* Look for dpmac1 to dpmac24(current max) arg
505 * in dpmac environment variable
507 sprintf(dpmacid, "dpmac%d", i);
508 ret = hwconfig_arg_f(dpmacid, &len, env_dpmac);
510 do_dpmac_config(i, dpmacid, env_dpmac);
513 printf("Warning: environment dpmac not found.\n"
514 "DPAA network interfaces may not work\n");
517 /*Look for phy config for serdes1 in phy config table*/
518 phy_config = get_phy_config(srds_s1, serdes1_phy_config,
519 ARRAY_SIZE(serdes1_phy_config));
521 printf("%s WRIOP: Unsupported SerDes1 Protocol %d\n",
524 do_phy_config(phy_config);
526 phy_config = get_phy_config(srds_s2, serdes2_phy_config,
527 ARRAY_SIZE(serdes2_phy_config));
529 printf("%s WRIOP: Unsupported SerDes2 Protocol %d\n",
532 do_phy_config(phy_config);
534 phy_config = get_phy_config(srds_s3, serdes3_phy_config,
535 ARRAY_SIZE(serdes3_phy_config));
537 printf("%s WRIOP: Unsupported SerDes3 Protocol %d\n",
540 do_phy_config(phy_config);
544 if (wriop_get_enet_if(WRIOP1_DPMAC17) == PHY_INTERFACE_MODE_RGMII_ID) {
545 wriop_set_phy_address(WRIOP1_DPMAC17, 0, RGMII_PHY_ADDR1);
546 bus = lx2160a_qds_mdio_init(EMI1, EMI1_RGMII1);
548 printf("could not get bus for RGMII1\n");
550 wriop_set_mdio(WRIOP1_DPMAC17, bus);
553 if (wriop_get_enet_if(WRIOP1_DPMAC18) == PHY_INTERFACE_MODE_RGMII_ID) {
554 wriop_set_phy_address(WRIOP1_DPMAC18, 0, RGMII_PHY_ADDR2);
555 bus = lx2160a_qds_mdio_init(EMI1, EMI1_RGMII2);
557 printf("could not get bus for RGMII2\n");
559 wriop_set_mdio(WRIOP1_DPMAC18, bus);
563 #endif /* CONFIG_FMAN_ENET */
565 #ifdef CONFIG_PHY_AQUANTIA
567 * Export functions to be used by AQ firmware
570 gd->jt->strcpy = strcpy;
571 gd->jt->mdelay = mdelay;
572 gd->jt->mdio_get_current_dev = mdio_get_current_dev;
573 gd->jt->phy_find_by_mask = phy_find_by_mask;
574 gd->jt->mdio_phydev_for_ethname = mdio_phydev_for_ethname;
575 gd->jt->miiphy_set_current_dev = miiphy_set_current_dev;
577 return pci_eth_init(bis);
580 #if defined(CONFIG_RESET_PHY_R)
583 #if defined(CONFIG_FSL_MC_ENET)
587 #endif /* CONFIG_RESET_PHY_R */
589 #if defined(CONFIG_FSL_MC_ENET)
590 int fdt_fixup_dpmac_phy_handle(void *fdt, int dpmac_id, int node_phandle)
594 char dpmac_str[] = "dpmacs@00";
595 const char *phy_string;
597 offset = fdt_path_offset(fdt, "/soc/fsl-mc/dpmacs");
600 offset = fdt_path_offset(fdt, "/fsl-mc/dpmacs");
603 printf("dpmacs node not found in device tree\n");
607 sprintf(dpmac_str, "dpmac@%x", dpmac_id);
608 debug("dpmac_str = %s\n", dpmac_str);
610 offset = fdt_subnode_offset(fdt, offset, dpmac_str);
612 printf("%s node not found in device tree\n", dpmac_str);
616 ret = fdt_appendprop_cell(fdt, offset, "phy-handle", node_phandle);
618 printf("%d@%s %d\n", __LINE__, __func__, ret);
620 phy_string = phy_string_for_interface(wriop_get_enet_if(dpmac_id));
621 ret = fdt_setprop_string(fdt, offset, "phy-connection-type",
624 printf("%d@%s %d\n", __LINE__, __func__, ret);
629 int fdt_get_ioslot_offset(void *fdt, struct mii_dev *mii_dev, int fpga_offset)
631 char mdio_ioslot_str[] = "mdio@00";
632 struct lx2160a_qds_mdio *priv;
637 /*Test if the MDIO bus is real mdio bus or muxing front end ?*/
638 if (strncmp(mii_dev->name, "LX2160A_QDS_MDIO",
639 strlen("LX2160A_QDS_MDIO")))
642 /*Get the real MDIO bus num and ioslot info from bus's priv data*/
643 priv = mii_dev->priv;
645 debug("real_bus_num = %d, ioslot = %d\n",
646 priv->realbusnum, priv->ioslot);
648 if (priv->realbusnum == EMI1)
649 reg = CONFIG_SYS_FSL_WRIOP1_MDIO1;
651 reg = CONFIG_SYS_FSL_WRIOP1_MDIO2;
653 offset = fdt_node_offset_by_compat_reg(fdt, "fsl,fman-memac-mdio", reg);
655 printf("mdio@%llx node not found in device tree\n", reg);
659 phandle = fdt_get_phandle(fdt, offset);
660 phandle = cpu_to_fdt32(phandle);
661 offset = fdt_node_offset_by_prop_value(fdt, -1, "mdio-parent-bus",
664 printf("mdio-mux-%d node not found in device tree\n",
665 priv->realbusnum == EMI1 ? 1 : 2);
669 mux_val = lx2160a_qds_get_mdio_mux_val(priv->realbusnum, priv->ioslot);
670 if (priv->realbusnum == EMI1)
671 mux_val >>= BRDCFG4_EMI1SEL_SHIFT;
673 mux_val >>= BRDCFG4_EMI2SEL_SHIFT;
674 sprintf(mdio_ioslot_str, "mdio@%x", (u8)mux_val);
676 offset = fdt_subnode_offset(fdt, offset, mdio_ioslot_str);
678 printf("%s node not found in device tree\n", mdio_ioslot_str);
685 int fdt_create_phy_node(void *fdt, int offset, u8 phyaddr, int *subnodeoffset,
686 struct phy_device *phy_dev, int phandle)
688 char phy_node_name[] = "ethernet-phy@00";
689 char phy_id_compatible_str[] = "ethernet-phy-id0000.0000,";
692 sprintf(phy_node_name, "ethernet-phy@%x", phyaddr);
693 debug("phy_node_name = %s\n", phy_node_name);
695 *subnodeoffset = fdt_add_subnode(fdt, offset, phy_node_name);
696 if (*subnodeoffset <= 0) {
697 printf("Could not add subnode %s inside node %s err = %s\n",
698 phy_node_name, fdt_get_name(fdt, offset, NULL),
699 fdt_strerror(*subnodeoffset));
700 return *subnodeoffset;
703 sprintf(phy_id_compatible_str, "ethernet-phy-id%04x.%04x,",
704 phy_dev->phy_id >> 16, phy_dev->phy_id & 0xFFFF);
705 debug("phy_id_compatible_str %s\n", phy_id_compatible_str);
707 ret = fdt_setprop_string(fdt, *subnodeoffset, "compatible",
708 phy_id_compatible_str);
710 printf("%d@%s %d\n", __LINE__, __func__, ret);
714 if (phy_dev->is_c45) {
715 ret = fdt_appendprop_string(fdt, *subnodeoffset, "compatible",
716 "ethernet-phy-ieee802.3-c45");
718 printf("%d@%s %d\n", __LINE__, __func__, ret);
722 ret = fdt_appendprop_string(fdt, *subnodeoffset, "compatible",
723 "ethernet-phy-ieee802.3-c22");
725 printf("%d@%s %d\n", __LINE__, __func__, ret);
730 ret = fdt_setprop_cell(fdt, *subnodeoffset, "reg", phyaddr);
732 printf("%d@%s %d\n", __LINE__, __func__, ret);
736 ret = fdt_set_phandle(fdt, *subnodeoffset, phandle);
738 printf("%d@%s %d\n", __LINE__, __func__, ret);
744 fdt_del_node(fdt, *subnodeoffset);
749 int fdt_fixup_board_phy(void *fdt)
751 int fpga_offset, offset, subnodeoffset;
752 struct mii_dev *mii_dev;
753 struct list_head *mii_devs, *entry;
754 int ret, dpmac_id, phandle, i;
755 struct phy_device *phy_dev;
756 char ethname[ETH_NAME_LEN];
757 phy_interface_t phy_iface;
760 /* we know FPGA is connected to i2c0, therefore search path directly,
761 * instead of compatible property, as it saves time
763 fpga_offset = fdt_path_offset(fdt, "/soc/i2c@2000000/fpga");
766 fpga_offset = fdt_path_offset(fdt, "/i2c@2000000/fpga");
768 if (fpga_offset < 0) {
769 printf("i2c@2000000/fpga node not found in device tree\n");
773 phandle = fdt_alloc_phandle(fdt);
774 mii_devs = mdio_get_list_head();
776 list_for_each(entry, mii_devs) {
777 mii_dev = list_entry(entry, struct mii_dev, link);
778 debug("mii_dev name : %s\n", mii_dev->name);
779 offset = fdt_get_ioslot_offset(fdt, mii_dev, fpga_offset);
783 // Look for phy devices attached to MDIO bus muxing front end
784 // and create their entries with compatible being the device id
785 for (i = 0; i < PHY_MAX_ADDR; i++) {
786 phy_dev = mii_dev->phymap[i];
790 // TODO: use sscanf instead of loop
791 dpmac_id = WRIOP1_DPMAC1;
792 while (dpmac_id < NUM_WRIOP_PORTS) {
793 phy_iface = wriop_get_enet_if(dpmac_id);
794 snprintf(ethname, ETH_NAME_LEN, "DPMAC%d@%s",
796 phy_string_for_interface(phy_iface));
797 if (strcmp(ethname, phy_dev->dev->name) == 0)
801 if (dpmac_id == NUM_WRIOP_PORTS)
803 ret = fdt_create_phy_node(fdt, offset, i,
809 ret = fdt_fixup_dpmac_phy_handle(fdt,
812 fdt_del_node(fdt, subnodeoffset);
815 /* calculate offset again as new node addition may have
818 offset = fdt_get_ioslot_offset(fdt, mii_dev,
829 #endif // CONFIG_FSL_MC_ENET