Skip to content

Commit 6229ed1

Browse files
zonquedavem330
authored andcommitted
net: phy: at803x: add suspend/resume callbacks
When WOL is enabled, the chip can't be put into power-down (BMCR_PDOWN) mode, as that will also switch off the MAC, which consequently leads to a link loss. Use BMCR_ISOLATE in that case, which will at least save us some milliamperes in comparison to normal operation mode. Signed-off-by: Daniel Mack <zonque@gmail.com> Acked-by: Mugunthan V N <mugunthanvnm@ti.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0197ffe commit 6229ed1

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

‎drivers/net/phy/at803x.c‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,45 @@ static void at803x_get_wol(struct phy_device *phydev,
100100
wol->wolopts |= WAKE_MAGIC;
101101
}
102102

103+
static int at803x_suspend(struct phy_device *phydev)
104+
{
105+
int value;
106+
int wol_enabled;
107+
108+
mutex_lock(&phydev->lock);
109+
110+
value = phy_read(phydev, AT803X_INTR_ENABLE);
111+
wol_enabled = value & AT803X_WOL_ENABLE;
112+
113+
value = phy_read(phydev, MII_BMCR);
114+
115+
if (wol_enabled)
116+
value |= BMCR_ISOLATE;
117+
else
118+
value |= BMCR_PDOWN;
119+
120+
phy_write(phydev, MII_BMCR, value);
121+
122+
mutex_unlock(&phydev->lock);
123+
124+
return 0;
125+
}
126+
127+
static int at803x_resume(struct phy_device *phydev)
128+
{
129+
int value;
130+
131+
mutex_lock(&phydev->lock);
132+
133+
value = phy_read(phydev, MII_BMCR);
134+
value &= ~(BMCR_PDOWN | BMCR_ISOLATE);
135+
phy_write(phydev, MII_BMCR, value);
136+
137+
mutex_unlock(&phydev->lock);
138+
139+
return 0;
140+
}
141+
103142
static int at803x_config_init(struct phy_device *phydev)
104143
{
105144
int val;
@@ -161,6 +200,8 @@ static struct phy_driver at803x_driver[] = {
161200
.config_init = at803x_config_init,
162201
.set_wol = at803x_set_wol,
163202
.get_wol = at803x_get_wol,
203+
.suspend = at803x_suspend,
204+
.resume = at803x_resume,
164205
.features = PHY_GBIT_FEATURES,
165206
.flags = PHY_HAS_INTERRUPT,
166207
.config_aneg = genphy_config_aneg,
@@ -176,6 +217,8 @@ static struct phy_driver at803x_driver[] = {
176217
.config_init = at803x_config_init,
177218
.set_wol = at803x_set_wol,
178219
.get_wol = at803x_get_wol,
220+
.suspend = at803x_suspend,
221+
.resume = at803x_resume,
179222
.features = PHY_GBIT_FEATURES,
180223
.flags = PHY_HAS_INTERRUPT,
181224
.config_aneg = genphy_config_aneg,
@@ -191,6 +234,8 @@ static struct phy_driver at803x_driver[] = {
191234
.config_init = at803x_config_init,
192235
.set_wol = at803x_set_wol,
193236
.get_wol = at803x_get_wol,
237+
.suspend = at803x_suspend,
238+
.resume = at803x_resume,
194239
.features = PHY_GBIT_FEATURES,
195240
.flags = PHY_HAS_INTERRUPT,
196241
.config_aneg = genphy_config_aneg,

0 commit comments

Comments
 (0)