6746a4d43ca87a82d990197c08e3d997e337657b
[openwrt/staging/neocturne.git] /
1 From 27b89c9dc1b0393090d68d651b82f30ad2696baa Mon Sep 17 00:00:00 2001
2 From: Christian Marangi <ansuelsmth@gmail.com>
3 Date: Fri, 8 Dec 2023 15:51:55 +0100
4 Subject: [PATCH 08/13] net: phy: at803x: move specific at8031 WOL bits to
5 dedicated function
6
7 Move specific at8031 WOL enable/disable to dedicated function to make
8 at803x_set_wol more generic.
9
10 This is needed in preparation for PHY driver split as qca8081 share the
11 same function to toggle WOL settings.
12
13 In this new implementation WOL module in at8031 is enabled after the
14 generic interrupt is setup. This should not cause any problem as the
15 WOL_INT has a separate implementation and only relay on MAC bits.
16
17 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
18 Signed-off-by: David S. Miller <davem@davemloft.net>
19 ---
20 drivers/net/phy/at803x.c | 42 ++++++++++++++++++++++++----------------
21 1 file changed, 25 insertions(+), 17 deletions(-)
22
23 --- a/drivers/net/phy/at803x.c
24 +++ b/drivers/net/phy/at803x.c
25 @@ -466,27 +466,11 @@ static int at803x_set_wol(struct phy_dev
26 phy_write_mmd(phydev, MDIO_MMD_PCS, offsets[i],
27 mac[(i * 2) + 1] | (mac[(i * 2)] << 8));
28
29 - /* Enable WOL function for 1588 */
30 - if (phydev->drv->phy_id == ATH8031_PHY_ID) {
31 - ret = phy_modify_mmd(phydev, MDIO_MMD_PCS,
32 - AT803X_PHY_MMD3_WOL_CTRL,
33 - 0, AT803X_WOL_EN);
34 - if (ret)
35 - return ret;
36 - }
37 /* Enable WOL interrupt */
38 ret = phy_modify(phydev, AT803X_INTR_ENABLE, 0, AT803X_INTR_ENABLE_WOL);
39 if (ret)
40 return ret;
41 } else {
42 - /* Disable WoL function for 1588 */
43 - if (phydev->drv->phy_id == ATH8031_PHY_ID) {
44 - ret = phy_modify_mmd(phydev, MDIO_MMD_PCS,
45 - AT803X_PHY_MMD3_WOL_CTRL,
46 - AT803X_WOL_EN, 0);
47 - if (ret)
48 - return ret;
49 - }
50 /* Disable WOL interrupt */
51 ret = phy_modify(phydev, AT803X_INTR_ENABLE, AT803X_INTR_ENABLE_WOL, 0);
52 if (ret)
53 @@ -1609,6 +1593,30 @@ static int at8031_config_init(struct phy
54 return at803x_config_init(phydev);
55 }
56
57 +static int at8031_set_wol(struct phy_device *phydev,
58 + struct ethtool_wolinfo *wol)
59 +{
60 + int ret;
61 +
62 + /* First setup MAC address and enable WOL interrupt */
63 + ret = at803x_set_wol(phydev, wol);
64 + if (ret)
65 + return ret;
66 +
67 + if (wol->wolopts & WAKE_MAGIC)
68 + /* Enable WOL function for 1588 */
69 + ret = phy_modify_mmd(phydev, MDIO_MMD_PCS,
70 + AT803X_PHY_MMD3_WOL_CTRL,
71 + 0, AT803X_WOL_EN);
72 + else
73 + /* Disable WoL function for 1588 */
74 + ret = phy_modify_mmd(phydev, MDIO_MMD_PCS,
75 + AT803X_PHY_MMD3_WOL_CTRL,
76 + AT803X_WOL_EN, 0);
77 +
78 + return ret;
79 +}
80 +
81 static int qca83xx_config_init(struct phy_device *phydev)
82 {
83 u8 switch_revision;
84 @@ -2121,7 +2129,7 @@ static struct phy_driver at803x_driver[]
85 .config_init = at8031_config_init,
86 .config_aneg = at803x_config_aneg,
87 .soft_reset = genphy_soft_reset,
88 - .set_wol = at803x_set_wol,
89 + .set_wol = at8031_set_wol,
90 .get_wol = at803x_get_wol,
91 .suspend = at803x_suspend,
92 .resume = at803x_resume,