]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
net: mdio-uclass: introduce dm_eth_phy_connect_interface()
authorMatthias Schiffer <matthias.schiffer@ew.tq-group.com>
Tue, 30 Sep 2025 08:05:10 +0000 (10:05 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 10 Oct 2025 17:07:44 +0000 (11:07 -0600)
dm_eth_phy_connect_interface() is a variant of dm_eth_phy_connect() that
allows to set the used PHY mode, in case the MAC driver needs to fix it
up. The previously static dm_eth_connect_phy_handle() is renamed and
extended for this purpose.

Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com>
include/miiphy.h
net/mdio-uclass.c

index 00d0b9b6a43cdce4efb0a67eeb44cc36bc880e52..96afe5f4030ea7b00f702c3d18880dc534fdb414 100644 (file)
@@ -192,6 +192,21 @@ struct phy_device *dm_mdio_phy_connect(struct udevice *mdiodev, int phyaddr,
                                       struct udevice *ethdev,
                                       phy_interface_t interface);
 
+/**
+ * dm_eth_phy_connect_interface - Connect an Eth device to a PHY based on device
+ * tree with custom PHY interface
+ *
+ * Picks up the DT phy-handle and from ethernet device node and connects the
+ * ethernet device to the linked PHY, while allowing the caller to specify
+ * the phy-mode to use.
+ *
+ * @ethdev: ethernet device
+ * @interface: MAC-PHY protocol
+ *
+ * Return: pointer to phy_device, or 0 on error
+ */
+struct phy_device *dm_eth_phy_connect_interface(struct udevice *ethdev,
+                                               phy_interface_t interface);
 /**
  * dm_eth_phy_connect - Connect an Eth device to a PHY based on device tree
  *
index 4f052ae432c659eb3c5ca5e10537eef2d9a62209..64af689d2dfef7d658b3515b1caf14371d7cf6c7 100644 (file)
@@ -242,8 +242,8 @@ struct phy_device *dm_mdio_phy_connect(struct udevice *mdiodev, int phyaddr,
        return phy_connect(pdata->mii_bus, phyaddr, ethdev, interface);
 }
 
-static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,
-                                                   phy_interface_t interface)
+struct phy_device *dm_eth_phy_connect_interface(struct udevice *ethdev,
+                                               phy_interface_t interface)
 {
        u32 phy_addr;
        struct udevice *mdiodev;
@@ -282,8 +282,10 @@ static struct phy_device *dm_eth_connect_phy_handle(struct udevice *ethdev,
        phy = dm_mdio_phy_connect(mdiodev, phy_addr, ethdev, interface);
 
 out:
-       if (phy)
+       if (phy) {
                phy->node = phynode;
+               phy->interface = interface;
+       }
 
        return phy;
 }
@@ -292,7 +294,6 @@ out:
 struct phy_device *dm_eth_phy_connect(struct udevice *ethdev)
 {
        phy_interface_t interface;
-       struct phy_device *phy;
 
        if (!dev_has_ofnode(ethdev)) {
                debug("%s: supplied eth dev has no DT node!\n", ethdev->name);
@@ -303,14 +304,7 @@ struct phy_device *dm_eth_phy_connect(struct udevice *ethdev)
        if (interface == PHY_INTERFACE_MODE_NA)
                dev_dbg(ethdev, "can't find interface mode, default to NA\n");
 
-       phy = dm_eth_connect_phy_handle(ethdev, interface);
-
-       if (!phy)
-               return NULL;
-
-       phy->interface = interface;
-
-       return phy;
+       return dm_eth_phy_connect_interface(ethdev, interface);
 }
 
 UCLASS_DRIVER(mdio) = {