Skip to content

Commit e31cf3c

Browse files
Luo Jiekuba-moo
authored andcommitted
net: phy: qcom: move the WoL function to shared library
Move the WoL (Wake-on-LAN) functionality to a shared library to enable its reuse by the QCA808X PHY driver, incorporating support for WoL functionality similar to the implementation in at8031_set_wol(). Reviewed-by: Maxime Chevallier <[email protected]> Signed-off-by: Luo Jie <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b9fd988 commit e31cf3c

File tree

3 files changed

+30
-27
lines changed

3 files changed

+30
-27
lines changed

drivers/net/phy/qcom/at803x.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626

2727
#define AT803X_LED_CONTROL 0x18
2828

29-
#define AT803X_PHY_MMD3_WOL_CTRL 0x8012
30-
#define AT803X_WOL_EN BIT(5)
31-
3229
#define AT803X_REG_CHIP_CONFIG 0x1f
3330
#define AT803X_BT_BX_REG_SEL 0x8000
3431

@@ -866,30 +863,6 @@ static int at8031_config_init(struct phy_device *phydev)
866863
return at803x_config_init(phydev);
867864
}
868865

869-
static int at8031_set_wol(struct phy_device *phydev,
870-
struct ethtool_wolinfo *wol)
871-
{
872-
int ret;
873-
874-
/* First setup MAC address and enable WOL interrupt */
875-
ret = at803x_set_wol(phydev, wol);
876-
if (ret)
877-
return ret;
878-
879-
if (wol->wolopts & WAKE_MAGIC)
880-
/* Enable WOL function for 1588 */
881-
ret = phy_modify_mmd(phydev, MDIO_MMD_PCS,
882-
AT803X_PHY_MMD3_WOL_CTRL,
883-
0, AT803X_WOL_EN);
884-
else
885-
/* Disable WoL function for 1588 */
886-
ret = phy_modify_mmd(phydev, MDIO_MMD_PCS,
887-
AT803X_PHY_MMD3_WOL_CTRL,
888-
AT803X_WOL_EN, 0);
889-
890-
return ret;
891-
}
892-
893866
static int at8031_config_intr(struct phy_device *phydev)
894867
{
895868
struct at803x_priv *priv = phydev->priv;

drivers/net/phy/qcom/qcom-phy-lib.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,31 @@ int at803x_set_wol(struct phy_device *phydev,
115115
}
116116
EXPORT_SYMBOL_GPL(at803x_set_wol);
117117

118+
int at8031_set_wol(struct phy_device *phydev,
119+
struct ethtool_wolinfo *wol)
120+
{
121+
int ret;
122+
123+
/* First setup MAC address and enable WOL interrupt */
124+
ret = at803x_set_wol(phydev, wol);
125+
if (ret)
126+
return ret;
127+
128+
if (wol->wolopts & WAKE_MAGIC)
129+
/* Enable WOL function for 1588 */
130+
ret = phy_modify_mmd(phydev, MDIO_MMD_PCS,
131+
AT803X_PHY_MMD3_WOL_CTRL,
132+
0, AT803X_WOL_EN);
133+
else
134+
/* Disable WoL function for 1588 */
135+
ret = phy_modify_mmd(phydev, MDIO_MMD_PCS,
136+
AT803X_PHY_MMD3_WOL_CTRL,
137+
AT803X_WOL_EN, 0);
138+
139+
return ret;
140+
}
141+
EXPORT_SYMBOL_GPL(at8031_set_wol);
142+
118143
void at803x_get_wol(struct phy_device *phydev,
119144
struct ethtool_wolinfo *wol)
120145
{

drivers/net/phy/qcom/qcom.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@
172172
#define AT803X_LOC_MAC_ADDR_16_31_OFFSET 0x804B
173173
#define AT803X_LOC_MAC_ADDR_32_47_OFFSET 0x804A
174174

175+
#define AT803X_PHY_MMD3_WOL_CTRL 0x8012
176+
#define AT803X_WOL_EN BIT(5)
177+
175178
#define AT803X_DEBUG_ADDR 0x1D
176179
#define AT803X_DEBUG_DATA 0x1E
177180

@@ -215,6 +218,8 @@ int at803x_debug_reg_mask(struct phy_device *phydev, u16 reg,
215218
int at803x_debug_reg_write(struct phy_device *phydev, u16 reg, u16 data);
216219
int at803x_set_wol(struct phy_device *phydev,
217220
struct ethtool_wolinfo *wol);
221+
int at8031_set_wol(struct phy_device *phydev,
222+
struct ethtool_wolinfo *wol);
218223
void at803x_get_wol(struct phy_device *phydev,
219224
struct ethtool_wolinfo *wol);
220225
int at803x_ack_interrupt(struct phy_device *phydev);

0 commit comments

Comments
 (0)