Re: [PATCH 2/2] net: phy: realtek: Add optional external PHY clock

From: Florian Fainelli
Date: Thu Jun 01 2023 - 16:14:56 EST


On 6/1/23 12:37, Andrew Lunn wrote:
I'm not sure about this. Isn't the clock still necessary when suspended for
things like wake on lan ?

Yes, but the PHY should know if its a WoL source, and not disable its
own clock. There is some support for this in phylib, and Florian has
also reworked it recently for Broadcom PHYs.

If you want to have the PHY driver have a chance to disable the clock if Wake-on-LAN is disabled and therefore conserve power, you should set PHY_ALWAYS_CALL_SUSPEND in the phy_driver::flags and in the suspend/resume functions do something like:

suspend:
/* last step after all registers are accessed */
if (!phydev->wol_enabled)
clk_disable_unprepare()
resume:
/* first step before registers are accessed */
if (!phydev->wol_enabled)
clk_prepare_enable()

The flag is necessary to ensure that the PHY driver's suspend function will be called. The resume will be called regardless of Wake-on-LAN being enabled or not.
--
Florian