Commit d14ccea0 authored by Quentin Schulz's avatar Quentin Schulz Committed by Marc Kleine-Budde

can: m_can: add deep Suspend/Resume support

This adds Power Management deep Suspend/Resume support for Bosch M_CAN
chip.

When entering deep sleep, the clocks are gated, the interrupts are
disabled. When resuming from deep sleep, the chip needs to be
reinitialized, the clocks ungated and the interrupts enabled.
Signed-off-by: default avatarQuentin Schulz <quentin.schulz@free-electrons.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent ef7b8aa8
...@@ -1668,6 +1668,8 @@ static int m_can_plat_probe(struct platform_device *pdev) ...@@ -1668,6 +1668,8 @@ static int m_can_plat_probe(struct platform_device *pdev)
return ret; return ret;
} }
/* TODO: runtime PM with power down or sleep mode */
static __maybe_unused int m_can_suspend(struct device *dev) static __maybe_unused int m_can_suspend(struct device *dev)
{ {
struct net_device *ndev = dev_get_drvdata(dev); struct net_device *ndev = dev_get_drvdata(dev);
...@@ -1676,10 +1678,10 @@ static __maybe_unused int m_can_suspend(struct device *dev) ...@@ -1676,10 +1678,10 @@ static __maybe_unused int m_can_suspend(struct device *dev)
if (netif_running(ndev)) { if (netif_running(ndev)) {
netif_stop_queue(ndev); netif_stop_queue(ndev);
netif_device_detach(ndev); netif_device_detach(ndev);
m_can_stop(ndev);
m_can_clk_stop(priv);
} }
/* TODO: enter low power */
priv->can.state = CAN_STATE_SLEEPING; priv->can.state = CAN_STATE_SLEEPING;
return 0; return 0;
...@@ -1690,11 +1692,18 @@ static __maybe_unused int m_can_resume(struct device *dev) ...@@ -1690,11 +1692,18 @@ static __maybe_unused int m_can_resume(struct device *dev)
struct net_device *ndev = dev_get_drvdata(dev); struct net_device *ndev = dev_get_drvdata(dev);
struct m_can_priv *priv = netdev_priv(ndev); struct m_can_priv *priv = netdev_priv(ndev);
/* TODO: exit low power */ m_can_init_ram(priv);
priv->can.state = CAN_STATE_ERROR_ACTIVE; priv->can.state = CAN_STATE_ERROR_ACTIVE;
if (netif_running(ndev)) { if (netif_running(ndev)) {
int ret;
ret = m_can_clk_start(priv);
if (ret)
return ret;
m_can_start(ndev);
netif_device_attach(ndev); netif_device_attach(ndev);
netif_start_queue(ndev); netif_start_queue(ndev);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment