8000 net: phy: workaround for buggy cable detection by LAN8700 after cable… · bsd-unix/linux@776829d · GitHub
[go: up one dir, main page]

Skip to content

Commit 776829d

Browse files
plyatovdavem330
authored andcommitted
net: phy: workaround for buggy cable detection by LAN8700 after cable plugging
* Due to HW bug, LAN8700 sometimes does not detect presence of energy in the Ethernet cable in Energy Detect Power-Down mode (e.g while EDPWRDOWN bit is set, the ENERGYON bit does not asserted sometimes). This is a common bug of LAN87xx family of PHY chips. * The lan87xx_read_status() was improved to acquire ENERGYON bit. Its previous algorythm still not reliable on 100 % and sometimes skip cable plugging. Signed-off-by: Igor Plyatov <plyatov@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a27cc68 commit 776829d

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

drivers/net/phy/smsc.c

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,18 @@ static int lan911x_config_init(struct phy_device *phydev)
9191
}
9292

9393
/*
94-
* The LAN8710/LAN8720 requires a minimum of 2 link pulses within 64ms of each
95-
* other in order to set the ENERGYON bit and exit EDPD mode. If a link partner
96-
* does send the pulses within this interval, the PHY will remained powered
97-
* down.
98-
*
99-
* This workaround will manually toggle the PHY on/off upon calls to read_status
100-
* in order to generate link test pulses if the link is down. If a link partner
101-
* is present, it will respond to the pulses, which will cause the ENERGYON bit
102-
* to be set and will cause the EDPD mode to be exited.
94+
* The LAN87xx suffers from rare absence of the ENERGYON-bit when Ethernet cable
95+
* plugs in while LAN87xx is in Energy Detect Power-Down mode. This leads to
96+
* unstable detection of plugging in Ethernet cable.
97+
* This workaround disables Energy Detect Power-Down mode and waiting for
98+
* response on link pulses to detect presence of plugged Ethernet cable.
99+
* The Energy Detect Power-Down mode is enabled again in the end of procedure to
100+
* save approximately 220 mW of power if cable is unplugged.
103101
*/
104102
static int lan87xx_read_status(struct phy_device *phydev)
105103
{
106104
int err = genphy_read_status(phydev);
105+
int i;
107106

108107
if (!phydev->link) {
109108
/* Disable EDPD to wake up PHY */
@@ -116,8 +115,16 @@ static int lan87xx_read_status(struct phy_device *phydev)
116115
if (rc < 0)
117116
return rc;
118117

119-
/* Sleep 64 ms to allow ~5 link test pulses to be sent */
120-
msleep(64);
118+
/* Wait max 640 ms to detect energy */
119+
for (i = 0; i < 64; i++) {
120+
/* Sleep to allow link test pulses to be sent */
121+
msleep(10);
122+
rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
123+
if (rc < 0)
124+
return rc;
125+
if (rc & MII_LAN83C185_ENERGYON)
126+
break;
127+
};
121128

122129
/* Re-enable EDPD */
123130
rc = phy_read(phydev, MII_LAN83C185_CTRL_STATUS);
@@ -191,7 +198,7 @@ static struct phy_driver smsc_phy_driver[] = {
191198

192199
/* basic functions */
193200
.config_aneg = genphy_config_aneg,
194-
.read_status = genphy_read_status,
201+
.read_status = lan87xx_read_status,
195202
.config_init = smsc_phy_config_init,
196203
.soft_reset = smsc_phy_reset,
197204

0 commit comments

Comments
 (0)
0