From 123ca114e07ecf28aa2538748d733e2b22d8b8b5 Mon Sep 17 00:00:00 2001 From: Marek Behún Date: Thu, 7 Apr 2022 00:33:01 +0200 Subject: net: introduce helpers to get PHY interface mode from a device/ofnode Add helpers ofnode_read_phy_mode() and dev_read_phy_mode() to parse the "phy-mode" / "phy-connection-type" property. Add corresponding UT test. Use them treewide. This allows us to inline the phy_get_interface_by_name() into ofnode_read_phy_mode(), since the former is not used anymore. Signed-off-by: Marek Behún Reviewed-by: Ramon Fried Tested-by: Patrice Chotard --- board/st/stm32f746-disco/stm32f746-disco.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'board') diff --git a/board/st/stm32f746-disco/stm32f746-disco.c b/board/st/stm32f746-disco/stm32f746-disco.c index 95d83e73ee8..69f657c54b8 100644 --- a/board/st/stm32f746-disco/stm32f746-disco.c +++ b/board/st/stm32f746-disco/stm32f746-disco.c @@ -117,16 +117,13 @@ int board_late_init(void) int board_init(void) { #ifdef CONFIG_ETH_DESIGNWARE - const char *phy_mode; - int node; + ofnode node; - node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,stm32-dwmac"); - if (node < 0) + node = ofnode_by_compatible(ofnode_null(), "st,stm32-dwmac"); + if (!ofnode_valid(node)) return -1; - phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL); - - switch (phy_get_interface_by_name(phy_mode)) { + switch (ofnode_read_phy_mode(node)) { case PHY_INTERFACE_MODE_RMII: STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL; break; @@ -134,7 +131,7 @@ int board_init(void) STM32_SYSCFG->pmc &= ~SYSCFG_PMC_MII_RMII_SEL; break; default: - printf("PHY interface %s not supported !\n", phy_mode); + printf("Unsupported PHY interface!\n"); } #endif -- cgit v1.2.3 From ffb0f6f488b9eee2822c3c691778a26e1590694c Mon Sep 17 00:00:00 2001 From: Marek Behún Date: Thu, 7 Apr 2022 00:33:03 +0200 Subject: treewide: Rename PHY_INTERFACE_MODE_NONE to PHY_INTERFACE_MODE_NA Rename constant PHY_INTERFACE_MODE_NONE to PHY_INTERFACE_MODE_NA to make it compatible with Linux' naming. Signed-off-by: Marek Behún Reviewed-by: Stefan Roese Reviewed-by: Ramon Fried Reviewed-by: Vladimir Oltean --- board/freescale/corenet_ds/eth_hydra.c | 2 +- board/freescale/corenet_ds/eth_superhydra.c | 4 ++-- board/freescale/t104xrdb/eth.c | 4 ++-- drivers/core/ofnode.c | 4 ++-- drivers/net/ag7xxx.c | 2 +- drivers/net/altera_tse.c | 2 +- drivers/net/bcm6348-eth.c | 2 +- drivers/net/bcmgenet.c | 2 +- drivers/net/designware.c | 2 +- drivers/net/dwc_eth_qos.c | 4 ++-- drivers/net/fec_mxc.c | 2 +- drivers/net/fm/b4860.c | 8 ++++---- drivers/net/fm/init.c | 8 ++++---- drivers/net/fm/ls1043.c | 6 +++--- drivers/net/fm/ls1046.c | 8 ++++---- drivers/net/fm/p1023.c | 4 ++-- drivers/net/fm/p4080.c | 6 +++--- drivers/net/fm/p5020.c | 6 +++--- drivers/net/fm/p5040.c | 6 +++--- drivers/net/fm/t1024.c | 4 ++-- drivers/net/fm/t1040.c | 4 ++-- drivers/net/fm/t2080.c | 6 +++--- drivers/net/fm/t4240.c | 6 +++--- drivers/net/fsl_enetc.c | 2 +- drivers/net/ftgmac100.c | 2 +- drivers/net/higmacv300.c | 2 +- drivers/net/ldpaa_eth/ldpaa_eth.c | 2 +- drivers/net/ldpaa_eth/ldpaa_wriop.c | 10 +++++----- drivers/net/ldpaa_eth/ls1088a.c | 4 ++-- drivers/net/ldpaa_eth/ls2080a.c | 4 ++-- drivers/net/ldpaa_eth/lx2160a.c | 4 ++-- drivers/net/macb.c | 2 +- drivers/net/mscc_eswitch/jr2_switch.c | 2 +- drivers/net/mscc_eswitch/luton_switch.c | 2 +- drivers/net/mscc_eswitch/ocelot_switch.c | 2 +- drivers/net/mscc_eswitch/serval_switch.c | 2 +- drivers/net/mscc_eswitch/servalt_switch.c | 2 +- drivers/net/mt7620-eth.c | 12 ++++++------ drivers/net/mtk_eth.c | 2 +- drivers/net/mvgbe.c | 2 +- drivers/net/mvneta.c | 2 +- drivers/net/mvpp2.c | 2 +- drivers/net/pic32_eth.c | 2 +- drivers/net/qe/dm_qe_uec.c | 2 +- drivers/net/ravb.c | 2 +- drivers/net/sh_eth.c | 2 +- drivers/net/sni_ave.c | 2 +- drivers/net/sni_netsec.c | 2 +- drivers/net/sun8i_emac.c | 2 +- drivers/net/ti/am65-cpsw-nuss.c | 2 +- drivers/net/ti/cpsw.c | 2 +- drivers/net/ti/keystone_net.c | 2 +- drivers/net/tsec.c | 2 +- drivers/net/xilinx_axi_emac.c | 2 +- drivers/net/zynq_gem.c | 2 +- include/dm/ofnode.h | 2 +- include/dm/read.h | 2 +- include/fm_eth.h | 2 +- include/phy_interface.h | 8 ++++---- include/vsc9953.h | 2 +- net/mdio-uclass.c | 4 ++-- 61 files changed, 105 insertions(+), 105 deletions(-) (limited to 'board') diff --git a/board/freescale/corenet_ds/eth_hydra.c b/board/freescale/corenet_ds/eth_hydra.c index 6500c2fcf67..a27e905ace9 100644 --- a/board/freescale/corenet_ds/eth_hydra.c +++ b/board/freescale/corenet_ds/eth_hydra.c @@ -471,7 +471,7 @@ int board_eth_init(struct bd_info *bis) fm_info_set_mdio(i, miiphy_get_dev_by_name("HYDRA_RGMII_MDIO")); break; - case PHY_INTERFACE_MODE_NONE: + case PHY_INTERFACE_MODE_NA: fm_info_set_phy_address(i, 0); break; default: diff --git a/board/freescale/corenet_ds/eth_superhydra.c b/board/freescale/corenet_ds/eth_superhydra.c index de7b692f3fe..55bac0f7615 100644 --- a/board/freescale/corenet_ds/eth_superhydra.c +++ b/board/freescale/corenet_ds/eth_superhydra.c @@ -583,7 +583,7 @@ int board_eth_init(struct bd_info *bis) fm_info_set_mdio(i, miiphy_get_dev_by_name("SUPER_HYDRA_RGMII_MDIO")); break; - case PHY_INTERFACE_MODE_NONE: + case PHY_INTERFACE_MODE_NA: fm_info_set_phy_address(i, 0); break; default: @@ -733,7 +733,7 @@ int board_eth_init(struct bd_info *bis) fm_info_set_mdio(i, miiphy_get_dev_by_name("SUPER_HYDRA_RGMII_MDIO")); break; - case PHY_INTERFACE_MODE_NONE: + case PHY_INTERFACE_MODE_NA: fm_info_set_phy_address(i, 0); break; default: diff --git a/board/freescale/t104xrdb/eth.c b/board/freescale/t104xrdb/eth.c index b034f11d68a..3ae5d722aab 100644 --- a/board/freescale/t104xrdb/eth.c +++ b/board/freescale/t104xrdb/eth.c @@ -89,7 +89,7 @@ int board_eth_init(struct bd_info *bis) case PHY_INTERFACE_MODE_QSGMII: fm_info_set_phy_address(i, 0); break; - case PHY_INTERFACE_MODE_NONE: + case PHY_INTERFACE_MODE_NA: fm_info_set_phy_address(i, 0); break; default: @@ -99,7 +99,7 @@ int board_eth_init(struct bd_info *bis) break; } if (fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_QSGMII || - fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_NONE) + fm_info_get_enet_if(i) == PHY_INTERFACE_MODE_NA) fm_info_set_mdio(i, NULL); else fm_info_set_mdio(i, diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index d9ccb1bad26..a59832ebbfb 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -1232,7 +1232,7 @@ phy_interface_t ofnode_read_phy_mode(ofnode node) mode = ofnode_read_string(node, "phy-connection-type"); if (!mode) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; for (i = 0; i < PHY_INTERFACE_MODE_MAX; i++) if (!strcmp(mode, phy_interface_strings[i])) @@ -1240,5 +1240,5 @@ phy_interface_t ofnode_read_phy_mode(ofnode node) debug("%s: Invalid PHY interface '%s'\n", __func__, mode); - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } diff --git a/drivers/net/ag7xxx.c b/drivers/net/ag7xxx.c index f24a917bd43..a16c998b2ab 100644 --- a/drivers/net/ag7xxx.c +++ b/drivers/net/ag7xxx.c @@ -1265,7 +1265,7 @@ static int ag7xxx_eth_of_to_plat(struct udevice *dev) return ret; pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; return 0; diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c index 25247472b03..b1e5c5890aa 100644 --- a/drivers/net/altera_tse.c +++ b/drivers/net/altera_tse.c @@ -678,7 +678,7 @@ static int altera_tse_of_to_plat(struct udevice *dev) struct eth_pdata *pdata = dev_get_plat(dev); pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; return 0; diff --git a/drivers/net/bcm6348-eth.c b/drivers/net/bcm6348-eth.c index 8f1864a334c..53171736117 100644 --- a/drivers/net/bcm6348-eth.c +++ b/drivers/net/bcm6348-eth.c @@ -425,7 +425,7 @@ static int bcm6348_eth_probe(struct udevice *dev) /* get phy mode */ pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -ENODEV; /* get phy */ diff --git a/drivers/net/bcmgenet.c b/drivers/net/bcmgenet.c index c6acb4932b4..ef321f28399 100644 --- a/drivers/net/bcmgenet.c +++ b/drivers/net/bcmgenet.c @@ -696,7 +696,7 @@ static int bcmgenet_eth_of_to_plat(struct udevice *dev) /* Get phy mode from DT */ pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; ret = dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 7b7b0f65780..1584b9eac17 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -921,7 +921,7 @@ int designware_eth_of_to_plat(struct udevice *dev) pdata->iobase = dev_read_addr(dev); pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; pdata->max_speed = dev_read_u32_default(dev, "max-speed", 0); diff --git a/drivers/net/dwc_eth_qos.c b/drivers/net/dwc_eth_qos.c index 9777f6cb9c6..39aedc80f44 100644 --- a/drivers/net/dwc_eth_qos.c +++ b/drivers/net/dwc_eth_qos.c @@ -1682,7 +1682,7 @@ static int eqos_probe_resources_stm32(struct udevice *dev) interface = eqos->config->interface(dev); - if (interface == PHY_INTERFACE_MODE_NONE) { + if (interface == PHY_INTERFACE_MODE_NA) { pr_err("Invalid PHY interface\n"); return -EINVAL; } @@ -1743,7 +1743,7 @@ static int eqos_probe_resources_imx(struct udevice *dev) interface = eqos->config->interface(dev); - if (interface == PHY_INTERFACE_MODE_NONE) { + if (interface == PHY_INTERFACE_MODE_NA) { pr_err("Invalid PHY interface\n"); return -EINVAL; } diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 22c2a3a30f2..3ac8e2a9cd1 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -1315,7 +1315,7 @@ static int fecmxc_of_to_plat(struct udevice *dev) priv->eth = (struct ethernet_regs *)pdata->iobase; pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; #ifdef CONFIG_DM_REGULATOR diff --git a/drivers/net/fm/b4860.c b/drivers/net/fm/b4860.c index 6e3d008199a..e622d86ba38 100644 --- a/drivers/net/fm/b4860.c +++ b/drivers/net/fm/b4860.c @@ -55,7 +55,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port) #endif if (is_device_disabled(port)) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; /*B4860 has two 10Gig Mac*/ if ((port == FM1_10GEC1 || port == FM1_10GEC2) && @@ -112,7 +112,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port) (port == FM1_DTSEC2) || (port == FM1_DTSEC3) || (port == FM1_DTSEC4)) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } } } @@ -131,8 +131,8 @@ phy_interface_t fman_port_enet_if(enum fm_port port) return PHY_INTERFACE_MODE_SGMII; break; default: - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } diff --git a/drivers/net/fm/init.c b/drivers/net/fm/init.c index 2fed64205cb..af94dabe291 100644 --- a/drivers/net/fm/init.c +++ b/drivers/net/fm/init.c @@ -130,7 +130,7 @@ static int fm_port_to_index(enum fm_port port) /* * Determine if an interface is actually active based on HW config - * we expect fman_port_enet_if() to report PHY_INTERFACE_MODE_NONE if + * we expect fman_port_enet_if() to report PHY_INTERFACE_MODE_NA if * the interface is not active based on HW cfg of the SoC */ void fman_enet_init(void) @@ -141,7 +141,7 @@ void fman_enet_init(void) phy_interface_t enet_if; enet_if = fman_port_enet_if(fm_info[i].port); - if (enet_if != PHY_INTERFACE_MODE_NONE) { + if (enet_if != PHY_INTERFACE_MODE_NA) { fm_info[i].enabled = 1; fm_info[i].enet_if = enet_if; } else { @@ -221,12 +221,12 @@ phy_interface_t fm_info_get_enet_if(enum fm_port port) int i = fm_port_to_index(port); if (i == -1) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; if (fm_info[i].enabled) return fm_info[i].enet_if; - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } static void diff --git a/drivers/net/fm/ls1043.c b/drivers/net/fm/ls1043.c index e1abf8f6bb7..cd8376a6150 100644 --- a/drivers/net/fm/ls1043.c +++ b/drivers/net/fm/ls1043.c @@ -54,13 +54,13 @@ phy_interface_t fman_port_enet_if(enum fm_port port) u32 rcwsr13 = in_be32(&gur->rcwsr[13]); if (is_device_disabled(port)) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; if ((port == FM1_10GEC1) && (is_serdes_configured(XFI_FM1_MAC9))) return PHY_INTERFACE_MODE_XGMII; if ((port == FM1_DTSEC9) && (is_serdes_configured(XFI_FM1_MAC9))) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; if (port == FM1_DTSEC3) if ((rcwsr13 & FSL_CHASSIS2_RCWSR13_EC1) == @@ -107,5 +107,5 @@ phy_interface_t fman_port_enet_if(enum fm_port port) break; } - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } diff --git a/drivers/net/fm/ls1046.c b/drivers/net/fm/ls1046.c index 09df0aa5376..876f48b1477 100644 --- a/drivers/net/fm/ls1046.c +++ b/drivers/net/fm/ls1046.c @@ -54,19 +54,19 @@ phy_interface_t fman_port_enet_if(enum fm_port port) u32 rcwsr13 = in_be32(&gur->rcwsr[13]); if (is_device_disabled(port)) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; if ((port == FM1_10GEC1) && (is_serdes_configured(XFI_FM1_MAC9))) return PHY_INTERFACE_MODE_XGMII; if ((port == FM1_DTSEC9) && (is_serdes_configured(XFI_FM1_MAC9))) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; if ((port == FM1_10GEC2) && (is_serdes_configured(XFI_FM1_MAC10))) return PHY_INTERFACE_MODE_XGMII; if ((port == FM1_DTSEC10) && (is_serdes_configured(XFI_FM1_MAC10))) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; if (port == FM1_DTSEC3) if ((rcwsr13 & FSL_CHASSIS2_RCWSR13_EC1) == @@ -118,5 +118,5 @@ phy_interface_t fman_port_enet_if(enum fm_port port) break; } - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } diff --git a/drivers/net/fm/p1023.c b/drivers/net/fm/p1023.c index d4167e4d696..c9b85fc8a8a 100644 --- a/drivers/net/fm/p1023.c +++ b/drivers/net/fm/p1023.c @@ -46,7 +46,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port) u32 pordevsr = in_be32(&gur->pordevsr); if (is_device_disabled(port)) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; /* DTSEC1 can be SGMII, RGMII or RMII */ if (port == FM1_DTSEC1) { @@ -68,5 +68,5 @@ phy_interface_t fman_port_enet_if(enum fm_port port) return PHY_INTERFACE_MODE_RGMII; } - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } diff --git a/drivers/net/fm/p4080.c b/drivers/net/fm/p4080.c index b78b02d8284..577ee22cb0a 100644 --- a/drivers/net/fm/p4080.c +++ b/drivers/net/fm/p4080.c @@ -54,7 +54,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port) u32 rcwsr11 = in_be32(&gur->rcwsr[11]); if (is_device_disabled(port)) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; if ((port == FM1_10GEC1) && (is_serdes_configured(XAUI_FM1))) return PHY_INTERFACE_MODE_XGMII; @@ -91,8 +91,8 @@ phy_interface_t fman_port_enet_if(enum fm_port port) return PHY_INTERFACE_MODE_SGMII; break; default: - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } diff --git a/drivers/net/fm/p5020.c b/drivers/net/fm/p5020.c index 81895312153..8ecc48276a9 100644 --- a/drivers/net/fm/p5020.c +++ b/drivers/net/fm/p5020.c @@ -50,7 +50,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port) u32 rcwsr11 = in_be32(&gur->rcwsr[11]); if (is_device_disabled(port)) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; if ((port == FM1_10GEC1) && (is_serdes_configured(XAUI_FM1))) return PHY_INTERFACE_MODE_XGMII; @@ -82,8 +82,8 @@ phy_interface_t fman_port_enet_if(enum fm_port port) return PHY_INTERFACE_MODE_SGMII; break; default: - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } diff --git a/drivers/net/fm/p5040.c b/drivers/net/fm/p5040.c index 38744e7b7b3..3a1494d1315 100644 --- a/drivers/net/fm/p5040.c +++ b/drivers/net/fm/p5040.c @@ -56,7 +56,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port) u32 rcwsr11 = in_be32(&gur->rcwsr[11]); if (is_device_disabled(port)) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; if ((port == FM1_10GEC1) && (is_serdes_configured(XAUI_FM1))) return PHY_INTERFACE_MODE_XGMII; @@ -99,8 +99,8 @@ phy_interface_t fman_port_enet_if(enum fm_port port) return PHY_INTERFACE_MODE_SGMII; break; default: - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } diff --git a/drivers/net/fm/t1024.c b/drivers/net/fm/t1024.c index 696e74c9e6f..7110fb4fb11 100644 --- a/drivers/net/fm/t1024.c +++ b/drivers/net/fm/t1024.c @@ -39,7 +39,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port) u32 rcwsr13 = in_be32(&gur->rcwsr[13]); if (is_device_disabled(port)) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; if ((port == FM1_10GEC1) && (is_serdes_configured(XFI_FM1_MAC1))) return PHY_INTERFACE_MODE_XGMII; @@ -83,5 +83,5 @@ phy_interface_t fman_port_enet_if(enum fm_port port) break; } - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } diff --git a/drivers/net/fm/t1040.c b/drivers/net/fm/t1040.c index af4f5c56107..192f1c6c81e 100644 --- a/drivers/net/fm/t1040.c +++ b/drivers/net/fm/t1040.c @@ -56,8 +56,8 @@ phy_interface_t fman_port_enet_if(enum fm_port port) return PHY_INTERFACE_MODE_SGMII; break; default: - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } diff --git a/drivers/net/fm/t2080.c b/drivers/net/fm/t2080.c index f4d8d2d869a..bfbd8de9cf1 100644 --- a/drivers/net/fm/t2080.c +++ b/drivers/net/fm/t2080.c @@ -47,7 +47,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port) u32 rcwsr13 = in_be32(&gur->rcwsr[13]); if (is_device_disabled(port)) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; if ((port == FM1_10GEC1 || port == FM1_10GEC2) && ((is_serdes_configured(XAUI_FM1_MAC9)) || @@ -85,8 +85,8 @@ phy_interface_t fman_port_enet_if(enum fm_port port) return PHY_INTERFACE_MODE_SGMII; break; default: - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } diff --git a/drivers/net/fm/t4240.c b/drivers/net/fm/t4240.c index f8e63c3d719..ba7b86282fb 100644 --- a/drivers/net/fm/t4240.c +++ b/drivers/net/fm/t4240.c @@ -61,7 +61,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port) u32 rcwsr13 = in_be32(&gur->rcwsr[13]); if (is_device_disabled(port)) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; if ((port == FM1_10GEC1 || port == FM1_10GEC2) && ((is_serdes_configured(XAUI_FM1_MAC9)) || @@ -73,7 +73,7 @@ phy_interface_t fman_port_enet_if(enum fm_port port) if ((port == FM1_DTSEC9 || port == FM1_DTSEC10) && ((is_serdes_configured(XFI_FM1_MAC9)) || (is_serdes_configured(XFI_FM1_MAC10)))) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; if ((port == FM2_10GEC1 || port == FM2_10GEC2) && ((is_serdes_configured(XAUI_FM2_MAC9)) || @@ -166,5 +166,5 @@ phy_interface_t fman_port_enet_if(enum fm_port port) break; } - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c index 8f5af1dbc03..1724f948bcd 100644 --- a/drivers/net/fsl_enetc.c +++ b/drivers/net/fsl_enetc.c @@ -277,7 +277,7 @@ static void enetc_start_pcs(struct udevice *dev) } priv->if_type = dev_read_phy_mode(dev); - if (priv->if_type == PHY_INTERFACE_MODE_NONE) { + if (priv->if_type == PHY_INTERFACE_MODE_NA) { enetc_dbg(dev, "phy-mode property not found, defaulting to SGMII\n"); priv->if_type = PHY_INTERFACE_MODE_SGMII; diff --git a/drivers/net/ftgmac100.c b/drivers/net/ftgmac100.c index 626c27d7bf8..78779d7d60b 100644 --- a/drivers/net/ftgmac100.c +++ b/drivers/net/ftgmac100.c @@ -553,7 +553,7 @@ static int ftgmac100_of_to_plat(struct udevice *dev) pdata->iobase = dev_read_addr(dev); pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; pdata->max_speed = dev_read_u32_default(dev, "max-speed", 0); diff --git a/drivers/net/higmacv300.c b/drivers/net/higmacv300.c index ce8f2dfd098..1862235d0cd 100644 --- a/drivers/net/higmacv300.c +++ b/drivers/net/higmacv300.c @@ -567,7 +567,7 @@ static int higmac_of_to_plat(struct udevice *dev) priv->macif_ctrl = dev_remap_addr_index(dev, 1); priv->phyintf = dev_read_phy_mode(dev); - if (priv->phyintf == PHY_INTERFACE_MODE_NONE) + if (priv->phyintf == PHY_INTERFACE_MODE_NA) return -ENODEV; phy_node = dev_read_subnode(dev, "phy"); diff --git a/drivers/net/ldpaa_eth/ldpaa_eth.c b/drivers/net/ldpaa_eth/ldpaa_eth.c index c775598b91f..b6f589eb91a 100644 --- a/drivers/net/ldpaa_eth/ldpaa_eth.c +++ b/drivers/net/ldpaa_eth/ldpaa_eth.c @@ -1127,7 +1127,7 @@ static int ldpaa_eth_bind(struct udevice *dev) int phy_mode = -1; phy_mode = dev_read_phy_mode(dev); - if (phy_mode == PHY_INTERFACE_MODE_NONE) { + if (phy_mode == PHY_INTERFACE_MODE_NA) { dev_err(dev, "incorrect phy mode\n"); return -EINVAL; } diff --git a/drivers/net/ldpaa_eth/ldpaa_wriop.c b/drivers/net/ldpaa_eth/ldpaa_wriop.c index 06a284ad684..adecb813576 100644 --- a/drivers/net/ldpaa_eth/ldpaa_wriop.c +++ b/drivers/net/ldpaa_eth/ldpaa_wriop.c @@ -16,7 +16,7 @@ struct wriop_dpmac_info dpmac_info[NUM_WRIOP_PORTS]; __weak phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtc) { - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl) @@ -26,10 +26,10 @@ void wriop_init_dpmac(int sd, int dpmac_id, int lane_prtcl) dpmac_info[dpmac_id].enabled = 0; dpmac_info[dpmac_id].id = 0; - dpmac_info[dpmac_id].enet_if = PHY_INTERFACE_MODE_NONE; + dpmac_info[dpmac_id].enet_if = PHY_INTERFACE_MODE_NA; enet_if = wriop_dpmac_enet_if(dpmac_id, lane_prtcl); - if (enet_if != PHY_INTERFACE_MODE_NONE) { + if (enet_if != PHY_INTERFACE_MODE_NA) { dpmac_info[dpmac_id].enabled = 1; dpmac_info[dpmac_id].id = dpmac_id; dpmac_info[dpmac_id].enet_if = enet_if; @@ -183,10 +183,10 @@ phy_interface_t wriop_get_enet_if(int dpmac_id) int i = wriop_dpmac_to_index(dpmac_id); if (i == -1) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; if (dpmac_info[i].enabled) return dpmac_info[i].enet_if; - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } diff --git a/drivers/net/ldpaa_eth/ls1088a.c b/drivers/net/ldpaa_eth/ls1088a.c index 54cb16e51b1..943113b20aa 100644 --- a/drivers/net/ldpaa_eth/ls1088a.c +++ b/drivers/net/ldpaa_eth/ls1088a.c @@ -50,7 +50,7 @@ phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtcl) enum srds_prtcl; if (is_device_disabled(dpmac_id + 1)) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; switch (lane_prtcl) { case SGMII1: @@ -66,7 +66,7 @@ phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtcl) if (lane_prtcl >= QSGMII_A && lane_prtcl <= QSGMII_B) return PHY_INTERFACE_MODE_QSGMII; - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } void wriop_init_dpmac_qsgmii(int sd, int lane_prtcl) diff --git a/drivers/net/ldpaa_eth/ls2080a.c b/drivers/net/ldpaa_eth/ls2080a.c index 49eee044f35..62e1d6b8691 100644 --- a/drivers/net/ldpaa_eth/ls2080a.c +++ b/drivers/net/ldpaa_eth/ls2080a.c @@ -62,7 +62,7 @@ phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtcl) enum srds_prtcl; if (is_device_disabled(dpmac_id + 1)) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; if (lane_prtcl >= SGMII1 && lane_prtcl <= SGMII16) return PHY_INTERFACE_MODE_SGMII; @@ -76,7 +76,7 @@ phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtcl) if (lane_prtcl >= QSGMII_A && lane_prtcl <= QSGMII_D) return PHY_INTERFACE_MODE_QSGMII; - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } void wriop_init_dpmac_qsgmii(int sd, int lane_prtcl) diff --git a/drivers/net/ldpaa_eth/lx2160a.c b/drivers/net/ldpaa_eth/lx2160a.c index e57f1a19a59..f0f8ee1d4de 100644 --- a/drivers/net/ldpaa_eth/lx2160a.c +++ b/drivers/net/ldpaa_eth/lx2160a.c @@ -58,7 +58,7 @@ phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtcl) enum srds_prtcl; if (is_device_disabled(dpmac_id)) - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; if (lane_prtcl >= SGMII1 && lane_prtcl <= SGMII18) return PHY_INTERFACE_MODE_SGMII; @@ -78,7 +78,7 @@ phy_interface_t wriop_dpmac_enet_if(int dpmac_id, int lane_prtcl) if (lane_prtcl >= _100GE1 && lane_prtcl <= _100GE2) return PHY_INTERFACE_MODE_CAUI4; - return PHY_INTERFACE_MODE_NONE; + return PHY_INTERFACE_MODE_NA; } #ifdef CONFIG_SYS_FSL_HAS_RGMII diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 317b380e8fe..e02a57b4114 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -1363,7 +1363,7 @@ static int macb_eth_probe(struct udevice *dev) int ret; macb->phy_interface = dev_read_phy_mode(dev); - if (macb->phy_interface == PHY_INTERFACE_MODE_NONE) + if (macb->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; /* Read phyaddr from DT */ diff --git a/drivers/net/mscc_eswitch/jr2_switch.c b/drivers/net/mscc_eswitch/jr2_switch.c index d1e5b61ea54..1462b8f3bc8 100644 --- a/drivers/net/mscc_eswitch/jr2_switch.c +++ b/drivers/net/mscc_eswitch/jr2_switch.c @@ -954,7 +954,7 @@ static int jr2_probe(struct udevice *dev) phy = phy_connect(priv->ports[i].bus, priv->ports[i].phy_addr, dev, - PHY_INTERFACE_MODE_NONE); + PHY_INTERFACE_MODE_NA); if (phy) board_phy_config(phy); } diff --git a/drivers/net/mscc_eswitch/luton_switch.c b/drivers/net/mscc_eswitch/luton_switch.c index 73c950d118f..5e4f00c4f4d 100644 --- a/drivers/net/mscc_eswitch/luton_switch.c +++ b/drivers/net/mscc_eswitch/luton_switch.c @@ -685,7 +685,7 @@ static int luton_probe(struct udevice *dev) phy = phy_connect(priv->ports[i].bus, priv->ports[i].phy_addr, dev, - PHY_INTERFACE_MODE_NONE); + PHY_INTERFACE_MODE_NA); if (phy && i >= MAX_INT_PORT) board_phy_config(phy); } diff --git a/drivers/net/mscc_eswitch/ocelot_switch.c b/drivers/net/mscc_eswitch/ocelot_switch.c index d1d0a489ab4..1bf6c42c0fc 100644 --- a/drivers/net/mscc_eswitch/ocelot_switch.c +++ b/drivers/net/mscc_eswitch/ocelot_switch.c @@ -608,7 +608,7 @@ static int ocelot_probe(struct udevice *dev) phy = phy_connect(priv->ports[i].bus, priv->ports[i].phy_addr, dev, - PHY_INTERFACE_MODE_NONE); + PHY_INTERFACE_MODE_NA); if (phy && external_bus(priv, i)) board_phy_config(phy); } diff --git a/drivers/net/mscc_eswitch/serval_switch.c b/drivers/net/mscc_eswitch/serval_switch.c index c4b81f75294..38ddba12b66 100644 --- a/drivers/net/mscc_eswitch/serval_switch.c +++ b/drivers/net/mscc_eswitch/serval_switch.c @@ -561,7 +561,7 @@ static int serval_probe(struct udevice *dev) phy = phy_connect(priv->ports[i].bus, priv->ports[i].phy_addr, dev, - PHY_INTERFACE_MODE_NONE); + PHY_INTERFACE_MODE_NA); if (phy) board_phy_config(phy); } diff --git a/drivers/net/mscc_eswitch/servalt_switch.c b/drivers/net/mscc_eswitch/servalt_switch.c index f114086ece6..db863c2a9ff 100644 --- a/drivers/net/mscc_eswitch/servalt_switch.c +++ b/drivers/net/mscc_eswitch/servalt_switch.c @@ -482,7 +482,7 @@ static int servalt_probe(struct udevice *dev) continue; phy_connect(priv->ports[i].bus, priv->ports[i].phy_addr, dev, - PHY_INTERFACE_MODE_NONE); + PHY_INTERFACE_MODE_NA); } return 0; diff --git a/drivers/net/mt7620-eth.c b/drivers/net/mt7620-eth.c index 24fcb9373f8..038cba12407 100644 --- a/drivers/net/mt7620-eth.c +++ b/drivers/net/mt7620-eth.c @@ -596,7 +596,7 @@ static int mt7620_setup_gmac_mode(struct mt7620_eth_priv *priv, u32 gmac, case PHY_INTERFACE_MODE_RGMII: ge_mode = MT7620_SYSC_GE_RGMII; break; - case PHY_INTERFACE_MODE_NONE: + case PHY_INTERFACE_MODE_NA: if (gmac == 2) ge_mode = MT7620_SYSC_GE_ESW_PHY; else @@ -620,7 +620,7 @@ static void mt7620_gsw_setup_port(struct mt7620_eth_priv *priv, u32 port, { u32 pmcr; - if (port_cfg->mode == PHY_INTERFACE_MODE_NONE) { + if (port_cfg->mode == PHY_INTERFACE_MODE_NA) { if (port == 5) { gsw_write(priv, GSW_PMCR(port), FORCE_MODE); return; @@ -666,7 +666,7 @@ static void mt7620_gsw_setup_phy_polling(struct mt7620_eth_priv *priv) { int phy_addr_st, phy_addr_end; - if (priv->port_cfg[0].mode == PHY_INTERFACE_MODE_NONE) + if (priv->port_cfg[0].mode == PHY_INTERFACE_MODE_NA) priv->ephy_num = NUM_FE_PHYS; else priv->ephy_num = NUM_FE_PHYS - 1; @@ -1057,7 +1057,7 @@ static int mt7620_eth_parse_gsw_port(struct mt7620_eth_priv *priv, u32 idx, case PHY_INTERFACE_MODE_MII: case PHY_INTERFACE_MODE_RMII: case PHY_INTERFACE_MODE_RGMII: - case PHY_INTERFACE_MODE_NONE: + case PHY_INTERFACE_MODE_NA: break; default: dev_err(priv->dev, "mt7620_eth: unsupported phy-mode\n"); @@ -1128,14 +1128,14 @@ static int mt7620_eth_parse_gsw_cfg(struct udevice *dev) if (ret) return ret; } else { - priv->port_cfg[0].mode = PHY_INTERFACE_MODE_NONE; + priv->port_cfg[0].mode = PHY_INTERFACE_MODE_NA; } subnode = ofnode_find_subnode(dev_ofnode(dev), "port5"); if (ofnode_valid(subnode)) return mt7620_eth_parse_gsw_port(priv, 1, subnode); - priv->port_cfg[1].mode = PHY_INTERFACE_MODE_NONE; + priv->port_cfg[1].mode = PHY_INTERFACE_MODE_NA; return 0; } diff --git a/drivers/net/mtk_eth.c b/drivers/net/mtk_eth.c index d6065db5fb7..666ddeb10d1 100644 --- a/drivers/net/mtk_eth.c +++ b/drivers/net/mtk_eth.c @@ -1449,7 +1449,7 @@ static int mtk_eth_of_to_plat(struct udevice *dev) /* Interface mode is required */ pdata->phy_interface = dev_read_phy_mode(dev); priv->phy_interface = pdata->phy_interface; - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) { + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) { printf("error: phy-mode is not set\n"); return -EINVAL; } diff --git a/drivers/net/mvgbe.c b/drivers/net/mvgbe.c index 32ec0b437d3..bf5ed5513ba 100644 --- a/drivers/net/mvgbe.c +++ b/drivers/net/mvgbe.c @@ -1005,7 +1005,7 @@ static int mvgbe_of_to_plat(struct udevice *dev) /* Get phy-mode / phy_interface from DT */ pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) pdata->phy_interface = PHY_INTERFACE_MODE_GMII; dmvgbe->phy_interface = pdata->phy_interface; diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c index d31b96a9d82..e2ac4d801dc 100644 --- a/drivers/net/mvneta.c +++ b/drivers/net/mvneta.c @@ -1804,7 +1804,7 @@ static int mvneta_of_to_plat(struct udevice *dev) /* Get phy-mode / phy_interface from DT */ pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; return 0; diff --git a/drivers/net/mvpp2.c b/drivers/net/mvpp2.c index dfddac180fd..8c9afdf79ab 100644 --- a/drivers/net/mvpp2.c +++ b/drivers/net/mvpp2.c @@ -4820,7 +4820,7 @@ static int phy_info_parse(struct udevice *dev, struct mvpp2_port *port) } port->phy_interface = dev_read_phy_mode(dev); - if (port->phy_interface == PHY_INTERFACE_MODE_NONE) { + if (port->phy_interface == PHY_INTERFACE_MODE_NA) { dev_err(dev, "incorrect phy mode\n"); return -EINVAL; } diff --git a/drivers/net/pic32_eth.c b/drivers/net/pic32_eth.c index 03eb51e51d5..1333a3aa7e4 100644 --- a/drivers/net/pic32_eth.c +++ b/drivers/net/pic32_eth.c @@ -550,7 +550,7 @@ static int pic32_eth_probe(struct udevice *dev) /* get phy mode */ pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; /* get phy addr */ diff --git a/drivers/net/qe/dm_qe_uec.c b/drivers/net/qe/dm_qe_uec.c index 5a66d726cd6..8fec1c21e10 100644 --- a/drivers/net/qe/dm_qe_uec.c +++ b/drivers/net/qe/dm_qe_uec.c @@ -1137,7 +1137,7 @@ static int qe_uec_of_to_plat(struct udevice *dev) pdata->iobase = (phys_addr_t)devfdt_get_addr(dev); pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; return 0; diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index f6d386bd6b8..5c152d6e0a5 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -679,7 +679,7 @@ int ravb_of_to_plat(struct udevice *dev) pdata->iobase = dev_read_addr(dev); pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; pdata->max_speed = 1000; diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index 04c9c2d968f..5c57e3dfcd4 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -920,7 +920,7 @@ int sh_ether_of_to_plat(struct udevice *dev) pdata->iobase = dev_read_addr(dev); pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; pdata->max_speed = 1000; diff --git a/drivers/net/sni_ave.c b/drivers/net/sni_ave.c index 0a368c6d03a..d684e60e72f 100644 --- a/drivers/net/sni_ave.c +++ b/drivers/net/sni_ave.c @@ -749,7 +749,7 @@ static int ave_of_to_plat(struct udevice *dev) pdata->iobase = dev_read_addr(dev); pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; pdata->max_speed = 0; diff --git a/drivers/net/sni_netsec.c b/drivers/net/sni_netsec.c index 693fd3a35db..24caacf8470 100644 --- a/drivers/net/sni_netsec.c +++ b/drivers/net/sni_netsec.c @@ -1034,7 +1034,7 @@ static int netsec_of_to_plat(struct udevice *dev) priv->eeprom_base = dev_read_addr_index(dev, 1) - EERPROM_MAP_OFFSET; pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; if (!dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, diff --git a/drivers/net/sun8i_emac.c b/drivers/net/sun8i_emac.c index 5654a3430e2..5943a5e3f0a 100644 --- a/drivers/net/sun8i_emac.c +++ b/drivers/net/sun8i_emac.c @@ -947,7 +947,7 @@ static int sun8i_emac_eth_of_to_plat(struct udevice *dev) pdata->phy_interface = dev_read_phy_mode(dev); printf("phy interface%d\n", pdata->phy_interface); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; if (priv->variant == H3_EMAC) { diff --git a/drivers/net/ti/am65-cpsw-nuss.c b/drivers/net/ti/am65-cpsw-nuss.c index c1da3347395..9580fa37eaf 100644 --- a/drivers/net/ti/am65-cpsw-nuss.c +++ b/drivers/net/ti/am65-cpsw-nuss.c @@ -607,7 +607,7 @@ static int am65_cpsw_ofdata_parse_phy(struct udevice *dev) dev_read_u32(dev, "reg", &priv->port_id); pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) { + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) { dev_err(dev, "Invalid PHY mode, port %u\n", priv->port_id); return -EINVAL; } diff --git a/drivers/net/ti/cpsw.c b/drivers/net/ti/cpsw.c index 5b7bab734e4..8988c21e667 100644 --- a/drivers/net/ti/cpsw.c +++ b/drivers/net/ti/cpsw.c @@ -1345,7 +1345,7 @@ static int cpsw_eth_of_to_plat(struct udevice *dev) } pdata->phy_interface = data->slave_data[data->active_slave].phy_if; - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; return 0; diff --git a/drivers/net/ti/keystone_net.c b/drivers/net/ti/keystone_net.c index b55e7da4c18..16e3f32bb03 100644 --- a/drivers/net/ti/keystone_net.c +++ b/drivers/net/ti/keystone_net.c @@ -728,7 +728,7 @@ static int ks2_eth_parse_slave_interface(int netcp, int slave, priv->has_mdio = true; } else if (priv->link_type == LINK_TYPE_RGMII_LINK_MAC_PHY) { priv->phy_if = ofnode_read_phy_mode(offset_to_ofnode(slave)); - if (priv->phy_if == PHY_INTERFACE_MODE_NONE) + if (priv->phy_if == PHY_INTERFACE_MODE_NA) priv->phy_if = PHY_INTERFACE_MODE_RGMII; pdata->phy_interface = priv->phy_if; diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c index fec051ebb7c..d69a9ff4773 100644 --- a/drivers/net/tsec.c +++ b/drivers/net/tsec.c @@ -894,7 +894,7 @@ int tsec_probe(struct udevice *dev) priv->tbiaddr = tbiaddr; pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) pdata->phy_interface = tsec_get_interface(priv); priv->interface = pdata->phy_interface; diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c index 02d13c3e0ad..a4715735c3c 100644 --- a/drivers/net/xilinx_axi_emac.c +++ b/drivers/net/xilinx_axi_emac.c @@ -850,7 +850,7 @@ static int axi_emac_of_to_plat(struct udevice *dev) } pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; plat->eth_hasnobuf = fdtdec_get_bool(gd->fdt_blob, node, diff --git a/drivers/net/zynq_gem.c b/drivers/net/zynq_gem.c index 0062851134d..cf6c53c8afb 100644 --- a/drivers/net/zynq_gem.c +++ b/drivers/net/zynq_gem.c @@ -859,7 +859,7 @@ static int zynq_gem_of_to_plat(struct udevice *dev) } pdata->phy_interface = dev_read_phy_mode(dev); - if (pdata->phy_interface == PHY_INTERFACE_MODE_NONE) + if (pdata->phy_interface == PHY_INTERFACE_MODE_NA) return -EINVAL; priv->interface = pdata->phy_interface; diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 3bd3ba49253..f27aca5877a 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -1239,7 +1239,7 @@ ofnode ofnode_get_phy_node(ofnode eth_node); * returns the corresponding PHY interface type. * * @mac_node: ofnode containing the property - * Return: one of PHY_INTERFACE_MODE_* constants, PHY_INTERFACE_MODE_NONE on + * Return: one of PHY_INTERFACE_MODE_* constants, PHY_INTERFACE_MODE_NA on * error */ phy_interface_t ofnode_read_phy_mode(ofnode mac_node); diff --git a/include/dm/read.h b/include/dm/read.h index bfa26459674..1b54b69acf0 100644 --- a/include/dm/read.h +++ b/include/dm/read.h @@ -764,7 +764,7 @@ ofnode dev_get_phy_node(const struct udevice *dev); * returns the corresponding PHY interface type. * * @dev: device representing the MAC - * Return: one of PHY_INTERFACE_MODE_* constants, PHY_INTERFACE_MODE_NONE on + * Return: one of PHY_INTERFACE_MODE_* constants, PHY_INTERFACE_MODE_NA on * error */ phy_interface_t dev_read_phy_mode(const struct udevice *dev); diff --git a/include/fm_eth.h b/include/fm_eth.h index 44da014c66c..bf9570679d2 100644 --- a/include/fm_eth.h +++ b/include/fm_eth.h @@ -72,7 +72,7 @@ enum fm_eth_type { #define FM_ETH_INFO_INITIALIZER(idx, pregs) \ .fm = idx, \ .phy_regs = (void *)pregs, \ - .enet_if = PHY_INTERFACE_MODE_NONE, \ + .enet_if = PHY_INTERFACE_MODE_NA, \ #ifdef CONFIG_SYS_FMAN_V3 #define FM_DTSEC_INFO_INITIALIZER(idx, n) \ diff --git a/include/phy_interface.h b/include/phy_interface.h index 494bc87e679..59e119a6399 100644 --- a/include/phy_interface.h +++ b/include/phy_interface.h @@ -39,7 +39,7 @@ typedef enum { PHY_INTERFACE_MODE_NCSI, PHY_INTERFACE_MODE_10GBASER, PHY_INTERFACE_MODE_USXGMII, - PHY_INTERFACE_MODE_NONE, /* Must be last */ + PHY_INTERFACE_MODE_NA, /* Must be last */ PHY_INTERFACE_MODE_MAX, } phy_interface_t; @@ -71,7 +71,7 @@ static const char * const phy_interface_strings[] = { [PHY_INTERFACE_MODE_NCSI] = "NC-SI", [PHY_INTERFACE_MODE_10GBASER] = "10gbase-r", [PHY_INTERFACE_MODE_USXGMII] = "usxgmii", - [PHY_INTERFACE_MODE_NONE] = "", + [PHY_INTERFACE_MODE_NA] = "", }; /* Backplane modes: @@ -86,8 +86,8 @@ static const char * const backplane_mode_strings[] = { static inline const char *phy_string_for_interface(phy_interface_t i) { /* Default to unknown */ - if (i > PHY_INTERFACE_MODE_NONE) - i = PHY_INTERFACE_MODE_NONE; + if (i > PHY_INTERFACE_MODE_NA) + i = PHY_INTERFACE_MODE_NA; return phy_interface_strings[i]; } diff --git a/include/vsc9953.h b/include/vsc9953.h index a9c84b4b50c..fd52c93044b 100644 --- a/include/vsc9953.h +++ b/include/vsc9953.h @@ -691,7 +691,7 @@ struct vsc9953_vcap { .phyaddr = 0, \ .index = idx, \ .phy_regs = NULL, \ - .enet_if = PHY_INTERFACE_MODE_NONE, \ + .enet_if = PHY_INTERFACE_MODE_NA, \ .bus = NULL, \ .phydev = NULL, \ } diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c index 874f59413a2..7593618d9ad 100644 --- a/net/mdio-uclass.c +++ b/net/mdio-uclass.c @@ -199,8 +199,8 @@ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev) } interface = dev_read_phy_mode(ethdev); - if (interface == PHY_INTERFACE_MODE_NONE) - dev_dbg(ethdev, "can't find interface mode, default to NONE\n"); + if (interface == PHY_INTERFACE_MODE_NA) + dev_dbg(ethdev, "can't find interface mode, default to NA\n"); phy = dm_eth_connect_phy_handle(ethdev, interface); -- cgit v1.2.3 From e24b58f5ed4f9a0b5b1c80a5f35aa71fcad7f233 Mon Sep 17 00:00:00 2001 From: Marek Behún Date: Thu, 7 Apr 2022 00:33:08 +0200 Subject: net: phy: don't require PHY interface mode during PHY creation Currently we require PHY interface mode to be known when finding/creating the PHY - the functions * phy_connect_phy_id() * phy_device_create() * create_phy_by_mask() * search_for_existing_phy() * get_phy_device_by_mask() * phy_find_by_mask() all require the interface parameter, but the only thing done with it is that it is assigned to phydev->interface. This makes it impossible to find a PHY device without overwriting the set mode. Since the interface mode is not used during .probe() and should be used at first in .config(), drop the interface parameter from these functions. Make the default value of phydev->interface (in phy_device_create()) to be PHY_INTERFACE_MODE_NA. Move the interface parameter to phy_connect_dev(), where it should be. Change all occurrences treewide. In occurrences where we don't call phy_connect_dev() for some reason (they only configure the PHY without connecting it to an ethernet controller), set phydev->interface = value from phy_find_by_mask call. Signed-off-by: Marek Behún Reviewed-by: Ramon Fried Reviewed-by: Vladimir Oltean --- board/CZ.NIC/turris_mox/turris_mox.c | 2 +- board/boundary/nitrogen6x/nitrogen6x.c | 2 +- board/gdsys/a38x/controlcenterdc.c | 7 +-- board/gdsys/a38x/ihs_phys.c | 6 +-- drivers/net/altera_tse.c | 4 +- drivers/net/ethoc.c | 4 +- drivers/net/pch_gbe.c | 4 +- drivers/net/phy/ethernet_id.c | 5 +- drivers/net/phy/phy.c | 88 ++++++++++++++-------------------- drivers/net/phy/xilinx_gmii2rgmii.c | 4 +- drivers/net/ravb.c | 4 +- drivers/net/sh_eth.c | 4 +- drivers/net/sni_ave.c | 4 +- drivers/net/sunxi_emac.c | 5 +- include/_exports.h | 3 +- include/exports.h | 3 +- include/phy.h | 20 ++++---- 17 files changed, 75 insertions(+), 94 deletions(-) (limited to 'board') diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index 8888a2dcabc..9702d1fc782 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -396,7 +396,7 @@ static void mox_phy_leds_start_blinking(void) return; } - phydev = phy_find_by_mask(bus, BIT(1), PHY_INTERFACE_MODE_RGMII); + phydev = phy_find_by_mask(bus, BIT(1)); if (!phydev) { printf("Cannot get ethernet PHY!\n"); return; diff --git a/board/boundary/nitrogen6x/nitrogen6x.c b/board/boundary/nitrogen6x/nitrogen6x.c index 8566c22a98f..83bb445d481 100644 --- a/board/boundary/nitrogen6x/nitrogen6x.c +++ b/board/boundary/nitrogen6x/nitrogen6x.c @@ -345,7 +345,7 @@ int board_eth_init(struct bd_info *bis) if (!bus) return -EINVAL; /* scan phy 4,5,6,7 */ - phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII); + phydev = phy_find_by_mask(bus, (0xf << 4)); if (!phydev) { ret = -EINVAL; goto free_bus; diff --git a/board/gdsys/a38x/controlcenterdc.c b/board/gdsys/a38x/controlcenterdc.c index 7d65400ccb0..ccebba72721 100644 --- a/board/gdsys/a38x/controlcenterdc.c +++ b/board/gdsys/a38x/controlcenterdc.c @@ -194,11 +194,12 @@ void init_host_phys(struct mii_dev *bus) for (k = 0; k < 2; ++k) { struct phy_device *phydev; - phydev = phy_find_by_mask(bus, 1 << k, - PHY_INTERFACE_MODE_SGMII); + phydev = phy_find_by_mask(bus, 1 << k); - if (phydev) + if (phydev) { + phydev->interface = PHY_INTERFACE_MODE_SGMII; phy_config(phydev); + } } } diff --git a/board/gdsys/a38x/ihs_phys.c b/board/gdsys/a38x/ihs_phys.c index e09c0006b76..60a5c37aeff 100644 --- a/board/gdsys/a38x/ihs_phys.c +++ b/board/gdsys/a38x/ihs_phys.c @@ -28,6 +28,7 @@ static void ihs_phy_config(struct phy_device *phydev, bool qinpn, bool qoutpn) { u16 reg; + phydev->interface = PHY_INTERFACE_MODE_MII; phy_config(phydev); /* enable QSGMII autonegotiation with flow control */ @@ -142,10 +143,9 @@ struct porttype *get_porttype(uint octo_phy_mask, uint k) int init_single_phy(struct porttype *porttype, struct mii_dev *bus, uint bus_idx, uint m, uint phy_idx) { - struct phy_device *phydev = phy_find_by_mask( - bus, 1 << (m * 8 + phy_idx), - PHY_INTERFACE_MODE_MII); + struct phy_device *phydev; + phydev = phy_find_by_mask(bus, BIT(m * 8 + phy_idx)); printf(" %u", bus_idx * 32 + m * 8 + phy_idx); if (!phydev) diff --git a/drivers/net/altera_tse.c b/drivers/net/altera_tse.c index b1e5c5890aa..912d28fca2e 100644 --- a/drivers/net/altera_tse.c +++ b/drivers/net/altera_tse.c @@ -435,11 +435,11 @@ static int tse_phy_init(struct altera_tse_priv *priv, void *dev) if (priv->phyaddr) mask = 1 << priv->phyaddr; - phydev = phy_find_by_mask(priv->bus, mask, priv->interface); + phydev = phy_find_by_mask(priv->bus, mask); if (!phydev) return -ENODEV; - phy_connect_dev(phydev, dev); + phy_connect_dev(phydev, dev, priv->interface); phydev->supported &= PHY_GBIT_FEATURES; phydev->advertising = phydev->supported; diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c index 7f146d4c8b4..a219affb58a 100644 --- a/drivers/net/ethoc.c +++ b/drivers/net/ethoc.c @@ -614,11 +614,11 @@ static int ethoc_phy_init(struct ethoc *priv, void *dev) mask = 1 << CONFIG_PHY_ADDR; #endif - phydev = phy_find_by_mask(priv->bus, mask, PHY_INTERFACE_MODE_MII); + phydev = phy_find_by_mask(priv->bus, mask); if (!phydev) return -ENODEV; - phy_connect_dev(phydev, dev); + phy_connect_dev(phydev, dev, PHY_INTERFACE_MODE_MII); phydev->supported &= PHY_BASIC_FEATURES; phydev->advertising = phydev->supported; diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c index fabcf85c0de..f1895246b93 100644 --- a/drivers/net/pch_gbe.c +++ b/drivers/net/pch_gbe.c @@ -416,13 +416,13 @@ static int pch_gbe_phy_init(struct udevice *dev) struct phy_device *phydev; int mask = 0xffffffff; - phydev = phy_find_by_mask(priv->bus, mask, plat->phy_interface); + phydev = phy_find_by_mask(priv->bus, mask); if (!phydev) { printf("pch_gbe: cannot find the phy\n"); return -1; } - phy_connect_dev(phydev, dev); + phy_connect_dev(phydev, dev, plat->phy_interface); phydev->supported &= PHY_GBIT_FEATURES; phydev->advertising = phydev->supported; diff --git a/drivers/net/phy/ethernet_id.c b/drivers/net/phy/ethernet_id.c index 5617ac3ad62..38a8dca347b 100644 --- a/drivers/net/phy/ethernet_id.c +++ b/drivers/net/phy/ethernet_id.c @@ -11,8 +11,7 @@ #include #include -struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev, - phy_interface_t interface) +struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev) { struct phy_device *phydev; struct ofnode_phandle_args phandle_args; @@ -61,7 +60,7 @@ struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev, } id = vendor << 16 | device; - phydev = phy_device_create(bus, 0, id, false, interface); + phydev = phy_device_create(bus, 0, id, false); if (phydev) phydev->node = node; diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 7f21c5535ba..bc838466062 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -642,8 +642,7 @@ static struct phy_driver *generic_for_phy(struct phy_device *phydev) return &genphy_driver; } -static struct phy_driver *get_phy_driver(struct phy_device *phydev, - phy_interface_t interface) +static struct phy_driver *get_phy_driver(struct phy_device *phydev) { struct list_head *entry; int phy_id = phydev->phy_id; @@ -660,8 +659,7 @@ static struct phy_driver *get_phy_driver(struct phy_device *phydev, } struct phy_device *phy_device_create(struct mii_dev *bus, int addr, - u32 phy_id, bool is_c45, - phy_interface_t interface) + u32 phy_id, bool is_c45) { struct phy_device *dev; @@ -680,7 +678,7 @@ struct phy_device *phy_device_create(struct mii_dev *bus, int addr, dev->duplex = -1; dev->link = 0; - dev->interface = interface; + dev->interface = PHY_INTERFACE_MODE_NA; #ifdef CONFIG_DM_ETH dev->node = ofnode_null(); @@ -693,7 +691,7 @@ struct phy_device *phy_device_create(struct mii_dev *bus, int addr, dev->is_c45 = is_c45; dev->bus = bus; - dev->drv = get_phy_driver(dev, interface); + dev->drv = get_phy_driver(dev); if (phy_probe(dev)) { printf("%s, PHY probe failed\n", __func__); @@ -742,8 +740,7 @@ int __weak get_phy_id(struct mii_dev *bus, int addr, int devad, u32 *phy_id) } static struct phy_device *create_phy_by_mask(struct mii_dev *bus, - uint phy_mask, int devad, - phy_interface_t interface) + uint phy_mask, int devad) { u32 phy_id = 0xffffffff; bool is_c45; @@ -764,8 +761,7 @@ static struct phy_device *create_phy_by_mask(struct mii_dev *bus, /* If the PHY ID is mostly f's, we didn't find anything */ if (r == 0 && (phy_id & 0x1fffffff) != 0x1fffffff) { is_c45 = (devad == MDIO_DEVAD_NONE) ? false : true; - return phy_device_create(bus, addr, phy_id, is_c45, - interface); + return phy_device_create(bus, addr, phy_id, is_c45); } next: phy_mask &= ~(1 << addr); @@ -774,25 +770,22 @@ next: } static struct phy_device *search_for_existing_phy(struct mii_dev *bus, - uint phy_mask, - phy_interface_t interface) + uint phy_mask) { /* If we have one, return the existing device, with new interface */ while (phy_mask) { int addr = ffs(phy_mask) - 1; - if (bus->phymap[addr]) { - bus->phymap[addr]->interface = interface; + if (bus->phymap[addr]) return bus->phymap[addr]; - } + phy_mask &= ~(1 << addr); } return NULL; } static struct phy_device *get_phy_device_by_mask(struct mii_dev *bus, - uint phy_mask, - phy_interface_t interface) + uint phy_mask) { struct phy_device *phydev; int devad[] = { @@ -808,13 +801,12 @@ static struct phy_device *get_phy_device_by_mask(struct mii_dev *bus, int i, devad_cnt; devad_cnt = sizeof(devad)/sizeof(int); - phydev = search_for_existing_phy(bus, phy_mask, interface); + phydev = search_for_existing_phy(bus, phy_mask); if (phydev) return phydev; /* try different access clauses */ for (i = 0; i < devad_cnt; i++) { - phydev = create_phy_by_mask(bus, phy_mask, - devad[i], interface); + phydev = create_phy_by_mask(bus, phy_mask, devad[i]); if (IS_ERR(phydev)) return NULL; if (phydev) @@ -842,10 +834,9 @@ static struct phy_device *get_phy_device_by_mask(struct mii_dev *bus, * Description: Reads the ID registers of the PHY at @addr on the * @bus, then allocates and returns the phy_device to represent it. */ -static struct phy_device *get_phy_device(struct mii_dev *bus, int addr, - phy_interface_t interface) +static struct phy_device *get_phy_device(struct mii_dev *bus, int addr) { - return get_phy_device_by_mask(bus, 1 << addr, interface); + return get_phy_device_by_mask(bus, 1 << addr); } int phy_reset(struct phy_device *phydev) @@ -904,18 +895,12 @@ int miiphy_reset(const char *devname, unsigned char addr) struct mii_dev *bus = miiphy_get_dev_by_name(devname); struct phy_device *phydev; - /* - * miiphy_reset was only used on standard PHYs, so we'll fake it here. - * If later code tries to connect with the right interface, this will - * be corrected by get_phy_device in phy_connect() - */ - phydev = get_phy_device(bus, addr, PHY_INTERFACE_MODE_MII); + phydev = get_phy_device(bus, addr); return phy_reset(phydev); } -struct phy_device *phy_find_by_mask(struct mii_dev *bus, uint phy_mask, - phy_interface_t interface) +struct phy_device *phy_find_by_mask(struct mii_dev *bus, uint phy_mask) { /* Reset the bus */ if (bus->reset) { @@ -925,13 +910,15 @@ struct phy_device *phy_find_by_mask(struct mii_dev *bus, uint phy_mask, mdelay(15); } - return get_phy_device_by_mask(bus, phy_mask, interface); + return get_phy_device_by_mask(bus, phy_mask); } #ifdef CONFIG_DM_ETH -void phy_connect_dev(struct phy_device *phydev, struct udevice *dev) +void phy_connect_dev(struct phy_device *phydev, struct udevice *dev, + phy_interface_t interface) #else -void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev) +void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev, + phy_interface_t interface) #endif { /* Soft Reset the PHY */ @@ -942,13 +929,14 @@ void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev) phydev->dev->name, dev->name); } phydev->dev = dev; - debug("%s connected to %s\n", dev->name, phydev->drv->name); + phydev->interface = interface; + debug("%s connected to %s mode %s\n", dev->name, phydev->drv->name, + phy_string_for_interface(interface)); } #ifdef CONFIG_PHY_XILINX_GMII2RGMII static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus, - struct udevice *dev, - phy_interface_t interface) + struct udevice *dev) { struct phy_device *phydev = NULL; ofnode node; @@ -957,8 +945,7 @@ static struct phy_device *phy_connect_gmii2rgmii(struct mii_dev *bus, node = ofnode_by_compatible(node, "xlnx,gmii-to-rgmii-1.0"); if (ofnode_valid(node)) { phydev = phy_device_create(bus, 0, - PHY_GMII2RGMII_ID, false, - interface); + PHY_GMII2RGMII_ID, false); if (phydev) phydev->node = node; break; @@ -990,24 +977,23 @@ struct phy_device *fixed_phy_create(ofnode node) return NULL; } - phydev = phy_device_create(NULL, 0, PHY_FIXED_ID, false, - ofnode_read_phy_mode(node)); + phydev = phy_device_create(NULL, 0, PHY_FIXED_ID, false); if (phydev) phydev->node = subnode; + phydev->interface = ofnode_read_phy_mode(node); + return phydev; } static struct phy_device *phy_connect_fixed(struct mii_dev *bus, - struct udevice *dev, - phy_interface_t interface) + struct udevice *dev) { ofnode node = dev_ofnode(dev), subnode; struct phy_device *phydev = NULL; if (ofnode_phy_is_fixed_link(node, &subnode)) { - phydev = phy_device_create(bus, 0, PHY_FIXED_ID, - false, interface); + phydev = phy_device_create(bus, 0, PHY_FIXED_ID, false); if (phydev) phydev->node = subnode; } @@ -1030,29 +1016,29 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr, uint mask = (addr >= 0) ? (1 << addr) : 0xffffffff; #ifdef CONFIG_PHY_FIXED - phydev = phy_connect_fixed(bus, dev, interface); + phydev = phy_connect_fixed(bus, dev); #endif #ifdef CONFIG_PHY_NCSI if (!phydev) - phydev = phy_device_create(bus, 0, PHY_NCSI_ID, false, interface); + phydev = phy_device_create(bus, 0, PHY_NCSI_ID, false); #endif #ifdef CONFIG_PHY_ETHERNET_ID if (!phydev) - phydev = phy_connect_phy_id(bus, dev, interface); + phydev = phy_connect_phy_id(bus, dev); #endif #ifdef CONFIG_PHY_XILINX_GMII2RGMII if (!phydev) - phydev = phy_connect_gmii2rgmii(bus, dev, interface); + phydev = phy_connect_gmii2rgmii(bus, dev); #endif if (!phydev) - phydev = phy_find_by_mask(bus, mask, interface); + phydev = phy_find_by_mask(bus, mask); if (phydev) - phy_connect_dev(phydev, dev); + phy_connect_dev(phydev, dev, interface); else printf("Could not get PHY for %s: addr %d\n", bus->name, addr); return phydev; diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c b/drivers/net/phy/xilinx_gmii2rgmii.c index d92a364365c..73762839565 100644 --- a/drivers/net/phy/xilinx_gmii2rgmii.c +++ b/drivers/net/phy/xilinx_gmii2rgmii.c @@ -42,13 +42,13 @@ static int xilinxgmiitorgmii_config(struct phy_device *phydev) ext_phyaddr = ofnode_read_u32_default(phandle.node, "reg", -1); ext_phydev = phy_find_by_mask(phydev->bus, - 1 << ext_phyaddr, - PHY_INTERFACE_MODE_RGMII); + 1 << ext_phyaddr); if (!ext_phydev) { printf("%s, No external phy device found\n", __func__); return -EINVAL; } + ext_phydev->interface = PHY_INTERFACE_MODE_RGMII; ext_phydev->node = phandle.node; phydev->priv = ext_phydev; diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index 5c152d6e0a5..c28680565fc 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -319,11 +319,11 @@ static int ravb_phy_config(struct udevice *dev) mdelay(1); } - phydev = phy_find_by_mask(eth->bus, mask, pdata->phy_interface); + phydev = phy_find_by_mask(eth->bus, mask); if (!phydev) return -ENODEV; - phy_connect_dev(phydev, dev); + phy_connect_dev(phydev, dev, pdata->phy_interface); eth->phydev = phydev; diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index 5c57e3dfcd4..1de3ff8add2 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c @@ -762,11 +762,11 @@ static int sh_eth_phy_config(struct udevice *dev) struct phy_device *phydev; int mask = 0xffffffff; - phydev = phy_find_by_mask(priv->bus, mask, pdata->phy_interface); + phydev = phy_find_by_mask(priv->bus, mask); if (!phydev) return -ENODEV; - phy_connect_dev(phydev, dev); + phy_connect_dev(phydev, dev, pdata->phy_interface); port_info->phydev = phydev; phy_config(phydev); diff --git a/drivers/net/sni_ave.c b/drivers/net/sni_ave.c index d684e60e72f..58276a40c77 100644 --- a/drivers/net/sni_ave.c +++ b/drivers/net/sni_ave.c @@ -393,11 +393,11 @@ static int ave_phy_init(struct ave_private *priv, void *dev) struct phy_device *phydev; int mask = GENMASK(31, 0), ret; - phydev = phy_find_by_mask(priv->bus, mask, priv->phy_mode); + phydev = phy_find_by_mask(priv->bus, mask); if (!phydev) return -ENODEV; - phy_connect_dev(phydev, dev); + phy_connect_dev(phydev, dev, priv->phy_mode); phydev->supported &= PHY_GBIT_FEATURES; if (priv->max_speed) { diff --git a/drivers/net/sunxi_emac.c b/drivers/net/sunxi_emac.c index 17ad88e732e..4c7ef2525bc 100644 --- a/drivers/net/sunxi_emac.c +++ b/drivers/net/sunxi_emac.c @@ -272,12 +272,11 @@ static int sunxi_emac_init_phy(struct emac_eth_dev *priv, void *dev) if (ret) return ret; - priv->phydev = phy_find_by_mask(priv->bus, mask, - PHY_INTERFACE_MODE_MII); + priv->phydev = phy_find_by_mask(priv->bus, mask); if (!priv->phydev) return -ENODEV; - phy_connect_dev(priv->phydev, dev); + phy_connect_dev(priv->phydev, dev, PHY_INTERFACE_MODE_MII); phy_config(priv->phydev); return 0; diff --git a/include/_exports.h b/include/_exports.h index 8030d70c0bc..f6df8b61073 100644 --- a/include/_exports.h +++ b/include/_exports.h @@ -77,8 +77,7 @@ EXPORT_FUNC(mdio_get_current_dev, struct mii_dev *, mdio_get_current_dev, void) EXPORT_FUNC(phy_find_by_mask, struct phy_device *, phy_find_by_mask, - struct mii_dev *bus, unsigned phy_mask, - phy_interface_t interface) + struct mii_dev *bus, unsigned phy_mask) EXPORT_FUNC(mdio_phydev_for_ethname, struct phy_device *, mdio_phydev_for_ethname, const char *ethname) EXPORT_FUNC(miiphy_set_current_dev, int, miiphy_set_current_dev, diff --git a/include/exports.h b/include/exports.h index 550cafdc7a1..6f8c9cf4517 100644 --- a/include/exports.h +++ b/include/exports.h @@ -55,8 +55,7 @@ int i2c_read (uchar, uint, int , uchar* , int); #endif #ifdef CONFIG_PHY_AQUANTIA struct mii_dev *mdio_get_current_dev(void); -struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask, - phy_interface_t interface); +struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask); struct phy_device *mdio_phydev_for_ethname(const char *ethname); int miiphy_set_current_dev(const char *devname); #endif diff --git a/include/phy.h b/include/phy.h index c7fa0ffba43..30af8bfa0e6 100644 --- a/include/phy.h +++ b/include/phy.h @@ -388,11 +388,9 @@ int phy_reset(struct phy_device *phydev); * * @bus: MII/MDIO bus to scan * @phy_mask: bitmap of PYH addresses to scan - * @interface: type of MAC-PHY interface * @return: pointer to phy_device if a PHY is found, or NULL otherwise */ -struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask, - phy_interface_t interface); +struct phy_device *phy_find_by_mask(struct mii_dev *bus, unsigned phy_mask); #ifdef CONFIG_PHY_FIXED @@ -421,8 +419,10 @@ static inline struct phy_device *fixed_phy_create(ofnode node) * phy_connect_dev() - Associates the given pair of PHY and Ethernet devices * @phydev: PHY device * @dev: Ethernet device + * @interface: type of MAC-PHY interface */ -void phy_connect_dev(struct phy_device *phydev, struct udevice *dev); +void phy_connect_dev(struct phy_device *phydev, struct udevice *dev, + phy_interface_t interface); /** * phy_connect() - Creates a PHY device for the Ethernet interface @@ -449,12 +449,10 @@ struct phy_device *phy_connect(struct mii_dev *bus, int addr, * @addr: PHY address on MDIO bus * @phy_id: where to store the ID retrieved * @is_c45: Device Identifiers if is_c45 - * @interface: interface between the MAC and PHY * @return: pointer to phy_device if a PHY is found, or NULL otherwise */ struct phy_device *phy_device_create(struct mii_dev *bus, int addr, - u32 phy_id, bool is_c45, - phy_interface_t interface); + u32 phy_id, bool is_c45); /** * phy_connect_phy_id() - Connect to phy device by reading PHY id @@ -462,12 +460,10 @@ struct phy_device *phy_device_create(struct mii_dev *bus, int addr, * * @bus: MII/MDIO bus that hosts the PHY * @dev: Ethernet device to associate to the PHY - * @interface: Interface between the MAC and PHY * @return: pointer to phy_device if a PHY is found, * or NULL otherwise */ -struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev, - phy_interface_t interface); +struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev); static inline ofnode phy_get_ofnode(struct phy_device *phydev) { @@ -482,8 +478,10 @@ static inline ofnode phy_get_ofnode(struct phy_device *phydev) * phy_connect_dev() - Associates the given pair of PHY and Ethernet devices * @phydev: PHY device * @dev: Ethernet device + * @interface: type of MAC-PHY interface */ -void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev); +void phy_connect_dev(struct phy_device *phydev, struct eth_device *dev, + phy_interface_t interface); /** * phy_connect() - Creates a PHY device for the Ethernet interface -- cgit v1.2.3