From: roger <cz@rock-chips.com>
Date: Mon, 22 Sep 2014 06:30:24 +0000 (+0800)
Subject: ethernet:gmac: fix the bug of connection failure with PHY because of wrong phy_addr
X-Git-Tag: firefly_0821_release~4640^2~7^2~22
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=77009753a67716c36b7ab1f8999d6a942be5ed56;p=firefly-linux-kernel-4.4.55.git

ethernet:gmac: fix the bug of connection failure with PHY because of wrong phy_addr
---

diff --git a/drivers/net/ethernet/rockchip/gmac/stmmac_main.c b/drivers/net/ethernet/rockchip/gmac/stmmac_main.c
index 6ce9fee67db2..4338bb0d8246 100755
--- a/drivers/net/ethernet/rockchip/gmac/stmmac_main.c
+++ b/drivers/net/ethernet/rockchip/gmac/stmmac_main.c
@@ -91,7 +91,7 @@ static int debug = -1;
 module_param(debug, int, S_IRUGO | S_IWUSR);
 MODULE_PARM_DESC(debug, "Message Level (-1: default, 0: no output, 16: all)");
 
-int phyaddr = 1;
+int phyaddr = -1;
 module_param(phyaddr, int, S_IRUGO);
 MODULE_PARM_DESC(phyaddr, "Physical device address");
 
@@ -2785,6 +2785,8 @@ struct stmmac_priv *stmmac_dvr_probe(struct device *device,
 	/* Verify driver arguments */
 	stmmac_verify_args();
 
+	priv->plat->phy_addr = -1;
+
 	/* Override with kernel parameters if supplied XXX CRS XXX
 	 * this needs to have multiple instances
 	 */
diff --git a/drivers/net/ethernet/rockchip/gmac/stmmac_mdio.c b/drivers/net/ethernet/rockchip/gmac/stmmac_mdio.c
index 4b148e9c217c..84ac35ebc016 100755
--- a/drivers/net/ethernet/rockchip/gmac/stmmac_mdio.c
+++ b/drivers/net/ethernet/rockchip/gmac/stmmac_mdio.c
@@ -211,6 +211,8 @@ int stmmac_mdio_register(struct net_device *ndev)
 			 */
 			if (priv->plat->phy_addr == -1)
 				priv->plat->phy_addr = addr;
+			else if (priv->plat->phy_addr == 0)
+				priv->plat->phy_addr = addr;
 
 			act = (priv->plat->phy_addr == addr);
 			switch (phydev->irq) {
@@ -229,6 +231,10 @@ int stmmac_mdio_register(struct net_device *ndev)
 				ndev->name, phydev->phy_id, addr,
 				irq_str, dev_name(&phydev->dev),
 				act ? " active" : "");
+			if ((phydev->drv) && phydev->drv->name) {
+				pr_info("PHY driver name: %s", phydev->drv->name);
+			}
+
 			found = 1;
 		}
 	}