Skip to content

Commit fbf3d03

Browse files
Niklas Söderlunddavem330
authored andcommitted
ravb: add workaround for clock when resuming with WoL enabled
The renesas-cpg-mssr clock driver are not yet aware of PSCI sleep where power is cut to the SoC. When resuming from this state with WoL enabled the enable count of the ravb clock is 1 and the clock driver thinks the clock is already on when PM core enables the clock and increments the enable count to 2. This will result in the ravb driver failing to talk to the hardware since the module clock is off. Work around this by forcing the enable count to 0 and then back to 2 when resuming with WoL enabled. This workaround should be reverted once the renesas-cpg-mssr clock driver becomes aware of this PSCI sleep behavior. Signed-off-by: Niklas Söderlund <[email protected]> Acked-by: Sergei Shtylyov <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3e3d647 commit fbf3d03

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

drivers/net/ethernet/renesas/ravb_main.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2270,9 +2270,32 @@ static int __maybe_unused ravb_resume(struct device *dev)
22702270
struct ravb_private *priv = netdev_priv(ndev);
22712271
int ret = 0;
22722272

2273-
/* If WoL is enabled set reset mode to rearm the WoL logic */
2274-
if (priv->wol_enabled)
2273+
if (priv->wol_enabled) {
2274+
/* Reduce the usecount of the clock to zero and then
2275+
* restore it to its original value. This is done to force
2276+
* the clock to be re-enabled which is a workaround
2277+
* for renesas-cpg-mssr driver which do not enable clocks
2278+
* when resuming from PSCI suspend/resume.
2279+
*
2280+
* Without this workaround the driver fails to communicate
2281+
* with the hardware if WoL was enabled when the system
2282+
* entered PSCI suspend. This is due to that if WoL is enabled
2283+
* we explicitly keep the clock from being turned off when
2284+
* suspending, but in PSCI sleep power is cut so the clock
2285+
* is disabled anyhow, the clock driver is not aware of this
2286+
* so the clock is not turned back on when resuming.
2287+
*
2288+
* TODO: once the renesas-cpg-mssr suspend/resume is working
2289+
* this clock dance should be removed.
2290+
*/
2291+
clk_disable(priv->clk);
2292+
clk_disable(priv->clk);
2293+
clk_enable(priv->clk);
2294+
clk_enable(priv->clk);
2295+
2296+
/* Set reset mode to rearm the WoL logic */
22752297
ravb_write(ndev, CCC_OPC_RESET, CCC);
2298+
}
22762299

22772300
/* All register have been reset to default values.
22782301
* Restore all registers which where setup at probe time and

0 commit comments

Comments
 (0)