summaryrefslogtreecommitdiff
path: root/drivers/dma
diff options
context:
space:
mode:
authorHuang Shijie <b32955@freescale.com>2014-05-07 14:04:09 +0800
committerNitin Garg <nitin.garg@freescale.com>2015-04-14 14:01:49 -0500
commitbc1cf79b491fbf924f6b40e1889042d81a83e618 (patch)
tree1c2ea768f952815b2e5d5e5bd145122618ef017b /drivers/dma
parent7e3677575edbcf77e852496aba99af8c4e01d9f1 (diff)
MLK-9810 dma: mxs-dma: add power management support
this patch adds power management support for mxs-dma driver. Signed-off-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Allen Xu <b45815@freescale.com> (cherry picked from commit 7a59828eeda36457e6e60383705a0bc5831ffbf7)
Diffstat (limited to 'drivers/dma')
-rw-r--r--drivers/dma/mxs-dma.c54
1 files changed, 51 insertions, 3 deletions
diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c
index ead491346da7..fb472031ef7b 100644
--- a/drivers/dma/mxs-dma.c
+++ b/drivers/dma/mxs-dma.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2011 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2011-2015 Freescale Semiconductor, Inc. All Rights Reserved.
*
* Refer to drivers/dma/imx-sdma.c
*
@@ -28,7 +28,7 @@
#include <linux/of_device.h>
#include <linux/of_dma.h>
#include <linux/list.h>
-
+#include <linux/pm_runtime.h>
#include <asm/irq.h>
#include "dmaengine.h"
@@ -710,7 +710,7 @@ static void mxs_dma_issue_pending(struct dma_chan *chan)
mxs_dma_enable_chan(mxs_chan);
}
-static int __init mxs_dma_init(struct mxs_dma_engine *mxs_dma)
+static int mxs_dma_init(struct mxs_dma_engine *mxs_dma)
{
int ret;
@@ -852,6 +852,7 @@ static int __init mxs_dma_probe(struct platform_device *pdev)
mxs_dma->pdev = pdev;
mxs_dma->dma_device.dev = &pdev->dev;
+ dev_set_drvdata(&pdev->dev, mxs_dma);
/* mxs_dma gets 65535 bytes maximum sg size */
mxs_dma->dma_device.dev->dma_parms = &mxs_dma->dma_parms;
@@ -883,9 +884,56 @@ static int __init mxs_dma_probe(struct platform_device *pdev)
return 0;
}
+static int mxs_dma_runtime_suspend(struct device *dev)
+{
+ struct mxs_dma_engine *mxs_dma = dev_get_drvdata(dev);
+
+ clk_disable(mxs_dma->clk);
+ return 0;
+}
+
+static int mxs_dma_runtime_resume(struct device *dev)
+{
+ struct mxs_dma_engine *mxs_dma = dev_get_drvdata(dev);
+ int ret;
+
+ ret = clk_enable(mxs_dma->clk);
+ if (ret < 0) {
+ dev_err(dev, "clk_enable failed: %d\n", ret);
+ return ret;
+ }
+ return 0;
+}
+
+static int mxs_dma_pm_suspend(struct device *dev)
+{
+ /*
+ * We do not save any registers here, since the gpmi will release its
+ * DMA channel.
+ */
+ return 0;
+}
+
+static int mxs_dma_pm_resume(struct device *dev)
+{
+ struct mxs_dma_engine *mxs_dma = dev_get_drvdata(dev);
+ int ret;
+
+ ret = mxs_dma_init(mxs_dma);
+ if (ret)
+ return ret;
+ return 0;
+}
+
+static const struct dev_pm_ops mxs_dma_pm_ops = {
+ SET_RUNTIME_PM_OPS(mxs_dma_runtime_suspend, mxs_dma_runtime_resume, NULL)
+ SET_SYSTEM_SLEEP_PM_OPS(mxs_dma_pm_suspend, mxs_dma_pm_resume)
+};
+
static struct platform_driver mxs_dma_driver = {
.driver = {
.name = "mxs-dma",
+ .pm = &mxs_dma_pm_ops,
.of_match_table = mxs_dma_dt_ids,
},
.id_table = mxs_dma_ids,