MLK-21411 can: flexcan: fix CAN can't suspend/resume when CAN is only capable of...
authorJoakim Zhang <qiangqing.zhang@nxp.com>
Mon, 8 Apr 2019 05:32:28 +0000 (13:32 +0800)
committerJoakim Zhang <qiangqing.zhang@nxp.com>
Thu, 18 Apr 2019 09:16:19 +0000 (17:16 +0800)
commitc23425feb311d19cfffbc82d2ec2cdbbdb72bbd9
treeb5184ca611971a7ed72e6ac52996a8dc952cad13
parentea1037c1959531e21a4f418798409dbdfd352029
MLK-21411 can: flexcan: fix CAN can't suspend/resume when CAN is only capable of wakeup

When dev->power.can_wakeup set to true, device_prepare() may runtime resume the device:
    dpm_suspend_start()
            dpm_prepare(state);
                    dev->driver->pm->prepare()
                            pm_genpd_prepare()
                                    if (resume_needed(dev, genpd))
                                        pm_runtime_resume(dev);

And imx8qm/qxp power domain driver don't implement the active_wakeup() callback, then
resume_needed() always return "true" when dev->power.can_wakeup is true.

Once CAN device is runtime active status, then CAN's clock's count is 1 during system
suspend. And CAN0/CAN1/CAN2 share the same module clock, so we can say all CAN's module
clock is enabled during system suspended.

    flexcan_runtime_resume()
            flexcan_clks_enable(priv);

i.MX8QM/QXP SCU code clock logic requires linux kernel clocks should be disabled during
suspend, otherwise SCU don't enable them after system resume back.

There are two ways to fix the issue:
1. CAN driver should check the runtime status to ensure all clocks are disabled  during
system suspend.
2. Don't set CAN wakeup capability during probe, move it into flexcan_open().

Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com>
drivers/net/can/flexcan.c