]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: phy: Bind ETH_PHY uclass driver to each new PHY
authorMarek Vasut <marek.vasut+renesas@mailbox.org>
Tue, 30 May 2023 22:51:26 +0000 (00:51 +0200)
committerMarek Vasut <marek.vasut+renesas@mailbox.org>
Sat, 10 Jun 2023 11:34:05 +0000 (13:34 +0200)
In case a new PHY is created and DM_ETH_PHY is enabled, bind a
generic PHY driver from ETH_PHY uclass to the PHY to have a
matching DM representation of that PHY.

Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
drivers/net/phy/ethernet_id.c

index a715e83db98e80a1cdd661232c7b0e1b3a76ca48..877a51c3d007d51a3562c183fa69ee137bb319c0 100644 (file)
@@ -7,6 +7,8 @@
 
 #include <common.h>
 #include <dm/device_compat.h>
+#include <dm/device-internal.h>
+#include <dm/lists.h>
 #include <phy.h>
 #include <linux/delay.h>
 #include <asm/gpio.h>
@@ -17,6 +19,8 @@ struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev,
        struct phy_device *phydev;
        struct ofnode_phandle_args phandle_args;
        struct gpio_desc gpio;
+       const char *node_name;
+       struct udevice *pdev;
        ofnode node;
        u32 id, assert, deassert;
        u16 vendor, device;
@@ -72,5 +76,18 @@ struct phy_device *phy_connect_phy_id(struct mii_dev *bus, struct udevice *dev,
        if (phydev)
                phydev->node = node;
 
+       if (IS_ENABLED(CONFIG_DM_ETH_PHY) && ofnode_valid(node)) {
+               node_name = ofnode_get_name(node);
+               ret = device_bind_driver_to_node(dev, "eth_phy_generic_drv",
+                                                node_name, node,
+                                                &pdev);
+               if (ret)
+                       return NULL;
+
+               ret = device_probe(pdev);
+               if (ret)
+                       return NULL;
+       }
+
        return phydev;
 }