Skip to content

Commit 76327a3

Browse files
Esben Haabendaldavem330
authored andcommitted
dp83640: Ensure against premature access to PHY registers after reset
The datasheet specifies a 3uS pause after performing a software reset. The default implementation of genphy_soft_reset() does not provide this, so implement soft_reset with the needed pause. Signed-off-by: Esben Haabendal <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1f1cba7 commit 76327a3

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

drivers/net/phy/dp83640.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,23 @@ static void dp83640_remove(struct phy_device *phydev)
12071207
kfree(dp83640);
12081208
}
12091209

1210+
static int dp83640_soft_reset(struct phy_device *phydev)
1211+
{
1212+
int ret;
1213+
1214+
ret = genphy_soft_reset(phydev);
1215+
if (ret < 0)
1216+
return ret;
1217+
1218+
/* From DP83640 datasheet: "Software driver code must wait 3 us
1219+
* following a software reset before allowing further serial MII
1220+
* operations with the DP83640."
1221+
*/
1222+
udelay(10); /* Taking udelay inaccuracy into account */
1223+
1224+
return 0;
1225+
}
1226+
12101227
static int dp83640_config_init(struct phy_device *phydev)
12111228
{
12121229
struct dp83640_private *dp83640 = phydev->priv;
@@ -1501,6 +1518,7 @@ static struct phy_driver dp83640_driver = {
15011518
.flags = PHY_HAS_INTERRUPT,
15021519
.probe = dp83640_probe,
15031520
.remove = dp83640_remove,
1521+
.soft_reset = dp83640_soft_reset,
15041522
.config_init = dp83640_config_init,
15051523
.ack_interrupt = dp83640_ack_interrupt,
15061524
.config_intr = dp83640_config_intr,

0 commit comments

Comments
 (0)