Skip to content

Commit 6dc70ea

Browse files
committed
net: phy: marvell: Add WAKE_PHY support to WOL event
Author: Song Yoong Siang <yoong.siang.song@intel.com> Add Wake-on-PHY feature support by enabling the Link Up Event. Signed-off-by: Song Yoong Siang <yoong.siang.song@intel.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit 6164659) Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2100606 Signed-off-by: Corinna Vinschen <vinschen@redhat.com>
1 parent cdcaf5d commit 6dc70ea

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

drivers/net/phy/marvell.c

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@
155155

156156
#define MII_88E1318S_PHY_WOL_CTRL 0x10
157157
#define MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS BIT(12)
158+
#define MII_88E1318S_PHY_WOL_CTRL_LINK_UP_ENABLE BIT(13)
158159
#define MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE BIT(14)
159160

160161
#define MII_PHY_LED_CTRL 16
@@ -1746,13 +1747,19 @@ static void m88e1318_get_wol(struct phy_device *phydev,
17461747
{
17471748
int ret;
17481749

1749-
wol->supported = WAKE_MAGIC;
1750+
wol->supported = WAKE_MAGIC | WAKE_PHY;
17501751
wol->wolopts = 0;
17511752

17521753
ret = phy_read_paged(phydev, MII_MARVELL_WOL_PAGE,
17531754
MII_88E1318S_PHY_WOL_CTRL);
1754-
if (ret >= 0 && ret & MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE)
1755+
if (ret < 0)
1756+
return;
1757+
1758+
if (ret & MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE)
17551759
wol->wolopts |= WAKE_MAGIC;
1760+
1761+
if (ret & MII_88E1318S_PHY_WOL_CTRL_LINK_UP_ENABLE)
1762+
wol->wolopts |= WAKE_PHY;
17561763
}
17571764

17581765
static int m88e1318_set_wol(struct phy_device *phydev,
@@ -1764,7 +1771,7 @@ static int m88e1318_set_wol(struct phy_device *phydev,
17641771
if (oldpage < 0)
17651772
goto error;
17661773

1767-
if (wol->wolopts & WAKE_MAGIC) {
1774+
if (wol->wolopts & (WAKE_MAGIC | WAKE_PHY)) {
17681775
/* Explicitly switch to page 0x00, just to be sure */
17691776
err = marvell_write_page(phydev, MII_MARVELL_COPPER_PAGE);
17701777
if (err < 0)
@@ -1796,7 +1803,9 @@ static int m88e1318_set_wol(struct phy_device *phydev,
17961803
MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW);
17971804
if (err < 0)
17981805
goto error;
1806+
}
17991807

1808+
if (wol->wolopts & WAKE_MAGIC) {
18001809
err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE);
18011810
if (err < 0)
18021811
goto error;
@@ -1837,6 +1846,30 @@ static int m88e1318_set_wol(struct phy_device *phydev,
18371846
goto error;
18381847
}
18391848

1849+
if (wol->wolopts & WAKE_PHY) {
1850+
err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE);
1851+
if (err < 0)
1852+
goto error;
1853+
1854+
/* Clear WOL status and enable link up event */
1855+
err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL, 0,
1856+
MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS |
1857+
MII_88E1318S_PHY_WOL_CTRL_LINK_UP_ENABLE);
1858+
if (err < 0)
1859+
goto error;
1860+
} else {
1861+
err = marvell_write_page(phydev, MII_MARVELL_WOL_PAGE);
1862+
if (err < 0)
1863+
goto error;
1864+
1865+
/* Clear WOL status and disable link up event */
1866+
err = __phy_modify(phydev, MII_88E1318S_PHY_WOL_CTRL,
1867+
MII_88E1318S_PHY_WOL_CTRL_LINK_UP_ENABLE,
1868+
MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS);
1869+
if (err < 0)
1870+
goto error;
1871+
}
1872+
18401873
error:
18411874
return phy_restore_page(phydev, oldpage, err);
18421875
}

0 commit comments

Comments
 (0)