[U-Boot] [PATCH 2/4] net: fec_mxc: add PHYLIB support

Troy Kisky troy.kisky at boundarydevices.com
Thu Jan 26 23:21:43 CET 2012


Signed-off-by: Troy Kisky <troy.kisky at boundarydevices.com>
---
 drivers/net/fec_mxc.c |   35 ++++++++++++++++++++++++++++++-----
 drivers/net/fec_mxc.h |    1 +
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index 3fffe79..4d7a38d 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -371,6 +371,20 @@ static int fec_set_hwaddr(struct eth_device *dev)
 	return 0;
 }
 
+static void fec_eth_phy_config(struct eth_device *dev)
+{
+#ifdef CONFIG_PHYLIB
+	struct fec_priv *fec = (struct fec_priv *)dev->priv;
+	struct phy_device *phydev;
+
+	phydev = phy_connect(miiphy_get_dev_by_name(dev->name),
+			fec->phy_id, dev, PHY_INTERFACE_MODE_RGMII);
+	fec->phydev = phydev;
+	if (phydev)
+		phy_config(phydev);
+#endif
+}
+
 /**
  * Start the FEC engine
  * @param[in] dev Our device to handle
@@ -427,9 +441,19 @@ static int fec_open(struct eth_device *edev)
 	}
 #endif
 
-	miiphy_wait_aneg(edev);
-	speed = miiphy_speed(edev->name, fec->phy_id);
-	miiphy_duplex(edev->name, fec->phy_id);
+	if (fec->phydev) {
+		/* Start up the PHY */
+#ifdef CONFIG_PHYLIB
+		phy_startup(fec->phydev);
+#endif
+		speed = fec->phydev->speed;
+	} else {
+		miiphy_wait_aneg(edev);
+		speed = miiphy_speed(edev->name, fec->phy_id);
+		miiphy_duplex(edev->name, fec->phy_id);
+	}
+
+
 #ifdef CONFIG_MX6Q
 	{
 		u32 ecr = readl(&fec->eth->ecntrl) & ~FEC_ECNTRL_SPEED;
@@ -556,7 +580,7 @@ static int fec_init(struct eth_device *dev, bd_t* bd)
 	fec_tbd_init(fec);
 
 
-	if (fec->xcv_type != SEVENWIRE)
+	if (!fec->phydev && fec->xcv_type != SEVENWIRE)
 		miiphy_restart_aneg(dev);
 
 	fec_open(dev);
@@ -842,7 +866,8 @@ static int fec_probe(bd_t *bd, int dev_id, int phy_id, uint32_t base_addr)
 		debug("got MAC address from fuse: %pM\n", ethaddr);
 		memcpy(edev->enetaddr, ethaddr, 6);
 	}
-
+	/* Configure phy */
+	fec_eth_phy_config(edev);
 	return ret;
 
 err3:
diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
index 1d6ab06..36125b5 100644
--- a/drivers/net/fec_mxc.h
+++ b/drivers/net/fec_mxc.h
@@ -286,6 +286,7 @@ struct fec_priv {
 	void *base_ptr;
 	int dev_id;
 	int phy_id;
+	struct phy_device *phydev;
 	int (*mii_postcall)(int);
 };
 
-- 
1.7.5.4



More information about the U-Boot mailing list