diff options
author | Marek BehĂșn | 2022-04-27 12:41:49 +0200 |
---|---|---|
committer | Stefan Roese | 2022-05-04 07:05:51 +0200 |
commit | 00b1bad961fff51db71573f5fc6e4e35b47381b2 (patch) | |
tree | 5d5a53b7a8c0058b05ccd8a2d9d70972dbbb9279 /net | |
parent | a2b2542992a96662740a39aad66e173a857dff2a (diff) |
net: mdio-uclass: add dm_phy_find_by_ofnode() helper
Add helper to resolve PHY node from it's ofnode via DM MDIO subsystem.
Signed-off-by: Marek BehĂșn <marek.behun@nic.cz>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Diffstat (limited to 'net')
-rw-r--r-- | net/mdio-uclass.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c index 7593618d9ad..4401492ca01 100644 --- a/net/mdio-uclass.c +++ b/net/mdio-uclass.c @@ -129,6 +129,28 @@ static int dm_mdio_pre_remove(struct udevice *dev) return 0; } +struct phy_device *dm_phy_find_by_ofnode(ofnode phynode) +{ + struct mdio_perdev_priv *pdata; + struct udevice *mdiodev; + u32 phy_addr; + + if (ofnode_read_u32(phynode, "reg", &phy_addr)) + return NULL; + + if (uclass_get_device_by_ofnode(UCLASS_MDIO, + ofnode_get_parent(phynode), + &mdiodev)) + return NULL; + + if (device_probe(mdiodev)) + return NULL; + + pdata = dev_get_uclass_priv(mdiodev); + + return phy_find_by_mask(pdata->mii_bus, BIT(phy_addr)); +} + struct phy_device *dm_mdio_phy_connect(struct udevice *mdiodev, int phyaddr, struct udevice *ethdev, phy_interface_t interface) |