Commit 34386344 authored by Andrew Lunn's avatar Andrew Lunn Committed by David S. Miller

net: phy: marvell: Use core genphy_soft_reset()

Rather than using an open coded equivalent, use the core
genphy_soft_reset() function.
Signed-off-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8cf8b87b
...@@ -292,17 +292,11 @@ static int marvell_config_aneg(struct phy_device *phydev) ...@@ -292,17 +292,11 @@ static int marvell_config_aneg(struct phy_device *phydev)
return err; return err;
if (phydev->autoneg != AUTONEG_ENABLE) { if (phydev->autoneg != AUTONEG_ENABLE) {
int bmcr;
/* A write to speed/duplex bits (that is performed by /* A write to speed/duplex bits (that is performed by
* genphy_config_aneg() call above) must be followed by * genphy_config_aneg() call above) must be followed by
* a software reset. Otherwise, the write has no effect. * a software reset. Otherwise, the write has no effect.
*/ */
bmcr = phy_read(phydev, MII_BMCR); err = genphy_soft_reset(phydev);
if (bmcr < 0)
return bmcr;
err = phy_write(phydev, MII_BMCR, bmcr | BMCR_RESET);
if (err < 0) if (err < 0)
return err; return err;
} }
...@@ -318,8 +312,7 @@ static int m88e1101_config_aneg(struct phy_device *phydev) ...@@ -318,8 +312,7 @@ static int m88e1101_config_aneg(struct phy_device *phydev)
* that certain registers get written in order * that certain registers get written in order
* to restart autonegotiation * to restart autonegotiation
*/ */
err = phy_write(phydev, MII_BMCR, BMCR_RESET); err = genphy_soft_reset(phydev);
if (err < 0) if (err < 0)
return err; return err;
...@@ -354,7 +347,7 @@ static int m88e1111_config_aneg(struct phy_device *phydev) ...@@ -354,7 +347,7 @@ static int m88e1111_config_aneg(struct phy_device *phydev)
* that certain registers get written in order * that certain registers get written in order
* to restart autonegotiation * to restart autonegotiation
*/ */
err = phy_write(phydev, MII_BMCR, BMCR_RESET); err = genphy_soft_reset(phydev);
err = marvell_set_polarity(phydev, phydev->mdix_ctrl); err = marvell_set_polarity(phydev, phydev->mdix_ctrl);
if (err < 0) if (err < 0)
...@@ -370,17 +363,11 @@ static int m88e1111_config_aneg(struct phy_device *phydev) ...@@ -370,17 +363,11 @@ static int m88e1111_config_aneg(struct phy_device *phydev)
return err; return err;
if (phydev->autoneg != AUTONEG_ENABLE) { if (phydev->autoneg != AUTONEG_ENABLE) {
int bmcr;
/* A write to speed/duplex bits (that is performed by /* A write to speed/duplex bits (that is performed by
* genphy_config_aneg() call above) must be followed by * genphy_config_aneg() call above) must be followed by
* a software reset. Otherwise, the write has no effect. * a software reset. Otherwise, the write has no effect.
*/ */
bmcr = phy_read(phydev, MII_BMCR); err = genphy_soft_reset(phydev);
if (bmcr < 0)
return bmcr;
err = phy_write(phydev, MII_BMCR, bmcr | BMCR_RESET);
if (err < 0) if (err < 0)
return err; return err;
} }
...@@ -493,7 +480,7 @@ static int m88e1121_config_aneg(struct phy_device *phydev) ...@@ -493,7 +480,7 @@ static int m88e1121_config_aneg(struct phy_device *phydev)
marvell_set_page(phydev, oldpage); marvell_set_page(phydev, oldpage);
err = phy_write(phydev, MII_BMCR, BMCR_RESET); err = genphy_soft_reset(phydev);
if (err < 0) if (err < 0)
return err; return err;
...@@ -656,9 +643,7 @@ static int m88e1116r_config_init(struct phy_device *phydev) ...@@ -656,9 +643,7 @@ static int m88e1116r_config_init(struct phy_device *phydev)
int temp; int temp;
int err; int err;
temp = phy_read(phydev, MII_BMCR); err = genphy_soft_reset(phydev);
temp |= BMCR_RESET;
err = phy_write(phydev, MII_BMCR, temp);
if (err < 0) if (err < 0)
return err; return err;
...@@ -689,14 +674,10 @@ static int m88e1116r_config_init(struct phy_device *phydev) ...@@ -689,14 +674,10 @@ static int m88e1116r_config_init(struct phy_device *phydev)
if (err < 0) if (err < 0)
return err; return err;
temp = phy_read(phydev, MII_BMCR); err = genphy_soft_reset(phydev);
temp |= BMCR_RESET;
err = phy_write(phydev, MII_BMCR, temp);
if (err < 0) if (err < 0)
return err; return err;
mdelay(500);
return marvell_config_init(phydev); return marvell_config_init(phydev);
} }
...@@ -804,14 +785,10 @@ static int m88e1111_config_init_rtbi(struct phy_device *phydev) ...@@ -804,14 +785,10 @@ static int m88e1111_config_init_rtbi(struct phy_device *phydev)
return err; return err;
/* soft reset */ /* soft reset */
err = phy_write(phydev, MII_BMCR, BMCR_RESET); err = genphy_soft_reset(phydev);
if (err < 0) if (err < 0)
return err; return err;
do
temp = phy_read(phydev, MII_BMCR);
while (temp & BMCR_RESET);
temp = phy_read(phydev, MII_M1111_PHY_EXT_SR); temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
if (temp < 0) if (temp < 0)
return temp; return temp;
...@@ -850,7 +827,7 @@ static int m88e1111_config_init(struct phy_device *phydev) ...@@ -850,7 +827,7 @@ static int m88e1111_config_init(struct phy_device *phydev)
if (err < 0) if (err < 0)
return err; return err;
return phy_write(phydev, MII_BMCR, BMCR_RESET); return genphy_soft_reset(phydev);
} }
static int m88e1121_config_init(struct phy_device *phydev) static int m88e1121_config_init(struct phy_device *phydev)
...@@ -912,7 +889,7 @@ static int m88e1118_config_aneg(struct phy_device *phydev) ...@@ -912,7 +889,7 @@ static int m88e1118_config_aneg(struct phy_device *phydev)
{ {
int err; int err;
err = phy_write(phydev, MII_BMCR, BMCR_RESET); err = genphy_soft_reset(phydev);
if (err < 0) if (err < 0)
return err; return err;
...@@ -961,7 +938,7 @@ static int m88e1118_config_init(struct phy_device *phydev) ...@@ -961,7 +938,7 @@ static int m88e1118_config_init(struct phy_device *phydev)
if (err < 0) if (err < 0)
return err; return err;
return phy_write(phydev, MII_BMCR, BMCR_RESET); return genphy_soft_reset(phydev);
} }
static int m88e1149_config_init(struct phy_device *phydev) static int m88e1149_config_init(struct phy_device *phydev)
...@@ -987,7 +964,7 @@ static int m88e1149_config_init(struct phy_device *phydev) ...@@ -987,7 +964,7 @@ static int m88e1149_config_init(struct phy_device *phydev)
if (err < 0) if (err < 0)
return err; return err;
return phy_write(phydev, MII_BMCR, BMCR_RESET); return genphy_soft_reset(phydev);
} }
static int m88e1145_config_init_rgmii(struct phy_device *phydev) static int m88e1145_config_init_rgmii(struct phy_device *phydev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment