diff options
author | Martin Hundebøll <martin@geanix.com> | 2023-11-13 16:14:50 +0300 |
---|---|---|
committer | Marc Kleine-Budde <mkl@pengutronix.de> | 2024-02-14 15:44:02 +0300 |
commit | 4a94d7e31cf5ab33f43ed381c35aabb0d1f2748d (patch) | |
tree | 5608bdc71416f422884234bd8f5a1a81ff0019b7 /drivers/net/can/m_can/m_can.c | |
parent | b00cf4f62969eb7067bc44851de9519953a7ae01 (diff) | |
download | linux-4a94d7e31cf5ab33f43ed381c35aabb0d1f2748d.tar.xz |
can: m_can: allow keeping the transceiver running in suspend
Add a flag to the device class structure that leaves the chip in a
running state with rx interrupt enabled, so that an m_can device driver
can configure and use the interrupt as a wakeup source.
Signed-off-by: Martin Hundebøll <martin@geanix.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can/m_can/m_can.c')
-rw-r--r-- | drivers/net/can/m_can/m_can.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c index 290880ce5329..14b231c4d7ec 100644 --- a/drivers/net/can/m_can/m_can.c +++ b/drivers/net/can/m_can/m_can.c @@ -2382,7 +2382,15 @@ int m_can_class_suspend(struct device *dev) if (netif_running(ndev)) { netif_stop_queue(ndev); netif_device_detach(ndev); - m_can_stop(ndev); + + /* leave the chip running with rx interrupt enabled if it is + * used as a wake-up source. + */ + if (cdev->pm_wake_source) + m_can_write(cdev, M_CAN_IE, IR_RF0N); + else + m_can_stop(ndev); + m_can_clk_stop(cdev); } @@ -2409,11 +2417,15 @@ int m_can_class_resume(struct device *dev) ret = m_can_clk_start(cdev); if (ret) return ret; - ret = m_can_start(ndev); - if (ret) { - m_can_clk_stop(cdev); - return ret; + if (cdev->pm_wake_source) { + m_can_write(cdev, M_CAN_IE, cdev->active_interrupts); + } else { + ret = m_can_start(ndev); + if (ret) { + m_can_clk_stop(cdev); + return ret; + } } netif_device_attach(ndev); |