MLK-16535 net: fec: Fix issue in DM probe function
authorYe Li <ye.li@nxp.com>
Tue, 26 Sep 2017 05:44:47 +0000 (00:44 -0500)
committerJason Liu <jason.hui.liu@nxp.com>
Thu, 2 Nov 2017 18:37:18 +0000 (02:37 +0800)
Met a problem that mii command fails to work after u-boot booting up.
The root cause is the fec_probe function initializes ethernet PHY first,
then reset the FEC controller. This causes the mii_speed register reset
to 0 and lead mdio can't work.
Change the flow to reset FEC controller prior than setup PHY.

Signed-off-by: Ye Li <ye.li@nxp.com>
drivers/net/fec_mxc.c

index 4c9fd73..d137c96 100644 (file)
@@ -1286,20 +1286,7 @@ static int fecmxc_probe(struct udevice *dev)
        if (ret)
                return ret;
 
-#ifdef CONFIG_FEC_MXC_MDIO_BASE
-       bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE, dev->seq);
-#else
-       bus = fec_get_miibus((ulong)priv->eth, dev->seq);
-#endif
-       if (!bus)
-               goto err_mii;
-
-       priv->bus = bus;
        priv->xcv_type = CONFIG_FEC_XCV_TYPE;
-       priv->interface = pdata->phy_interface;
-       ret = fec_phy_init(priv, dev);
-       if (ret)
-               goto err_phy;
 
        /* Reset chip. */
        writel(readl(&priv->eth->ecntrl) | FEC_ECNTRL_RESET,
@@ -1314,16 +1301,30 @@ static int fecmxc_probe(struct udevice *dev)
        }
 
        fec_reg_setup(priv);
+
+#ifdef CONFIG_FEC_MXC_MDIO_BASE
+       bus = fec_get_miibus((ulong)CONFIG_FEC_MXC_MDIO_BASE, dev->seq);
+#else
+       bus = fec_get_miibus((ulong)priv->eth, dev->seq);
+#endif
+       if (!bus)
+               goto err_mii;
+
+       priv->bus = bus;
+       priv->interface = pdata->phy_interface;
+       ret = fec_phy_init(priv, dev);
+       if (ret)
+               goto err_phy;
+
        priv->dev_id = dev->seq;
 
        return 0;
 
-err_timeout:
-       free(priv->phydev);
 err_phy:
        mdio_unregister(bus);
        free(bus);
 err_mii:
+err_timeout:
        fec_free_descs(priv);
        return ret;
 }