Skip to content

Commit da702f3

Browse files
Radu Pirea (NXP OSS)davem330
authored andcommitted
net: phy: add genphy_c45_pma_suspend/resume
Add generic PMA suspend and resume callback functions for C45 PHYs. Signed-off-by: Radu Pirea (NXP OSS) <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ced97ee commit da702f3

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

drivers/net/phy/phy-c45.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,49 @@
88
#include <linux/mii.h>
99
#include <linux/phy.h>
1010

11+
/**
12+
* genphy_c45_pma_can_sleep - checks if the PMA have sleep support
13+
* @phydev: target phy_device struct
14+
*/
15+
static bool genphy_c45_pma_can_sleep(struct phy_device *phydev)
16+
{
17+
int stat1;
18+
19+
stat1 = phy_read_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_STAT1);
20+
if (stat1 < 0)
21+
return false;
22+
23+
return !!(stat1 & MDIO_STAT1_LPOWERABLE);
24+
}
25+
26+
/**
27+
* genphy_c45_pma_resume - wakes up the PMA module
28+
* @phydev: target phy_device struct
29+
*/
30+
int genphy_c45_pma_resume(struct phy_device *phydev)
31+
{
32+
if (!genphy_c45_pma_can_sleep(phydev))
33+
return -EOPNOTSUPP;
34+
35+
return phy_clear_bits_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1,
36+
MDIO_CTRL1_LPOWER);
37+
}
38+
EXPORT_SYMBOL_GPL(genphy_c45_pma_resume);
39+
40+
/**
41+
* genphy_c45_pma_suspend - suspends the PMA module
42+
* @phydev: target phy_device struct
43+
*/
44+
int genphy_c45_pma_suspend(struct phy_device *phydev)
45+
{
46+
if (!genphy_c45_pma_can_sleep(phydev))
47+
return -EOPNOTSUPP;
48+
49+
return phy_set_bits_mmd(phydev, MDIO_MMD_PMAPMD, MDIO_CTRL1,
50+
MDIO_CTRL1_LPOWER);
51+
}
52+
EXPORT_SYMBOL_GPL(genphy_c45_pma_suspend);
53+
1154
/**
1255
* genphy_c45_pma_setup_forced - configures a forced speed
1356
* @phydev: target phy_device struct

include/linux/phy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,6 +1535,8 @@ int genphy_c45_pma_read_abilities(struct phy_device *phydev);
15351535
int genphy_c45_read_status(struct phy_device *phydev);
15361536
int genphy_c45_config_aneg(struct phy_device *phydev);
15371537
int genphy_c45_loopback(struct phy_device *phydev, bool enable);
1538+
int genphy_c45_pma_resume(struct phy_device *phydev);
1539+
int genphy_c45_pma_suspend(struct phy_device *phydev);
15381540

15391541
/* Generic C45 PHY driver */
15401542
extern struct phy_driver genphy_c45_driver;

0 commit comments

Comments
 (0)