Skip to content

Commit 6110dff

Browse files
oleremdavem330
authored andcommitted
net: phy: micrel: kszphy_resume(): add delay after genphy_resume() before accessing PHY registers
After the power-down bit is cleared, the chip internally triggers a global reset. According to the KSZ9031 documentation, we have to wait at least 1ms for the reset to finish. If the chip is accessed during reset, read will return 0xffff, while write will be ignored. Depending on the system performance and MDIO bus speed, we may or may not run in to this issue. This bug was discovered on an iMX6QP system with KSZ9031 PHY and attached PHY interrupt line. If IRQ was used, the link status update was lost. In polling mode, the link status update was always correct. The investigation showed, that during a read-modify-write access, the read returned 0xffff (while the chip was still in reset) and corresponding write hit the chip _after_ reset and triggered (due to the 0xffff) another reset in an undocumented bit (register 0x1f, bit 1), resulting in the next write being lost due to the new reset cycle. This patch fixes the issue by adding a 1...2 ms sleep after the genphy_resume(). Fixes: 836384d ("net: phy: micrel: Add specific suspend") Signed-off-by: Oleksij Rempel <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a8eab6d commit 6110dff

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

drivers/net/phy/micrel.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <linux/micrel_phy.h>
2626
#include <linux/of.h>
2727
#include <linux/clk.h>
28+
#include <linux/delay.h>
2829

2930
/* Operation Mode Strap Override */
3031
#define MII_KSZPHY_OMSO 0x16
@@ -952,6 +953,12 @@ static int kszphy_resume(struct phy_device *phydev)
952953

953954
genphy_resume(phydev);
954955

956+
/* After switching from power-down to normal mode, an internal global
957+
* reset is automatically generated. Wait a minimum of 1 ms before
958+
* read/write access to the PHY registers.
959+
*/
960+
usleep_range(1000, 2000);
961+
955962
ret = kszphy_config_reset(phydev);
956963
if (ret)
957964
return ret;

0 commit comments

Comments
 (0)