Message ID | 20230605151953.48539-4-detlev.casanova@collabora.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | [v3,1/3] net: phy: realtek: Add optional external PHY clock | expand |
On 6/5/23 08:19, Detlev Casanova wrote: > For PHYs that call rtl821x_probe() where an external clock can be > configured, make sure that the clock is disabled > when ->suspend() is called and enabled on resume. > > The PHY_ALWAYS_CALL_SUSPEND is added to ensure that the suspend function > is actually always called. > > Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> > Signed-off-by: Detlev Casanova <detlev.casanova@collabora.com> > --- > drivers/net/phy/realtek.c | 24 ++++++++++++++++++++++-- > 1 file changed, 22 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c > index b13dd0b3c99e..62eac4835def 100644 > --- a/drivers/net/phy/realtek.c > +++ b/drivers/net/phy/realtek.c > @@ -426,10 +426,28 @@ static int rtl8211f_config_init(struct phy_device *phydev) > return genphy_soft_reset(phydev); > } > > +static int rtl821x_suspend(struct phy_device *phydev) > +{ > + struct rtl821x_priv *priv = phydev->priv; > + int ret = genphy_suspend(phydev); Sorry I missed that part, if Wake-on-LAN is enabled you cannot suspend the PHY as this will typically prevent it from passing received frames up the MAC where Wake-on-LAN can be done. You need to move genphy_suspend() into the !phydev->wol_enabled clause.
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index b13dd0b3c99e..62eac4835def 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -426,10 +426,28 @@ static int rtl8211f_config_init(struct phy_device *phydev) return genphy_soft_reset(phydev); } +static int rtl821x_suspend(struct phy_device *phydev) +{ + struct rtl821x_priv *priv = phydev->priv; + int ret = genphy_suspend(phydev); + + if (ret) + return ret; + + if (!phydev->wol_enabled) + clk_disable_unprepare(priv->clk); + + return ret; +} + static int rtl821x_resume(struct phy_device *phydev) { + struct rtl821x_priv *priv = phydev->priv; int ret; + if (!phydev->wol_enabled) + clk_prepare_enable(priv->clk); + ret = genphy_resume(phydev); if (ret < 0) return ret; @@ -934,10 +952,11 @@ static struct phy_driver realtek_drvs[] = { .read_status = rtlgen_read_status, .config_intr = &rtl8211f_config_intr, .handle_interrupt = rtl8211f_handle_interrupt, - .suspend = genphy_suspend, + .suspend = rtl821x_suspend, .resume = rtl821x_resume, .read_page = rtl821x_read_page, .write_page = rtl821x_write_page, + .flags = PHY_ALWAYS_CALL_SUSPEND, }, { PHY_ID_MATCH_EXACT(RTL_8211FVD_PHYID), .name = "RTL8211F-VD Gigabit Ethernet", @@ -946,10 +965,11 @@ static struct phy_driver realtek_drvs[] = { .read_status = rtlgen_read_status, .config_intr = &rtl8211f_config_intr, .handle_interrupt = rtl8211f_handle_interrupt, - .suspend = genphy_suspend, + .suspend = rtl821x_suspend, .resume = rtl821x_resume, .read_page = rtl821x_read_page, .write_page = rtl821x_write_page, + .flags = PHY_ALWAYS_CALL_SUSPEND, }, { .name = "Generic FE-GE Realtek PHY", .match_phy_device = rtlgen_match_phy_device,