OSDN Git Service

clk: renesas: cpg-mssr: Restore module clocks during resume
authorGeert Uytterhoeven <geert+renesas@glider.be>
Wed, 7 Jun 2017 11:20:06 +0000 (13:20 +0200)
committerGeert Uytterhoeven <geert+renesas@glider.be>
Fri, 20 Oct 2017 09:15:29 +0000 (11:15 +0200)
commit560869100b99a3daea329efce738a3b7ae357be8
tree68cf1b8145d8646a1c5127d835e79e90ce9c7b77
parentd9341f2b00c0f2a50e1fada55f6a2a2c51818ae6
clk: renesas: cpg-mssr: Restore module clocks during resume

During PSCI system suspend, R-Car Gen3 SoCs are powered down, and their
clock register state is lost.  Note that as the boot loader skips most
initialization after system resume, clock register state differs from
the state encountered during normal system boot, too.

Hence after s2ram, some operations may fail because module clocks are
disabled, while drivers expect them to be still enabled.  E.g. EtherAVB
fails when Wake-on-LAN has been enabled using "ethtool -s eth0 wol g":

    ravb e6800000.ethernet eth0: failed to switch device to config mode
    ravb e6800000.ethernet eth0: device will be stopped after h/w processes are done.
    ravb e6800000.ethernet eth0: failed to switch device to config
    PM: Device e6800000.ethernet failed to resume: error -110

In addition, some module clocks that were disabled by
clk_disable_unused() may have been re-enabled, wasting power.

To fix this, restore all bits of the SMSTPCR registers that represent
clocks under control of Linux.

Notes:
  - While this fixes EtherAVB operation after resume from s2ram,
    EtherAVB cannot be used as an actual wake-up source from s2ram, only
    from s2idle, due to PSCI limitations,
  - To avoid overhead on platforms not needing it, the suspend/resume
    code has a build time dependency on sleep and PSCI support, and a
    runtime dependency on PSCI.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
drivers/clk/renesas/renesas-cpg-mssr.c