
Move eth_phy_get_addr() from drivers/net/eth-phy-uclass.c to drivers/net/phy/phy.c . The eth_phy_get_addr() code is generic and does not depend on DM_ETH_PHY , make it always available.
The dm/device_compat.h is pulled in to make dev_dbg() available.
Signed-off-by: Marek Vasut marek.vasut+renesas@mailbox.org --- Cc: Joe Hershberger joe.hershberger@ni.com Cc: Paul Barker paul.barker.ct@bp.renesas.com Cc: Ramon Fried rfried.dev@gmail.com --- drivers/net/eth-phy-uclass.c | 16 ---------------- drivers/net/phy/phy.c | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/drivers/net/eth-phy-uclass.c b/drivers/net/eth-phy-uclass.c index 9d1e8d38ffa..237c3b7de15 100644 --- a/drivers/net/eth-phy-uclass.c +++ b/drivers/net/eth-phy-uclass.c @@ -109,22 +109,6 @@ struct mii_dev *eth_phy_get_mdio_bus(struct udevice *eth_dev) return NULL; }
-int eth_phy_get_addr(struct udevice *dev) -{ - struct ofnode_phandle_args phandle_args; - int reg; - - if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, - &phandle_args)) { - dev_dbg(dev, "Failed to find phy-handle"); - return -ENODEV; - } - - reg = ofnode_read_u32_default(phandle_args.node, "reg", 0); - - return reg; -} - /* parsing generic properties of devicetree/bindings/net/ethernet-phy.yaml */ static int eth_phy_of_to_plat(struct udevice *dev) { diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 63b3e46f101..0d1a98bbbca 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -18,6 +18,7 @@ #include <phy.h> #include <errno.h> #include <asm/global_data.h> +#include <dm/device_compat.h> #include <dm/of_extra.h> #include <linux/bitops.h> #include <linux/delay.h> @@ -28,6 +29,30 @@ DECLARE_GLOBAL_DATA_PTR;
/* Generic PHY support and helper functions */
+/** + * eth_phy_get_addr - get PHY MDIO address from DT + * @dev: the udevice struct of the MAC + * + * Return PHY MDIO address read out of a PHY DT node "reg" property. + * The PHY DT node is located by resolving MAC "phy-handle" property. + * Returns PHY MDIO address on success, negative on failure. + */ +int eth_phy_get_addr(struct udevice *dev) +{ + struct ofnode_phandle_args phandle_args; + int reg; + + if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0, + &phandle_args)) { + dev_dbg(dev, "Failed to find phy-handle"); + return -ENODEV; + } + + reg = ofnode_read_u32_default(phandle_args.node, "reg", 0); + + return reg; +} + /** * genphy_config_advert - sanitize and advertise auto-negotiation parameters * @phydev: target phy_device struct