kernel: update 3.14 to 3.14.18
[openwrt/openwrt.git] / target / linux / ipq806x / patches / 0118-ata-ahci_platform-runtime-resume-the-device-before-u.patch
1 From abe309ab531f22b9b89329bd825606f6b68a95a1 Mon Sep 17 00:00:00 2001
2 From: Roger Quadros <rogerq@ti.com>
3 Date: Sat, 22 Feb 2014 16:53:41 +0100
4 Subject: [PATCH 118/182] ata: ahci_platform: runtime resume the device before
5 use
6
7 On OMAP platforms the device needs to be runtime resumed before it can
8 be accessed. The OMAP HWMOD framework takes care of enabling the
9 module and its resources based on the device's runtime PM state.
10
11 In this patch we runtime resume during .probe() and runtime suspend
12 after .remove().
13
14 We also update the runtime PM state during .resume().
15
16 CC: Balaji T K <balajitk@ti.com>
17 Signed-off-by: Roger Quadros <rogerq@ti.com>
18 Signed-off-by: Hans de Goede <hdegoede@redhat.com>
19 Signed-off-by: Tejun Heo <tj@kernel.org>
20 ---
21 drivers/ata/ahci.h | 1 +
22 drivers/ata/ahci_platform.c | 15 +++++++++++++++
23 2 files changed, 16 insertions(+)
24
25 --- a/drivers/ata/ahci.h
26 +++ b/drivers/ata/ahci.h
27 @@ -325,6 +325,7 @@ struct ahci_host_priv {
28 u32 em_loc; /* enclosure management location */
29 u32 em_buf_sz; /* EM buffer size in byte */
30 u32 em_msg_type; /* EM message type */
31 + bool got_runtime_pm; /* Did we do pm_runtime_get? */
32 struct clk *clks[AHCI_MAX_CLKS]; /* Optional */
33 struct regulator *target_pwr; /* Optional */
34 struct phy *phy; /* If platform uses phy */
35 --- a/drivers/ata/ahci_platform.c
36 +++ b/drivers/ata/ahci_platform.c
37 @@ -23,6 +23,7 @@
38 #include <linux/libata.h>
39 #include <linux/ahci_platform.h>
40 #include <linux/phy/phy.h>
41 +#include <linux/pm_runtime.h>
42 #include "ahci.h"
43
44 static void ahci_host_stop(struct ata_host *host);
45 @@ -216,6 +217,11 @@ static void ahci_platform_put_resources(
46 struct ahci_host_priv *hpriv = res;
47 int c;
48
49 + if (hpriv->got_runtime_pm) {
50 + pm_runtime_put_sync(dev);
51 + pm_runtime_disable(dev);
52 + }
53 +
54 for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++)
55 clk_put(hpriv->clks[c]);
56 }
57 @@ -309,6 +315,10 @@ struct ahci_host_priv *ahci_platform_get
58 }
59 }
60
61 + pm_runtime_enable(dev);
62 + pm_runtime_get_sync(dev);
63 + hpriv->got_runtime_pm = true;
64 +
65 devres_remove_group(dev, NULL);
66 return hpriv;
67
68 @@ -603,6 +613,11 @@ int ahci_platform_resume(struct device *
69 if (rc)
70 goto disable_resources;
71
72 + /* We resumed so update PM runtime state */
73 + pm_runtime_disable(dev);
74 + pm_runtime_set_active(dev);
75 + pm_runtime_enable(dev);
76 +
77 return 0;
78
79 disable_resources: