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)
This commit is contained in:
Huang Shijie
2014-05-07 14:04:09 +08:00
committed by Jason Liu
parent 30ddda20a4
commit b8784d5674

View File

@ -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"
@ -690,7 +690,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;
@ -832,6 +832,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;
@ -869,9 +870,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,