summaryrefslogtreecommitdiffstats
path: root/meta-agl-bsp/meta-renesas/recipes-kernel/linux/linux/hibernation/0001-Add-shdmac-hibernation-code.patch
blob: ad4e4bc0397c27d2ba3e7673def6dbf04c1399f5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
From dfc07c05c50155420e47f85442d099d433db869b Mon Sep 17 00:00:00 2001
From: Yuichi Kusakabe <yuichi.kusakabe@jp.fujitsu.com>
Date: Fri, 9 Jun 2017 20:11:49 +0900
Subject: [PATCH 1/3] Add shdmac hibernation code

Signed-off-by: Yuichi Kusakabe <yuichi.kusakabe@jp.fujitsu.com>
---
 drivers/dma/sh/shdmac.c | 36 ++++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
index 1c97cc5..d084437 100644
--- a/drivers/dma/sh/shdmac.c
+++ b/drivers/dma/sh/shdmac.c
@@ -743,11 +743,20 @@ static int sh_dmae_resume(struct device *dev)
 #define sh_dmae_resume NULL
 #endif
 
+static int sh_dmae_restore(struct device *dev)
+{
+#ifdef CONFIG_PM
+	return sh_dmae_resume(dev);
+#else
+	return 0;
+#endif
+}
+
 const struct dev_pm_ops sh_dmae_pm = {
-	.suspend		= sh_dmae_suspend,
-	.resume			= sh_dmae_resume,
-	.runtime_suspend	= sh_dmae_runtime_suspend,
-	.runtime_resume		= sh_dmae_runtime_resume,
+	SET_SYSTEM_SLEEP_PM_OPS(sh_dmae_suspend, sh_dmae_resume)
+	SET_RUNTIME_PM_OPS(sh_dmae_runtime_suspend, sh_dmae_runtime_resume,
+		NULL)
+	.restore_noirq = sh_dmae_restore,
 };
 
 static dma_addr_t sh_dmae_slave_addr(struct shdma_chan *schan)
@@ -798,7 +807,6 @@ static int sh_dmae_probe(struct platform_device *pdev)
 	struct sh_dmae_device *shdev;
 	struct dma_device *dma_dev;
 	struct resource *chan, *dmars, *errirq_res, *chanirq_res;
-	unsigned long flags;
 
 	if (pdev->dev.of_node)
 		pdata = of_match_device(sh_dmae_of_match, &pdev->dev)->data;
@@ -885,9 +893,9 @@ static int sh_dmae_probe(struct platform_device *pdev)
 	if (err < 0)
 		dev_err(&pdev->dev, "%s(): GET = %d\n", __func__, err);
 
-	spin_lock_irqsave(&sh_dmae_lock, flags);
+	spin_lock_irq(&sh_dmae_lock);
 	list_add_tail_rcu(&shdev->node, &sh_dmae_devices);
-	spin_unlock_irqrestore(&sh_dmae_lock, flags);
+	spin_unlock_irq(&sh_dmae_lock);
 
 	/* reset dma controller - only needed as a test */
 	err = sh_dmae_rst(shdev);
@@ -981,6 +989,7 @@ static int sh_dmae_probe(struct platform_device *pdev)
 	return err;
 
 edmadevreg:
+	pm_runtime_get(&pdev->dev);
 chan_probe_err:
 	sh_dmae_chan_remove(shdev);
 
@@ -988,9 +997,9 @@ chan_probe_err:
 eirq_err:
 #endif
 rst_err:
-	spin_lock_irqsave(&sh_dmae_lock, flags);
+	spin_lock_irq(&sh_dmae_lock);
 	list_del_rcu(&shdev->node);
-	spin_unlock_irqrestore(&sh_dmae_lock, flags);
+	spin_unlock_irq(&sh_dmae_lock);
 
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
@@ -1007,13 +1016,12 @@ static int sh_dmae_remove(struct platform_device *pdev)
 {
 	struct sh_dmae_device *shdev = platform_get_drvdata(pdev);
 	struct dma_device *dma_dev = &shdev->shdma_dev.dma_dev;
-	unsigned long flags;
 
 	dma_async_device_unregister(dma_dev);
 
-	spin_lock_irqsave(&sh_dmae_lock, flags);
+	spin_lock_irq(&sh_dmae_lock);
 	list_del_rcu(&shdev->node);
-	spin_unlock_irqrestore(&sh_dmae_lock, flags);
+	spin_unlock_irq(&sh_dmae_lock);
 
 	pm_runtime_disable(&pdev->dev);
 
@@ -1047,7 +1055,11 @@ static int __init sh_dmae_init(void)
 
 	return platform_driver_probe(&sh_dmae_driver, sh_dmae_probe);
 }
+#ifdef MODULE
 module_init(sh_dmae_init);
+#else
+subsys_initcall(sh_dmae_init);
+#endif
 
 static void __exit sh_dmae_exit(void)
 {
-- 
1.8.3.1