summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Bénard <eric@eukrea.com>2012-05-08 19:12:17 +0400
committerMarc Kleine-Budde <mkl@pengutronix.de>2012-05-24 00:55:48 +0400
commit8b5e218d8caa7592d26e68157bd71f50426bb7ae (patch)
tree6f9b84108386b4185629317afe9ea47f6906b967
parent31a67102f4762df5544bc2dfb34a931233d2a5b2 (diff)
downloadlinux-8b5e218d8caa7592d26e68157bd71f50426bb7ae.tar.xz
can: flexcan: add PM support
tested on an i.MX257 Signed-off-by: Eric Bénard <eric@eukrea.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
-rw-r--r--drivers/net/can/flexcan.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index 1efb08386c61..0d058b0a3cb6 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -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,
@@ -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);