/* * Given the following ... * * 1) A pointer to an Fman Ethernet node (as identified by the 'compat' * compatible string and 'addr' physical address) * * 2) An Fman port * * ... update the phy-handle property of the Ethernet node to point to the * right PHY. This assumes that we already know the PHY for each port. * * The offset of the Fman Ethernet node is also passed in for convenience, but * it is not used, and we recalculate the offset anyway. * * Note that what we call "Fman ports" (enum fm_port) is really an Fman MAC. * Inside the Fman, "ports" are things that connect to MACs. We only call them * ports in U-Boot because on previous Ethernet devices (e.g. Gianfar), MACs * and ports are the same thing. * */ void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr, enum fm_port port, int offset) { phy_interface_t intf = fm_info_get_enet_if(port); char phy[16]; /* The RGMII PHY is identified by the MAC connected to it */ if (intf == PHY_INTERFACE_MODE_RGMII) { sprintf(phy, "rgmii_phy%u", port == FM1_DTSEC4 ? 1 : 2); fdt_set_phy_handle(fdt, compat, addr, phy); } /* The SGMII PHY is identified by the MAC connected to it */ if (intf == PHY_INTERFACE_MODE_SGMII) { int lane = serdes_get_first_lane(FSL_SRDS_1, SGMII_FM1_DTSEC1 + port); u8 slot; if (lane < 0) return; slot = lane_to_slot[lane]; if (slot) { /* Slot housing a SGMII riser card */ sprintf(phy, "phy_s%x_%02x", slot, (fm_info_get_phy_address(port - FM1_DTSEC1)- CONFIG_SYS_FM1_DTSEC1_RISER_PHY_ADDR + 1)); fdt_set_phy_handle(fdt, compat, addr, phy); } } }
/* * Given the following ... * * 1) A pointer to an Fman Ethernet node (as identified by the 'compat' * compatible string and 'addr' physical address) * * 2) An Fman port * * ... update the phy-handle property of the Ethernet node to point to the * right PHY. This assumes that we already know the PHY for each port. That * information is stored in mdio_mux[]. * * The offset of the Fman Ethernet node is also passed in for convenience, but * it is not used. * * Note that what we call "Fman ports" (enum fm_port) is really an Fman MAC. * Inside the Fman, "ports" are things that connect to MACs. We only call them * ports in U-Boot because on previous Ethernet devices (e.g. Gianfar), MACs * and ports are the same thing. */ void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr, enum fm_port port, int offset) { enum srds_prtcl device; int lane, slot, phy; char alias[32]; /* RGMII and XGMII are already mapped correctly in the DTS */ if (fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_SGMII) { device = serdes_device_from_fm_port(port); lane = serdes_get_first_lane(device); slot = lane_to_slot[lane]; phy = fm_info_get_phy_address(port); sprintf(alias, "phy_sgmii_slot%u_%x", slot, phy); fdt_set_phy_handle(fdt, compat, addr, alias); } }
void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr, enum fm_port port, int offset) { int phy; char alias[20]; char lane_mode[2][20] = {"1000BASE-KX", "10GBASE-KR"}; char buf[32] = "serdes-1,"; struct fixed_link f_link; int media_type = 0; int off; ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); #ifdef CONFIG_T2080QDS serdes_corenet_t *srds_regs = (void *)CONFIG_SYS_FSL_CORENET_SERDES_ADDR; u32 srds1_pccr1 = in_be32(&srds_regs->srdspccr1); #endif u32 srds_s1 = in_be32(&gur->rcwsr[4]) & FSL_CORENET2_RCWSR4_SRDS1_PRTCL; srds_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT; if (fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_SGMII) { phy = fm_info_get_phy_address(port); switch (port) { #if defined(CONFIG_T2080QDS) case FM1_DTSEC1: if (hwconfig_sub("fsl_1gkx", "fm1_1g1")) { media_type = 1; fdt_set_phy_handle(fdt, compat, addr, "phy_1gkx1"); fdt_status_okay_by_alias(fdt, "1gkx_pcs_mdio1"); sprintf(buf, "%s%s%s", buf, "lane-c,", (char *)lane_mode[0]); out_be32(&srds_regs->srdspccr1, srds1_pccr1 | PCCR1_SGMIIH_KX_MASK); break; } case FM1_DTSEC2: if (hwconfig_sub("fsl_1gkx", "fm1_1g2")) { media_type = 1; fdt_set_phy_handle(fdt, compat, addr, "phy_1gkx2"); fdt_status_okay_by_alias(fdt, "1gkx_pcs_mdio2"); sprintf(buf, "%s%s%s", buf, "lane-d,", (char *)lane_mode[0]); out_be32(&srds_regs->srdspccr1, srds1_pccr1 | PCCR1_SGMIIG_KX_MASK); break; } case FM1_DTSEC9: if (hwconfig_sub("fsl_1gkx", "fm1_1g9")) { media_type = 1; fdt_set_phy_handle(fdt, compat, addr, "phy_1gkx9"); fdt_status_okay_by_alias(fdt, "1gkx_pcs_mdio9"); sprintf(buf, "%s%s%s", buf, "lane-a,", (char *)lane_mode[0]); out_be32(&srds_regs->srdspccr1, srds1_pccr1 | PCCR1_SGMIIE_KX_MASK); break; } case FM1_DTSEC10: if (hwconfig_sub("fsl_1gkx", "fm1_1g10")) { media_type = 1; fdt_set_phy_handle(fdt, compat, addr, "phy_1gkx10"); fdt_status_okay_by_alias(fdt, "1gkx_pcs_mdio10"); sprintf(buf, "%s%s%s", buf, "lane-b,", (char *)lane_mode[0]); out_be32(&srds_regs->srdspccr1, srds1_pccr1 | PCCR1_SGMIIF_KX_MASK); break; } if (mdio_mux[port] == EMI1_SLOT2) { sprintf(alias, "phy_sgmii_s2_%x", phy); fdt_set_phy_handle(fdt, compat, addr, alias); fdt_status_okay_by_alias(fdt, "emi1_slot2"); } else if (mdio_mux[port] == EMI1_SLOT3) { sprintf(alias, "phy_sgmii_s3_%x", phy); fdt_set_phy_handle(fdt, compat, addr, alias); fdt_status_okay_by_alias(fdt, "emi1_slot3"); } break; case FM1_DTSEC5: if (hwconfig_sub("fsl_1gkx", "fm1_1g5")) { media_type = 1; fdt_set_phy_handle(fdt, compat, addr, "phy_1gkx5"); fdt_status_okay_by_alias(fdt, "1gkx_pcs_mdio5"); sprintf(buf, "%s%s%s", buf, "lane-g,", (char *)lane_mode[0]); out_be32(&srds_regs->srdspccr1, srds1_pccr1 | PCCR1_SGMIIC_KX_MASK); break; } case FM1_DTSEC6: if (hwconfig_sub("fsl_1gkx", "fm1_1g6")) { media_type = 1; fdt_set_phy_handle(fdt, compat, addr, "phy_1gkx6"); fdt_status_okay_by_alias(fdt, "1gkx_pcs_mdio6"); sprintf(buf, "%s%s%s", buf, "lane-h,", (char *)lane_mode[0]); out_be32(&srds_regs->srdspccr1, srds1_pccr1 | PCCR1_SGMIID_KX_MASK); break; } if (mdio_mux[port] == EMI1_SLOT1) { sprintf(alias, "phy_sgmii_s1_%x", phy); fdt_set_phy_handle(fdt, compat, addr, alias); fdt_status_okay_by_alias(fdt, "emi1_slot1"); } else if (mdio_mux[port] == EMI1_SLOT2) { sprintf(alias, "phy_sgmii_s2_%x", phy); fdt_set_phy_handle(fdt, compat, addr, alias); fdt_status_okay_by_alias(fdt, "emi1_slot2"); } break; #elif defined(CONFIG_T2081QDS) case FM1_DTSEC1: case FM1_DTSEC2: case FM1_DTSEC5: case FM1_DTSEC6: case FM1_DTSEC9: case FM1_DTSEC10: if (mdio_mux[port] == EMI1_SLOT2) { sprintf(alias, "phy_sgmii_s2_%x", phy); fdt_set_phy_handle(fdt, compat, addr, alias); fdt_status_okay_by_alias(fdt, "emi1_slot2"); } else if (mdio_mux[port] == EMI1_SLOT3) { sprintf(alias, "phy_sgmii_s3_%x", phy); fdt_set_phy_handle(fdt, compat, addr, alias); fdt_status_okay_by_alias(fdt, "emi1_slot3"); } else if (mdio_mux[port] == EMI1_SLOT5) { sprintf(alias, "phy_sgmii_s5_%x", phy); fdt_set_phy_handle(fdt, compat, addr, alias); fdt_status_okay_by_alias(fdt, "emi1_slot5"); } else if (mdio_mux[port] == EMI1_SLOT6) { sprintf(alias, "phy_sgmii_s6_%x", phy); fdt_set_phy_handle(fdt, compat, addr, alias); fdt_status_okay_by_alias(fdt, "emi1_slot6"); } else if (mdio_mux[port] == EMI1_SLOT7) { sprintf(alias, "phy_sgmii_s7_%x", phy); fdt_set_phy_handle(fdt, compat, addr, alias); fdt_status_okay_by_alias(fdt, "emi1_slot7"); } break; #endif default: break; } if (media_type) { /* set property for 1000BASE-KX in dtb */ off = fdt_node_offset_by_compat_reg(fdt, "fsl,fman-memac-mdio", addr + 0x1000); fdt_setprop_string(fdt, off, "lane-instance", buf); } } else if (fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_XGMII) { switch (srds_s1) { case 0x66: /* XFI interface */ case 0x6b: case 0x6c: case 0x6d: case 0x71: /* * if the 10G is XFI, check hwconfig to see what is the * media type, there are two types, fiber or copper, * fix the dtb accordingly. */ switch (port) { case FM1_10GEC1: if (hwconfig_sub("fsl_10gkr_copper", "fm1_10g1")) { /* it's MAC9 */ media_type = 1; fdt_set_phy_handle(fdt, compat, addr, "phy_xfi9"); fdt_status_okay_by_alias(fdt, "xfi_pcs_mdio9"); sprintf(buf, "%s%s%s", buf, "lane-a,", (char *)lane_mode[1]); } break; case FM1_10GEC2: if (hwconfig_sub("fsl_10gkr_copper", "fm1_10g2")) { /* it's MAC10 */ media_type = 1; fdt_set_phy_handle(fdt, compat, addr, "phy_xfi10"); fdt_status_okay_by_alias(fdt, "xfi_pcs_mdio10"); sprintf(buf, "%s%s%s", buf, "lane-b,", (char *)lane_mode[1]); } break; case FM1_10GEC3: if (hwconfig_sub("fsl_10gkr_copper", "fm1_10g3")) { /* it's MAC1 */ media_type = 1; fdt_set_phy_handle(fdt, compat, addr, "phy_xfi1"); fdt_status_okay_by_alias(fdt, "xfi_pcs_mdio1"); sprintf(buf, "%s%s%s", buf, "lane-c,", (char *)lane_mode[1]); } break; case FM1_10GEC4: if (hwconfig_sub("fsl_10gkr_copper", "fm1_10g4")) { /* it's MAC2 */ media_type = 1; fdt_set_phy_handle(fdt, compat, addr, "phy_xfi2"); fdt_status_okay_by_alias(fdt, "xfi_pcs_mdio2"); sprintf(buf, "%s%s%s", buf, "lane-d,", (char *)lane_mode[1]); } break; default: return; } if (!media_type) { /* fixed-link is used for XFI fiber cable */ f_link.phy_id = port; f_link.duplex = 1; f_link.link_speed = 10000; f_link.pause = 0; f_link.asym_pause = 0; fdt_delprop(fdt, offset, "phy-handle"); fdt_setprop(fdt, offset, "fixed-link", &f_link, sizeof(f_link)); } else { /* set property for copper cable */ off = fdt_node_offset_by_compat_reg(fdt, "fsl,fman-memac-mdio", addr + 0x1000); fdt_setprop_string(fdt, off, "lane-instance", buf); } break; default: break; } } }
void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr, enum fm_port port, int offset) { int phy; char alias[32]; struct fixed_link f_link; ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); u32 prtcl2 = in_be32(&gur->rcwsr[4]) & FSL_CORENET2_RCWSR4_SRDS2_PRTCL; prtcl2 >>= FSL_CORENET2_RCWSR4_SRDS2_PRTCL_SHIFT; if (fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_SGMII) { phy = fm_info_get_phy_address(port); sprintf(alias, "phy_sgmii_%x", phy); fdt_set_phy_handle(fdt, compat, addr, alias); fdt_status_okay_by_alias(fdt, alias); } else if (fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_XGMII) { /* check if it's XFI interface for 10g */ switch (prtcl2) { case 0x80: case 0x81: case 0x82: case 0x83: case 0x84: case 0x85: case 0x86: case 0x87: case 0x88: case 0x89: case 0x8a: case 0x8b: case 0x8c: case 0x8d: case 0x8e: case 0xb1: case 0xb2: f_link.phy_id = port; f_link.duplex = 1; f_link.link_speed = 10000; f_link.pause = 0; f_link.asym_pause = 0; fdt_delprop(fdt, offset, "phy-handle"); fdt_setprop(fdt, offset, "fixed-link", &f_link, sizeof(f_link)); break; case 0x98: /* XAUI interface */ strcpy(alias, "phy_xaui_slot1"); fdt_status_okay_by_alias(fdt, alias); strcpy(alias, "phy_xaui_slot2"); fdt_status_okay_by_alias(fdt, alias); break; case 0x9e: /* XAUI interface */ case 0x9a: case 0x93: case 0x91: strcpy(alias, "phy_xaui_slot1"); fdt_status_okay_by_alias(fdt, alias); break; case 0x97: /* XAUI interface */ case 0xc3: strcpy(alias, "phy_xaui_slot2"); fdt_status_okay_by_alias(fdt, alias); break; default: break; } } }
void board_ft_fman_fixup_port(void *fdt, char *compat, phys_addr_t addr, enum fm_port port, int offset) { int phy; char alias[20]; struct fixed_link f_link; ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); u32 srds_s1 = in_be32(&gur->rcwsr[4]) & FSL_CORENET2_RCWSR4_SRDS1_PRTCL; srds_s1 >>= FSL_CORENET2_RCWSR4_SRDS1_PRTCL_SHIFT; if (fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_SGMII) { phy = fm_info_get_phy_address(port); switch (port) { case FM1_DTSEC1: case FM1_DTSEC2: case FM1_DTSEC9: case FM1_DTSEC10: sprintf(alias, "phy_sgmii_s3_%x", phy); fdt_set_phy_handle(fdt, compat, addr, alias); fdt_status_okay_by_alias(fdt, "emi1_slot3"); break; case FM1_DTSEC5: case FM1_DTSEC6: if (mdio_mux[port] == EMI1_SLOT1) { sprintf(alias, "phy_sgmii_s1_%x", phy); fdt_set_phy_handle(fdt, compat, addr, alias); fdt_status_okay_by_alias(fdt, "emi1_slot1"); } else if (mdio_mux[port] == EMI1_SLOT2) { sprintf(alias, "phy_sgmii_s2_%x", phy); fdt_set_phy_handle(fdt, compat, addr, alias); fdt_status_okay_by_alias(fdt, "emi1_slot2"); } break; default: break; } } else if (fm_info_get_enet_if(port) == PHY_INTERFACE_MODE_XGMII) { switch (srds_s1) { case 0x66: /* XFI interface */ case 0x6b: case 0x6c: case 0x6d: case 0x71: f_link.phy_id = port; f_link.duplex = 1; f_link.link_speed = 10000; f_link.pause = 0; f_link.asym_pause = 0; /* no PHY for XFI */ fdt_delprop(fdt, offset, "phy-handle"); fdt_setprop(fdt, offset, "fixed-link", &f_link, sizeof(f_link)); break; default: break; } } }