diff mbox series

[5/5] dma: add relative interface to support deep sleep

Message ID 20230807052056.2963-1-kaiwei.liu@unisoc.com (mailing list archive)
State Changes Requested
Headers show
Series [1/5] dma: delect redundant parameter for dma driver function | expand

Commit Message

Kaiwei Liu Aug. 7, 2023, 5:20 a.m. UTC
The DMA doesn't support deep sleep before, here add
relative interface in deep sleep framework.

Signed-off-by: Kaiwei Liu <kaiwei.liu@unisoc.com>
---
 drivers/dma/sprd-dma.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff mbox series

Patch

diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
index 41d427df5098..b1dbbc5f4e70 100644
--- a/drivers/dma/sprd-dma.c
+++ b/drivers/dma/sprd-dma.c
@@ -1339,10 +1339,30 @@  static int __maybe_unused sprd_dma_runtime_resume(struct device *dev)
 	return ret;
 }
 
+static int sprd_dma_suspend_noirq(struct device *dev)
+{
+	if ((pm_runtime_status_suspended(dev)) ||
+	    (atomic_read(&(dev->power.usage_count)) > 1))
+		return 0;
+
+	return sprd_dma_runtime_suspend(dev);
+}
+
+static int sprd_dma_resume_early(struct device *dev)
+{
+	if ((pm_runtime_status_suspended(dev)) ||
+	    (atomic_read(&(dev->power.usage_count)) > 1))
+		return 0;
+
+	return sprd_dma_runtime_resume(dev);
+}
+
 static const struct dev_pm_ops sprd_dma_pm_ops = {
 	SET_RUNTIME_PM_OPS(sprd_dma_runtime_suspend,
 			   sprd_dma_runtime_resume,
 			   NULL)
+	SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sprd_dma_suspend_noirq,
+				      sprd_dma_resume_early)
 };
 
 static struct platform_driver sprd_dma_driver = {