Skip to content

Commit

Permalink
can: flexcan: add PM support
Browse files Browse the repository at this point in the history
tested on an i.MX257

Signed-off-by: Eric Bénard <eric@eukrea.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Eric Bénard authored and Marc Kleine-Budde committed May 23, 2012
1 parent 31a6710 commit 8b5e218
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions drivers/net/can/flexcan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,42 @@ static struct of_device_id flexcan_of_match[] = {
{},
};

#ifdef CONFIG_PM
static int flexcan_suspend(struct platform_device *pdev, pm_message_t state)
{
struct net_device *dev = platform_get_drvdata(pdev);
struct flexcan_priv *priv = netdev_priv(dev);

flexcan_chip_disable(priv);

if (netif_running(dev)) {
netif_stop_queue(dev);
netif_device_detach(dev);
}
priv->can.state = CAN_STATE_SLEEPING;

return 0;
}

static int flexcan_resume(struct platform_device *pdev)
{
struct net_device *dev = platform_get_drvdata(pdev);
struct flexcan_priv *priv = netdev_priv(dev);

priv->can.state = CAN_STATE_ERROR_ACTIVE;
if (netif_running(dev)) {
netif_device_attach(dev);
netif_start_queue(dev);
}
flexcan_chip_enable(priv);

return 0;
}
#else
#define flexcan_suspend NULL
#define flexcan_resume NULL
#endif

static struct platform_driver flexcan_driver = {
.driver = {
.name = DRV_NAME,
Expand All @@ -1058,6 +1094,8 @@ static struct platform_driver flexcan_driver = {
},
.probe = flexcan_probe,
.remove = __devexit_p(flexcan_remove),
.suspend = flexcan_suspend,
.resume = flexcan_resume,
};

module_platform_driver(flexcan_driver);
Expand Down

0 comments on commit 8b5e218

Please sign in to comment.