From: Huang Shijie Date: Wed, 7 May 2014 06:04:09 +0000 (+0800) Subject: MLK-9810 dma: mxs-dma: add power management support X-Git-Tag: C0P2-H0.0--20200415~4550 X-Git-Url: https://git.somdevices.com/?a=commitdiff_plain;h=f7722b9f49fe670e6a270dad674dd22897abd601;p=linux.git MLK-9810 dma: mxs-dma: add power management support this patch adds power management support for mxs-dma driver. Signed-off-by: Huang Shijie Signed-off-by: Allen Xu Signed-off-by: Fugang Duan (cherry picked from commit 7a59828eeda36457e6e60383705a0bc5831ffbf7) --- diff --git a/drivers/dma/mxs-dma.c b/drivers/dma/mxs-dma.c index e217268c7098..fb2c7bf007d0 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 #include #include - +#include #include #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,