• Niklas Söderlund's avatar
    sh_eth: add generic wake-on-lan support via magic packet · d8981d02
    Niklas Söderlund authored
    Add generic functionality to support Wake-on-LAN using MagicPacket which
    are supported by at least a few versions of sh_eth. Only add
    functionality for WoL, no specific sh_eth versions are marked to support
    WoL yet.
    
    WoL is enabled in the suspend callback by setting MagicPacket detection
    and disabling all interrupts expect MagicPacket. In the resume path the
    driver needs to reset the hardware to rearm the WoL logic, this prevents
    the driver from simply restoring the registers and to take advantage of
    that sh_eth was not suspended to reduce resume time. To reset the
    hardware the driver closes and reopens the device just like it would do
    in a normal suspend/resume scenario without WoL enabled, but it both
    closes and opens the device in the resume callback since the device
    needs to be open for WoL to work.
    
    One quirk needed for WoL is that the module clock needs to be prevented
    from being switched off by Runtime PM. To keep the clock alive the
    suspend callback need to call clk_enable() directly to increase the
    usage count of the clock. Then when Runtime PM decreases the clock usage
    count it won't reach 0 and be switched off.
    Signed-off-by: default avatarNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    d8981d02
sh_eth.h 12.7 KB