Karthik Parsha | 6fb932d | 2012-01-24 18:04:12 -0800 | [diff] [blame] | 1 | /* Copyright (c) 2010-2012, Code Aurora Forum. All rights reserved. |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 2 | * |
| 3 | * This program is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License version 2 and |
| 5 | * only version 2 as published by the Free Software Foundation. |
| 6 | * |
| 7 | * This program is distributed in the hope that it will be useful, |
| 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | * GNU General Public License for more details. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/init.h> |
| 17 | #include <linux/completion.h> |
| 18 | #include <linux/cpuidle.h> |
| 19 | #include <linux/interrupt.h> |
| 20 | #include <linux/io.h> |
| 21 | #include <linux/ktime.h> |
| 22 | #include <linux/pm.h> |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 23 | #include <linux/pm_qos.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 24 | #include <linux/smp.h> |
| 25 | #include <linux/suspend.h> |
| 26 | #include <linux/tick.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 27 | #include <mach/msm_iomap.h> |
Praveen Chidambaram | 192979f | 2012-04-25 18:30:23 -0600 | [diff] [blame] | 28 | #include <mach/socinfo.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 29 | #include <mach/system.h> |
Girish Mahadevan | d27ca4a | 2012-08-15 09:21:23 -0600 | [diff] [blame^] | 30 | #include <mach/scm.h> |
| 31 | #include <mach/socinfo.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 32 | #include <asm/cacheflush.h> |
| 33 | #include <asm/hardware/gic.h> |
| 34 | #include <asm/pgtable.h> |
| 35 | #include <asm/pgalloc.h> |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 36 | #include <asm/hardware/cache-l2x0.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 37 | #ifdef CONFIG_VFP |
| 38 | #include <asm/vfp.h> |
| 39 | #endif |
| 40 | |
| 41 | #include "acpuclock.h" |
| 42 | #include "clock.h" |
| 43 | #include "avs.h" |
Abhijeet Dharmapurikar | efaca4f | 2011-12-27 16:24:07 -0800 | [diff] [blame] | 44 | #include <mach/cpuidle.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 45 | #include "idle.h" |
Matt Wagantall | 7cca464 | 2012-02-01 16:43:24 -0800 | [diff] [blame] | 46 | #include "pm.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 47 | #include "scm-boot.h" |
| 48 | #include "spm.h" |
| 49 | #include "timer.h" |
Maheshkumar Sivasubramanian | 8ccc16e | 2011-10-25 15:59:57 -0600 | [diff] [blame] | 50 | #include "pm-boot.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 51 | |
| 52 | /****************************************************************************** |
| 53 | * Debug Definitions |
| 54 | *****************************************************************************/ |
| 55 | |
| 56 | enum { |
| 57 | MSM_PM_DEBUG_SUSPEND = BIT(0), |
| 58 | MSM_PM_DEBUG_POWER_COLLAPSE = BIT(1), |
| 59 | MSM_PM_DEBUG_SUSPEND_LIMITS = BIT(2), |
| 60 | MSM_PM_DEBUG_CLOCK = BIT(3), |
| 61 | MSM_PM_DEBUG_RESET_VECTOR = BIT(4), |
Karthik Parsha | 6fb932d | 2012-01-24 18:04:12 -0800 | [diff] [blame] | 62 | MSM_PM_DEBUG_IDLE_CLK = BIT(5), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 63 | MSM_PM_DEBUG_IDLE = BIT(6), |
| 64 | MSM_PM_DEBUG_IDLE_LIMITS = BIT(7), |
| 65 | MSM_PM_DEBUG_HOTPLUG = BIT(8), |
| 66 | }; |
| 67 | |
| 68 | static int msm_pm_debug_mask = 1; |
| 69 | module_param_named( |
| 70 | debug_mask, msm_pm_debug_mask, int, S_IRUGO | S_IWUSR | S_IWGRP |
| 71 | ); |
Girish Mahadevan | d27ca4a | 2012-08-15 09:21:23 -0600 | [diff] [blame^] | 72 | static int msm_pm_retention_tz_call; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 73 | |
| 74 | |
| 75 | /****************************************************************************** |
| 76 | * Sleep Modes and Parameters |
| 77 | *****************************************************************************/ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 78 | enum { |
| 79 | MSM_PM_MODE_ATTR_SUSPEND, |
| 80 | MSM_PM_MODE_ATTR_IDLE, |
| 81 | MSM_PM_MODE_ATTR_NR, |
| 82 | }; |
| 83 | |
Girish Mahadevan | d27ca4a | 2012-08-15 09:21:23 -0600 | [diff] [blame^] | 84 | #define SCM_L2_RETENTION (0x2) |
| 85 | #define SCM_CMD_TERMINATE_PC (0x2) |
| 86 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 87 | static char *msm_pm_mode_attr_labels[MSM_PM_MODE_ATTR_NR] = { |
| 88 | [MSM_PM_MODE_ATTR_SUSPEND] = "suspend_enabled", |
| 89 | [MSM_PM_MODE_ATTR_IDLE] = "idle_enabled", |
| 90 | }; |
| 91 | |
| 92 | struct msm_pm_kobj_attribute { |
| 93 | unsigned int cpu; |
| 94 | struct kobj_attribute ka; |
| 95 | }; |
| 96 | |
| 97 | #define GET_CPU_OF_ATTR(attr) \ |
| 98 | (container_of(attr, struct msm_pm_kobj_attribute, ka)->cpu) |
| 99 | |
| 100 | struct msm_pm_sysfs_sleep_mode { |
| 101 | struct kobject *kobj; |
| 102 | struct attribute_group attr_group; |
| 103 | struct attribute *attrs[MSM_PM_MODE_ATTR_NR + 1]; |
| 104 | struct msm_pm_kobj_attribute kas[MSM_PM_MODE_ATTR_NR]; |
| 105 | }; |
| 106 | |
| 107 | static char *msm_pm_sleep_mode_labels[MSM_PM_SLEEP_MODE_NR] = { |
| 108 | [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = "power_collapse", |
| 109 | [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = "wfi", |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 110 | [MSM_PM_SLEEP_MODE_RETENTION] = "retention", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 111 | [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE] = |
| 112 | "standalone_power_collapse", |
| 113 | }; |
| 114 | |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 115 | static struct msm_pm_sleep_ops pm_sleep_ops; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 116 | /* |
| 117 | * Write out the attribute. |
| 118 | */ |
| 119 | static ssize_t msm_pm_mode_attr_show( |
| 120 | struct kobject *kobj, struct kobj_attribute *attr, char *buf) |
| 121 | { |
| 122 | int ret = -EINVAL; |
| 123 | int i; |
| 124 | |
| 125 | for (i = 0; i < MSM_PM_SLEEP_MODE_NR; i++) { |
| 126 | struct kernel_param kp; |
| 127 | unsigned int cpu; |
| 128 | struct msm_pm_platform_data *mode; |
| 129 | |
| 130 | if (msm_pm_sleep_mode_labels[i] == NULL) |
| 131 | continue; |
| 132 | |
| 133 | if (strcmp(kobj->name, msm_pm_sleep_mode_labels[i])) |
| 134 | continue; |
| 135 | |
| 136 | cpu = GET_CPU_OF_ATTR(attr); |
Praveen Chidambaram | 42da9d2 | 2012-03-30 12:16:34 -0600 | [diff] [blame] | 137 | mode = &msm_pm_sleep_modes[MSM_PM_MODE(cpu, i)]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 138 | |
| 139 | if (!strcmp(attr->attr.name, |
| 140 | msm_pm_mode_attr_labels[MSM_PM_MODE_ATTR_SUSPEND])) { |
| 141 | u32 arg = mode->suspend_enabled; |
| 142 | kp.arg = &arg; |
| 143 | ret = param_get_ulong(buf, &kp); |
| 144 | } else if (!strcmp(attr->attr.name, |
| 145 | msm_pm_mode_attr_labels[MSM_PM_MODE_ATTR_IDLE])) { |
| 146 | u32 arg = mode->idle_enabled; |
| 147 | kp.arg = &arg; |
| 148 | ret = param_get_ulong(buf, &kp); |
| 149 | } |
| 150 | |
| 151 | break; |
| 152 | } |
| 153 | |
| 154 | if (ret > 0) { |
Praveen Chidambaram | 2b0fdd0 | 2011-10-28 16:40:58 -0600 | [diff] [blame] | 155 | strlcat(buf, "\n", PAGE_SIZE); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 156 | ret++; |
| 157 | } |
| 158 | |
| 159 | return ret; |
| 160 | } |
| 161 | |
| 162 | /* |
| 163 | * Read in the new attribute value. |
| 164 | */ |
| 165 | static ssize_t msm_pm_mode_attr_store(struct kobject *kobj, |
| 166 | struct kobj_attribute *attr, const char *buf, size_t count) |
| 167 | { |
| 168 | int ret = -EINVAL; |
| 169 | int i; |
| 170 | |
| 171 | for (i = 0; i < MSM_PM_SLEEP_MODE_NR; i++) { |
| 172 | struct kernel_param kp; |
| 173 | unsigned int cpu; |
| 174 | struct msm_pm_platform_data *mode; |
| 175 | |
| 176 | if (msm_pm_sleep_mode_labels[i] == NULL) |
| 177 | continue; |
| 178 | |
| 179 | if (strcmp(kobj->name, msm_pm_sleep_mode_labels[i])) |
| 180 | continue; |
| 181 | |
| 182 | cpu = GET_CPU_OF_ATTR(attr); |
Praveen Chidambaram | 42da9d2 | 2012-03-30 12:16:34 -0600 | [diff] [blame] | 183 | mode = &msm_pm_sleep_modes[MSM_PM_MODE(cpu, i)]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 184 | |
| 185 | if (!strcmp(attr->attr.name, |
| 186 | msm_pm_mode_attr_labels[MSM_PM_MODE_ATTR_SUSPEND])) { |
| 187 | kp.arg = &mode->suspend_enabled; |
| 188 | ret = param_set_byte(buf, &kp); |
| 189 | } else if (!strcmp(attr->attr.name, |
| 190 | msm_pm_mode_attr_labels[MSM_PM_MODE_ATTR_IDLE])) { |
| 191 | kp.arg = &mode->idle_enabled; |
| 192 | ret = param_set_byte(buf, &kp); |
| 193 | } |
| 194 | |
| 195 | break; |
| 196 | } |
| 197 | |
| 198 | return ret ? ret : count; |
| 199 | } |
| 200 | |
| 201 | /* |
| 202 | * Add sysfs entries for one cpu. |
| 203 | */ |
| 204 | static int __init msm_pm_mode_sysfs_add_cpu( |
| 205 | unsigned int cpu, struct kobject *modes_kobj) |
| 206 | { |
| 207 | char cpu_name[8]; |
| 208 | struct kobject *cpu_kobj; |
Praveen Chidambaram | 2b0fdd0 | 2011-10-28 16:40:58 -0600 | [diff] [blame] | 209 | struct msm_pm_sysfs_sleep_mode *mode = NULL; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 210 | int i, j, k; |
| 211 | int ret; |
| 212 | |
| 213 | snprintf(cpu_name, sizeof(cpu_name), "cpu%u", cpu); |
| 214 | cpu_kobj = kobject_create_and_add(cpu_name, modes_kobj); |
| 215 | if (!cpu_kobj) { |
| 216 | pr_err("%s: cannot create %s kobject\n", __func__, cpu_name); |
| 217 | ret = -ENOMEM; |
| 218 | goto mode_sysfs_add_cpu_exit; |
| 219 | } |
| 220 | |
| 221 | for (i = 0; i < MSM_PM_SLEEP_MODE_NR; i++) { |
| 222 | int idx = MSM_PM_MODE(cpu, i); |
| 223 | |
Praveen Chidambaram | 42da9d2 | 2012-03-30 12:16:34 -0600 | [diff] [blame] | 224 | if ((!msm_pm_sleep_modes[idx].suspend_supported) |
| 225 | && (!msm_pm_sleep_modes[idx].idle_supported)) |
| 226 | continue; |
| 227 | |
| 228 | if (!msm_pm_sleep_mode_labels[i] || |
| 229 | !msm_pm_sleep_mode_labels[i][0]) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 230 | continue; |
| 231 | |
| 232 | mode = kzalloc(sizeof(*mode), GFP_KERNEL); |
| 233 | if (!mode) { |
| 234 | pr_err("%s: cannot allocate memory for attributes\n", |
| 235 | __func__); |
| 236 | ret = -ENOMEM; |
| 237 | goto mode_sysfs_add_cpu_exit; |
| 238 | } |
| 239 | |
| 240 | mode->kobj = kobject_create_and_add( |
| 241 | msm_pm_sleep_mode_labels[i], cpu_kobj); |
| 242 | if (!mode->kobj) { |
| 243 | pr_err("%s: cannot create kobject\n", __func__); |
| 244 | ret = -ENOMEM; |
| 245 | goto mode_sysfs_add_cpu_exit; |
| 246 | } |
| 247 | |
| 248 | for (k = 0, j = 0; k < MSM_PM_MODE_ATTR_NR; k++) { |
| 249 | if ((k == MSM_PM_MODE_ATTR_IDLE) && |
Praveen Chidambaram | 42da9d2 | 2012-03-30 12:16:34 -0600 | [diff] [blame] | 250 | !msm_pm_sleep_modes[idx].idle_supported) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 251 | continue; |
| 252 | if ((k == MSM_PM_MODE_ATTR_SUSPEND) && |
Praveen Chidambaram | 42da9d2 | 2012-03-30 12:16:34 -0600 | [diff] [blame] | 253 | !msm_pm_sleep_modes[idx].suspend_supported) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 254 | continue; |
Stephen Boyd | d2059c3 | 2012-07-03 15:11:15 -0700 | [diff] [blame] | 255 | sysfs_attr_init(&mode->kas[j].ka.attr); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 256 | mode->kas[j].cpu = cpu; |
| 257 | mode->kas[j].ka.attr.mode = 0644; |
| 258 | mode->kas[j].ka.show = msm_pm_mode_attr_show; |
| 259 | mode->kas[j].ka.store = msm_pm_mode_attr_store; |
| 260 | mode->kas[j].ka.attr.name = msm_pm_mode_attr_labels[k]; |
| 261 | mode->attrs[j] = &mode->kas[j].ka.attr; |
| 262 | j++; |
| 263 | } |
| 264 | mode->attrs[j] = NULL; |
| 265 | |
| 266 | mode->attr_group.attrs = mode->attrs; |
| 267 | ret = sysfs_create_group(mode->kobj, &mode->attr_group); |
| 268 | if (ret) { |
| 269 | pr_err("%s: cannot create kobject attribute group\n", |
| 270 | __func__); |
| 271 | goto mode_sysfs_add_cpu_exit; |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | ret = 0; |
| 276 | |
| 277 | mode_sysfs_add_cpu_exit: |
Praveen Chidambaram | d5ac2d3 | 2011-10-24 14:30:27 -0600 | [diff] [blame] | 278 | if (ret) { |
Praveen Chidambaram | 2cfda63 | 2011-10-11 16:58:09 -0600 | [diff] [blame] | 279 | if (mode && mode->kobj) |
| 280 | kobject_del(mode->kobj); |
| 281 | kfree(mode); |
| 282 | } |
| 283 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 284 | return ret; |
| 285 | } |
| 286 | |
| 287 | /* |
| 288 | * Add sysfs entries for the sleep modes. |
| 289 | */ |
| 290 | static int __init msm_pm_mode_sysfs_add(void) |
| 291 | { |
| 292 | struct kobject *module_kobj; |
| 293 | struct kobject *modes_kobj; |
| 294 | unsigned int cpu; |
| 295 | int ret; |
| 296 | |
| 297 | module_kobj = kset_find_obj(module_kset, KBUILD_MODNAME); |
| 298 | if (!module_kobj) { |
| 299 | pr_err("%s: cannot find kobject for module %s\n", |
| 300 | __func__, KBUILD_MODNAME); |
| 301 | ret = -ENOENT; |
| 302 | goto mode_sysfs_add_exit; |
| 303 | } |
| 304 | |
| 305 | modes_kobj = kobject_create_and_add("modes", module_kobj); |
| 306 | if (!modes_kobj) { |
| 307 | pr_err("%s: cannot create modes kobject\n", __func__); |
| 308 | ret = -ENOMEM; |
| 309 | goto mode_sysfs_add_exit; |
| 310 | } |
| 311 | |
| 312 | for_each_possible_cpu(cpu) { |
| 313 | ret = msm_pm_mode_sysfs_add_cpu(cpu, modes_kobj); |
| 314 | if (ret) |
| 315 | goto mode_sysfs_add_exit; |
| 316 | } |
| 317 | |
| 318 | ret = 0; |
| 319 | |
| 320 | mode_sysfs_add_exit: |
| 321 | return ret; |
| 322 | } |
| 323 | |
| 324 | /****************************************************************************** |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 325 | * Configure Hardware before/after Low Power Mode |
| 326 | *****************************************************************************/ |
| 327 | |
| 328 | /* |
| 329 | * Configure hardware registers in preparation for Apps power down. |
| 330 | */ |
| 331 | static void msm_pm_config_hw_before_power_down(void) |
| 332 | { |
| 333 | return; |
| 334 | } |
| 335 | |
| 336 | /* |
| 337 | * Clear hardware registers after Apps powers up. |
| 338 | */ |
| 339 | static void msm_pm_config_hw_after_power_up(void) |
| 340 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | /* |
| 344 | * Configure hardware registers in preparation for SWFI. |
| 345 | */ |
| 346 | static void msm_pm_config_hw_before_swfi(void) |
| 347 | { |
| 348 | return; |
| 349 | } |
| 350 | |
Girish Mahadevan | d27ca4a | 2012-08-15 09:21:23 -0600 | [diff] [blame^] | 351 | /* |
| 352 | * Configure/Restore hardware registers in preparation for Retention. |
| 353 | */ |
| 354 | |
| 355 | static void msm_pm_config_hw_after_retention(void) |
| 356 | { |
| 357 | int ret; |
| 358 | ret = msm_spm_set_low_power_mode(MSM_SPM_MODE_CLOCK_GATING, false); |
| 359 | WARN_ON(ret); |
| 360 | } |
| 361 | |
| 362 | static void msm_pm_config_hw_before_retention(void) |
| 363 | { |
| 364 | return; |
| 365 | } |
| 366 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 367 | |
| 368 | /****************************************************************************** |
| 369 | * Suspend Max Sleep Time |
| 370 | *****************************************************************************/ |
| 371 | |
| 372 | #ifdef CONFIG_MSM_SLEEP_TIME_OVERRIDE |
| 373 | static int msm_pm_sleep_time_override; |
| 374 | module_param_named(sleep_time_override, |
| 375 | msm_pm_sleep_time_override, int, S_IRUGO | S_IWUSR | S_IWGRP); |
| 376 | #endif |
| 377 | |
| 378 | #define SCLK_HZ (32768) |
| 379 | #define MSM_PM_SLEEP_TICK_LIMIT (0x6DDD000) |
| 380 | |
| 381 | static uint32_t msm_pm_max_sleep_time; |
| 382 | |
| 383 | /* |
| 384 | * Convert time from nanoseconds to slow clock ticks, then cap it to the |
| 385 | * specified limit |
| 386 | */ |
| 387 | static int64_t msm_pm_convert_and_cap_time(int64_t time_ns, int64_t limit) |
| 388 | { |
| 389 | do_div(time_ns, NSEC_PER_SEC / SCLK_HZ); |
| 390 | return (time_ns > limit) ? limit : time_ns; |
| 391 | } |
| 392 | |
| 393 | /* |
| 394 | * Set the sleep time for suspend. 0 means infinite sleep time. |
| 395 | */ |
| 396 | void msm_pm_set_max_sleep_time(int64_t max_sleep_time_ns) |
| 397 | { |
| 398 | if (max_sleep_time_ns == 0) { |
| 399 | msm_pm_max_sleep_time = 0; |
| 400 | } else { |
| 401 | msm_pm_max_sleep_time = (uint32_t)msm_pm_convert_and_cap_time( |
| 402 | max_sleep_time_ns, MSM_PM_SLEEP_TICK_LIMIT); |
| 403 | |
| 404 | if (msm_pm_max_sleep_time == 0) |
| 405 | msm_pm_max_sleep_time = 1; |
| 406 | } |
| 407 | |
| 408 | if (msm_pm_debug_mask & MSM_PM_DEBUG_SUSPEND) |
| 409 | pr_info("%s: Requested %lld ns Giving %u sclk ticks\n", |
| 410 | __func__, max_sleep_time_ns, msm_pm_max_sleep_time); |
| 411 | } |
| 412 | EXPORT_SYMBOL(msm_pm_set_max_sleep_time); |
| 413 | |
| 414 | |
| 415 | /****************************************************************************** |
| 416 | * |
| 417 | *****************************************************************************/ |
| 418 | |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 419 | static void *msm_pm_idle_rs_limits; |
Praveen Chidambaram | 192979f | 2012-04-25 18:30:23 -0600 | [diff] [blame] | 420 | static bool msm_pm_use_qtimer; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 421 | |
| 422 | static void msm_pm_swfi(void) |
| 423 | { |
| 424 | msm_pm_config_hw_before_swfi(); |
| 425 | msm_arch_idle(); |
| 426 | } |
| 427 | |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 428 | |
| 429 | static void msm_pm_retention(void) |
| 430 | { |
| 431 | int ret = 0; |
| 432 | |
Girish Mahadevan | d27ca4a | 2012-08-15 09:21:23 -0600 | [diff] [blame^] | 433 | msm_pm_config_hw_before_retention(); |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 434 | ret = msm_spm_set_low_power_mode(MSM_SPM_MODE_POWER_RETENTION, false); |
| 435 | WARN_ON(ret); |
Girish Mahadevan | d27ca4a | 2012-08-15 09:21:23 -0600 | [diff] [blame^] | 436 | |
| 437 | if (msm_pm_retention_tz_call) |
| 438 | scm_call_atomic1(SCM_SVC_BOOT, SCM_CMD_TERMINATE_PC, |
| 439 | SCM_L2_RETENTION); |
| 440 | else |
| 441 | msm_arch_idle(); |
| 442 | |
| 443 | msm_pm_config_hw_after_retention(); |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 444 | } |
| 445 | |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 446 | #ifdef CONFIG_CACHE_L2X0 |
| 447 | static inline bool msm_pm_l2x0_power_collapse(void) |
| 448 | { |
| 449 | bool collapsed = 0; |
| 450 | |
Taniya Das | 38a8c6e | 2012-05-09 20:34:39 +0530 | [diff] [blame] | 451 | l2cc_suspend(); |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 452 | collapsed = msm_pm_collapse(); |
Taniya Das | 38a8c6e | 2012-05-09 20:34:39 +0530 | [diff] [blame] | 453 | l2cc_resume(); |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 454 | |
| 455 | return collapsed; |
| 456 | } |
| 457 | #else |
| 458 | static inline bool msm_pm_l2x0_power_collapse(void) |
| 459 | { |
| 460 | return msm_pm_collapse(); |
| 461 | } |
| 462 | #endif |
| 463 | |
Stephen Boyd | b29750d | 2012-02-21 01:21:32 -0800 | [diff] [blame] | 464 | static bool __ref msm_pm_spm_power_collapse( |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 465 | unsigned int cpu, bool from_idle, bool notify_rpm) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 466 | { |
| 467 | void *entry; |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 468 | bool collapsed = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 469 | int ret; |
Rohit Vaswani | e78dfb6 | 2012-02-21 10:29:29 -0800 | [diff] [blame] | 470 | unsigned int saved_gic_cpu_ctrl; |
| 471 | |
| 472 | saved_gic_cpu_ctrl = readl_relaxed(MSM_QGIC_CPU_BASE + GIC_CPU_CTRL); |
| 473 | mb(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 474 | |
| 475 | if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask) |
| 476 | pr_info("CPU%u: %s: notify_rpm %d\n", |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 477 | cpu, __func__, (int) notify_rpm); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 478 | |
| 479 | ret = msm_spm_set_low_power_mode( |
| 480 | MSM_SPM_MODE_POWER_COLLAPSE, notify_rpm); |
| 481 | WARN_ON(ret); |
| 482 | |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 483 | entry = (!cpu || from_idle) ? |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 484 | msm_pm_collapse_exit : msm_secondary_startup; |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 485 | msm_pm_boot_config_before_pc(cpu, virt_to_phys(entry)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 486 | |
| 487 | if (MSM_PM_DEBUG_RESET_VECTOR & msm_pm_debug_mask) |
| 488 | pr_info("CPU%u: %s: program vector to %p\n", |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 489 | cpu, __func__, entry); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 490 | |
| 491 | #ifdef CONFIG_VFP |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 492 | vfp_pm_suspend(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 493 | #endif |
| 494 | |
Maheshkumar Sivasubramanian | c6c5503 | 2011-10-25 16:01:32 -0600 | [diff] [blame] | 495 | collapsed = msm_pm_l2x0_power_collapse(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 496 | |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 497 | msm_pm_boot_config_after_pc(cpu); |
Maheshkumar Sivasubramanian | 8ccc16e | 2011-10-25 15:59:57 -0600 | [diff] [blame] | 498 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 499 | if (collapsed) { |
| 500 | #ifdef CONFIG_VFP |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 501 | vfp_pm_resume(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 502 | #endif |
| 503 | cpu_init(); |
| 504 | writel(0xF0, MSM_QGIC_CPU_BASE + GIC_CPU_PRIMASK); |
Rohit Vaswani | e78dfb6 | 2012-02-21 10:29:29 -0800 | [diff] [blame] | 505 | writel_relaxed(saved_gic_cpu_ctrl, |
| 506 | MSM_QGIC_CPU_BASE + GIC_CPU_CTRL); |
| 507 | mb(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 508 | local_fiq_enable(); |
| 509 | } |
| 510 | |
| 511 | if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask) |
| 512 | pr_info("CPU%u: %s: msm_pm_collapse returned, collapsed %d\n", |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 513 | cpu, __func__, collapsed); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 514 | |
| 515 | ret = msm_spm_set_low_power_mode(MSM_SPM_MODE_CLOCK_GATING, false); |
| 516 | WARN_ON(ret); |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 517 | return collapsed; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 518 | } |
| 519 | |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 520 | static bool msm_pm_power_collapse_standalone(bool from_idle) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 521 | { |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 522 | unsigned int cpu = smp_processor_id(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 523 | unsigned int avsdscr_setting; |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 524 | bool collapsed; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 525 | |
| 526 | avsdscr_setting = avs_get_avsdscr(); |
| 527 | avs_disable(); |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 528 | collapsed = msm_pm_spm_power_collapse(cpu, from_idle, false); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 529 | avs_reset_delays(avsdscr_setting); |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 530 | return collapsed; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 531 | } |
| 532 | |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 533 | static bool msm_pm_power_collapse(bool from_idle) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 534 | { |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 535 | unsigned int cpu = smp_processor_id(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 536 | unsigned long saved_acpuclk_rate; |
| 537 | unsigned int avsdscr_setting; |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 538 | bool collapsed; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 539 | |
| 540 | if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask) |
| 541 | pr_info("CPU%u: %s: idle %d\n", |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 542 | cpu, __func__, (int)from_idle); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 543 | |
| 544 | msm_pm_config_hw_before_power_down(); |
| 545 | if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask) |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 546 | pr_info("CPU%u: %s: pre power down\n", cpu, __func__); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 547 | |
| 548 | avsdscr_setting = avs_get_avsdscr(); |
| 549 | avs_disable(); |
| 550 | |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 551 | if (cpu_online(cpu)) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 552 | saved_acpuclk_rate = acpuclk_power_collapse(); |
| 553 | else |
| 554 | saved_acpuclk_rate = 0; |
| 555 | |
| 556 | if (MSM_PM_DEBUG_CLOCK & msm_pm_debug_mask) |
| 557 | pr_info("CPU%u: %s: change clock rate (old rate = %lu)\n", |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 558 | cpu, __func__, saved_acpuclk_rate); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 559 | |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 560 | collapsed = msm_pm_spm_power_collapse(cpu, from_idle, true); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 561 | |
Girish Mahadevan | 4e025d9 | 2012-02-29 13:26:51 -0700 | [diff] [blame] | 562 | if (cpu_online(cpu)) { |
| 563 | if (MSM_PM_DEBUG_CLOCK & msm_pm_debug_mask) |
| 564 | pr_info("CPU%u: %s: restore clock rate to %lu\n", |
| 565 | cpu, __func__, saved_acpuclk_rate); |
| 566 | if (acpuclk_set_rate(cpu, saved_acpuclk_rate, SETRATE_PC) < 0) |
| 567 | pr_err("CPU%u: %s: failed to restore clock rate(%lu)\n", |
| 568 | cpu, __func__, saved_acpuclk_rate); |
| 569 | } else { |
| 570 | unsigned int gic_dist_enabled; |
| 571 | unsigned int gic_dist_pending; |
| 572 | gic_dist_enabled = readl_relaxed( |
| 573 | MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_CLEAR); |
| 574 | gic_dist_pending = readl_relaxed( |
| 575 | MSM_QGIC_DIST_BASE + GIC_DIST_PENDING_SET); |
| 576 | mb(); |
| 577 | gic_dist_pending &= gic_dist_enabled; |
| 578 | |
| 579 | if (gic_dist_pending) |
| 580 | pr_err("CPU %d interrupted during hotplug.Pending int 0x%x\n", |
| 581 | cpu, gic_dist_pending); |
| 582 | } |
| 583 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 584 | |
| 585 | avs_reset_delays(avsdscr_setting); |
| 586 | msm_pm_config_hw_after_power_up(); |
| 587 | if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask) |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 588 | pr_info("CPU%u: %s: post power up\n", cpu, __func__); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 589 | |
| 590 | if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask) |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 591 | pr_info("CPU%u: %s: return\n", cpu, __func__); |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 592 | return collapsed; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 593 | } |
| 594 | |
Praveen Chidambaram | 192979f | 2012-04-25 18:30:23 -0600 | [diff] [blame] | 595 | static void msm_pm_qtimer_available(void) |
| 596 | { |
Abhimanyu Kapur | 90ced6e | 2012-06-26 17:41:25 -0700 | [diff] [blame] | 597 | if (machine_is_msm8974()) |
Praveen Chidambaram | 192979f | 2012-04-25 18:30:23 -0600 | [diff] [blame] | 598 | msm_pm_use_qtimer = true; |
| 599 | } |
| 600 | |
| 601 | static int64_t msm_pm_timer_enter_idle(void) |
| 602 | { |
| 603 | if (msm_pm_use_qtimer) |
| 604 | return ktime_to_ns(tick_nohz_get_sleep_length()); |
| 605 | |
| 606 | return msm_timer_enter_idle(); |
| 607 | } |
| 608 | |
| 609 | static void msm_pm_timer_exit_idle(bool timer_halted) |
| 610 | { |
| 611 | if (msm_pm_use_qtimer) |
| 612 | return; |
| 613 | |
| 614 | msm_timer_exit_idle((int) timer_halted); |
| 615 | } |
| 616 | |
Praveen Chidambaram | 3895bde | 2012-05-14 19:42:40 +0530 | [diff] [blame] | 617 | static int64_t msm_pm_timer_enter_suspend(int64_t *period) |
| 618 | { |
Anji Jonnala | c02367a | 2012-07-01 02:56:11 +0530 | [diff] [blame] | 619 | int64_t time = 0; |
Praveen Chidambaram | 3895bde | 2012-05-14 19:42:40 +0530 | [diff] [blame] | 620 | |
| 621 | if (msm_pm_use_qtimer) |
| 622 | return sched_clock(); |
| 623 | |
| 624 | time = msm_timer_get_sclk_time(period); |
| 625 | if (!time) |
| 626 | pr_err("%s: Unable to read sclk.\n", __func__); |
| 627 | |
| 628 | return time; |
| 629 | } |
| 630 | |
| 631 | static int64_t msm_pm_timer_exit_suspend(int64_t time, int64_t period) |
| 632 | { |
| 633 | if (msm_pm_use_qtimer) |
| 634 | return sched_clock() - time; |
| 635 | |
| 636 | if (time != 0) { |
| 637 | int64_t end_time = msm_timer_get_sclk_time(NULL); |
| 638 | if (end_time != 0) { |
| 639 | time = end_time - time; |
| 640 | if (time < 0) |
| 641 | time += period; |
| 642 | } else |
| 643 | time = 0; |
| 644 | } |
| 645 | |
| 646 | return time; |
| 647 | } |
| 648 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 649 | /****************************************************************************** |
| 650 | * External Idle/Suspend Functions |
| 651 | *****************************************************************************/ |
| 652 | |
| 653 | void arch_idle(void) |
| 654 | { |
| 655 | return; |
| 656 | } |
| 657 | |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 658 | int msm_pm_idle_prepare(struct cpuidle_device *dev, |
| 659 | struct cpuidle_driver *drv, int index) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 660 | { |
| 661 | uint32_t latency_us; |
| 662 | uint32_t sleep_us; |
| 663 | int i; |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 664 | unsigned int power_usage = -1; |
| 665 | int ret = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 666 | |
| 667 | latency_us = (uint32_t) pm_qos_request(PM_QOS_CPU_DMA_LATENCY); |
| 668 | sleep_us = (uint32_t) ktime_to_ns(tick_nohz_get_sleep_length()); |
| 669 | sleep_us = DIV_ROUND_UP(sleep_us, 1000); |
| 670 | |
| 671 | for (i = 0; i < dev->state_count; i++) { |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 672 | struct cpuidle_state *state = &drv->states[i]; |
| 673 | struct cpuidle_state_usage *st_usage = &dev->states_usage[i]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 674 | enum msm_pm_sleep_mode mode; |
| 675 | bool allow; |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 676 | void *rs_limits = NULL; |
| 677 | uint32_t power; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 678 | int idx; |
| 679 | |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 680 | mode = (enum msm_pm_sleep_mode) cpuidle_get_statedata(st_usage); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 681 | idx = MSM_PM_MODE(dev->cpu, mode); |
| 682 | |
Praveen Chidambaram | 42da9d2 | 2012-03-30 12:16:34 -0600 | [diff] [blame] | 683 | allow = msm_pm_sleep_modes[idx].idle_enabled && |
| 684 | msm_pm_sleep_modes[idx].idle_supported; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 685 | |
| 686 | switch (mode) { |
| 687 | case MSM_PM_SLEEP_MODE_POWER_COLLAPSE: |
| 688 | if (!allow) |
| 689 | break; |
| 690 | |
| 691 | if (num_online_cpus() > 1) { |
| 692 | allow = false; |
| 693 | break; |
| 694 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 695 | /* fall through */ |
| 696 | |
| 697 | case MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE: |
| 698 | if (!allow) |
| 699 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 700 | /* fall through */ |
| 701 | |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 702 | case MSM_PM_SLEEP_MODE_RETENTION: |
| 703 | if (!allow) |
| 704 | break; |
Girish Mahadevan | d27ca4a | 2012-08-15 09:21:23 -0600 | [diff] [blame^] | 705 | if (num_online_cpus() > 1) { |
| 706 | allow = false; |
| 707 | break; |
| 708 | } |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 709 | /* fall through */ |
| 710 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 711 | case MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT: |
| 712 | if (!allow) |
| 713 | break; |
| 714 | |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 715 | if (pm_sleep_ops.lowest_limits) |
| 716 | rs_limits = pm_sleep_ops.lowest_limits(true, |
| 717 | mode, latency_us, sleep_us, |
| 718 | &power); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 719 | |
| 720 | if (MSM_PM_DEBUG_IDLE & msm_pm_debug_mask) |
| 721 | pr_info("CPU%u: %s: %s, latency %uus, " |
| 722 | "sleep %uus, limit %p\n", |
| 723 | dev->cpu, __func__, state->desc, |
| 724 | latency_us, sleep_us, rs_limits); |
| 725 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 726 | if (!rs_limits) |
| 727 | allow = false; |
| 728 | break; |
| 729 | |
| 730 | default: |
| 731 | allow = false; |
| 732 | break; |
| 733 | } |
| 734 | |
| 735 | if (MSM_PM_DEBUG_IDLE & msm_pm_debug_mask) |
| 736 | pr_info("CPU%u: %s: allow %s: %d\n", |
| 737 | dev->cpu, __func__, state->desc, (int)allow); |
| 738 | |
| 739 | if (allow) { |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 740 | if (power < power_usage) { |
| 741 | power_usage = power; |
| 742 | ret = mode; |
| 743 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 744 | |
| 745 | if (MSM_PM_SLEEP_MODE_POWER_COLLAPSE == mode) |
| 746 | msm_pm_idle_rs_limits = rs_limits; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 747 | } |
| 748 | } |
| 749 | |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 750 | return ret; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 751 | } |
| 752 | |
| 753 | int msm_pm_idle_enter(enum msm_pm_sleep_mode sleep_mode) |
| 754 | { |
| 755 | int64_t time; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 756 | int exit_stat; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 757 | |
| 758 | if (MSM_PM_DEBUG_IDLE & msm_pm_debug_mask) |
| 759 | pr_info("CPU%u: %s: mode %d\n", |
| 760 | smp_processor_id(), __func__, sleep_mode); |
| 761 | |
| 762 | time = ktime_to_ns(ktime_get()); |
| 763 | |
| 764 | switch (sleep_mode) { |
| 765 | case MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT: |
| 766 | msm_pm_swfi(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 767 | exit_stat = MSM_PM_STAT_IDLE_WFI; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 768 | break; |
| 769 | |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 770 | case MSM_PM_SLEEP_MODE_RETENTION: |
| 771 | msm_pm_retention(); |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 772 | exit_stat = MSM_PM_STAT_RETENTION; |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 773 | break; |
| 774 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 775 | case MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE: |
| 776 | msm_pm_power_collapse_standalone(true); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 777 | exit_stat = MSM_PM_STAT_IDLE_STANDALONE_POWER_COLLAPSE; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 778 | break; |
| 779 | |
| 780 | case MSM_PM_SLEEP_MODE_POWER_COLLAPSE: { |
Praveen Chidambaram | 192979f | 2012-04-25 18:30:23 -0600 | [diff] [blame] | 781 | int64_t timer_expiration = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 782 | bool timer_halted = false; |
| 783 | uint32_t sleep_delay; |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 784 | int ret = -ENODEV; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 785 | int notify_rpm = |
| 786 | (sleep_mode == MSM_PM_SLEEP_MODE_POWER_COLLAPSE); |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 787 | int collapsed; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 788 | |
Praveen Chidambaram | 192979f | 2012-04-25 18:30:23 -0600 | [diff] [blame] | 789 | timer_expiration = msm_pm_timer_enter_idle(); |
| 790 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 791 | sleep_delay = (uint32_t) msm_pm_convert_and_cap_time( |
| 792 | timer_expiration, MSM_PM_SLEEP_TICK_LIMIT); |
| 793 | if (sleep_delay == 0) /* 0 would mean infinite time */ |
| 794 | sleep_delay = 1; |
| 795 | |
Karthik Parsha | 6fb932d | 2012-01-24 18:04:12 -0800 | [diff] [blame] | 796 | if (MSM_PM_DEBUG_IDLE_CLK & msm_pm_debug_mask) |
| 797 | clock_debug_print_enabled(); |
| 798 | |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 799 | if (pm_sleep_ops.enter_sleep) |
| 800 | ret = pm_sleep_ops.enter_sleep(sleep_delay, |
| 801 | msm_pm_idle_rs_limits, |
| 802 | true, notify_rpm); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 803 | if (!ret) { |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 804 | collapsed = msm_pm_power_collapse(true); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 805 | timer_halted = true; |
| 806 | |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 807 | if (pm_sleep_ops.exit_sleep) |
| 808 | pm_sleep_ops.exit_sleep(msm_pm_idle_rs_limits, |
| 809 | true, notify_rpm, collapsed); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 810 | } |
Praveen Chidambaram | 192979f | 2012-04-25 18:30:23 -0600 | [diff] [blame] | 811 | msm_pm_timer_exit_idle(timer_halted); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 812 | exit_stat = MSM_PM_STAT_IDLE_POWER_COLLAPSE; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 813 | break; |
| 814 | } |
| 815 | |
| 816 | default: |
| 817 | __WARN(); |
| 818 | goto cpuidle_enter_bail; |
| 819 | } |
| 820 | |
| 821 | time = ktime_to_ns(ktime_get()) - time; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 822 | msm_pm_add_stat(exit_stat, time); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 823 | |
| 824 | do_div(time, 1000); |
| 825 | return (int) time; |
| 826 | |
| 827 | cpuidle_enter_bail: |
| 828 | return 0; |
| 829 | } |
| 830 | |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 831 | void msm_pm_cpu_enter_lowpower(unsigned int cpu) |
| 832 | { |
| 833 | int i; |
| 834 | bool allow[MSM_PM_SLEEP_MODE_NR]; |
| 835 | |
| 836 | for (i = 0; i < MSM_PM_SLEEP_MODE_NR; i++) { |
| 837 | struct msm_pm_platform_data *mode; |
| 838 | |
Praveen Chidambaram | 42da9d2 | 2012-03-30 12:16:34 -0600 | [diff] [blame] | 839 | mode = &msm_pm_sleep_modes[MSM_PM_MODE(cpu, i)]; |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 840 | allow[i] = mode->suspend_supported && mode->suspend_enabled; |
| 841 | } |
| 842 | |
| 843 | if (MSM_PM_DEBUG_HOTPLUG & msm_pm_debug_mask) |
| 844 | pr_notice("CPU%u: %s: shutting down cpu\n", cpu, __func__); |
| 845 | |
Matt Wagantall | 5375aa7 | 2012-07-02 19:59:51 -0700 | [diff] [blame] | 846 | if (allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE]) |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 847 | msm_pm_power_collapse(false); |
Matt Wagantall | 5375aa7 | 2012-07-02 19:59:51 -0700 | [diff] [blame] | 848 | else if (allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE]) |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 849 | msm_pm_power_collapse_standalone(false); |
Matt Wagantall | 5375aa7 | 2012-07-02 19:59:51 -0700 | [diff] [blame] | 850 | else if (allow[MSM_PM_SLEEP_MODE_RETENTION]) |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 851 | msm_pm_retention(); |
Stephen Boyd | bda7427 | 2012-08-09 14:01:27 -0700 | [diff] [blame] | 852 | else |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 853 | msm_pm_swfi(); |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 854 | } |
| 855 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 856 | static int msm_pm_enter(suspend_state_t state) |
| 857 | { |
| 858 | bool allow[MSM_PM_SLEEP_MODE_NR]; |
| 859 | int i; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 860 | int64_t period = 0; |
Praveen Chidambaram | 3895bde | 2012-05-14 19:42:40 +0530 | [diff] [blame] | 861 | int64_t time = msm_pm_timer_enter_suspend(&period); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 862 | |
| 863 | if (MSM_PM_DEBUG_SUSPEND & msm_pm_debug_mask) |
| 864 | pr_info("%s\n", __func__); |
| 865 | |
| 866 | if (smp_processor_id()) { |
| 867 | __WARN(); |
| 868 | goto enter_exit; |
| 869 | } |
| 870 | |
| 871 | |
| 872 | for (i = 0; i < MSM_PM_SLEEP_MODE_NR; i++) { |
| 873 | struct msm_pm_platform_data *mode; |
| 874 | |
Praveen Chidambaram | 42da9d2 | 2012-03-30 12:16:34 -0600 | [diff] [blame] | 875 | mode = &msm_pm_sleep_modes[MSM_PM_MODE(0, i)]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 876 | allow[i] = mode->suspend_supported && mode->suspend_enabled; |
| 877 | } |
| 878 | |
| 879 | if (allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE]) { |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 880 | void *rs_limits = NULL; |
| 881 | int ret = -ENODEV; |
| 882 | uint32_t power; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 883 | |
| 884 | if (MSM_PM_DEBUG_SUSPEND & msm_pm_debug_mask) |
| 885 | pr_info("%s: power collapse\n", __func__); |
| 886 | |
| 887 | clock_debug_print_enabled(); |
| 888 | |
| 889 | #ifdef CONFIG_MSM_SLEEP_TIME_OVERRIDE |
| 890 | if (msm_pm_sleep_time_override > 0) { |
| 891 | int64_t ns = NSEC_PER_SEC * |
| 892 | (int64_t) msm_pm_sleep_time_override; |
| 893 | msm_pm_set_max_sleep_time(ns); |
| 894 | msm_pm_sleep_time_override = 0; |
| 895 | } |
| 896 | #endif /* CONFIG_MSM_SLEEP_TIME_OVERRIDE */ |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 897 | if (pm_sleep_ops.lowest_limits) |
| 898 | rs_limits = pm_sleep_ops.lowest_limits(false, |
| 899 | MSM_PM_SLEEP_MODE_POWER_COLLAPSE, -1, |
| 900 | -1, &power); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 901 | |
| 902 | if (rs_limits) { |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 903 | if (pm_sleep_ops.enter_sleep) |
| 904 | ret = pm_sleep_ops.enter_sleep( |
| 905 | msm_pm_max_sleep_time, |
| 906 | rs_limits, false, true); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 907 | if (!ret) { |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 908 | int collapsed = msm_pm_power_collapse(false); |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 909 | if (pm_sleep_ops.exit_sleep) { |
| 910 | pm_sleep_ops.exit_sleep(rs_limits, |
| 911 | false, true, collapsed); |
| 912 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 913 | } |
| 914 | } else { |
| 915 | pr_err("%s: cannot find the lowest power limit\n", |
| 916 | __func__); |
| 917 | } |
Praveen Chidambaram | 3895bde | 2012-05-14 19:42:40 +0530 | [diff] [blame] | 918 | time = msm_pm_timer_exit_suspend(time, period); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 919 | msm_pm_add_stat(MSM_PM_STAT_SUSPEND, time); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 920 | } else if (allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE]) { |
| 921 | if (MSM_PM_DEBUG_SUSPEND & msm_pm_debug_mask) |
| 922 | pr_info("%s: standalone power collapse\n", __func__); |
| 923 | msm_pm_power_collapse_standalone(false); |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 924 | } else if (allow[MSM_PM_SLEEP_MODE_RETENTION]) { |
| 925 | if (MSM_PM_DEBUG_SUSPEND & msm_pm_debug_mask) |
| 926 | pr_info("%s: retention\n", __func__); |
| 927 | msm_pm_retention(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 928 | } else if (allow[MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT]) { |
| 929 | if (MSM_PM_DEBUG_SUSPEND & msm_pm_debug_mask) |
| 930 | pr_info("%s: swfi\n", __func__); |
| 931 | msm_pm_swfi(); |
| 932 | } |
| 933 | |
| 934 | |
| 935 | enter_exit: |
| 936 | if (MSM_PM_DEBUG_SUSPEND & msm_pm_debug_mask) |
| 937 | pr_info("%s: return\n", __func__); |
| 938 | |
| 939 | return 0; |
| 940 | } |
| 941 | |
| 942 | static struct platform_suspend_ops msm_pm_ops = { |
| 943 | .enter = msm_pm_enter, |
| 944 | .valid = suspend_valid_only_mem, |
| 945 | }; |
| 946 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 947 | /****************************************************************************** |
| 948 | * Initialization routine |
| 949 | *****************************************************************************/ |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 950 | void msm_pm_set_sleep_ops(struct msm_pm_sleep_ops *ops) |
| 951 | { |
| 952 | if (ops) |
| 953 | pm_sleep_ops = *ops; |
| 954 | } |
| 955 | |
Girish Mahadevan | d27ca4a | 2012-08-15 09:21:23 -0600 | [diff] [blame^] | 956 | void __init msm_pm_set_tz_retention_flag(unsigned int flag) |
| 957 | { |
| 958 | msm_pm_retention_tz_call = flag; |
| 959 | } |
| 960 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 961 | static int __init msm_pm_init(void) |
| 962 | { |
| 963 | pgd_t *pc_pgd; |
| 964 | pmd_t *pmd; |
| 965 | unsigned long pmdval; |
Praveen Chidambaram | 3895bde | 2012-05-14 19:42:40 +0530 | [diff] [blame] | 966 | enum msm_pm_time_stats_id enable_stats[] = { |
| 967 | MSM_PM_STAT_IDLE_WFI, |
| 968 | MSM_PM_STAT_RETENTION, |
| 969 | MSM_PM_STAT_IDLE_STANDALONE_POWER_COLLAPSE, |
| 970 | MSM_PM_STAT_IDLE_POWER_COLLAPSE, |
| 971 | MSM_PM_STAT_SUSPEND, |
| 972 | }; |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 973 | unsigned long exit_phys; |
Praveen Chidambaram | 3895bde | 2012-05-14 19:42:40 +0530 | [diff] [blame] | 974 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 975 | /* Page table for cores to come back up safely. */ |
| 976 | pc_pgd = pgd_alloc(&init_mm); |
| 977 | if (!pc_pgd) |
| 978 | return -ENOMEM; |
| 979 | |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 980 | exit_phys = virt_to_phys(msm_pm_collapse_exit); |
| 981 | |
| 982 | pmd = pmd_offset(pud_offset(pc_pgd + pgd_index(exit_phys),exit_phys), |
| 983 | exit_phys); |
| 984 | pmdval = (exit_phys & PGDIR_MASK) | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 985 | PMD_TYPE_SECT | PMD_SECT_AP_WRITE; |
| 986 | pmd[0] = __pmd(pmdval); |
| 987 | pmd[1] = __pmd(pmdval + (1 << (PGDIR_SHIFT - 1))); |
| 988 | |
Steve Muckle | fcece05 | 2012-02-18 20:09:58 -0800 | [diff] [blame] | 989 | msm_saved_state_phys = |
| 990 | allocate_contiguous_ebi_nomap(CPU_SAVED_STATE_SIZE * |
| 991 | num_possible_cpus(), 4); |
| 992 | if (!msm_saved_state_phys) |
| 993 | return -ENOMEM; |
| 994 | msm_saved_state = ioremap_nocache(msm_saved_state_phys, |
| 995 | CPU_SAVED_STATE_SIZE * |
| 996 | num_possible_cpus()); |
| 997 | if (!msm_saved_state) |
| 998 | return -ENOMEM; |
| 999 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1000 | /* It is remotely possible that the code in msm_pm_collapse_exit() |
| 1001 | * which turns on the MMU with this mapping is in the |
| 1002 | * next even-numbered megabyte beyond the |
| 1003 | * start of msm_pm_collapse_exit(). |
| 1004 | * Map this megabyte in as well. |
| 1005 | */ |
| 1006 | pmd[2] = __pmd(pmdval + (2 << (PGDIR_SHIFT - 1))); |
| 1007 | flush_pmd_entry(pmd); |
| 1008 | msm_pm_pc_pgd = virt_to_phys(pc_pgd); |
Steve Muckle | 730ad7a | 2012-02-21 15:26:37 -0800 | [diff] [blame] | 1009 | clean_caches((unsigned long)&msm_pm_pc_pgd, sizeof(msm_pm_pc_pgd), |
| 1010 | virt_to_phys(&msm_pm_pc_pgd)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1011 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1012 | msm_pm_mode_sysfs_add(); |
Praveen Chidambaram | 3895bde | 2012-05-14 19:42:40 +0530 | [diff] [blame] | 1013 | msm_pm_add_stats(enable_stats, ARRAY_SIZE(enable_stats)); |
| 1014 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1015 | suspend_set_ops(&msm_pm_ops); |
Praveen Chidambaram | 192979f | 2012-04-25 18:30:23 -0600 | [diff] [blame] | 1016 | msm_pm_qtimer_available(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1017 | msm_cpuidle_init(); |
| 1018 | |
| 1019 | return 0; |
| 1020 | } |
| 1021 | |
| 1022 | late_initcall(msm_pm_init); |