Mahesh Sivasubramanian | 1b8601b | 2012-12-20 14:11:23 -0700 | [diff] [blame] | 1 | /* Copyright (c) 2010-2013, The Linux Foundation. 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 | |
Laura Abbott | 2ff1d12 | 2013-04-24 16:13:03 -0700 | [diff] [blame] | 14 | #include <linux/dma-mapping.h> |
Priyanka Mathur | 13bdad1 | 2013-01-28 15:52:56 -0800 | [diff] [blame] | 15 | #include <linux/debugfs.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 16 | #include <linux/module.h> |
| 17 | #include <linux/kernel.h> |
| 18 | #include <linux/init.h> |
| 19 | #include <linux/completion.h> |
| 20 | #include <linux/cpuidle.h> |
| 21 | #include <linux/interrupt.h> |
| 22 | #include <linux/io.h> |
| 23 | #include <linux/ktime.h> |
| 24 | #include <linux/pm.h> |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 25 | #include <linux/pm_qos.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 26 | #include <linux/smp.h> |
| 27 | #include <linux/suspend.h> |
| 28 | #include <linux/tick.h> |
Anji Jonnala | 02dac8d | 2013-03-06 21:31:04 +0530 | [diff] [blame] | 29 | #include <linux/delay.h> |
Mahesh Sivasubramanian | cb39662 | 2012-03-14 14:50:37 -0600 | [diff] [blame] | 30 | #include <linux/platform_device.h> |
Anji Jonnala | 02dac8d | 2013-03-06 21:31:04 +0530 | [diff] [blame] | 31 | #include <linux/of_platform.h> |
Abhijeet Dharmapurikar | e8f8385 | 2013-02-06 18:57:17 -0800 | [diff] [blame] | 32 | #include <linux/regulator/krait-regulator.h> |
Mahesh Sivasubramanian | b7bda88 | 2013-04-08 09:55:48 -0600 | [diff] [blame] | 33 | #include <linux/cpu.h> |
Badhri Jagan Sridharan | 9b186af | 2013-05-24 12:47:35 -0700 | [diff] [blame] | 34 | #include <linux/clk.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 35 | #include <mach/msm_iomap.h> |
Praveen Chidambaram | 192979f | 2012-04-25 18:30:23 -0600 | [diff] [blame] | 36 | #include <mach/socinfo.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 37 | #include <mach/system.h> |
Girish Mahadevan | d27ca4a | 2012-08-15 09:21:23 -0600 | [diff] [blame] | 38 | #include <mach/scm.h> |
| 39 | #include <mach/socinfo.h> |
Hanumant Singh | bd82a3e | 2013-02-26 13:51:17 -0800 | [diff] [blame] | 40 | #define CREATE_TRACE_POINTS |
| 41 | #include <mach/trace_msm_low_power.h> |
Praveen Chidambaram | c594a09 | 2012-09-18 19:48:29 -0600 | [diff] [blame] | 42 | #include <mach/msm-krait-l2-accessors.h> |
Girish Mahadevan | ec50d2d | 2013-05-15 12:07:38 -0600 | [diff] [blame] | 43 | #include <mach/msm_bus.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 44 | #include <asm/cacheflush.h> |
| 45 | #include <asm/hardware/gic.h> |
| 46 | #include <asm/pgtable.h> |
| 47 | #include <asm/pgalloc.h> |
Girish Mahadevan | 5594499 | 2012-10-26 11:03:07 -0600 | [diff] [blame] | 48 | #include <asm/outercache.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 49 | #ifdef CONFIG_VFP |
| 50 | #include <asm/vfp.h> |
| 51 | #endif |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 52 | #include "acpuclock.h" |
| 53 | #include "clock.h" |
| 54 | #include "avs.h" |
Abhijeet Dharmapurikar | efaca4f | 2011-12-27 16:24:07 -0800 | [diff] [blame] | 55 | #include <mach/cpuidle.h> |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 56 | #include "idle.h" |
Matt Wagantall | 7cca464 | 2012-02-01 16:43:24 -0800 | [diff] [blame] | 57 | #include "pm.h" |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 58 | #include "scm-boot.h" |
| 59 | #include "spm.h" |
| 60 | #include "timer.h" |
Maheshkumar Sivasubramanian | 8ccc16e | 2011-10-25 15:59:57 -0600 | [diff] [blame] | 61 | #include "pm-boot.h" |
Girish Mahadevan | dc318fd | 2012-08-17 16:48:05 -0600 | [diff] [blame] | 62 | #include <mach/event_timer.h> |
Venkat Devarasetty | 722f91f | 2013-06-03 19:41:27 +0530 | [diff] [blame] | 63 | #include <linux/cpu_pm.h> |
Hanumant Singh | bd82a3e | 2013-02-26 13:51:17 -0800 | [diff] [blame] | 64 | |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 65 | #define SCM_L2_RETENTION (0x2) |
| 66 | #define SCM_CMD_TERMINATE_PC (0x2) |
| 67 | |
| 68 | #define GET_CPU_OF_ATTR(attr) \ |
| 69 | (container_of(attr, struct msm_pm_kobj_attribute, ka)->cpu) |
| 70 | |
| 71 | #define SCLK_HZ (32768) |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 72 | |
Priyanka Mathur | 13bdad1 | 2013-01-28 15:52:56 -0800 | [diff] [blame] | 73 | #define NUM_OF_COUNTERS 3 |
| 74 | #define MAX_BUF_SIZE 512 |
| 75 | |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 76 | static int msm_pm_debug_mask = 1; |
| 77 | module_param_named( |
| 78 | debug_mask, msm_pm_debug_mask, int, S_IRUGO | S_IWUSR | S_IWGRP |
| 79 | ); |
| 80 | |
| 81 | static int msm_pm_sleep_time_override; |
| 82 | module_param_named(sleep_time_override, |
| 83 | msm_pm_sleep_time_override, int, S_IRUGO | S_IWUSR | S_IWGRP); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 84 | |
| 85 | enum { |
| 86 | MSM_PM_DEBUG_SUSPEND = BIT(0), |
| 87 | MSM_PM_DEBUG_POWER_COLLAPSE = BIT(1), |
| 88 | MSM_PM_DEBUG_SUSPEND_LIMITS = BIT(2), |
| 89 | MSM_PM_DEBUG_CLOCK = BIT(3), |
| 90 | MSM_PM_DEBUG_RESET_VECTOR = BIT(4), |
Karthik Parsha | 6fb932d | 2012-01-24 18:04:12 -0800 | [diff] [blame] | 91 | MSM_PM_DEBUG_IDLE_CLK = BIT(5), |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 92 | MSM_PM_DEBUG_IDLE = BIT(6), |
| 93 | MSM_PM_DEBUG_IDLE_LIMITS = BIT(7), |
| 94 | MSM_PM_DEBUG_HOTPLUG = BIT(8), |
| 95 | }; |
| 96 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 97 | enum { |
| 98 | MSM_PM_MODE_ATTR_SUSPEND, |
| 99 | MSM_PM_MODE_ATTR_IDLE, |
| 100 | MSM_PM_MODE_ATTR_NR, |
| 101 | }; |
| 102 | |
| 103 | static char *msm_pm_mode_attr_labels[MSM_PM_MODE_ATTR_NR] = { |
| 104 | [MSM_PM_MODE_ATTR_SUSPEND] = "suspend_enabled", |
| 105 | [MSM_PM_MODE_ATTR_IDLE] = "idle_enabled", |
| 106 | }; |
| 107 | |
| 108 | struct msm_pm_kobj_attribute { |
| 109 | unsigned int cpu; |
| 110 | struct kobj_attribute ka; |
| 111 | }; |
| 112 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 113 | struct msm_pm_sysfs_sleep_mode { |
| 114 | struct kobject *kobj; |
| 115 | struct attribute_group attr_group; |
| 116 | struct attribute *attrs[MSM_PM_MODE_ATTR_NR + 1]; |
| 117 | struct msm_pm_kobj_attribute kas[MSM_PM_MODE_ATTR_NR]; |
| 118 | }; |
| 119 | |
| 120 | static char *msm_pm_sleep_mode_labels[MSM_PM_SLEEP_MODE_NR] = { |
| 121 | [MSM_PM_SLEEP_MODE_POWER_COLLAPSE] = "power_collapse", |
| 122 | [MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT] = "wfi", |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 123 | [MSM_PM_SLEEP_MODE_RETENTION] = "retention", |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 124 | [MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE] = |
| 125 | "standalone_power_collapse", |
| 126 | }; |
| 127 | |
Girish Mahadevan | dc318fd | 2012-08-17 16:48:05 -0600 | [diff] [blame] | 128 | static struct hrtimer pm_hrtimer; |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 129 | static struct msm_pm_sleep_ops pm_sleep_ops; |
Mahesh Sivasubramanian | 1b8601b | 2012-12-20 14:11:23 -0700 | [diff] [blame] | 130 | static bool msm_pm_ldo_retention_enabled = true; |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 131 | static bool msm_pm_use_sync_timer; |
| 132 | static struct msm_pm_cp15_save_data cp15_data; |
| 133 | static bool msm_pm_retention_calls_tz; |
Praveen Chidambaram | 4b8df03 | 2013-01-18 16:21:16 -0700 | [diff] [blame] | 134 | static bool msm_no_ramp_down_pc; |
Anji Jonnala | 02dac8d | 2013-03-06 21:31:04 +0530 | [diff] [blame] | 135 | static struct msm_pm_sleep_status_data *msm_pm_slp_sts; |
Mahesh Sivasubramanian | b7bda88 | 2013-04-08 09:55:48 -0600 | [diff] [blame] | 136 | static bool msm_pm_pc_reset_timer; |
Badhri Jagan Sridharan | 9b186af | 2013-05-24 12:47:35 -0700 | [diff] [blame] | 137 | static struct clk *pnoc_clk; |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 138 | |
Archana Sathyakumar | 2b91dc8 | 2013-02-01 17:38:23 -0700 | [diff] [blame] | 139 | static int msm_pm_get_pc_mode(struct device_node *node, |
| 140 | const char *key, uint32_t *pc_mode_val) |
| 141 | { |
| 142 | struct pc_mode_of { |
| 143 | uint32_t mode; |
| 144 | char *mode_name; |
| 145 | }; |
| 146 | int i; |
| 147 | struct pc_mode_of pc_modes[] = { |
| 148 | {MSM_PM_PC_TZ_L2_INT, "tz_l2_int"}, |
| 149 | {MSM_PM_PC_NOTZ_L2_EXT, "no_tz_l2_ext"}, |
| 150 | {MSM_PM_PC_TZ_L2_EXT , "tz_l2_ext"} }; |
| 151 | int ret; |
| 152 | const char *pc_mode_str; |
| 153 | |
| 154 | ret = of_property_read_string(node, key, &pc_mode_str); |
| 155 | if (ret) { |
| 156 | pr_debug("%s: Cannot read %s,defaulting to 0", __func__, key); |
| 157 | pc_mode_val = MSM_PM_PC_TZ_L2_INT; |
| 158 | ret = 0; |
| 159 | } else { |
| 160 | ret = -EINVAL; |
| 161 | for (i = 0; i < ARRAY_SIZE(pc_modes); i++) { |
| 162 | if (!strncmp(pc_mode_str, pc_modes[i].mode_name, |
| 163 | strlen(pc_modes[i].mode_name))) { |
| 164 | *pc_mode_val = pc_modes[i].mode; |
| 165 | ret = 0; |
| 166 | break; |
| 167 | } |
| 168 | } |
| 169 | } |
| 170 | return ret; |
| 171 | } |
| 172 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 173 | /* |
| 174 | * Write out the attribute. |
| 175 | */ |
| 176 | static ssize_t msm_pm_mode_attr_show( |
| 177 | struct kobject *kobj, struct kobj_attribute *attr, char *buf) |
| 178 | { |
| 179 | int ret = -EINVAL; |
| 180 | int i; |
| 181 | |
| 182 | for (i = 0; i < MSM_PM_SLEEP_MODE_NR; i++) { |
| 183 | struct kernel_param kp; |
| 184 | unsigned int cpu; |
| 185 | struct msm_pm_platform_data *mode; |
| 186 | |
| 187 | if (msm_pm_sleep_mode_labels[i] == NULL) |
| 188 | continue; |
| 189 | |
| 190 | if (strcmp(kobj->name, msm_pm_sleep_mode_labels[i])) |
| 191 | continue; |
| 192 | |
| 193 | cpu = GET_CPU_OF_ATTR(attr); |
Praveen Chidambaram | 42da9d2 | 2012-03-30 12:16:34 -0600 | [diff] [blame] | 194 | mode = &msm_pm_sleep_modes[MSM_PM_MODE(cpu, i)]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 195 | |
| 196 | if (!strcmp(attr->attr.name, |
| 197 | msm_pm_mode_attr_labels[MSM_PM_MODE_ATTR_SUSPEND])) { |
| 198 | u32 arg = mode->suspend_enabled; |
| 199 | kp.arg = &arg; |
| 200 | ret = param_get_ulong(buf, &kp); |
| 201 | } else if (!strcmp(attr->attr.name, |
| 202 | msm_pm_mode_attr_labels[MSM_PM_MODE_ATTR_IDLE])) { |
| 203 | u32 arg = mode->idle_enabled; |
| 204 | kp.arg = &arg; |
| 205 | ret = param_get_ulong(buf, &kp); |
| 206 | } |
| 207 | |
| 208 | break; |
| 209 | } |
| 210 | |
| 211 | if (ret > 0) { |
Praveen Chidambaram | 2b0fdd0 | 2011-10-28 16:40:58 -0600 | [diff] [blame] | 212 | strlcat(buf, "\n", PAGE_SIZE); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 213 | ret++; |
| 214 | } |
| 215 | |
| 216 | return ret; |
| 217 | } |
| 218 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 219 | static ssize_t msm_pm_mode_attr_store(struct kobject *kobj, |
| 220 | struct kobj_attribute *attr, const char *buf, size_t count) |
| 221 | { |
| 222 | int ret = -EINVAL; |
| 223 | int i; |
| 224 | |
| 225 | for (i = 0; i < MSM_PM_SLEEP_MODE_NR; i++) { |
| 226 | struct kernel_param kp; |
| 227 | unsigned int cpu; |
| 228 | struct msm_pm_platform_data *mode; |
| 229 | |
| 230 | if (msm_pm_sleep_mode_labels[i] == NULL) |
| 231 | continue; |
| 232 | |
| 233 | if (strcmp(kobj->name, msm_pm_sleep_mode_labels[i])) |
| 234 | continue; |
| 235 | |
| 236 | cpu = GET_CPU_OF_ATTR(attr); |
Praveen Chidambaram | 42da9d2 | 2012-03-30 12:16:34 -0600 | [diff] [blame] | 237 | mode = &msm_pm_sleep_modes[MSM_PM_MODE(cpu, i)]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 238 | |
| 239 | if (!strcmp(attr->attr.name, |
| 240 | msm_pm_mode_attr_labels[MSM_PM_MODE_ATTR_SUSPEND])) { |
| 241 | kp.arg = &mode->suspend_enabled; |
| 242 | ret = param_set_byte(buf, &kp); |
| 243 | } else if (!strcmp(attr->attr.name, |
| 244 | msm_pm_mode_attr_labels[MSM_PM_MODE_ATTR_IDLE])) { |
| 245 | kp.arg = &mode->idle_enabled; |
| 246 | ret = param_set_byte(buf, &kp); |
| 247 | } |
| 248 | |
| 249 | break; |
| 250 | } |
| 251 | |
| 252 | return ret ? ret : count; |
| 253 | } |
| 254 | |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 255 | static int __devinit msm_pm_mode_sysfs_add_cpu( |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 256 | unsigned int cpu, struct kobject *modes_kobj) |
| 257 | { |
| 258 | char cpu_name[8]; |
| 259 | struct kobject *cpu_kobj; |
Praveen Chidambaram | 2b0fdd0 | 2011-10-28 16:40:58 -0600 | [diff] [blame] | 260 | struct msm_pm_sysfs_sleep_mode *mode = NULL; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 261 | int i, j, k; |
| 262 | int ret; |
| 263 | |
| 264 | snprintf(cpu_name, sizeof(cpu_name), "cpu%u", cpu); |
| 265 | cpu_kobj = kobject_create_and_add(cpu_name, modes_kobj); |
| 266 | if (!cpu_kobj) { |
| 267 | pr_err("%s: cannot create %s kobject\n", __func__, cpu_name); |
| 268 | ret = -ENOMEM; |
| 269 | goto mode_sysfs_add_cpu_exit; |
| 270 | } |
| 271 | |
| 272 | for (i = 0; i < MSM_PM_SLEEP_MODE_NR; i++) { |
| 273 | int idx = MSM_PM_MODE(cpu, i); |
| 274 | |
Praveen Chidambaram | 42da9d2 | 2012-03-30 12:16:34 -0600 | [diff] [blame] | 275 | if ((!msm_pm_sleep_modes[idx].suspend_supported) |
| 276 | && (!msm_pm_sleep_modes[idx].idle_supported)) |
| 277 | continue; |
| 278 | |
| 279 | if (!msm_pm_sleep_mode_labels[i] || |
| 280 | !msm_pm_sleep_mode_labels[i][0]) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 281 | continue; |
| 282 | |
| 283 | mode = kzalloc(sizeof(*mode), GFP_KERNEL); |
| 284 | if (!mode) { |
| 285 | pr_err("%s: cannot allocate memory for attributes\n", |
| 286 | __func__); |
| 287 | ret = -ENOMEM; |
| 288 | goto mode_sysfs_add_cpu_exit; |
| 289 | } |
| 290 | |
| 291 | mode->kobj = kobject_create_and_add( |
| 292 | msm_pm_sleep_mode_labels[i], cpu_kobj); |
| 293 | if (!mode->kobj) { |
| 294 | pr_err("%s: cannot create kobject\n", __func__); |
| 295 | ret = -ENOMEM; |
| 296 | goto mode_sysfs_add_cpu_exit; |
| 297 | } |
| 298 | |
| 299 | for (k = 0, j = 0; k < MSM_PM_MODE_ATTR_NR; k++) { |
| 300 | if ((k == MSM_PM_MODE_ATTR_IDLE) && |
Praveen Chidambaram | 42da9d2 | 2012-03-30 12:16:34 -0600 | [diff] [blame] | 301 | !msm_pm_sleep_modes[idx].idle_supported) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 302 | continue; |
| 303 | if ((k == MSM_PM_MODE_ATTR_SUSPEND) && |
Praveen Chidambaram | 42da9d2 | 2012-03-30 12:16:34 -0600 | [diff] [blame] | 304 | !msm_pm_sleep_modes[idx].suspend_supported) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 305 | continue; |
Stephen Boyd | d2059c3 | 2012-07-03 15:11:15 -0700 | [diff] [blame] | 306 | sysfs_attr_init(&mode->kas[j].ka.attr); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 307 | mode->kas[j].cpu = cpu; |
| 308 | mode->kas[j].ka.attr.mode = 0644; |
| 309 | mode->kas[j].ka.show = msm_pm_mode_attr_show; |
| 310 | mode->kas[j].ka.store = msm_pm_mode_attr_store; |
| 311 | mode->kas[j].ka.attr.name = msm_pm_mode_attr_labels[k]; |
| 312 | mode->attrs[j] = &mode->kas[j].ka.attr; |
| 313 | j++; |
| 314 | } |
| 315 | mode->attrs[j] = NULL; |
| 316 | |
| 317 | mode->attr_group.attrs = mode->attrs; |
| 318 | ret = sysfs_create_group(mode->kobj, &mode->attr_group); |
| 319 | if (ret) { |
| 320 | pr_err("%s: cannot create kobject attribute group\n", |
| 321 | __func__); |
| 322 | goto mode_sysfs_add_cpu_exit; |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | ret = 0; |
| 327 | |
| 328 | mode_sysfs_add_cpu_exit: |
Praveen Chidambaram | d5ac2d3 | 2011-10-24 14:30:27 -0600 | [diff] [blame] | 329 | if (ret) { |
Praveen Chidambaram | 2cfda63 | 2011-10-11 16:58:09 -0600 | [diff] [blame] | 330 | if (mode && mode->kobj) |
| 331 | kobject_del(mode->kobj); |
| 332 | kfree(mode); |
| 333 | } |
| 334 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 335 | return ret; |
| 336 | } |
| 337 | |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 338 | int __devinit msm_pm_mode_sysfs_add(void) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 339 | { |
| 340 | struct kobject *module_kobj; |
| 341 | struct kobject *modes_kobj; |
| 342 | unsigned int cpu; |
| 343 | int ret; |
| 344 | |
| 345 | module_kobj = kset_find_obj(module_kset, KBUILD_MODNAME); |
| 346 | if (!module_kobj) { |
| 347 | pr_err("%s: cannot find kobject for module %s\n", |
| 348 | __func__, KBUILD_MODNAME); |
| 349 | ret = -ENOENT; |
| 350 | goto mode_sysfs_add_exit; |
| 351 | } |
| 352 | |
| 353 | modes_kobj = kobject_create_and_add("modes", module_kobj); |
| 354 | if (!modes_kobj) { |
| 355 | pr_err("%s: cannot create modes kobject\n", __func__); |
| 356 | ret = -ENOMEM; |
| 357 | goto mode_sysfs_add_exit; |
| 358 | } |
| 359 | |
| 360 | for_each_possible_cpu(cpu) { |
| 361 | ret = msm_pm_mode_sysfs_add_cpu(cpu, modes_kobj); |
| 362 | if (ret) |
| 363 | goto mode_sysfs_add_exit; |
| 364 | } |
| 365 | |
| 366 | ret = 0; |
| 367 | |
| 368 | mode_sysfs_add_exit: |
| 369 | return ret; |
| 370 | } |
| 371 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 372 | /* |
| 373 | * Configure hardware registers in preparation for Apps power down. |
| 374 | */ |
| 375 | static void msm_pm_config_hw_before_power_down(void) |
| 376 | { |
| 377 | return; |
| 378 | } |
| 379 | |
| 380 | /* |
| 381 | * Clear hardware registers after Apps powers up. |
| 382 | */ |
| 383 | static void msm_pm_config_hw_after_power_up(void) |
| 384 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 385 | } |
| 386 | |
| 387 | /* |
| 388 | * Configure hardware registers in preparation for SWFI. |
| 389 | */ |
| 390 | static void msm_pm_config_hw_before_swfi(void) |
| 391 | { |
| 392 | return; |
| 393 | } |
| 394 | |
Girish Mahadevan | d27ca4a | 2012-08-15 09:21:23 -0600 | [diff] [blame] | 395 | /* |
| 396 | * Configure/Restore hardware registers in preparation for Retention. |
| 397 | */ |
| 398 | |
| 399 | static void msm_pm_config_hw_after_retention(void) |
| 400 | { |
| 401 | int ret; |
Abhijeet Dharmapurikar | e8f8385 | 2013-02-06 18:57:17 -0800 | [diff] [blame] | 402 | |
Girish Mahadevan | d27ca4a | 2012-08-15 09:21:23 -0600 | [diff] [blame] | 403 | ret = msm_spm_set_low_power_mode(MSM_SPM_MODE_CLOCK_GATING, false); |
| 404 | WARN_ON(ret); |
| 405 | } |
| 406 | |
| 407 | static void msm_pm_config_hw_before_retention(void) |
| 408 | { |
| 409 | return; |
| 410 | } |
| 411 | |
Praveen Chidambaram | c594a09 | 2012-09-18 19:48:29 -0600 | [diff] [blame] | 412 | static void msm_pm_save_cpu_reg(void) |
| 413 | { |
| 414 | int i; |
| 415 | |
| 416 | /* Only on core0 */ |
| 417 | if (smp_processor_id()) |
| 418 | return; |
| 419 | |
| 420 | /** |
| 421 | * On some targets, L2 PC will turn off may reset the core |
| 422 | * configuration for the mux and the default may not make the core |
| 423 | * happy when it resumes. |
| 424 | * Save the active vdd, and set the core vdd to QSB max vdd, so that |
| 425 | * when the core resumes, it is capable of supporting the current QSB |
| 426 | * rate. Then restore the active vdd before switching the acpuclk rate. |
| 427 | */ |
| 428 | if (msm_pm_get_l2_flush_flag() == 1) { |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 429 | cp15_data.active_vdd = msm_spm_get_vdd(0); |
| 430 | for (i = 0; i < cp15_data.reg_saved_state_size; i++) |
| 431 | cp15_data.reg_val[i] = |
| 432 | get_l2_indirect_reg( |
| 433 | cp15_data.reg_data[i]); |
| 434 | msm_spm_set_vdd(0, cp15_data.qsb_pc_vdd); |
Praveen Chidambaram | c594a09 | 2012-09-18 19:48:29 -0600 | [diff] [blame] | 435 | } |
| 436 | } |
| 437 | |
| 438 | static void msm_pm_restore_cpu_reg(void) |
| 439 | { |
| 440 | int i; |
| 441 | |
| 442 | /* Only on core0 */ |
| 443 | if (smp_processor_id()) |
| 444 | return; |
| 445 | |
| 446 | if (msm_pm_get_l2_flush_flag() == 1) { |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 447 | for (i = 0; i < cp15_data.reg_saved_state_size; i++) |
| 448 | set_l2_indirect_reg( |
| 449 | cp15_data.reg_data[i], |
| 450 | cp15_data.reg_val[i]); |
| 451 | msm_spm_set_vdd(0, cp15_data.active_vdd); |
Praveen Chidambaram | c594a09 | 2012-09-18 19:48:29 -0600 | [diff] [blame] | 452 | } |
| 453 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 454 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 455 | static void msm_pm_swfi(void) |
| 456 | { |
| 457 | msm_pm_config_hw_before_swfi(); |
| 458 | msm_arch_idle(); |
| 459 | } |
| 460 | |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 461 | static void msm_pm_retention(void) |
| 462 | { |
| 463 | int ret = 0; |
| 464 | |
Girish Mahadevan | d27ca4a | 2012-08-15 09:21:23 -0600 | [diff] [blame] | 465 | msm_pm_config_hw_before_retention(); |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 466 | ret = msm_spm_set_low_power_mode(MSM_SPM_MODE_POWER_RETENTION, false); |
| 467 | WARN_ON(ret); |
Girish Mahadevan | d27ca4a | 2012-08-15 09:21:23 -0600 | [diff] [blame] | 468 | |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 469 | if (msm_pm_retention_calls_tz) |
Girish Mahadevan | d27ca4a | 2012-08-15 09:21:23 -0600 | [diff] [blame] | 470 | scm_call_atomic1(SCM_SVC_BOOT, SCM_CMD_TERMINATE_PC, |
| 471 | SCM_L2_RETENTION); |
| 472 | else |
| 473 | msm_arch_idle(); |
| 474 | |
| 475 | msm_pm_config_hw_after_retention(); |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 476 | } |
| 477 | |
Stephen Boyd | b29750d | 2012-02-21 01:21:32 -0800 | [diff] [blame] | 478 | static bool __ref msm_pm_spm_power_collapse( |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 479 | unsigned int cpu, bool from_idle, bool notify_rpm) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 480 | { |
| 481 | void *entry; |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 482 | bool collapsed = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 483 | int ret; |
Mahesh Sivasubramanian | da74625 | 2013-05-02 09:58:08 -0600 | [diff] [blame] | 484 | bool save_cpu_regs = !cpu || from_idle; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 485 | |
| 486 | if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask) |
| 487 | pr_info("CPU%u: %s: notify_rpm %d\n", |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 488 | cpu, __func__, (int) notify_rpm); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 489 | |
Venkat Devarasetty | 722f91f | 2013-06-03 19:41:27 +0530 | [diff] [blame] | 490 | if (from_idle == true) |
| 491 | cpu_pm_enter(); |
| 492 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 493 | ret = msm_spm_set_low_power_mode( |
| 494 | MSM_SPM_MODE_POWER_COLLAPSE, notify_rpm); |
| 495 | WARN_ON(ret); |
| 496 | |
Mahesh Sivasubramanian | da74625 | 2013-05-02 09:58:08 -0600 | [diff] [blame] | 497 | entry = save_cpu_regs ? msm_pm_collapse_exit : msm_secondary_startup; |
| 498 | |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 499 | msm_pm_boot_config_before_pc(cpu, virt_to_phys(entry)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 500 | |
| 501 | if (MSM_PM_DEBUG_RESET_VECTOR & msm_pm_debug_mask) |
| 502 | pr_info("CPU%u: %s: program vector to %p\n", |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 503 | cpu, __func__, entry); |
Mahesh Sivasubramanian | b7bda88 | 2013-04-08 09:55:48 -0600 | [diff] [blame] | 504 | if (from_idle && msm_pm_pc_reset_timer) |
| 505 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ENTER, &cpu); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 506 | |
Mahesh Sivasubramanian | da74625 | 2013-05-02 09:58:08 -0600 | [diff] [blame] | 507 | collapsed = save_cpu_regs ? msm_pm_collapse() : msm_pm_pc_hotplug(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 508 | |
Mahesh Sivasubramanian | b7bda88 | 2013-04-08 09:55:48 -0600 | [diff] [blame] | 509 | if (from_idle && msm_pm_pc_reset_timer) |
| 510 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_EXIT, &cpu); |
| 511 | |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 512 | msm_pm_boot_config_after_pc(cpu); |
Maheshkumar Sivasubramanian | 8ccc16e | 2011-10-25 15:59:57 -0600 | [diff] [blame] | 513 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 514 | if (collapsed) { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 515 | cpu_init(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 516 | local_fiq_enable(); |
| 517 | } |
| 518 | |
| 519 | if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask) |
| 520 | pr_info("CPU%u: %s: msm_pm_collapse returned, collapsed %d\n", |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 521 | cpu, __func__, collapsed); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 522 | |
| 523 | ret = msm_spm_set_low_power_mode(MSM_SPM_MODE_CLOCK_GATING, false); |
| 524 | WARN_ON(ret); |
Venkat Devarasetty | 722f91f | 2013-06-03 19:41:27 +0530 | [diff] [blame] | 525 | |
| 526 | if (from_idle == true) |
| 527 | cpu_pm_exit(); |
| 528 | |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 529 | return collapsed; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 530 | } |
| 531 | |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 532 | static bool msm_pm_power_collapse_standalone(bool from_idle) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 533 | { |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 534 | unsigned int cpu = smp_processor_id(); |
Praveen Chidambaram | 5e61411 | 2012-11-08 17:53:34 -0700 | [diff] [blame] | 535 | unsigned int avsdscr; |
| 536 | unsigned int avscsr; |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 537 | bool collapsed; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 538 | |
Praveen Chidambaram | 5e61411 | 2012-11-08 17:53:34 -0700 | [diff] [blame] | 539 | avsdscr = avs_get_avsdscr(); |
| 540 | avscsr = avs_get_avscsr(); |
| 541 | avs_set_avscsr(0); /* Disable AVS */ |
| 542 | |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 543 | collapsed = msm_pm_spm_power_collapse(cpu, from_idle, false); |
Praveen Chidambaram | 5e61411 | 2012-11-08 17:53:34 -0700 | [diff] [blame] | 544 | |
| 545 | avs_set_avsdscr(avsdscr); |
| 546 | avs_set_avscsr(avscsr); |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 547 | return collapsed; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 548 | } |
| 549 | |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 550 | static bool msm_pm_power_collapse(bool from_idle) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 551 | { |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 552 | unsigned int cpu = smp_processor_id(); |
Praveen Chidambaram | 4b8df03 | 2013-01-18 16:21:16 -0700 | [diff] [blame] | 553 | unsigned long saved_acpuclk_rate = 0; |
Praveen Chidambaram | 5e61411 | 2012-11-08 17:53:34 -0700 | [diff] [blame] | 554 | unsigned int avsdscr; |
| 555 | unsigned int avscsr; |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 556 | bool collapsed; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 557 | |
| 558 | if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask) |
| 559 | pr_info("CPU%u: %s: idle %d\n", |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 560 | cpu, __func__, (int)from_idle); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 561 | |
| 562 | msm_pm_config_hw_before_power_down(); |
| 563 | if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask) |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 564 | pr_info("CPU%u: %s: pre power down\n", cpu, __func__); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 565 | |
Praveen Chidambaram | 5e61411 | 2012-11-08 17:53:34 -0700 | [diff] [blame] | 566 | avsdscr = avs_get_avsdscr(); |
| 567 | avscsr = avs_get_avscsr(); |
| 568 | avs_set_avscsr(0); /* Disable AVS */ |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 569 | |
Praveen Chidambaram | 4b8df03 | 2013-01-18 16:21:16 -0700 | [diff] [blame] | 570 | if (cpu_online(cpu) && !msm_no_ramp_down_pc) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 571 | saved_acpuclk_rate = acpuclk_power_collapse(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 572 | |
| 573 | if (MSM_PM_DEBUG_CLOCK & msm_pm_debug_mask) |
| 574 | pr_info("CPU%u: %s: change clock rate (old rate = %lu)\n", |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 575 | cpu, __func__, saved_acpuclk_rate); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 576 | |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 577 | if (cp15_data.save_cp15) |
Praveen Chidambaram | c594a09 | 2012-09-18 19:48:29 -0600 | [diff] [blame] | 578 | msm_pm_save_cpu_reg(); |
| 579 | |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 580 | collapsed = msm_pm_spm_power_collapse(cpu, from_idle, true); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 581 | |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 582 | if (cp15_data.save_cp15) |
Praveen Chidambaram | c594a09 | 2012-09-18 19:48:29 -0600 | [diff] [blame] | 583 | msm_pm_restore_cpu_reg(); |
| 584 | |
Girish Mahadevan | 4e025d9 | 2012-02-29 13:26:51 -0700 | [diff] [blame] | 585 | if (cpu_online(cpu)) { |
| 586 | if (MSM_PM_DEBUG_CLOCK & msm_pm_debug_mask) |
| 587 | pr_info("CPU%u: %s: restore clock rate to %lu\n", |
| 588 | cpu, __func__, saved_acpuclk_rate); |
Praveen Chidambaram | 4b8df03 | 2013-01-18 16:21:16 -0700 | [diff] [blame] | 589 | if (!msm_no_ramp_down_pc && |
| 590 | acpuclk_set_rate(cpu, saved_acpuclk_rate, SETRATE_PC) |
| 591 | < 0) |
Girish Mahadevan | 4e025d9 | 2012-02-29 13:26:51 -0700 | [diff] [blame] | 592 | pr_err("CPU%u: %s: failed to restore clock rate(%lu)\n", |
| 593 | cpu, __func__, saved_acpuclk_rate); |
| 594 | } else { |
| 595 | unsigned int gic_dist_enabled; |
| 596 | unsigned int gic_dist_pending; |
| 597 | gic_dist_enabled = readl_relaxed( |
| 598 | MSM_QGIC_DIST_BASE + GIC_DIST_ENABLE_CLEAR); |
| 599 | gic_dist_pending = readl_relaxed( |
| 600 | MSM_QGIC_DIST_BASE + GIC_DIST_PENDING_SET); |
| 601 | mb(); |
| 602 | gic_dist_pending &= gic_dist_enabled; |
| 603 | |
| 604 | if (gic_dist_pending) |
| 605 | pr_err("CPU %d interrupted during hotplug.Pending int 0x%x\n", |
| 606 | cpu, gic_dist_pending); |
| 607 | } |
| 608 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 609 | |
Praveen Chidambaram | 5e61411 | 2012-11-08 17:53:34 -0700 | [diff] [blame] | 610 | avs_set_avsdscr(avsdscr); |
| 611 | avs_set_avscsr(avscsr); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 612 | msm_pm_config_hw_after_power_up(); |
| 613 | if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask) |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 614 | pr_info("CPU%u: %s: post power up\n", cpu, __func__); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 615 | |
| 616 | if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask) |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 617 | pr_info("CPU%u: %s: return\n", cpu, __func__); |
Maheshkumar Sivasubramanian | dd93ecf | 2011-09-15 19:39:14 -0600 | [diff] [blame] | 618 | return collapsed; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 619 | } |
| 620 | |
Praveen Chidambaram | 192979f | 2012-04-25 18:30:23 -0600 | [diff] [blame] | 621 | static int64_t msm_pm_timer_enter_idle(void) |
| 622 | { |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 623 | if (msm_pm_use_sync_timer) |
Praveen Chidambaram | 192979f | 2012-04-25 18:30:23 -0600 | [diff] [blame] | 624 | return ktime_to_ns(tick_nohz_get_sleep_length()); |
| 625 | |
| 626 | return msm_timer_enter_idle(); |
| 627 | } |
| 628 | |
| 629 | static void msm_pm_timer_exit_idle(bool timer_halted) |
| 630 | { |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 631 | if (msm_pm_use_sync_timer) |
Praveen Chidambaram | 192979f | 2012-04-25 18:30:23 -0600 | [diff] [blame] | 632 | return; |
| 633 | |
| 634 | msm_timer_exit_idle((int) timer_halted); |
| 635 | } |
| 636 | |
Praveen Chidambaram | 3895bde | 2012-05-14 19:42:40 +0530 | [diff] [blame] | 637 | static int64_t msm_pm_timer_enter_suspend(int64_t *period) |
| 638 | { |
Anji Jonnala | c02367a | 2012-07-01 02:56:11 +0530 | [diff] [blame] | 639 | int64_t time = 0; |
Praveen Chidambaram | 3895bde | 2012-05-14 19:42:40 +0530 | [diff] [blame] | 640 | |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 641 | if (msm_pm_use_sync_timer) |
Mahesh Sivasubramanian | 0eaeb30 | 2013-03-14 14:56:32 -0600 | [diff] [blame] | 642 | return sched_clock(); |
Praveen Chidambaram | 3895bde | 2012-05-14 19:42:40 +0530 | [diff] [blame] | 643 | |
| 644 | time = msm_timer_get_sclk_time(period); |
| 645 | if (!time) |
| 646 | pr_err("%s: Unable to read sclk.\n", __func__); |
| 647 | |
| 648 | return time; |
| 649 | } |
| 650 | |
| 651 | static int64_t msm_pm_timer_exit_suspend(int64_t time, int64_t period) |
| 652 | { |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 653 | if (msm_pm_use_sync_timer) |
Mahesh Sivasubramanian | 0eaeb30 | 2013-03-14 14:56:32 -0600 | [diff] [blame] | 654 | return sched_clock() - time; |
Praveen Chidambaram | 3895bde | 2012-05-14 19:42:40 +0530 | [diff] [blame] | 655 | |
| 656 | if (time != 0) { |
| 657 | int64_t end_time = msm_timer_get_sclk_time(NULL); |
| 658 | if (end_time != 0) { |
| 659 | time = end_time - time; |
| 660 | if (time < 0) |
| 661 | time += period; |
| 662 | } else |
| 663 | time = 0; |
| 664 | } |
| 665 | |
| 666 | return time; |
| 667 | } |
| 668 | |
Girish Mahadevan | dc318fd | 2012-08-17 16:48:05 -0600 | [diff] [blame] | 669 | /** |
| 670 | * pm_hrtimer_cb() : Callback function for hrtimer created if the |
| 671 | * core needs to be awake to handle an event. |
| 672 | * @hrtimer : Pointer to hrtimer |
| 673 | */ |
| 674 | static enum hrtimer_restart pm_hrtimer_cb(struct hrtimer *hrtimer) |
| 675 | { |
| 676 | return HRTIMER_NORESTART; |
| 677 | } |
| 678 | |
| 679 | /** |
| 680 | * msm_pm_set_timer() : Set an hrtimer to wakeup the core in time |
| 681 | * to handle an event. |
| 682 | */ |
| 683 | static void msm_pm_set_timer(uint32_t modified_time_us) |
| 684 | { |
| 685 | u64 modified_time_ns = modified_time_us * NSEC_PER_USEC; |
| 686 | ktime_t modified_ktime = ns_to_ktime(modified_time_ns); |
| 687 | pm_hrtimer.function = pm_hrtimer_cb; |
Girish Mahadevan | 3249361 | 2013-05-10 14:37:17 -0600 | [diff] [blame] | 688 | hrtimer_start(&pm_hrtimer, modified_ktime, HRTIMER_MODE_REL); |
Girish Mahadevan | dc318fd | 2012-08-17 16:48:05 -0600 | [diff] [blame] | 689 | } |
| 690 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 691 | /****************************************************************************** |
| 692 | * External Idle/Suspend Functions |
| 693 | *****************************************************************************/ |
| 694 | |
| 695 | void arch_idle(void) |
| 696 | { |
| 697 | return; |
| 698 | } |
| 699 | |
Priyanka Mathur | 26b4a4b | 2012-11-05 13:45:45 -0800 | [diff] [blame] | 700 | static inline void msm_pm_ftrace_lpm_enter(unsigned int cpu, |
| 701 | uint32_t latency, uint32_t sleep_us, |
| 702 | uint32_t wake_up, |
| 703 | enum msm_pm_sleep_mode mode) |
| 704 | { |
| 705 | switch (mode) { |
| 706 | case MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT: |
| 707 | trace_msm_pm_enter_wfi(cpu, latency, sleep_us, wake_up); |
| 708 | break; |
| 709 | case MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE: |
| 710 | trace_msm_pm_enter_spc(cpu, latency, sleep_us, wake_up); |
| 711 | break; |
| 712 | case MSM_PM_SLEEP_MODE_POWER_COLLAPSE: |
| 713 | trace_msm_pm_enter_pc(cpu, latency, sleep_us, wake_up); |
| 714 | break; |
| 715 | case MSM_PM_SLEEP_MODE_RETENTION: |
| 716 | trace_msm_pm_enter_ret(cpu, latency, sleep_us, wake_up); |
| 717 | break; |
| 718 | default: |
| 719 | break; |
| 720 | } |
| 721 | } |
| 722 | |
| 723 | static inline void msm_pm_ftrace_lpm_exit(unsigned int cpu, |
| 724 | enum msm_pm_sleep_mode mode, |
| 725 | bool success) |
| 726 | { |
| 727 | switch (mode) { |
| 728 | case MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT: |
| 729 | trace_msm_pm_exit_wfi(cpu, success); |
| 730 | break; |
| 731 | case MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE: |
| 732 | trace_msm_pm_exit_spc(cpu, success); |
| 733 | break; |
| 734 | case MSM_PM_SLEEP_MODE_POWER_COLLAPSE: |
| 735 | trace_msm_pm_exit_pc(cpu, success); |
| 736 | break; |
| 737 | case MSM_PM_SLEEP_MODE_RETENTION: |
| 738 | trace_msm_pm_exit_ret(cpu, success); |
| 739 | break; |
| 740 | default: |
| 741 | break; |
| 742 | } |
| 743 | } |
| 744 | |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 745 | static int msm_pm_idle_prepare(struct cpuidle_device *dev, |
| 746 | struct cpuidle_driver *drv, int index, |
| 747 | void **msm_pm_idle_rs_limits) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 748 | { |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 749 | int i; |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 750 | unsigned int power_usage = -1; |
Priyanka Mathur | 848bb4c | 2012-11-30 18:04:57 -0800 | [diff] [blame] | 751 | int ret = MSM_PM_SLEEP_MODE_NOT_SELECTED; |
Girish Mahadevan | dc318fd | 2012-08-17 16:48:05 -0600 | [diff] [blame] | 752 | uint32_t modified_time_us = 0; |
| 753 | struct msm_pm_time_params time_param; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 754 | |
Girish Mahadevan | dc318fd | 2012-08-17 16:48:05 -0600 | [diff] [blame] | 755 | time_param.latency_us = |
| 756 | (uint32_t) pm_qos_request(PM_QOS_CPU_DMA_LATENCY); |
| 757 | time_param.sleep_us = |
| 758 | (uint32_t) (ktime_to_us(tick_nohz_get_sleep_length()) |
| 759 | & UINT_MAX); |
| 760 | time_param.modified_time_us = 0; |
| 761 | |
| 762 | if (!dev->cpu) |
| 763 | time_param.next_event_us = |
| 764 | (uint32_t) (ktime_to_us(get_next_event_time()) |
| 765 | & UINT_MAX); |
| 766 | else |
| 767 | time_param.next_event_us = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 768 | |
| 769 | for (i = 0; i < dev->state_count; i++) { |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 770 | struct cpuidle_state *state = &drv->states[i]; |
| 771 | struct cpuidle_state_usage *st_usage = &dev->states_usage[i]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 772 | enum msm_pm_sleep_mode mode; |
| 773 | bool allow; |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 774 | uint32_t power; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 775 | int idx; |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 776 | void *rs_limits = NULL; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 777 | |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 778 | mode = (enum msm_pm_sleep_mode) cpuidle_get_statedata(st_usage); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 779 | idx = MSM_PM_MODE(dev->cpu, mode); |
| 780 | |
Praveen Chidambaram | 42da9d2 | 2012-03-30 12:16:34 -0600 | [diff] [blame] | 781 | allow = msm_pm_sleep_modes[idx].idle_enabled && |
| 782 | msm_pm_sleep_modes[idx].idle_supported; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 783 | |
| 784 | switch (mode) { |
| 785 | case MSM_PM_SLEEP_MODE_POWER_COLLAPSE: |
Mahesh Sivasubramanian | 87f579c | 2013-02-04 11:59:44 -0700 | [diff] [blame] | 786 | if (num_online_cpus() > 1) |
Priyanka Mathur | 68a9bc5 | 2012-10-03 15:15:01 -0700 | [diff] [blame] | 787 | allow = false; |
Mahesh Sivasubramanian | 87f579c | 2013-02-04 11:59:44 -0700 | [diff] [blame] | 788 | break; |
Mahesh Sivasubramanian | ba7e01c | 2012-09-04 18:22:51 -0600 | [diff] [blame] | 789 | case MSM_PM_SLEEP_MODE_RETENTION: |
Mahesh Sivasubramanian | 1b8601b | 2012-12-20 14:11:23 -0700 | [diff] [blame] | 790 | /* |
| 791 | * The Krait BHS regulator doesn't have enough head |
| 792 | * room to drive the retention voltage on LDO and so |
| 793 | * has disabled retention |
| 794 | */ |
| 795 | if (!msm_pm_ldo_retention_enabled) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 796 | allow = false; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 797 | |
Mahesh Sivasubramanian | 87f579c | 2013-02-04 11:59:44 -0700 | [diff] [blame] | 798 | if (msm_pm_retention_calls_tz && num_online_cpus() > 1) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 799 | allow = false; |
| 800 | break; |
Mahesh Sivasubramanian | 87f579c | 2013-02-04 11:59:44 -0700 | [diff] [blame] | 801 | case MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE: |
| 802 | case MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT: |
| 803 | break; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 804 | default: |
| 805 | allow = false; |
| 806 | break; |
| 807 | } |
| 808 | |
Mahesh Sivasubramanian | 87f579c | 2013-02-04 11:59:44 -0700 | [diff] [blame] | 809 | if (!allow) |
| 810 | continue; |
| 811 | |
| 812 | if (pm_sleep_ops.lowest_limits) |
| 813 | rs_limits = pm_sleep_ops.lowest_limits(true, |
| 814 | mode, &time_param, &power); |
| 815 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 816 | if (MSM_PM_DEBUG_IDLE & msm_pm_debug_mask) |
Mahesh Sivasubramanian | 87f579c | 2013-02-04 11:59:44 -0700 | [diff] [blame] | 817 | pr_info("CPU%u:%s:%s, latency %uus, slp %uus, lim %p\n", |
| 818 | dev->cpu, __func__, state->desc, |
| 819 | time_param.latency_us, |
| 820 | time_param.sleep_us, rs_limits); |
| 821 | if (!rs_limits) |
| 822 | continue; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 823 | |
Mahesh Sivasubramanian | 87f579c | 2013-02-04 11:59:44 -0700 | [diff] [blame] | 824 | if (power < power_usage) { |
| 825 | power_usage = power; |
| 826 | modified_time_us = time_param.modified_time_us; |
| 827 | ret = mode; |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 828 | *msm_pm_idle_rs_limits = rs_limits; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 829 | } |
Mahesh Sivasubramanian | 87f579c | 2013-02-04 11:59:44 -0700 | [diff] [blame] | 830 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 831 | } |
| 832 | |
Girish Mahadevan | dc318fd | 2012-08-17 16:48:05 -0600 | [diff] [blame] | 833 | if (modified_time_us && !dev->cpu) |
| 834 | msm_pm_set_timer(modified_time_us); |
Priyanka Mathur | 26b4a4b | 2012-11-05 13:45:45 -0800 | [diff] [blame] | 835 | |
| 836 | msm_pm_ftrace_lpm_enter(dev->cpu, time_param.latency_us, |
| 837 | time_param.sleep_us, time_param.next_event_us, |
| 838 | ret); |
| 839 | |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 840 | return ret; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 841 | } |
| 842 | |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 843 | enum msm_pm_sleep_mode msm_pm_idle_enter(struct cpuidle_device *dev, |
| 844 | struct cpuidle_driver *drv, int index) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 845 | { |
| 846 | int64_t time; |
Priyanka Mathur | 26b4a4b | 2012-11-05 13:45:45 -0800 | [diff] [blame] | 847 | bool collapsed = 1; |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 848 | int exit_stat = -1; |
| 849 | enum msm_pm_sleep_mode sleep_mode; |
| 850 | void *msm_pm_idle_rs_limits = NULL; |
Mahesh Sivasubramanian | 0369876 | 2013-04-18 16:18:46 -0600 | [diff] [blame] | 851 | uint32_t sleep_delay = 1; |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 852 | int ret = -ENODEV; |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 853 | int notify_rpm = false; |
| 854 | bool timer_halted = false; |
| 855 | |
| 856 | sleep_mode = msm_pm_idle_prepare(dev, drv, index, |
| 857 | &msm_pm_idle_rs_limits); |
| 858 | |
| 859 | if (!msm_pm_idle_rs_limits) { |
| 860 | sleep_mode = MSM_PM_SLEEP_MODE_NOT_SELECTED; |
| 861 | goto cpuidle_enter_bail; |
| 862 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 863 | |
| 864 | if (MSM_PM_DEBUG_IDLE & msm_pm_debug_mask) |
| 865 | pr_info("CPU%u: %s: mode %d\n", |
| 866 | smp_processor_id(), __func__, sleep_mode); |
| 867 | |
| 868 | time = ktime_to_ns(ktime_get()); |
| 869 | |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 870 | if (sleep_mode == MSM_PM_SLEEP_MODE_POWER_COLLAPSE) { |
Mahesh Sivasubramanian | 2f41538 | 2013-05-17 16:29:05 -0600 | [diff] [blame] | 871 | int64_t ns = msm_pm_timer_enter_idle(); |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 872 | notify_rpm = true; |
Mahesh Sivasubramanian | 2f41538 | 2013-05-17 16:29:05 -0600 | [diff] [blame] | 873 | do_div(ns, NSEC_PER_SEC / SCLK_HZ); |
| 874 | sleep_delay = (uint32_t)ns; |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 875 | |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 876 | if (sleep_delay == 0) /* 0 would mean infinite time */ |
| 877 | sleep_delay = 1; |
| 878 | } |
| 879 | |
| 880 | if (pm_sleep_ops.enter_sleep) |
| 881 | ret = pm_sleep_ops.enter_sleep(sleep_delay, |
| 882 | msm_pm_idle_rs_limits, true, notify_rpm); |
| 883 | if (ret) |
| 884 | goto cpuidle_enter_bail; |
| 885 | |
Mahesh Sivasubramanian | 95a48e7 | 2013-02-15 14:23:26 -0700 | [diff] [blame] | 886 | switch (sleep_mode) { |
| 887 | case MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT: |
| 888 | msm_pm_swfi(); |
| 889 | exit_stat = MSM_PM_STAT_IDLE_WFI; |
| 890 | break; |
| 891 | |
| 892 | case MSM_PM_SLEEP_MODE_RETENTION: |
| 893 | msm_pm_retention(); |
| 894 | exit_stat = MSM_PM_STAT_RETENTION; |
| 895 | break; |
| 896 | |
| 897 | case MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE: |
| 898 | collapsed = msm_pm_power_collapse_standalone(true); |
Venkat Devarasetty | 849f47f | 2013-05-19 17:44:18 +0530 | [diff] [blame] | 899 | if (collapsed) |
| 900 | exit_stat = MSM_PM_STAT_IDLE_STANDALONE_POWER_COLLAPSE; |
| 901 | else |
| 902 | exit_stat |
| 903 | = MSM_PM_STAT_IDLE_FAILED_STANDALONE_POWER_COLLAPSE; |
Mahesh Sivasubramanian | 95a48e7 | 2013-02-15 14:23:26 -0700 | [diff] [blame] | 904 | break; |
| 905 | |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 906 | case MSM_PM_SLEEP_MODE_POWER_COLLAPSE: |
Mahesh Sivasubramanian | 95a48e7 | 2013-02-15 14:23:26 -0700 | [diff] [blame] | 907 | if (MSM_PM_DEBUG_IDLE_CLK & msm_pm_debug_mask) |
| 908 | clock_debug_print_enabled(); |
Karthik Parsha | 6fb932d | 2012-01-24 18:04:12 -0800 | [diff] [blame] | 909 | |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 910 | collapsed = msm_pm_power_collapse(true); |
| 911 | timer_halted = true; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 912 | |
Venkat Devarasetty | 849f47f | 2013-05-19 17:44:18 +0530 | [diff] [blame] | 913 | if (collapsed) |
| 914 | exit_stat = MSM_PM_STAT_IDLE_POWER_COLLAPSE; |
| 915 | else |
| 916 | exit_stat = MSM_PM_STAT_IDLE_FAILED_POWER_COLLAPSE; |
| 917 | |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 918 | msm_pm_timer_exit_idle(timer_halted); |
Mahesh Sivasubramanian | 95a48e7 | 2013-02-15 14:23:26 -0700 | [diff] [blame] | 919 | break; |
Mahesh Sivasubramanian | 95a48e7 | 2013-02-15 14:23:26 -0700 | [diff] [blame] | 920 | |
| 921 | case MSM_PM_SLEEP_MODE_NOT_SELECTED: |
| 922 | goto cpuidle_enter_bail; |
| 923 | break; |
| 924 | |
| 925 | default: |
| 926 | __WARN(); |
| 927 | goto cpuidle_enter_bail; |
| 928 | break; |
| 929 | } |
| 930 | |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 931 | if (pm_sleep_ops.exit_sleep) |
| 932 | pm_sleep_ops.exit_sleep(msm_pm_idle_rs_limits, true, |
| 933 | notify_rpm, collapsed); |
Mahesh Sivasubramanian | 95a48e7 | 2013-02-15 14:23:26 -0700 | [diff] [blame] | 934 | |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 935 | time = ktime_to_ns(ktime_get()) - time; |
| 936 | msm_pm_ftrace_lpm_exit(smp_processor_id(), sleep_mode, collapsed); |
| 937 | if (exit_stat >= 0) |
| 938 | msm_pm_add_stat(exit_stat, time); |
Mahesh Sivasubramanian | 95a48e7 | 2013-02-15 14:23:26 -0700 | [diff] [blame] | 939 | do_div(time, 1000); |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 940 | dev->last_residency = (int) time; |
| 941 | return sleep_mode; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 942 | |
| 943 | cpuidle_enter_bail: |
Priyanka Mathur | 92fe575 | 2013-01-17 10:58:04 -0800 | [diff] [blame] | 944 | dev->last_residency = 0; |
| 945 | if (sleep_mode == MSM_PM_SLEEP_MODE_POWER_COLLAPSE) |
| 946 | msm_pm_timer_exit_idle(timer_halted); |
| 947 | sleep_mode = MSM_PM_SLEEP_MODE_NOT_SELECTED; |
| 948 | return sleep_mode; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 949 | } |
| 950 | |
Anji Jonnala | 02dac8d | 2013-03-06 21:31:04 +0530 | [diff] [blame] | 951 | int msm_pm_wait_cpu_shutdown(unsigned int cpu) |
| 952 | { |
Mahesh Sivasubramanian | 32b9d42 | 2013-05-20 13:50:16 -0600 | [diff] [blame] | 953 | int timeout = 0; |
Anji Jonnala | 02dac8d | 2013-03-06 21:31:04 +0530 | [diff] [blame] | 954 | |
| 955 | if (!msm_pm_slp_sts) |
| 956 | return 0; |
| 957 | if (!msm_pm_slp_sts[cpu].base_addr) |
| 958 | return 0; |
Mahesh Sivasubramanian | 32b9d42 | 2013-05-20 13:50:16 -0600 | [diff] [blame] | 959 | while (1) { |
Anji Jonnala | 02dac8d | 2013-03-06 21:31:04 +0530 | [diff] [blame] | 960 | /* |
| 961 | * Check for the SPM of the core being hotplugged to set |
| 962 | * its sleep state.The SPM sleep state indicates that the |
| 963 | * core has been power collapsed. |
| 964 | */ |
| 965 | int acc_sts = __raw_readl(msm_pm_slp_sts[cpu].base_addr); |
| 966 | |
| 967 | if (acc_sts & msm_pm_slp_sts[cpu].mask) |
| 968 | return 0; |
Mahesh Sivasubramanian | 65187f9 | 2013-03-19 15:14:06 -0600 | [diff] [blame] | 969 | udelay(100); |
Priyanka Mathur | e9dfe2b | 2013-05-24 15:25:57 -0700 | [diff] [blame] | 970 | WARN(++timeout == 20, "CPU%u didn't collape within 2ms\n", |
Mahesh Sivasubramanian | 32b9d42 | 2013-05-20 13:50:16 -0600 | [diff] [blame] | 971 | cpu); |
Anji Jonnala | 02dac8d | 2013-03-06 21:31:04 +0530 | [diff] [blame] | 972 | } |
| 973 | |
Anji Jonnala | 02dac8d | 2013-03-06 21:31:04 +0530 | [diff] [blame] | 974 | return -EBUSY; |
| 975 | } |
| 976 | |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 977 | void msm_pm_cpu_enter_lowpower(unsigned int cpu) |
| 978 | { |
| 979 | int i; |
| 980 | bool allow[MSM_PM_SLEEP_MODE_NR]; |
| 981 | |
| 982 | for (i = 0; i < MSM_PM_SLEEP_MODE_NR; i++) { |
| 983 | struct msm_pm_platform_data *mode; |
| 984 | |
Praveen Chidambaram | 42da9d2 | 2012-03-30 12:16:34 -0600 | [diff] [blame] | 985 | mode = &msm_pm_sleep_modes[MSM_PM_MODE(cpu, i)]; |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 986 | allow[i] = mode->suspend_supported && mode->suspend_enabled; |
| 987 | } |
| 988 | |
| 989 | if (MSM_PM_DEBUG_HOTPLUG & msm_pm_debug_mask) |
| 990 | pr_notice("CPU%u: %s: shutting down cpu\n", cpu, __func__); |
| 991 | |
Matt Wagantall | 5375aa7 | 2012-07-02 19:59:51 -0700 | [diff] [blame] | 992 | if (allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE]) |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 993 | msm_pm_power_collapse(false); |
Matt Wagantall | 5375aa7 | 2012-07-02 19:59:51 -0700 | [diff] [blame] | 994 | else if (allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE]) |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 995 | msm_pm_power_collapse_standalone(false); |
Matt Wagantall | 5375aa7 | 2012-07-02 19:59:51 -0700 | [diff] [blame] | 996 | else if (allow[MSM_PM_SLEEP_MODE_RETENTION]) |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 997 | msm_pm_retention(); |
Stephen Boyd | bda7427 | 2012-08-09 14:01:27 -0700 | [diff] [blame] | 998 | else |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 999 | msm_pm_swfi(); |
Mahesh Sivasubramanian | d23add1 | 2011-11-18 14:30:11 -0700 | [diff] [blame] | 1000 | } |
| 1001 | |
Mahesh Sivasubramanian | 1b8601b | 2012-12-20 14:11:23 -0700 | [diff] [blame] | 1002 | static void msm_pm_ack_retention_disable(void *data) |
| 1003 | { |
| 1004 | /* |
| 1005 | * This is a NULL function to ensure that the core has woken up |
| 1006 | * and is safe to disable retention. |
| 1007 | */ |
| 1008 | } |
| 1009 | /** |
| 1010 | * msm_pm_enable_retention() - Disable/Enable retention on all cores |
| 1011 | * @enable: Enable/Disable retention |
| 1012 | * |
| 1013 | */ |
| 1014 | void msm_pm_enable_retention(bool enable) |
| 1015 | { |
Matt Wagantall | d06f5c2 | 2013-03-14 19:31:14 -0700 | [diff] [blame] | 1016 | if (enable == msm_pm_ldo_retention_enabled) |
| 1017 | return; |
| 1018 | |
Mahesh Sivasubramanian | 1b8601b | 2012-12-20 14:11:23 -0700 | [diff] [blame] | 1019 | msm_pm_ldo_retention_enabled = enable; |
| 1020 | /* |
| 1021 | * If retention is being disabled, wakeup all online core to ensure |
| 1022 | * that it isn't executing retention. Offlined cores need not be woken |
| 1023 | * up as they enter the deepest sleep mode, namely RPM assited power |
| 1024 | * collapse |
| 1025 | */ |
Mahesh Sivasubramanian | 96f67d1 | 2013-03-14 22:44:42 -0600 | [diff] [blame] | 1026 | if (!enable) { |
| 1027 | preempt_disable(); |
Mahesh Sivasubramanian | 1b8601b | 2012-12-20 14:11:23 -0700 | [diff] [blame] | 1028 | smp_call_function_many(cpu_online_mask, |
| 1029 | msm_pm_ack_retention_disable, |
| 1030 | NULL, true); |
Mahesh Sivasubramanian | 96f67d1 | 2013-03-14 22:44:42 -0600 | [diff] [blame] | 1031 | preempt_enable(); |
| 1032 | |
| 1033 | |
| 1034 | } |
Mahesh Sivasubramanian | 1b8601b | 2012-12-20 14:11:23 -0700 | [diff] [blame] | 1035 | } |
| 1036 | EXPORT_SYMBOL(msm_pm_enable_retention); |
| 1037 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1038 | static int msm_pm_enter(suspend_state_t state) |
| 1039 | { |
| 1040 | bool allow[MSM_PM_SLEEP_MODE_NR]; |
| 1041 | int i; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1042 | int64_t period = 0; |
Praveen Chidambaram | 3895bde | 2012-05-14 19:42:40 +0530 | [diff] [blame] | 1043 | int64_t time = msm_pm_timer_enter_suspend(&period); |
Girish Mahadevan | dc318fd | 2012-08-17 16:48:05 -0600 | [diff] [blame] | 1044 | struct msm_pm_time_params time_param; |
| 1045 | |
| 1046 | time_param.latency_us = -1; |
| 1047 | time_param.sleep_us = -1; |
| 1048 | time_param.next_event_us = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1049 | |
| 1050 | if (MSM_PM_DEBUG_SUSPEND & msm_pm_debug_mask) |
| 1051 | pr_info("%s\n", __func__); |
| 1052 | |
| 1053 | if (smp_processor_id()) { |
| 1054 | __WARN(); |
| 1055 | goto enter_exit; |
| 1056 | } |
| 1057 | |
| 1058 | |
| 1059 | for (i = 0; i < MSM_PM_SLEEP_MODE_NR; i++) { |
| 1060 | struct msm_pm_platform_data *mode; |
| 1061 | |
Praveen Chidambaram | 42da9d2 | 2012-03-30 12:16:34 -0600 | [diff] [blame] | 1062 | mode = &msm_pm_sleep_modes[MSM_PM_MODE(0, i)]; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1063 | allow[i] = mode->suspend_supported && mode->suspend_enabled; |
| 1064 | } |
| 1065 | |
| 1066 | if (allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE]) { |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 1067 | void *rs_limits = NULL; |
| 1068 | int ret = -ENODEV; |
| 1069 | uint32_t power; |
Mahesh Sivasubramanian | 0369876 | 2013-04-18 16:18:46 -0600 | [diff] [blame] | 1070 | uint32_t msm_pm_max_sleep_time = 0; |
Venkat Devarasetty | 849f47f | 2013-05-19 17:44:18 +0530 | [diff] [blame] | 1071 | int collapsed = 0; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1072 | |
| 1073 | if (MSM_PM_DEBUG_SUSPEND & msm_pm_debug_mask) |
| 1074 | pr_info("%s: power collapse\n", __func__); |
| 1075 | |
| 1076 | clock_debug_print_enabled(); |
| 1077 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1078 | if (msm_pm_sleep_time_override > 0) { |
| 1079 | int64_t ns = NSEC_PER_SEC * |
| 1080 | (int64_t) msm_pm_sleep_time_override; |
Mahesh Sivasubramanian | 0369876 | 2013-04-18 16:18:46 -0600 | [diff] [blame] | 1081 | do_div(ns, NSEC_PER_SEC / SCLK_HZ); |
| 1082 | msm_pm_max_sleep_time = (uint32_t) ns; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1083 | } |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 1084 | |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 1085 | if (pm_sleep_ops.lowest_limits) |
| 1086 | rs_limits = pm_sleep_ops.lowest_limits(false, |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 1087 | MSM_PM_SLEEP_MODE_POWER_COLLAPSE, &time_param, &power); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1088 | |
| 1089 | if (rs_limits) { |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 1090 | if (pm_sleep_ops.enter_sleep) |
| 1091 | ret = pm_sleep_ops.enter_sleep( |
| 1092 | msm_pm_max_sleep_time, |
| 1093 | rs_limits, false, true); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1094 | if (!ret) { |
Venkat Devarasetty | 849f47f | 2013-05-19 17:44:18 +0530 | [diff] [blame] | 1095 | collapsed = msm_pm_power_collapse(false); |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 1096 | if (pm_sleep_ops.exit_sleep) { |
| 1097 | pm_sleep_ops.exit_sleep(rs_limits, |
| 1098 | false, true, collapsed); |
| 1099 | } |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1100 | } |
| 1101 | } else { |
| 1102 | pr_err("%s: cannot find the lowest power limit\n", |
| 1103 | __func__); |
| 1104 | } |
Praveen Chidambaram | 3895bde | 2012-05-14 19:42:40 +0530 | [diff] [blame] | 1105 | time = msm_pm_timer_exit_suspend(time, period); |
Venkat Devarasetty | 849f47f | 2013-05-19 17:44:18 +0530 | [diff] [blame] | 1106 | if (collapsed) |
| 1107 | msm_pm_add_stat(MSM_PM_STAT_SUSPEND, time); |
| 1108 | else |
| 1109 | msm_pm_add_stat(MSM_PM_STAT_FAILED_SUSPEND, time); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1110 | } else if (allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE]) { |
| 1111 | if (MSM_PM_DEBUG_SUSPEND & msm_pm_debug_mask) |
| 1112 | pr_info("%s: standalone power collapse\n", __func__); |
| 1113 | msm_pm_power_collapse_standalone(false); |
Praveen Chidambaram | d3d844d | 2012-04-24 09:47:38 -0600 | [diff] [blame] | 1114 | } else if (allow[MSM_PM_SLEEP_MODE_RETENTION]) { |
| 1115 | if (MSM_PM_DEBUG_SUSPEND & msm_pm_debug_mask) |
| 1116 | pr_info("%s: retention\n", __func__); |
| 1117 | msm_pm_retention(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1118 | } else if (allow[MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT]) { |
| 1119 | if (MSM_PM_DEBUG_SUSPEND & msm_pm_debug_mask) |
| 1120 | pr_info("%s: swfi\n", __func__); |
| 1121 | msm_pm_swfi(); |
| 1122 | } |
| 1123 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1124 | enter_exit: |
| 1125 | if (MSM_PM_DEBUG_SUSPEND & msm_pm_debug_mask) |
| 1126 | pr_info("%s: return\n", __func__); |
| 1127 | |
| 1128 | return 0; |
| 1129 | } |
| 1130 | |
Mahesh Sivasubramanian | 6d06e3a | 2012-05-16 13:41:07 -0600 | [diff] [blame] | 1131 | void msm_pm_set_sleep_ops(struct msm_pm_sleep_ops *ops) |
| 1132 | { |
| 1133 | if (ops) |
| 1134 | pm_sleep_ops = *ops; |
| 1135 | } |
| 1136 | |
Badhri Jagan Sridharan | 9b186af | 2013-05-24 12:47:35 -0700 | [diff] [blame] | 1137 | int msm_suspend_prepare(void) |
| 1138 | { |
| 1139 | if (pnoc_clk != NULL) |
| 1140 | clk_disable_unprepare(pnoc_clk); |
| 1141 | return 0; |
| 1142 | } |
| 1143 | |
| 1144 | void msm_suspend_wake(void) |
| 1145 | { |
| 1146 | if (pnoc_clk != NULL) |
| 1147 | clk_prepare_enable(pnoc_clk); |
| 1148 | } |
| 1149 | |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 1150 | static const struct platform_suspend_ops msm_pm_ops = { |
| 1151 | .enter = msm_pm_enter, |
| 1152 | .valid = suspend_valid_only_mem, |
Badhri Jagan Sridharan | 9b186af | 2013-05-24 12:47:35 -0700 | [diff] [blame] | 1153 | .prepare_late = msm_suspend_prepare, |
| 1154 | .wake = msm_suspend_wake, |
Mahesh Sivasubramanian | cb39662 | 2012-03-14 14:50:37 -0600 | [diff] [blame] | 1155 | }; |
Girish Mahadevan | ec50d2d | 2013-05-15 12:07:38 -0600 | [diff] [blame] | 1156 | |
| 1157 | static int __devinit msm_pm_snoc_client_probe(struct platform_device *pdev) |
| 1158 | { |
| 1159 | int rc = 0; |
| 1160 | static struct msm_bus_scale_pdata *msm_pm_bus_pdata; |
| 1161 | static uint32_t msm_pm_bus_client; |
| 1162 | |
| 1163 | msm_pm_bus_pdata = msm_bus_cl_get_pdata(pdev); |
| 1164 | |
| 1165 | if (msm_pm_bus_pdata) { |
| 1166 | msm_pm_bus_client = |
| 1167 | msm_bus_scale_register_client(msm_pm_bus_pdata); |
| 1168 | |
| 1169 | if (!msm_pm_bus_client) { |
| 1170 | pr_err("%s: Failed to register SNOC client", |
| 1171 | __func__); |
| 1172 | rc = -ENXIO; |
| 1173 | goto snoc_cl_probe_done; |
| 1174 | } |
| 1175 | |
| 1176 | rc = msm_bus_scale_client_update_request(msm_pm_bus_client, 1); |
| 1177 | |
| 1178 | if (rc) |
| 1179 | pr_err("%s: Error setting bus rate", __func__); |
| 1180 | } |
| 1181 | |
| 1182 | snoc_cl_probe_done: |
| 1183 | return rc; |
| 1184 | } |
| 1185 | |
Anji Jonnala | 02dac8d | 2013-03-06 21:31:04 +0530 | [diff] [blame] | 1186 | static int __devinit msm_cpu_status_probe(struct platform_device *pdev) |
| 1187 | { |
| 1188 | struct msm_pm_sleep_status_data *pdata; |
| 1189 | char *key; |
| 1190 | u32 cpu; |
| 1191 | |
| 1192 | if (!pdev) |
| 1193 | return -EFAULT; |
| 1194 | |
| 1195 | msm_pm_slp_sts = |
| 1196 | kzalloc(sizeof(*msm_pm_slp_sts) * num_possible_cpus(), |
| 1197 | GFP_KERNEL); |
| 1198 | |
| 1199 | if (!msm_pm_slp_sts) |
| 1200 | return -ENOMEM; |
| 1201 | |
| 1202 | if (pdev->dev.of_node) { |
| 1203 | struct resource *res; |
| 1204 | u32 offset; |
| 1205 | int rc; |
| 1206 | u32 mask; |
| 1207 | |
| 1208 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 1209 | if (!res) |
| 1210 | goto fail_free_mem; |
| 1211 | |
| 1212 | key = "qcom,cpu-alias-addr"; |
| 1213 | rc = of_property_read_u32(pdev->dev.of_node, key, &offset); |
| 1214 | |
| 1215 | if (rc) |
| 1216 | goto fail_free_mem; |
| 1217 | |
| 1218 | key = "qcom,sleep-status-mask"; |
| 1219 | rc = of_property_read_u32(pdev->dev.of_node, key, |
| 1220 | &mask); |
| 1221 | if (rc) |
| 1222 | goto fail_free_mem; |
| 1223 | |
| 1224 | for_each_possible_cpu(cpu) { |
| 1225 | msm_pm_slp_sts[cpu].base_addr = |
| 1226 | ioremap(res->start + cpu * offset, |
| 1227 | resource_size(res)); |
| 1228 | msm_pm_slp_sts[cpu].mask = mask; |
| 1229 | |
| 1230 | if (!msm_pm_slp_sts[cpu].base_addr) |
| 1231 | goto failed_of_node; |
| 1232 | } |
| 1233 | |
| 1234 | } else { |
| 1235 | pdata = pdev->dev.platform_data; |
| 1236 | if (!pdev->dev.platform_data) |
| 1237 | goto fail_free_mem; |
| 1238 | |
| 1239 | for_each_possible_cpu(cpu) { |
| 1240 | msm_pm_slp_sts[cpu].base_addr = |
| 1241 | pdata->base_addr + cpu * pdata->cpu_offset; |
| 1242 | msm_pm_slp_sts[cpu].mask = pdata->mask; |
| 1243 | } |
| 1244 | } |
| 1245 | |
| 1246 | return 0; |
| 1247 | |
| 1248 | failed_of_node: |
| 1249 | pr_info("%s(): Failed to key=%s\n", __func__, key); |
| 1250 | for_each_possible_cpu(cpu) { |
| 1251 | if (msm_pm_slp_sts[cpu].base_addr) |
| 1252 | iounmap(msm_pm_slp_sts[cpu].base_addr); |
| 1253 | } |
| 1254 | fail_free_mem: |
| 1255 | kfree(msm_pm_slp_sts); |
| 1256 | return -EINVAL; |
| 1257 | |
| 1258 | }; |
| 1259 | |
| 1260 | static struct of_device_id msm_slp_sts_match_tbl[] = { |
| 1261 | {.compatible = "qcom,cpu-sleep-status"}, |
| 1262 | {}, |
| 1263 | }; |
| 1264 | |
| 1265 | static struct platform_driver msm_cpu_status_driver = { |
| 1266 | .probe = msm_cpu_status_probe, |
| 1267 | .driver = { |
| 1268 | .name = "cpu_slp_status", |
| 1269 | .owner = THIS_MODULE, |
| 1270 | .of_match_table = msm_slp_sts_match_tbl, |
| 1271 | }, |
| 1272 | }; |
Mahesh Sivasubramanian | cb39662 | 2012-03-14 14:50:37 -0600 | [diff] [blame] | 1273 | |
Girish Mahadevan | ec50d2d | 2013-05-15 12:07:38 -0600 | [diff] [blame] | 1274 | static struct of_device_id msm_snoc_clnt_match_tbl[] = { |
| 1275 | {.compatible = "qcom,pm-snoc-client"}, |
| 1276 | {}, |
| 1277 | }; |
| 1278 | |
| 1279 | static struct platform_driver msm_cpu_pm_snoc_client_driver = { |
| 1280 | .probe = msm_pm_snoc_client_probe, |
| 1281 | .driver = { |
| 1282 | .name = "pm_snoc_client", |
| 1283 | .owner = THIS_MODULE, |
| 1284 | .of_match_table = msm_snoc_clnt_match_tbl, |
| 1285 | }, |
| 1286 | }; |
| 1287 | |
| 1288 | |
Praveen Chidambaram | ede45d0 | 2013-02-20 17:45:21 -0700 | [diff] [blame] | 1289 | static int __init msm_pm_setup_saved_state(void) |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1290 | { |
| 1291 | pgd_t *pc_pgd; |
| 1292 | pmd_t *pmd; |
| 1293 | unsigned long pmdval; |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1294 | unsigned long exit_phys; |
Laura Abbott | 2ff1d12 | 2013-04-24 16:13:03 -0700 | [diff] [blame] | 1295 | dma_addr_t temp_phys; |
Praveen Chidambaram | 3895bde | 2012-05-14 19:42:40 +0530 | [diff] [blame] | 1296 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1297 | /* Page table for cores to come back up safely. */ |
| 1298 | pc_pgd = pgd_alloc(&init_mm); |
| 1299 | if (!pc_pgd) |
| 1300 | return -ENOMEM; |
| 1301 | |
Steve Muckle | f132c6c | 2012-06-06 18:30:57 -0700 | [diff] [blame] | 1302 | exit_phys = virt_to_phys(msm_pm_collapse_exit); |
| 1303 | |
| 1304 | pmd = pmd_offset(pud_offset(pc_pgd + pgd_index(exit_phys),exit_phys), |
| 1305 | exit_phys); |
| 1306 | pmdval = (exit_phys & PGDIR_MASK) | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1307 | PMD_TYPE_SECT | PMD_SECT_AP_WRITE; |
| 1308 | pmd[0] = __pmd(pmdval); |
| 1309 | pmd[1] = __pmd(pmdval + (1 << (PGDIR_SHIFT - 1))); |
| 1310 | |
Laura Abbott | 2ff1d12 | 2013-04-24 16:13:03 -0700 | [diff] [blame] | 1311 | msm_saved_state = dma_zalloc_coherent(NULL, CPU_SAVED_STATE_SIZE * |
| 1312 | num_possible_cpus(), |
| 1313 | &temp_phys, 0); |
| 1314 | |
Steve Muckle | fcece05 | 2012-02-18 20:09:58 -0800 | [diff] [blame] | 1315 | if (!msm_saved_state) |
| 1316 | return -ENOMEM; |
| 1317 | |
Laura Abbott | 2ff1d12 | 2013-04-24 16:13:03 -0700 | [diff] [blame] | 1318 | /* |
| 1319 | * Explicitly cast here since msm_saved_state_phys is defined |
| 1320 | * in assembly and we want to avoid any kind of truncation |
| 1321 | * or endian problems. |
| 1322 | */ |
| 1323 | msm_saved_state_phys = (unsigned long)temp_phys; |
| 1324 | |
| 1325 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1326 | /* It is remotely possible that the code in msm_pm_collapse_exit() |
| 1327 | * which turns on the MMU with this mapping is in the |
| 1328 | * next even-numbered megabyte beyond the |
| 1329 | * start of msm_pm_collapse_exit(). |
| 1330 | * Map this megabyte in as well. |
| 1331 | */ |
| 1332 | pmd[2] = __pmd(pmdval + (2 << (PGDIR_SHIFT - 1))); |
| 1333 | flush_pmd_entry(pmd); |
| 1334 | msm_pm_pc_pgd = virt_to_phys(pc_pgd); |
Steve Muckle | 730ad7a | 2012-02-21 15:26:37 -0800 | [diff] [blame] | 1335 | clean_caches((unsigned long)&msm_pm_pc_pgd, sizeof(msm_pm_pc_pgd), |
| 1336 | virt_to_phys(&msm_pm_pc_pgd)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1337 | |
Praveen Chidambaram | ede45d0 | 2013-02-20 17:45:21 -0700 | [diff] [blame] | 1338 | return 0; |
| 1339 | } |
Laura Abbott | 2ff1d12 | 2013-04-24 16:13:03 -0700 | [diff] [blame] | 1340 | arch_initcall(msm_pm_setup_saved_state); |
Praveen Chidambaram | ede45d0 | 2013-02-20 17:45:21 -0700 | [diff] [blame] | 1341 | |
Mahesh Sivasubramanian | b7bda88 | 2013-04-08 09:55:48 -0600 | [diff] [blame] | 1342 | static void setup_broadcast_timer(void *arg) |
| 1343 | { |
Mahesh Sivasubramanian | b7bda88 | 2013-04-08 09:55:48 -0600 | [diff] [blame] | 1344 | int cpu = smp_processor_id(); |
| 1345 | |
Mahesh Sivasubramanian | 738eaf6 | 2013-04-30 12:42:59 -0600 | [diff] [blame] | 1346 | clockevents_notify(CLOCK_EVT_NOTIFY_BROADCAST_ON, &cpu); |
Mahesh Sivasubramanian | b7bda88 | 2013-04-08 09:55:48 -0600 | [diff] [blame] | 1347 | } |
| 1348 | |
| 1349 | static int setup_broadcast_cpuhp_notify(struct notifier_block *n, |
| 1350 | unsigned long action, void *hcpu) |
| 1351 | { |
Mahesh Sivasubramanian | 738eaf6 | 2013-04-30 12:42:59 -0600 | [diff] [blame] | 1352 | int cpu = (unsigned long)hcpu; |
Mahesh Sivasubramanian | b7bda88 | 2013-04-08 09:55:48 -0600 | [diff] [blame] | 1353 | |
| 1354 | switch (action & ~CPU_TASKS_FROZEN) { |
| 1355 | case CPU_ONLINE: |
Mahesh Sivasubramanian | 738eaf6 | 2013-04-30 12:42:59 -0600 | [diff] [blame] | 1356 | smp_call_function_single(cpu, setup_broadcast_timer, NULL, 1); |
Mahesh Sivasubramanian | b7bda88 | 2013-04-08 09:55:48 -0600 | [diff] [blame] | 1357 | break; |
| 1358 | } |
| 1359 | |
| 1360 | return NOTIFY_OK; |
| 1361 | } |
| 1362 | |
| 1363 | static struct notifier_block setup_broadcast_notifier = { |
| 1364 | .notifier_call = setup_broadcast_cpuhp_notify, |
| 1365 | }; |
| 1366 | |
Praveen Chidambaram | ede45d0 | 2013-02-20 17:45:21 -0700 | [diff] [blame] | 1367 | static int __init msm_pm_init(void) |
| 1368 | { |
| 1369 | enum msm_pm_time_stats_id enable_stats[] = { |
| 1370 | MSM_PM_STAT_IDLE_WFI, |
| 1371 | MSM_PM_STAT_RETENTION, |
| 1372 | MSM_PM_STAT_IDLE_STANDALONE_POWER_COLLAPSE, |
| 1373 | MSM_PM_STAT_IDLE_POWER_COLLAPSE, |
| 1374 | MSM_PM_STAT_SUSPEND, |
| 1375 | }; |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1376 | msm_pm_mode_sysfs_add(); |
Praveen Chidambaram | 3895bde | 2012-05-14 19:42:40 +0530 | [diff] [blame] | 1377 | msm_pm_add_stats(enable_stats, ARRAY_SIZE(enable_stats)); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1378 | suspend_set_ops(&msm_pm_ops); |
Girish Mahadevan | 3249361 | 2013-05-10 14:37:17 -0600 | [diff] [blame] | 1379 | hrtimer_init(&pm_hrtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1380 | msm_cpuidle_init(); |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1381 | |
Mahesh Sivasubramanian | b7bda88 | 2013-04-08 09:55:48 -0600 | [diff] [blame] | 1382 | if (msm_pm_pc_reset_timer) { |
Mahesh Sivasubramanian | 738eaf6 | 2013-04-30 12:42:59 -0600 | [diff] [blame] | 1383 | on_each_cpu(setup_broadcast_timer, NULL, 1); |
Mahesh Sivasubramanian | b7bda88 | 2013-04-08 09:55:48 -0600 | [diff] [blame] | 1384 | register_cpu_notifier(&setup_broadcast_notifier); |
| 1385 | } |
| 1386 | |
Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 1387 | return 0; |
| 1388 | } |
| 1389 | |
Girish Mahadevan | 5594499 | 2012-10-26 11:03:07 -0600 | [diff] [blame] | 1390 | static void __devinit msm_pm_set_flush_fn(uint32_t pc_mode) |
| 1391 | { |
| 1392 | msm_pm_disable_l2_fn = NULL; |
| 1393 | msm_pm_enable_l2_fn = NULL; |
| 1394 | msm_pm_flush_l2_fn = outer_flush_all; |
| 1395 | |
| 1396 | if (pc_mode == MSM_PM_PC_NOTZ_L2_EXT) { |
| 1397 | msm_pm_disable_l2_fn = outer_disable; |
| 1398 | msm_pm_enable_l2_fn = outer_resume; |
| 1399 | } |
| 1400 | } |
| 1401 | |
Priyanka Mathur | 13bdad1 | 2013-01-28 15:52:56 -0800 | [diff] [blame] | 1402 | struct msm_pc_debug_counters_buffer { |
| 1403 | void __iomem *reg; |
| 1404 | u32 len; |
| 1405 | char buf[MAX_BUF_SIZE]; |
| 1406 | }; |
| 1407 | |
| 1408 | static inline u32 msm_pc_debug_counters_read_register( |
| 1409 | void __iomem *reg, int index , int offset) |
| 1410 | { |
| 1411 | return readl_relaxed(reg + (index * 4 + offset) * 4); |
| 1412 | } |
| 1413 | |
| 1414 | static char *counter_name[] = { |
| 1415 | "PC Entry Counter", |
| 1416 | "Warmboot Entry Counter", |
| 1417 | "PC Bailout Counter" |
| 1418 | }; |
| 1419 | |
| 1420 | static int msm_pc_debug_counters_copy( |
| 1421 | struct msm_pc_debug_counters_buffer *data) |
| 1422 | { |
| 1423 | int j; |
| 1424 | u32 stat; |
| 1425 | unsigned int cpu; |
| 1426 | |
| 1427 | for_each_possible_cpu(cpu) { |
| 1428 | data->len += scnprintf(data->buf + data->len, |
| 1429 | sizeof(data->buf)-data->len, |
| 1430 | "CPU%d\n", cpu); |
| 1431 | |
| 1432 | for (j = 0; j < NUM_OF_COUNTERS; j++) { |
| 1433 | stat = msm_pc_debug_counters_read_register( |
| 1434 | data->reg, cpu, j); |
| 1435 | data->len += scnprintf(data->buf + data->len, |
| 1436 | sizeof(data->buf)-data->len, |
| 1437 | "\t%s : %d\n", counter_name[j], |
| 1438 | stat); |
| 1439 | } |
| 1440 | |
| 1441 | } |
| 1442 | |
| 1443 | return data->len; |
| 1444 | } |
| 1445 | |
| 1446 | static int msm_pc_debug_counters_file_read(struct file *file, |
| 1447 | char __user *bufu, size_t count, loff_t *ppos) |
| 1448 | { |
| 1449 | struct msm_pc_debug_counters_buffer *data; |
| 1450 | |
| 1451 | data = file->private_data; |
| 1452 | |
| 1453 | if (!data) |
| 1454 | return -EINVAL; |
| 1455 | |
Mahesh Sivasubramanian | 6900fdc | 2013-04-18 14:02:52 -0600 | [diff] [blame] | 1456 | if (!bufu) |
Priyanka Mathur | 13bdad1 | 2013-01-28 15:52:56 -0800 | [diff] [blame] | 1457 | return -EINVAL; |
| 1458 | |
| 1459 | if (!access_ok(VERIFY_WRITE, bufu, count)) |
| 1460 | return -EFAULT; |
| 1461 | |
| 1462 | if (*ppos >= data->len && data->len == 0) |
| 1463 | data->len = msm_pc_debug_counters_copy(data); |
| 1464 | |
| 1465 | return simple_read_from_buffer(bufu, count, ppos, |
| 1466 | data->buf, data->len); |
| 1467 | } |
| 1468 | |
| 1469 | static int msm_pc_debug_counters_file_open(struct inode *inode, |
| 1470 | struct file *file) |
| 1471 | { |
| 1472 | struct msm_pc_debug_counters_buffer *buf; |
| 1473 | void __iomem *msm_pc_debug_counters_reg; |
| 1474 | |
| 1475 | msm_pc_debug_counters_reg = inode->i_private; |
| 1476 | |
| 1477 | if (!msm_pc_debug_counters_reg) |
| 1478 | return -EINVAL; |
| 1479 | |
| 1480 | file->private_data = kzalloc( |
| 1481 | sizeof(struct msm_pc_debug_counters_buffer), GFP_KERNEL); |
| 1482 | |
| 1483 | if (!file->private_data) { |
| 1484 | pr_err("%s: ERROR kmalloc failed to allocate %d bytes\n", |
| 1485 | __func__, sizeof(struct msm_pc_debug_counters_buffer)); |
| 1486 | |
| 1487 | return -ENOMEM; |
| 1488 | } |
| 1489 | |
| 1490 | buf = file->private_data; |
| 1491 | buf->reg = msm_pc_debug_counters_reg; |
| 1492 | |
| 1493 | return 0; |
| 1494 | } |
| 1495 | |
| 1496 | static int msm_pc_debug_counters_file_close(struct inode *inode, |
| 1497 | struct file *file) |
| 1498 | { |
| 1499 | kfree(file->private_data); |
| 1500 | return 0; |
| 1501 | } |
| 1502 | |
| 1503 | static const struct file_operations msm_pc_debug_counters_fops = { |
| 1504 | .open = msm_pc_debug_counters_file_open, |
| 1505 | .read = msm_pc_debug_counters_file_read, |
| 1506 | .release = msm_pc_debug_counters_file_close, |
| 1507 | .llseek = no_llseek, |
| 1508 | }; |
| 1509 | |
Girish Mahadevan | 5594499 | 2012-10-26 11:03:07 -0600 | [diff] [blame] | 1510 | static int __devinit msm_pm_8x60_probe(struct platform_device *pdev) |
| 1511 | { |
| 1512 | char *key = NULL; |
Priyanka Mathur | 13bdad1 | 2013-01-28 15:52:56 -0800 | [diff] [blame] | 1513 | struct dentry *dent = NULL; |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 1514 | struct resource *res = NULL; |
| 1515 | int i ; |
| 1516 | struct msm_pm_init_data_type pdata_local; |
Girish Mahadevan | 5594499 | 2012-10-26 11:03:07 -0600 | [diff] [blame] | 1517 | int ret = 0; |
| 1518 | |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 1519 | memset(&pdata_local, 0, sizeof(struct msm_pm_init_data_type)); |
| 1520 | |
| 1521 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 1522 | if (res) { |
| 1523 | msm_pc_debug_counters_phys = res->start; |
| 1524 | WARN_ON(resource_size(res) < SZ_64); |
| 1525 | msm_pc_debug_counters = devm_ioremap(&pdev->dev, res->start, |
| 1526 | resource_size(res)); |
Priyanka Mathur | 13bdad1 | 2013-01-28 15:52:56 -0800 | [diff] [blame] | 1527 | if (msm_pc_debug_counters) |
| 1528 | for (i = 0; i < resource_size(res)/4; i++) |
| 1529 | __raw_writel(0, msm_pc_debug_counters + i * 4); |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 1530 | |
| 1531 | } |
| 1532 | |
| 1533 | if (!msm_pc_debug_counters) { |
| 1534 | msm_pc_debug_counters = 0; |
| 1535 | msm_pc_debug_counters_phys = 0; |
Priyanka Mathur | 13bdad1 | 2013-01-28 15:52:56 -0800 | [diff] [blame] | 1536 | } else { |
| 1537 | dent = debugfs_create_file("pc_debug_counter", S_IRUGO, NULL, |
| 1538 | msm_pc_debug_counters, |
| 1539 | &msm_pc_debug_counters_fops); |
| 1540 | if (!dent) |
| 1541 | pr_err("%s: ERROR debugfs_create_file failed\n", |
| 1542 | __func__); |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 1543 | } |
| 1544 | |
Girish Mahadevan | 5594499 | 2012-10-26 11:03:07 -0600 | [diff] [blame] | 1545 | if (!pdev->dev.of_node) { |
| 1546 | struct msm_pm_init_data_type *d = pdev->dev.platform_data; |
| 1547 | |
| 1548 | if (!d) |
| 1549 | goto pm_8x60_probe_done; |
| 1550 | |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 1551 | memcpy(&pdata_local, d, sizeof(struct msm_pm_init_data_type)); |
| 1552 | |
Girish Mahadevan | 5594499 | 2012-10-26 11:03:07 -0600 | [diff] [blame] | 1553 | } else { |
| 1554 | key = "qcom,pc-mode"; |
Archana Sathyakumar | 2b91dc8 | 2013-02-01 17:38:23 -0700 | [diff] [blame] | 1555 | ret = msm_pm_get_pc_mode(pdev->dev.of_node, |
| 1556 | key, |
| 1557 | &pdata_local.pc_mode); |
Girish Mahadevan | 5594499 | 2012-10-26 11:03:07 -0600 | [diff] [blame] | 1558 | if (ret) { |
Archana Sathyakumar | 2b91dc8 | 2013-02-01 17:38:23 -0700 | [diff] [blame] | 1559 | pr_debug("%s: Error reading key %s", |
Girish Mahadevan | 5594499 | 2012-10-26 11:03:07 -0600 | [diff] [blame] | 1560 | __func__, key); |
Archana Sathyakumar | 2b91dc8 | 2013-02-01 17:38:23 -0700 | [diff] [blame] | 1561 | return -EINVAL; |
Girish Mahadevan | 5594499 | 2012-10-26 11:03:07 -0600 | [diff] [blame] | 1562 | } |
Girish Mahadevan | 5594499 | 2012-10-26 11:03:07 -0600 | [diff] [blame] | 1563 | |
| 1564 | key = "qcom,use-sync-timer"; |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 1565 | pdata_local.use_sync_timer = |
Girish Mahadevan | 5594499 | 2012-10-26 11:03:07 -0600 | [diff] [blame] | 1566 | of_property_read_bool(pdev->dev.of_node, key); |
Praveen Chidambaram | 4b8df03 | 2013-01-18 16:21:16 -0700 | [diff] [blame] | 1567 | |
| 1568 | key = "qcom,saw-turns-off-pll"; |
| 1569 | msm_no_ramp_down_pc = of_property_read_bool(pdev->dev.of_node, |
| 1570 | key); |
Mahesh Sivasubramanian | b7bda88 | 2013-04-08 09:55:48 -0600 | [diff] [blame] | 1571 | |
| 1572 | key = "qcom,pc-resets-timer"; |
| 1573 | msm_pm_pc_reset_timer = of_property_read_bool( |
| 1574 | pdev->dev.of_node, key); |
Girish Mahadevan | 5594499 | 2012-10-26 11:03:07 -0600 | [diff] [blame] | 1575 | } |
| 1576 | |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 1577 | if (pdata_local.cp15_data.reg_data && |
| 1578 | pdata_local.cp15_data.reg_saved_state_size > 0) { |
| 1579 | cp15_data.reg_data = kzalloc(sizeof(uint32_t) * |
| 1580 | pdata_local.cp15_data.reg_saved_state_size, |
| 1581 | GFP_KERNEL); |
| 1582 | if (!cp15_data.reg_data) |
| 1583 | return -ENOMEM; |
| 1584 | |
| 1585 | cp15_data.reg_val = kzalloc(sizeof(uint32_t) * |
| 1586 | pdata_local.cp15_data.reg_saved_state_size, |
| 1587 | GFP_KERNEL); |
| 1588 | if (cp15_data.reg_val) |
| 1589 | return -ENOMEM; |
| 1590 | |
| 1591 | memcpy(cp15_data.reg_data, pdata_local.cp15_data.reg_data, |
| 1592 | pdata_local.cp15_data.reg_saved_state_size * |
| 1593 | sizeof(uint32_t)); |
| 1594 | } |
| 1595 | |
| 1596 | msm_pm_set_flush_fn(pdata_local.pc_mode); |
| 1597 | msm_pm_use_sync_timer = pdata_local.use_sync_timer; |
| 1598 | msm_pm_retention_calls_tz = pdata_local.retention_calls_tz; |
| 1599 | |
Girish Mahadevan | 5594499 | 2012-10-26 11:03:07 -0600 | [diff] [blame] | 1600 | pm_8x60_probe_done: |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 1601 | msm_pm_init(); |
Anji Jonnala | 02dac8d | 2013-03-06 21:31:04 +0530 | [diff] [blame] | 1602 | if (pdev->dev.of_node) |
| 1603 | of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev); |
| 1604 | |
Girish Mahadevan | 5594499 | 2012-10-26 11:03:07 -0600 | [diff] [blame] | 1605 | return ret; |
| 1606 | } |
| 1607 | |
| 1608 | static struct of_device_id msm_pm_8x60_table[] = { |
| 1609 | {.compatible = "qcom,pm-8x60"}, |
| 1610 | {}, |
| 1611 | }; |
| 1612 | |
| 1613 | static struct platform_driver msm_pm_8x60_driver = { |
| 1614 | .probe = msm_pm_8x60_probe, |
| 1615 | .driver = { |
| 1616 | .name = "pm-8x60", |
| 1617 | .owner = THIS_MODULE, |
| 1618 | .of_match_table = msm_pm_8x60_table, |
| 1619 | }, |
| 1620 | }; |
| 1621 | |
| 1622 | static int __init msm_pm_8x60_init(void) |
| 1623 | { |
Anji Jonnala | 02dac8d | 2013-03-06 21:31:04 +0530 | [diff] [blame] | 1624 | int rc; |
| 1625 | |
Girish Mahadevan | ec50d2d | 2013-05-15 12:07:38 -0600 | [diff] [blame] | 1626 | rc = platform_driver_register(&msm_cpu_pm_snoc_client_driver); |
| 1627 | |
| 1628 | if (rc) { |
| 1629 | pr_err("%s(): failed to register driver %s\n", __func__, |
| 1630 | msm_cpu_pm_snoc_client_driver.driver.name); |
| 1631 | return rc; |
| 1632 | } |
| 1633 | |
Badhri Jagan Sridharan | 9b186af | 2013-05-24 12:47:35 -0700 | [diff] [blame] | 1634 | pnoc_clk = clk_get_sys("pm_8x60", "bus_clk"); |
| 1635 | |
| 1636 | if (IS_ERR(pnoc_clk)) |
| 1637 | pnoc_clk = NULL; |
| 1638 | else { |
| 1639 | clk_set_rate(pnoc_clk, 19200000); |
| 1640 | rc = clk_prepare_enable(pnoc_clk); |
| 1641 | |
| 1642 | if (rc) |
| 1643 | pr_err("%s: PNOC clock enable failed\n", __func__); |
| 1644 | } |
| 1645 | |
Girish Mahadevan | 5594499 | 2012-10-26 11:03:07 -0600 | [diff] [blame] | 1646 | return platform_driver_register(&msm_pm_8x60_driver); |
| 1647 | } |
Praveen Chidambaram | f27a515 | 2013-02-01 11:44:53 -0700 | [diff] [blame] | 1648 | device_initcall(msm_pm_8x60_init); |
Mahesh Sivasubramanian | 59ffcb0 | 2013-05-31 15:08:15 -0600 | [diff] [blame] | 1649 | |
| 1650 | void __init msm_pm_sleep_status_init(void) |
| 1651 | { |
| 1652 | platform_driver_register(&msm_cpu_status_driver); |
| 1653 | } |