]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
net: ksz9477: add port_probe function to config phy
authorTim Harvey <tharvey@gateworks.com>
Tue, 7 Feb 2023 23:37:18 +0000 (15:37 -0800)
committerTom Rini <trini@konsulko.com>
Fri, 5 May 2023 17:41:55 +0000 (13:41 -0400)
Add a port_probe function to configure the phy. This leads to
earlier link negotiation so the port is more likely to be ready
when used.

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
drivers/net/ksz9477.c

index 5b0ef78ab93b8be833253f77c0ef3d7074cc8397..6b59b5fcd265c5cf3a0a70a2592a0a0eca3bfa7e 100644 (file)
@@ -337,11 +337,21 @@ static int ksz_port_setup(struct udevice *dev, int port,
        return 0;
 }
 
+static int ksz_port_probe(struct udevice *dev, int port, struct phy_device *phy)
+{
+       int supported = PHY_GBIT_FEATURES;
+
+       /* configure phy */
+       phy->supported &= supported;
+       phy->advertising &= supported;
+
+       return phy_config(phy);
+}
+
 static int ksz_port_enable(struct udevice *dev, int port, struct phy_device *phy)
 {
        struct dsa_pdata *pdata = dev_get_uclass_plat(dev);
        struct ksz_dsa_priv *priv = dev_get_priv(dev);
-       int supported = PHY_GBIT_FEATURES;
        u8 data8;
        int ret;
 
@@ -365,23 +375,12 @@ static int ksz_port_enable(struct udevice *dev, int port, struct phy_device *phy
        if (port == pdata->cpu_port)
                return 0;
 
-       /* configure phy */
-       phy->supported &= supported;
-       phy->advertising &= supported;
-       ret = phy_config(phy);
-       if (ret)
-               return ret;
-
-       ret = phy_startup(phy);
-       if (ret)
-               return ret;
-
        /* start switch */
        ksz_read8(priv->dev, REG_SW_OPERATION, &data8);
        data8 |= SW_START;
        ksz_write8(priv->dev, REG_SW_OPERATION, data8);
 
-       return 0;
+       return phy_startup(phy);
 }
 
 static void ksz_port_disable(struct udevice *dev, int port, struct phy_device *phy)
@@ -410,6 +409,7 @@ static void ksz_port_disable(struct udevice *dev, int port, struct phy_device *p
 }
 
 static const struct dsa_ops ksz_dsa_ops = {
+       .port_probe = ksz_port_probe,
        .port_enable = ksz_port_enable,
        .port_disable = ksz_port_disable,
 };