aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2011-04-28 18:36:21 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2011-04-28 18:36:21 -0400
commit38ade3a1fa0421c12627c7b48c33e89414fc9b76 (patch)
tree8efd13e1b6368690c31e30b59e130a0559e05eb6 /arch
parent69c9dd1ecf446ad8a830e4afc539a2a1adc85b78 (diff)
shmobile: Use power domains for platform runtime PM
shmobile platforms replace the runtime PM callbacks of the platform bus type with their own routines, but this means that the callbacks are replaced system-wide. This may not be the right approach if the platform devices on the system are not of the same type (e.g. some of them belong to an SoC and the others are located in separate chips), because in those cases they may require different handling. Thus it is better to use power domains to override the platform bus type's PM handling, as it generally is possible to use different power domains for devices with different PM requirements. Define a default power domain for shmobile in both the SH and ARM falvors and use it to override the platform bus type's PM callbacks. Since the suspend and hibernate callbacks of the new "default" power domains need to be the same and the platform bus type's suspend and hibernate callbacks for the time being, export those callbacks so that can be used outside of the platform bus type code. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-shmobile/pm_runtime.c25
-rw-r--r--arch/sh/kernel/cpu/shmobile/pm_runtime.c33
2 files changed, 40 insertions, 18 deletions
diff --git a/arch/arm/mach-shmobile/pm_runtime.c b/arch/arm/mach-shmobile/pm_runtime.c
index 94912d3944d3..12bb504c7f49 100644
--- a/arch/arm/mach-shmobile/pm_runtime.c
+++ b/arch/arm/mach-shmobile/pm_runtime.c
@@ -66,11 +66,11 @@ static void platform_pm_runtime_bug(struct device *dev,
66 dev_err(dev, "runtime pm suspend before resume\n"); 66 dev_err(dev, "runtime pm suspend before resume\n");
67} 67}
68 68
69int platform_pm_runtime_suspend(struct device *dev) 69static int default_platform_runtime_suspend(struct device *dev)
70{ 70{
71 struct pm_runtime_data *prd = __to_prd(dev); 71 struct pm_runtime_data *prd = __to_prd(dev);
72 72
73 dev_dbg(dev, "platform_pm_runtime_suspend()\n"); 73 dev_dbg(dev, "%s()\n", __func__);
74 74
75 platform_pm_runtime_bug(dev, prd); 75 platform_pm_runtime_bug(dev, prd);
76 76
@@ -82,11 +82,11 @@ int platform_pm_runtime_suspend(struct device *dev)
82 return 0; 82 return 0;
83} 83}
84 84
85int platform_pm_runtime_resume(struct device *dev) 85static int default_platform_runtime_resume(struct device *dev)
86{ 86{
87 struct pm_runtime_data *prd = __to_prd(dev); 87 struct pm_runtime_data *prd = __to_prd(dev);
88 88
89 dev_dbg(dev, "platform_pm_runtime_resume()\n"); 89 dev_dbg(dev, "%s()\n", __func__);
90 90
91 platform_pm_runtime_init(dev, prd); 91 platform_pm_runtime_init(dev, prd);
92 92
@@ -98,12 +98,21 @@ int platform_pm_runtime_resume(struct device *dev)
98 return 0; 98 return 0;
99} 99}
100 100
101int platform_pm_runtime_idle(struct device *dev) 101static int default_platform_runtime_idle(struct device *dev)
102{ 102{
103 /* suspend synchronously to disable clocks immediately */ 103 /* suspend synchronously to disable clocks immediately */
104 return pm_runtime_suspend(dev); 104 return pm_runtime_suspend(dev);
105} 105}
106 106
107static struct dev_power_domain default_power_domain = {
108 .ops = {
109 .runtime_suspend = default_platform_runtime_suspend,
110 .runtime_resume = default_platform_runtime_resume,
111 .runtime_idle = default_platform_runtime_idle,
112 USE_PLATFORM_PM_SLEEP_OPS
113 },
114};
115
107static int platform_bus_notify(struct notifier_block *nb, 116static int platform_bus_notify(struct notifier_block *nb,
108 unsigned long action, void *data) 117 unsigned long action, void *data)
109{ 118{
@@ -114,10 +123,12 @@ static int platform_bus_notify(struct notifier_block *nb,
114 123
115 if (action == BUS_NOTIFY_BIND_DRIVER) { 124 if (action == BUS_NOTIFY_BIND_DRIVER) {
116 prd = devres_alloc(__devres_release, sizeof(*prd), GFP_KERNEL); 125 prd = devres_alloc(__devres_release, sizeof(*prd), GFP_KERNEL);
117 if (prd) 126 if (prd) {
118 devres_add(dev, prd); 127 devres_add(dev, prd);
119 else 128 dev->pwr_domain = &default_power_domain;
129 } else {
120 dev_err(dev, "unable to alloc memory for runtime pm\n"); 130 dev_err(dev, "unable to alloc memory for runtime pm\n");
131 }
121 } 132 }
122 133
123 return 0; 134 return 0;
diff --git a/arch/sh/kernel/cpu/shmobile/pm_runtime.c b/arch/sh/kernel/cpu/shmobile/pm_runtime.c
index 6dcb8166a64d..22db127afa7b 100644
--- a/arch/sh/kernel/cpu/shmobile/pm_runtime.c
+++ b/arch/sh/kernel/cpu/shmobile/pm_runtime.c
@@ -139,7 +139,7 @@ void platform_pm_runtime_suspend_idle(void)
139 queue_work(pm_wq, &hwblk_work); 139 queue_work(pm_wq, &hwblk_work);
140} 140}
141 141
142int platform_pm_runtime_suspend(struct device *dev) 142static int default_platform_runtime_suspend(struct device *dev)
143{ 143{
144 struct platform_device *pdev = to_platform_device(dev); 144 struct platform_device *pdev = to_platform_device(dev);
145 struct pdev_archdata *ad = &pdev->archdata; 145 struct pdev_archdata *ad = &pdev->archdata;
@@ -147,7 +147,7 @@ int platform_pm_runtime_suspend(struct device *dev)
147 int hwblk = ad->hwblk_id; 147 int hwblk = ad->hwblk_id;
148 int ret = 0; 148 int ret = 0;
149 149
150 dev_dbg(dev, "platform_pm_runtime_suspend() [%d]\n", hwblk); 150 dev_dbg(dev, "%s() [%d]\n", __func__, hwblk);
151 151
152 /* ignore off-chip platform devices */ 152 /* ignore off-chip platform devices */
153 if (!hwblk) 153 if (!hwblk)
@@ -183,20 +183,20 @@ int platform_pm_runtime_suspend(struct device *dev)
183 mutex_unlock(&ad->mutex); 183 mutex_unlock(&ad->mutex);
184 184
185out: 185out:
186 dev_dbg(dev, "platform_pm_runtime_suspend() [%d] returns %d\n", 186 dev_dbg(dev, "%s() [%d] returns %d\n",
187 hwblk, ret); 187 __func__, hwblk, ret);
188 188
189 return ret; 189 return ret;
190} 190}
191 191
192int platform_pm_runtime_resume(struct device *dev) 192static int default_platform_runtime_resume(struct device *dev)
193{ 193{
194 struct platform_device *pdev = to_platform_device(dev); 194 struct platform_device *pdev = to_platform_device(dev);
195 struct pdev_archdata *ad = &pdev->archdata; 195 struct pdev_archdata *ad = &pdev->archdata;
196 int hwblk = ad->hwblk_id; 196 int hwblk = ad->hwblk_id;
197 int ret = 0; 197 int ret = 0;
198 198
199 dev_dbg(dev, "platform_pm_runtime_resume() [%d]\n", hwblk); 199 dev_dbg(dev, "%s() [%d]\n", __func__, hwblk);
200 200
201 /* ignore off-chip platform devices */ 201 /* ignore off-chip platform devices */
202 if (!hwblk) 202 if (!hwblk)
@@ -228,19 +228,19 @@ int platform_pm_runtime_resume(struct device *dev)
228 */ 228 */
229 mutex_unlock(&ad->mutex); 229 mutex_unlock(&ad->mutex);
230out: 230out:
231 dev_dbg(dev, "platform_pm_runtime_resume() [%d] returns %d\n", 231 dev_dbg(dev, "%s() [%d] returns %d\n",
232 hwblk, ret); 232 __func__, hwblk, ret);
233 233
234 return ret; 234 return ret;
235} 235}
236 236
237int platform_pm_runtime_idle(struct device *dev) 237static int default_platform_runtime_idle(struct device *dev)
238{ 238{
239 struct platform_device *pdev = to_platform_device(dev); 239 struct platform_device *pdev = to_platform_device(dev);
240 int hwblk = pdev->archdata.hwblk_id; 240 int hwblk = pdev->archdata.hwblk_id;
241 int ret = 0; 241 int ret = 0;
242 242
243 dev_dbg(dev, "platform_pm_runtime_idle() [%d]\n", hwblk); 243 dev_dbg(dev, "%s() [%d]\n", __func__, hwblk);
244 244
245 /* ignore off-chip platform devices */ 245 /* ignore off-chip platform devices */
246 if (!hwblk) 246 if (!hwblk)
@@ -252,10 +252,19 @@ int platform_pm_runtime_idle(struct device *dev)
252 /* suspend synchronously to disable clocks immediately */ 252 /* suspend synchronously to disable clocks immediately */
253 ret = pm_runtime_suspend(dev); 253 ret = pm_runtime_suspend(dev);
254out: 254out:
255 dev_dbg(dev, "platform_pm_runtime_idle() [%d] done!\n", hwblk); 255 dev_dbg(dev, "%s() [%d] done!\n", __func__, hwblk);
256 return ret; 256 return ret;
257} 257}
258 258
259static struct dev_power_domain default_power_domain = {
260 .ops = {
261 .runtime_suspend = default_platform_runtime_suspend,
262 .runtime_resume = default_platform_runtime_resume,
263 .runtime_idle = default_platform_runtime_idle,
264 USE_PLATFORM_PM_SLEEP_OPS
265 },
266};
267
259static int platform_bus_notify(struct notifier_block *nb, 268static int platform_bus_notify(struct notifier_block *nb,
260 unsigned long action, void *data) 269 unsigned long action, void *data)
261{ 270{
@@ -276,6 +285,7 @@ static int platform_bus_notify(struct notifier_block *nb,
276 hwblk_disable(hwblk_info, hwblk); 285 hwblk_disable(hwblk_info, hwblk);
277 /* make sure driver re-inits itself once */ 286 /* make sure driver re-inits itself once */
278 __set_bit(PDEV_ARCHDATA_FLAG_INIT, &pdev->archdata.flags); 287 __set_bit(PDEV_ARCHDATA_FLAG_INIT, &pdev->archdata.flags);
288 dev->pwr_domain = &default_power_domain;
279 break; 289 break;
280 /* TODO: add BUS_NOTIFY_BIND_DRIVER and increase idle count */ 290 /* TODO: add BUS_NOTIFY_BIND_DRIVER and increase idle count */
281 case BUS_NOTIFY_BOUND_DRIVER: 291 case BUS_NOTIFY_BOUND_DRIVER:
@@ -289,6 +299,7 @@ static int platform_bus_notify(struct notifier_block *nb,
289 __set_bit(PDEV_ARCHDATA_FLAG_INIT, &pdev->archdata.flags); 299 __set_bit(PDEV_ARCHDATA_FLAG_INIT, &pdev->archdata.flags);
290 break; 300 break;
291 case BUS_NOTIFY_DEL_DEVICE: 301 case BUS_NOTIFY_DEL_DEVICE:
302 dev->pwr_domain = NULL;
292 break; 303 break;
293 } 304 }
294 return 0; 305 return 0;