diff options
author | Huang Shijie <b32955@freescale.com> | 2014-05-07 14:04:09 +0800 |
---|---|---|
committer | Nitin Garg <nitin.garg@nxp.com> | 2016-01-14 10:59:44 -0600 |
commit | 34947d3adbe4a53d83429c6ce11aabdb9808eefa (patch) | |
tree | 3fb98fd2ef69db7102f810b40c29318489c8f63c /drivers/dma/mxs-dma.c | |
parent | 7b2069dc22c0ba7a202da750c296356b2e3ddd1e (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>
Signed-off-by: Fugang Duan <B38611@freescale.com>
(cherry picked from commit 7a59828eeda36457e6e60383705a0bc5831ffbf7)
Diffstat (limited to 'drivers/dma/mxs-dma.c')
-rw-r--r-- | drivers/dma/mxs-dma.c | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c index 829ec686dac3..e1631199cdb5 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" @@ -693,7 +693,7 @@ static enum dma_status mxs_dma_tx_status(struct dma_chan *chan, return mxs_chan->status; } -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; @@ -835,6 +835,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; @@ -872,9 +873,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, |