]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
drivers: net: phy: micrel: Try to get phy node from phy-handle
authorNaresh Kumar Ravulapalli <nareshkumar.ravulapalli@altera.com>
Tue, 1 Jul 2025 04:49:23 +0000 (21:49 -0700)
committerTom Rini <trini@konsulko.com>
Thu, 10 Jul 2025 14:40:45 +0000 (08:40 -0600)
If phy node isn't found in ethernet-phy subnode, try to get it from
phy-handle. And when this fails, only then use Ethernet node. This
fix results in getting correct phy handle properties for the
phy node if defined.

Signed-off-by: Naresh Kumar Ravulapalli <nareshkumar.ravulapalli@altera.com>
drivers/net/phy/micrel_ksz90x1.c

index ee8eae1efd92c97b7382de02423a531201de1566..a02dbe900b89acf9b816844619ac198657108ec7 100644 (file)
@@ -7,6 +7,7 @@
  * (C) 2012 NetModule AG, David Andrey, added KSZ9031
  * (C) Copyright 2017 Adaptrum, Inc.
  * Written by Alexandru Gagniuc <alex.g@adaptrum.com> for Adaptrum, Inc.
+ * Copyright (C) 2025 Altera Corporation <www.altera.com>
  */
 #include <dm.h>
 #include <env.h>
@@ -110,6 +111,7 @@ static int ksz90x1_of_config_group(struct phy_device *phydev,
 {
        struct udevice *dev = phydev->dev;
        struct phy_driver *drv = phydev->drv;
+       struct ofnode_phandle_args phandle;
        int val[4];
        int i, changed = 0, offset, max;
        u16 regval = 0;
@@ -126,8 +128,14 @@ static int ksz90x1_of_config_group(struct phy_device *phydev,
        }
 
        if (!ofnode_valid(node)) {
-               /* No node found, look in the Ethernet node */
-               node = dev_ofnode(dev);
+               if (dev_read_phandle_with_args(dev, "phy-handle", NULL, 0, 0,
+                                              &phandle)) {
+                       /* No phy-handle found, look in the Ethernet node */
+                       node = dev_ofnode(dev);
+               } else {
+                       /* phy-handle found */
+                       node = phandle.node;
+               }
        }
 
        for (i = 0; i < ofcfg->grpsz; i++) {