[PATCH v5 4/9] net: mdio: teach dm_eth_connect_phy_handle to connect to fixed PHY

Vladimir Oltean olteanv at gmail.com
Tue Feb 16 22:19:31 CET 2021


From: Vladimir Oltean <vladimir.oltean at nxp.com>

dm_eth_connect_phy_handle has all the info it needs in order to hide
away from the UCLASS_ETH caller the fact that it is attached to a
fixed-link PHY. So only attempt to search for a phy-handle if we've
exhausted the fixed-link option first.

Signed-off-by: Vladimir Oltean <vladimir.oltean at nxp.com>
---
Changes in v5:
None.

 net/mdio-uclass.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/net/mdio-uclass.c b/net/mdio-uclass.c
index 697e5f838d94..766d4711cc23 100644
--- a/net/mdio-uclass.c
+++ b/net/mdio-uclass.c
@@ -177,9 +177,10 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,
 /* Connect to a PHY linked in eth DT node */
 struct phy_device *dm_eth_phy_connect(struct udevice *ethdev)
 {
-	const char *if_str;
+	ofnode node = dev_ofnode(ethdev), subnode;
 	phy_interface_t interface;
 	struct phy_device *phy;
+	const char *if_str;
 	int i;
 
 	if (!dev_has_ofnode(ethdev)) {
@@ -200,7 +201,14 @@ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev)
 	if (interface == PHY_INTERFACE_MODE_NONE)
 		dev_dbg(ethdev, "can't find interface mode, default to NONE\n");
 
-	phy = dm_eth_connect_phy_handle(ethdev, interface);
+	subnode = ofnode_find_subnode(node, "fixed-link");
+	if (ofnode_valid(subnode)) {
+		phy = phy_connect(NULL, 0, ethdev, interface);
+		if (phy)
+			phy->node = subnode;
+	} else {
+		phy = dm_eth_connect_phy_handle(ethdev, interface);
+	}
 
 	if (!phy)
 		return NULL;
-- 
2.25.1



More information about the U-Boot mailing list