aboutsummaryrefslogtreecommitdiffstats
path: root/meta-agl-bsp/meta-renesas/recipes-kernel/linux/linux/hibernation/0015-Add-rcar-usbphy-hibernation-code.patch
blob: c0c2b1675949f7edec4ae191e52625da1eedfb8a (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
From 28393daa686ef43966e3fa1652bcd8d860698ef4 Mon Sep 17 00:00:00 2001
From: Yuichi Kusakabe <yuichi.kusakabe@jp.fujitsu.com>
Date: Thu, 18 May 2017 18:00:39 +0900
Subject: [PATCH 15/15] Add rcar-usbphy hibernation code

Signed-off-by: Yuichi Kusakabe <yuichi.kusakabe@jp.fujitsu.com>
---
 drivers/usb/phy/phy-rcar-gen2-usb.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/drivers/usb/phy/phy-rcar-gen2-usb.c b/drivers/usb/phy/phy-rcar-gen2-usb.c
index 9e7205d..05849e7 100644
--- a/drivers/usb/phy/phy-rcar-gen2-usb.c
+++ b/drivers/usb/phy/phy-rcar-gen2-usb.c
@@ -148,6 +148,7 @@ static int rcar_gen2_usb_phy_set_suspend(struct usb_phy *phy, int suspend)
 
 	devm_release_mem_region(&pdev->dev, res->start, resource_size(res));
 	devm_iounmap(&pdev->dev, priv->base);
+	priv->base = NULL;
 
 	spin_unlock_irqrestore(&priv->lock, flags);
 
@@ -178,6 +179,7 @@ static int rcar_gen2_usb_phy_init(struct usb_phy *phy)
 		devm_release_mem_region(&pdev->dev, res->start,
 							resource_size(res));
 		devm_iounmap(&pdev->dev, priv->base);
+		priv->base = NULL;
 		spin_unlock_irqrestore(&priv->lock, flags);
 	}
 	return 0;
@@ -209,6 +211,7 @@ static void rcar_gen2_usb_phy_shutdown(struct usb_phy *phy)
 		devm_release_mem_region(&pdev->dev, res->start,
 							resource_size(res));
 		devm_iounmap(&pdev->dev, priv->base);
+		priv->base = NULL;
 	}
 out:
 	spin_unlock_irqrestore(&priv->lock, flags);
@@ -431,9 +434,41 @@ static int phy_rcar_gen2_pm_resume(struct device *dev)
 	return 0;
 }
 
+static int phy_rcar_gen2_pm_freeze(struct device *dev)
+{
+	struct rcar_gen2_usb_phy_priv *priv = dev_get_drvdata(dev);
+	pr_info("freeze: %p\n", priv->base);
+
+	return phy_rcar_gen2_pm_suspend(dev);
+}
+
+static int phy_rcar_gen2_pm_restore(struct device *dev)
+{
+	struct rcar_gen2_usb_phy_priv *priv = dev_get_drvdata(dev);
+	struct resource *res;
+
+	res = platform_get_resource(to_platform_device(dev), IORESOURCE_MEM, 0);
+	priv->base = devm_ioremap_resource(dev, res);
+	if (IS_ERR(priv->base)) {
+		pr_info("restore: pointer error %ld\n", PTR_ERR(priv->base));
+		return PTR_ERR(priv->base);
+	}
+	pr_info("restore: %p\n", priv->base);
+	__rcar_gen2_usb_phy_init(priv);
+	devm_release_mem_region(dev, res->start,
+						resource_size(res));
+	devm_iounmap(dev, priv->base);
+	priv->base = NULL;
+	return phy_rcar_gen2_pm_resume(dev);
+}
+
 static const struct dev_pm_ops phy_rcar_gen2_dev_pm_ops = {
 	.suspend	= phy_rcar_gen2_pm_suspend,
 	.resume		= phy_rcar_gen2_pm_resume,
+	.freeze_noirq	= phy_rcar_gen2_pm_freeze,
+	.restore	= phy_rcar_gen2_pm_restore,
+	.thaw		= phy_rcar_gen2_pm_resume,
+	.poweroff	= phy_rcar_gen2_pm_suspend,
 };
 #endif
 
-- 
1.8.3.1