From: Vladimir Oltean Date: Tue, 16 Feb 2021 23:19:31 +0200 Subject: [PATCH v5 4/9] net: mdio: teach dm_eth_connect_phy_handle to connect to fixed PHY In-Reply-To: <20210216211936.3291988-1-olteanv@gmail.com> References: <20210216211936.3291988-1-olteanv@gmail.com> Message-ID: <20210216211936.3291988-5-olteanv@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: Vladimir Oltean 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 --- 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