public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] phylib: Detect link on 10G devices correctly
@ 2011-05-18 23:44 Andy Fleming
  2011-05-19  8:53 ` Detlev Zundel
  2011-07-27 21:21 ` Wolfgang Denk
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Fleming @ 2011-05-18 23:44 UTC (permalink / raw)
  To: u-boot

gen10g_startup() had 2 bugs:

1) It had a boolean logic error in checking the MMD mask, and
always checked all of them.

2) It checked devices which don't actually report link state, which
meant that it would never believe the link was fully up.

Fix the boolean logic, and then mask the MMD mask so only link-reporting
devices are checked.

Signed-off-by: Andy Fleming <afleming@freescale.com>
Reported-by: Ed Swarthout <Ed.Swarthout@freescale.com>
---

 drivers/net/phy/generic_10g.c |    8 ++++++--
 include/linux/mdio.h          |    8 ++++++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/generic_10g.c b/drivers/net/phy/generic_10g.c
index 315c508..1c3e69e 100644
--- a/drivers/net/phy/generic_10g.c
+++ b/drivers/net/phy/generic_10g.c
@@ -36,7 +36,7 @@ int gen10g_shutdown(struct phy_device *phydev)
 int gen10g_startup(struct phy_device *phydev)
 {
 	int devad, reg;
-	u32 mmd_mask = phydev->mmds;
+	u32 mmd_mask = phydev->mmds & MDIO_DEVS_LINK;
 
 	phydev->link = 1;
 
@@ -44,8 +44,12 @@ int gen10g_startup(struct phy_device *phydev)
 	phydev->speed = SPEED_10000;
 	phydev->duplex = DUPLEX_FULL;
 
+	/*
+	 * Go through all the link-reporting devices, and make sure
+	 * they're all up and happy
+	 */
 	for (devad = 0; mmd_mask; devad++, mmd_mask = mmd_mask >> 1) {
-		if (!mmd_mask & 1)
+		if (!(mmd_mask & 1))
 			continue;
 
 		/* Read twice because link state is latched and a
diff --git a/include/linux/mdio.h b/include/linux/mdio.h
index 022d772..f2080dd 100644
--- a/include/linux/mdio.h
+++ b/include/linux/mdio.h
@@ -120,6 +120,14 @@
 #define MDIO_DEVS_VEND1			MDIO_DEVS_PRESENT(MDIO_MMD_VEND1)
 #define MDIO_DEVS_VEND2			MDIO_DEVS_PRESENT(MDIO_MMD_VEND2)
 
+#define MDIO_DEVS_LINK			(MDIO_DEVS_PMAPMD | \
+					MDIO_DEVS_WIS | \
+					MDIO_DEVS_PCS | \
+					MDIO_DEVS_PHYXS | \
+					MDIO_DEVS_DTEXS | \
+					MDIO_DEVS_AN)
+					
+
 
 /* Control register 2. */
 #define MDIO_PMA_CTRL2_TYPE		0x000f	/* PMA/PMD type selection */
-- 
1.6.5.2.g6ff9a

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-07-27 21:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-18 23:44 [U-Boot] [PATCH] phylib: Detect link on 10G devices correctly Andy Fleming
2011-05-19  8:53 ` Detlev Zundel
2011-07-27 21:21 ` Wolfgang Denk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox