Lines Matching +full:d +full:- +full:bus

1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2018-2019 NXP
19 #include <fsl-mc/fsl_mc.h>
20 #include <fsl-mc/ldpaa_wriop.h>
27 #define EMI1 1 /* Mdio Bus 1 */
28 #define EMI2 2 /* Mdio Bus 2 */
57 /* -1 terminated array */
66 * e.g. for serdes1 protocol 19 it is being assumed that X-M11-USXGMII
67 * card is being used for dpmac 3-4. (X-M12-XFI could also have been used)
69 * to any of the 8 IO slots (IO slot 1 - IO slot 8)).
70 * similarly, it is also being assumed that MDIO 1 is selected on X-M7-40G card
78 {3, {{WRIOP1_DPMAC3, {AQ_PHY_ADDR1, -1},
80 {WRIOP1_DPMAC4, {AQ_PHY_ADDR2, -1},
82 {WRIOP1_DPMAC5, {AQ_PHY_ADDR3, -1},
84 {WRIOP1_DPMAC6, {AQ_PHY_ADDR4, -1},
86 {7, {{WRIOP1_DPMAC3, {AQ_PHY_ADDR1, -1},
88 {WRIOP1_DPMAC4, {AQ_PHY_ADDR2, -1},
90 {WRIOP1_DPMAC5, {AQ_PHY_ADDR3, -1},
92 {WRIOP1_DPMAC6, {AQ_PHY_ADDR4, -1},
94 {WRIOP1_DPMAC7, {SGMII_CARD_PORT1_PHY_ADDR, -1},
96 {WRIOP1_DPMAC8, {SGMII_CARD_PORT2_PHY_ADDR, -1},
98 {WRIOP1_DPMAC9, {SGMII_CARD_PORT3_PHY_ADDR, -1},
100 {WRIOP1_DPMAC10, {SGMII_CARD_PORT4_PHY_ADDR, -1},
103 {13, {{WRIOP1_DPMAC1, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
105 {WRIOP1_DPMAC2, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
107 {15, {{WRIOP1_DPMAC1, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
109 {WRIOP1_DPMAC2, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
111 {17, {{WRIOP1_DPMAC3, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
113 {WRIOP1_DPMAC4, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
115 {WRIOP1_DPMAC5, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
117 {WRIOP1_DPMAC6, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
119 {19, {{WRIOP1_DPMAC2, {CORTINA_PHY_ADDR1, -1},
121 {WRIOP1_DPMAC3, {AQ_PHY_ADDR1, -1},
123 {WRIOP1_DPMAC4, {AQ_PHY_ADDR2, -1},
125 {WRIOP1_DPMAC5, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
127 {WRIOP1_DPMAC6, {INPHI_PHY_ADDR1, INPHI_PHY_ADDR2, -1},
129 {20, {{WRIOP1_DPMAC1, {CORTINA_PHY_ADDR1, -1},
131 {WRIOP1_DPMAC2, {CORTINA_PHY_ADDR1, -1},
139 {11, {{WRIOP1_DPMAC12, {SGMII_CARD_PORT2_PHY_ADDR, -1},
141 {WRIOP1_DPMAC17, {SGMII_CARD_PORT3_PHY_ADDR, -1},
143 {WRIOP1_DPMAC18, {SGMII_CARD_PORT4_PHY_ADDR, -1},
145 {WRIOP1_DPMAC16, {SGMII_CARD_PORT2_PHY_ADDR, -1},
147 {WRIOP1_DPMAC13, {SGMII_CARD_PORT3_PHY_ADDR, -1},
149 {WRIOP1_DPMAC14, {SGMII_CARD_PORT4_PHY_ADDR, -1},
175 * 7-6 EMI Interface #1 Primary Routing (CFG_MUX1_EMI1) (1.8V):
176 * EMI1 00= On-board PHY #1
177 * 01= On-board PHY #2
180 * 5-3 EMI Interface #1 Secondary Routing (CFG_MUX2_EMI1) (2.5V):
189 * 2-0 EMI Interface #2 Routing (CFG_MUX_EMI2):
209 return (((ioslot - 1) << BRDCFG4_EMI1SEL_SHIFT) | 0xC0); in lx2160a_qds_get_mdio_mux_val()
213 return ((ioslot - 1) << BRDCFG4_EMI2SEL_SHIFT); in lx2160a_qds_get_mdio_mux_val()
215 return -1; in lx2160a_qds_get_mdio_mux_val()
225 mux_val = lx2160a_qds_get_mdio_mux_val(priv->realbusnum, priv->ioslot); in lx2160a_qds_mux_mdio()
227 switch (priv->realbusnum) { in lx2160a_qds_mux_mdio()
242 static int lx2160a_qds_mdio_read(struct mii_dev *bus, int addr, in lx2160a_qds_mdio_read() argument
245 struct lx2160a_qds_mdio *priv = bus->priv; in lx2160a_qds_mdio_read()
249 return priv->realbus->read(priv->realbus, addr, devad, regnum); in lx2160a_qds_mdio_read()
252 static int lx2160a_qds_mdio_write(struct mii_dev *bus, int addr, int devad, in lx2160a_qds_mdio_write() argument
255 struct lx2160a_qds_mdio *priv = bus->priv; in lx2160a_qds_mdio_write()
259 return priv->realbus->write(priv->realbus, addr, devad, regnum, value); in lx2160a_qds_mdio_write()
262 static int lx2160a_qds_mdio_reset(struct mii_dev *bus) in lx2160a_qds_mdio_reset() argument
264 struct lx2160a_qds_mdio *priv = bus->priv; in lx2160a_qds_mdio_reset()
266 return priv->realbus->reset(priv->realbus); in lx2160a_qds_mdio_reset()
272 struct mii_dev *bus; in lx2160a_qds_mdio_init() local
278 printf("invalid ioslot %d\n", ioslot); in lx2160a_qds_mdio_init()
283 printf("invalid ioslot %d\n", ioslot); in lx2160a_qds_mdio_init()
287 printf("not supported real mdio bus %d\n", realbusnum); in lx2160a_qds_mdio_init()
296 sprintf(dummy_mdio_name, "LX2160A_QDS_MDIO%d_IOSLOT%d", in lx2160a_qds_mdio_init()
298 bus = miiphy_get_dev_by_name(dummy_mdio_name); in lx2160a_qds_mdio_init()
300 if (bus) in lx2160a_qds_mdio_init()
301 return bus; in lx2160a_qds_mdio_init()
303 bus = mdio_alloc(); in lx2160a_qds_mdio_init()
304 if (!bus) { in lx2160a_qds_mdio_init()
305 printf("Failed to allocate %s bus\n", dummy_mdio_name); in lx2160a_qds_mdio_init()
312 free(bus); in lx2160a_qds_mdio_init()
318 pmdio->realbus = in lx2160a_qds_mdio_init()
322 pmdio->realbus = in lx2160a_qds_mdio_init()
327 if (!pmdio->realbus) { in lx2160a_qds_mdio_init()
328 printf("No real mdio bus num %d found\n", realbusnum); in lx2160a_qds_mdio_init()
329 free(bus); in lx2160a_qds_mdio_init()
334 pmdio->realbusnum = realbusnum; in lx2160a_qds_mdio_init()
335 pmdio->ioslot = ioslot; in lx2160a_qds_mdio_init()
336 bus->read = lx2160a_qds_mdio_read; in lx2160a_qds_mdio_init()
337 bus->write = lx2160a_qds_mdio_write; in lx2160a_qds_mdio_init()
338 bus->reset = lx2160a_qds_mdio_reset; in lx2160a_qds_mdio_init()
339 strcpy(bus->name, dummy_mdio_name); in lx2160a_qds_mdio_init()
340 bus->priv = pmdio; in lx2160a_qds_mdio_init()
342 if (!mdio_register(bus)) in lx2160a_qds_mdio_init()
343 return bus; in lx2160a_qds_mdio_init()
345 printf("No bus with name %s\n", dummy_mdio_name); in lx2160a_qds_mdio_init()
346 free(bus); in lx2160a_qds_mdio_init()
353 struct mii_dev *bus; in do_phy_config() local
364 if (phy_address == -1) in do_phy_config()
369 /*Register the muxing front-ends to the MDIO buses*/ in do_phy_config()
370 bus = lx2160a_qds_mdio_init(phy_config[i].mdio_bus, in do_phy_config()
372 if (!bus) in do_phy_config()
373 printf("could not get bus for mdio %d ioslot %d\n", in do_phy_config()
377 wriop_set_mdio(phy_config[i].dpmacid, bus); in do_phy_config()
387 struct mii_dev *bus; in do_dpmac_config() local
393 sprintf(phystr, "phy%d", phy_num + 1); in do_dpmac_config()
406 "specify phy%d for %s in hex format e.g. 0x12\n", in do_dpmac_config()
416 realbusnum = *ret - '0'; in do_dpmac_config()
424 ioslot = *ret - '0'; in do_dpmac_config()
427 /*Register the muxing front-ends to the MDIO buses*/ in do_dpmac_config()
428 bus = lx2160a_qds_mdio_init(realbusnum, ioslot); in do_dpmac_config()
429 if (!bus) in do_dpmac_config()
430 printf("could not get bus for mdio %d ioslot %d\n", in do_dpmac_config()
433 wriop_set_mdio(dpmac, bus); in do_dpmac_config()
449 struct mii_dev *bus; in board_eth_init() local
454 srds_s1 = in_le32(&gur->rcwsr[28]) & in board_eth_init()
458 srds_s2 = in_le32(&gur->rcwsr[28]) & in board_eth_init()
462 srds_s3 = in_le32(&gur->rcwsr[28]) & in board_eth_init()
466 sprintf(srds, "%d_%d_%d", srds_s1, srds_s2, srds_s3); in board_eth_init()
506 sprintf(dpmacid, "dpmac%d", i); in board_eth_init()
520 printf("%s WRIOP: Unsupported SerDes1 Protocol %d\n", in board_eth_init()
528 printf("%s WRIOP: Unsupported SerDes2 Protocol %d\n", in board_eth_init()
536 printf("%s WRIOP: Unsupported SerDes3 Protocol %d\n", in board_eth_init()
545 bus = lx2160a_qds_mdio_init(EMI1, EMI1_RGMII1); in board_eth_init()
546 if (!bus) in board_eth_init()
547 printf("could not get bus for RGMII1\n"); in board_eth_init()
549 wriop_set_mdio(WRIOP1_DPMAC17, bus); in board_eth_init()
554 bus = lx2160a_qds_mdio_init(EMI1, EMI1_RGMII2); in board_eth_init()
555 if (!bus) in board_eth_init()
556 printf("could not get bus for RGMII2\n"); in board_eth_init()
558 wriop_set_mdio(WRIOP1_DPMAC18, bus); in board_eth_init()
569 gd->jt->strcpy = strcpy; in board_eth_init()
570 gd->jt->mdelay = mdelay; in board_eth_init()
571 gd->jt->mdio_get_current_dev = mdio_get_current_dev; in board_eth_init()
572 gd->jt->phy_find_by_mask = phy_find_by_mask; in board_eth_init()
573 gd->jt->mdio_phydev_for_ethname = mdio_phydev_for_ethname; in board_eth_init()
574 gd->jt->miiphy_set_current_dev = miiphy_set_current_dev; in board_eth_init()
596 offset = fdt_path_offset(fdt, "/soc/fsl-mc/dpmacs"); in fdt_fixup_dpmac_phy_handle()
599 offset = fdt_path_offset(fdt, "/fsl-mc/dpmacs"); in fdt_fixup_dpmac_phy_handle()
615 ret = fdt_appendprop_cell(fdt, offset, "phy-handle", node_phandle); in fdt_fixup_dpmac_phy_handle()
617 printf("%d@%s %d\n", __LINE__, __func__, ret); in fdt_fixup_dpmac_phy_handle()
620 ret = fdt_setprop_string(fdt, offset, "phy-connection-type", in fdt_fixup_dpmac_phy_handle()
623 printf("%d@%s %d\n", __LINE__, __func__, ret); in fdt_fixup_dpmac_phy_handle()
636 /*Test if the MDIO bus is real mdio bus or muxing front end ?*/ in fdt_get_ioslot_offset()
637 if (strncmp(mii_dev->name, "LX2160A_QDS_MDIO", in fdt_get_ioslot_offset()
639 return -1; in fdt_get_ioslot_offset()
641 /*Get the real MDIO bus num and ioslot info from bus's priv data*/ in fdt_get_ioslot_offset()
642 priv = mii_dev->priv; in fdt_get_ioslot_offset()
644 debug("real_bus_num = %d, ioslot = %d\n", in fdt_get_ioslot_offset()
645 priv->realbusnum, priv->ioslot); in fdt_get_ioslot_offset()
647 if (priv->realbusnum == EMI1) in fdt_get_ioslot_offset()
652 offset = fdt_node_offset_by_compat_reg(fdt, "fsl,fman-memac-mdio", reg); in fdt_get_ioslot_offset()
660 offset = fdt_node_offset_by_prop_value(fdt, -1, "mdio-parent-bus", in fdt_get_ioslot_offset()
663 printf("mdio-mux-%d node not found in device tree\n", in fdt_get_ioslot_offset()
664 priv->realbusnum == EMI1 ? 1 : 2); in fdt_get_ioslot_offset()
668 mux_val = lx2160a_qds_get_mdio_mux_val(priv->realbusnum, priv->ioslot); in fdt_get_ioslot_offset()
669 if (priv->realbusnum == EMI1) in fdt_get_ioslot_offset()
687 char phy_node_name[] = "ethernet-phy@00"; in fdt_create_phy_node()
688 char phy_id_compatible_str[] = "ethernet-phy-id0000.0000"; in fdt_create_phy_node()
691 sprintf(phy_node_name, "ethernet-phy@%x", phyaddr); in fdt_create_phy_node()
702 sprintf(phy_id_compatible_str, "ethernet-phy-id%04x.%04x", in fdt_create_phy_node()
703 phy_dev->phy_id >> 16, phy_dev->phy_id & 0xFFFF); in fdt_create_phy_node()
709 printf("%d@%s %d\n", __LINE__, __func__, ret); in fdt_create_phy_node()
713 if (phy_dev->is_c45) { in fdt_create_phy_node()
715 "ethernet-phy-ieee802.3-c45"); in fdt_create_phy_node()
717 printf("%d@%s %d\n", __LINE__, __func__, ret); in fdt_create_phy_node()
722 "ethernet-phy-ieee802.3-c22"); in fdt_create_phy_node()
724 printf("%d@%s %d\n", __LINE__, __func__, ret); in fdt_create_phy_node()
731 printf("%d@%s %d\n", __LINE__, __func__, ret); in fdt_create_phy_node()
737 printf("%d@%s %d\n", __LINE__, __func__, ret); in fdt_create_phy_node()
777 debug("mii_dev name : %s\n", mii_dev->name); in fdt_fixup_board_phy()
782 // Look for phy devices attached to MDIO bus muxing front end in fdt_fixup_board_phy()
785 phy_dev = mii_dev->phymap[i]; in fdt_fixup_board_phy()
793 snprintf(ethname, ETH_NAME_LEN, "DPMAC%d@%s", in fdt_fixup_board_phy()
796 if (strcmp(ethname, phy_dev->dev->name) == 0) in fdt_fixup_board_phy()