[U-Boot] [PATCH V1 2/3] fec_mxc: use phy_connect_by_mask

Troy Kisky troy.kisky at boundarydevices.com
Tue Aug 21 00:48:37 CEST 2012


Allow board config files to list a range
of possible phy addresses, in case the
exact phy address is not certain.

Signed-off-by: Troy Kisky <troy.kisky at boundarydevices.com>

---
v2: add README.fec_mxc for config options currently used
	in fec_mxc
---
 doc/README.fec_mxc    |   34 ++++++++++++++++++++++++++++++++++
 drivers/net/fec_mxc.c |   21 +++++++++++++++------
 drivers/net/fec_mxc.h |    3 ++-
 3 files changed, 51 insertions(+), 7 deletions(-)
 create mode 100644 doc/README.fec_mxc

diff --git a/doc/README.fec_mxc b/doc/README.fec_mxc
new file mode 100644
index 0000000..1365b96
--- /dev/null
+++ b/doc/README.fec_mxc
@@ -0,0 +1,34 @@
+U-boot config options used in fec_mxc.c
+
+CONFIG_FEC_MXC
+	Selects fec_mxc.c to be compiled into u-boot.
+
+CONFIG_MII
+	Must be defined if CONFIG_FEC_MXC is defined.
+
+CONFIG_FEC_XCV_TYPE
+	Defaults to MII100 for 100 Base-tx.
+	RGMII selects 1000 Base-tx reduced pin count interface.
+	RMII selects 100 Base-tx reduced pin count interface.
+
+CONFIG_FEC_MXC_SWAP_PACKET
+	Forced on iff MX28.
+	Swaps the bytes order of all words(4 byte units) in the packet.
+	This should not be specified by a board file. It is cpu specific.
+
+CONFIG_PHYLIB
+	fec_mxc supports PHYLIB and should be used for new boards.
+
+CONFIG_FEC_MXC_NO_ANEG
+	Relevant only if PHYLIB not used. Skips auto-negotiation restart.
+
+CONFIG_FEC_MXC_MULTI
+	Initializes multiple ethernet interfaces using this driver.
+
+CONFIG_FEC_MXC_PHYMASK
+	Relevant only if CONFIG_FEC_MXC_MULTI is not set.
+	Selects a range of phy addresses to try to connect.
+
+CONFIG_FEC_MXC_PHYADDR
+	Relevant only if CONFIG_FEC_MXC_MULTI and CONFIG_FEC_MXC_PHYMASK are
+	not set. Selects the exact phy address that should be connected.
diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c
index fbfc842..4af4976 100644
--- a/drivers/net/fec_mxc.c
+++ b/drivers/net/fec_mxc.c
@@ -391,7 +391,7 @@ static void fec_eth_phy_config(struct eth_device *dev)
 	struct fec_priv *fec = (struct fec_priv *)dev->priv;
 	struct phy_device *phydev;
 
-	phydev = phy_connect(fec->bus, fec->phy_id, dev,
+	phydev = phy_connect_by_mask(fec->bus, fec->phy_mask, dev,
 			PHY_INTERFACE_MODE_RGMII);
 	if (phydev) {
 		fec->phydev = phydev;
@@ -898,7 +898,8 @@ static int fec_recv(struct eth_device *dev)
 	return len;
 }
 
-static int fec_probe(bd_t *bd, int dev_id, int phy_id, uint32_t base_addr)
+static int fec_probe(bd_t *bd, int dev_id, unsigned phy_mask,
+		uint32_t base_addr)
 {
 	struct eth_device *edev;
 	struct fec_priv *fec;
@@ -958,8 +959,11 @@ static int fec_probe(bd_t *bd, int dev_id, int phy_id, uint32_t base_addr)
 		sprintf(edev->name, "FEC%i", dev_id);
 		fec->dev_id = dev_id;
 	}
-	fec->phy_id = phy_id;
-
+#ifdef CONFIG_PHYLIB
+	fec->phy_mask = phy_mask;
+#else
+	fec->phy_id = ffs(phy_mask) - 1;
+#endif
 	bus = mdio_alloc();
 	if (!bus) {
 		printf("mdio_alloc failed\n");
@@ -1008,9 +1012,14 @@ err1:
 int fecmxc_initialize(bd_t *bd)
 {
 	int lout = 1;
+#ifdef CONFIG_FEC_MXC_PHYMASK
+	unsigned phy_mask = CONFIG_FEC_MXC_PHYMASK;
+#else
+	unsigned phy_mask = 1 << CONFIG_FEC_MXC_PHYADDR;
+#endif
 
 	debug("eth_init: fec_probe(bd)\n");
-	lout = fec_probe(bd, -1, CONFIG_FEC_MXC_PHYADDR, IMX_FEC_BASE);
+	lout = fec_probe(bd, -1, phy_mask, IMX_FEC_BASE);
 
 	return lout;
 }
@@ -1021,7 +1030,7 @@ int fecmxc_initialize_multi(bd_t *bd, int dev_id, int phy_id, uint32_t addr)
 	int lout = 1;
 
 	debug("eth_init: fec_probe(bd, %i, %i) @ %08x\n", dev_id, phy_id, addr);
-	lout = fec_probe(bd, dev_id, phy_id, addr);
+	lout = fec_probe(bd, dev_id, 1 << phy_id, addr);
 
 	return lout;
 }
diff --git a/drivers/net/fec_mxc.h b/drivers/net/fec_mxc.h
index 852b2e0..a0f50af 100644
--- a/drivers/net/fec_mxc.h
+++ b/drivers/net/fec_mxc.h
@@ -268,11 +268,12 @@ struct fec_priv {
 	bd_t *bd;
 	uint8_t *tdb_ptr;
 	int dev_id;
-	int phy_id;
 	struct mii_dev *bus;
 #ifdef CONFIG_PHYLIB
+	int phy_mask;
 	struct phy_device *phydev;
 #else
+	int phy_id;
 	int (*mii_postcall)(int);
 #endif
 };
-- 
1.7.9.5



More information about the U-Boot mailing list