Skip to content

Commit 3758be3

Browse files
Charles-Antoine Couretdavem330
authored andcommitted
Marvell phy: add functions to suspend and resume both interfaces: fiber and copper links.
These functions used standards registers in a different page for both interfaces: copper and fiber. Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: Charles-Antoine Couret <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 78301eb commit 3758be3

File tree

1 file changed

+71
-2
lines changed

1 file changed

+71
-2
lines changed

drivers/net/phy/marvell.c

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,75 @@ static int marvell_read_status(struct phy_device *phydev)
12241224
phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_M1111_COPPER);
12251225
return err;
12261226
}
1227+
1228+
/* marvell_suspend
1229+
*
1230+
* Some Marvell's phys have two modes: fiber and copper.
1231+
* Both need to be suspended
1232+
*/
1233+
static int marvell_suspend(struct phy_device *phydev)
1234+
{
1235+
int err;
1236+
1237+
/* Suspend the fiber mode first */
1238+
if (!(phydev->supported & SUPPORTED_FIBRE)) {
1239+
err = phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_M1111_FIBER);
1240+
if (err < 0)
1241+
goto error;
1242+
1243+
/* With the page set, use the generic suspend */
1244+
err = genphy_suspend(phydev);
1245+
if (err < 0)
1246+
goto error;
1247+
1248+
/* Then, the copper link */
1249+
err = phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_M1111_COPPER);
1250+
if (err < 0)
1251+
goto error;
1252+
}
1253+
1254+
/* With the page set, use the generic suspend */
1255+
return genphy_suspend(phydev);
1256+
1257+
error:
1258+
phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_M1111_COPPER);
1259+
return err;
1260+
}
1261+
1262+
/* marvell_resume
1263+
*
1264+
* Some Marvell's phys have two modes: fiber and copper.
1265+
* Both need to be resumed
1266+
*/
1267+
static int marvell_resume(struct phy_device *phydev)
1268+
{
1269+
int err;
1270+
1271+
/* Resume the fiber mode first */
1272+
if (!(phydev->supported & SUPPORTED_FIBRE)) {
1273+
err = phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_M1111_FIBER);
1274+
if (err < 0)
1275+
goto error;
1276+
1277+
/* With the page set, use the generic resume */
1278+
err = genphy_resume(phydev);
1279+
if (err < 0)
1280+
goto error;
1281+
1282+
/* Then, the copper link */
1283+
err = phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_M1111_COPPER);
1284+
if (err < 0)
1285+
goto error;
1286+
}
1287+
1288+
/* With the page set, use the generic resume */
1289+
return genphy_resume(phydev);
1290+
1291+
error:
1292+
phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_M1111_COPPER);
1293+
return err;
1294+
}
1295+
12271296
static int marvell_aneg_done(struct phy_device *phydev)
12281297
{
12291298
int retval = phy_read(phydev, MII_M1011_PHY_STATUS);
@@ -1611,8 +1680,8 @@ static struct phy_driver marvell_drivers[] = {
16111680
.ack_interrupt = &marvell_ack_interrupt,
16121681
.config_intr = &marvell_config_intr,
16131682
.did_interrupt = &m88e1121_did_interrupt,
1614-
.resume = &genphy_resume,
1615-
.suspend = &genphy_suspend,
1683+
.resume = &marvell_resume,
1684+
.suspend = &marvell_suspend,
16161685
.get_sset_count = marvell_get_sset_count,
16171686
.get_strings = marvell_get_strings,
16181687
.get_stats = marvell_get_stats,

0 commit comments

Comments
 (0)