blob: aa33f2c69b388889cbe9d847196caedaf0ee821e [file] [log] [blame]
Priyanka Mathur3abfd442013-01-11 12:58:51 -08001/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
Praveen Chidambaram85b7b282012-04-16 13:45:15 -06002 *
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/slab.h>
18#include <linux/platform_device.h>
19#include <linux/of.h>
20#include <mach/mpm.h>
Girish Mahadevan40abbe12012-04-25 14:58:13 -060021#include "lpm_resources.h"
Mahesh Sivasubramanian6d06e3a2012-05-16 13:41:07 -060022#include "pm.h"
Mahesh Sivasubramanian11dad772012-07-13 14:00:01 -060023#include "rpm-notifier.h"
Praveen Chidambaram85b7b282012-04-16 13:45:15 -060024
Mahesh Sivasubramanianfae923f2012-10-08 16:22:51 -060025
26enum {
27 MSM_LPM_LVL_DBG_SUSPEND_LIMITS = BIT(0),
28 MSM_LPM_LVL_DBG_IDLE_LIMITS = BIT(1),
29};
30
Archana Sathyakumare6a35102013-01-31 16:18:49 -070031#define MAX_STR_LEN 30
32
Mahesh Sivasubramanianfae923f2012-10-08 16:22:51 -060033static int msm_lpm_lvl_dbg_msk;
34
35module_param_named(
36 debug_mask, msm_lpm_lvl_dbg_msk, int, S_IRUGO | S_IWUSR | S_IWGRP
37);
38
Praveen Chidambaram85b7b282012-04-16 13:45:15 -060039static struct msm_rpmrs_level *msm_lpm_levels;
40static int msm_lpm_level_count;
41
Priyanka Mathur3abfd442013-01-11 12:58:51 -080042static DEFINE_PER_CPU(uint32_t , msm_lpm_sleep_time);
43static DEFINE_PER_CPU(int , lpm_permitted_level);
44static DEFINE_PER_CPU(struct atomic_notifier_head, lpm_notify_head);
45
Archana Sathyakumare6a35102013-01-31 16:18:49 -070046static int msm_pm_get_sleep_mode_value(struct device_node *node,
47 const char *key, uint32_t *sleep_mode_val)
48{
49 int i;
50 struct lpm_lookup_table {
51 uint32_t modes;
52 const char *mode_name;
53 };
54 struct lpm_lookup_table pm_sm_lookup[] = {
55 {MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT,
56 "wfi"},
57 {MSM_PM_SLEEP_MODE_RAMP_DOWN_AND_WAIT_FOR_INTERRUPT,
58 "ramp_down_and_wfi"},
59 {MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE,
60 "standalone_pc"},
61 {MSM_PM_SLEEP_MODE_POWER_COLLAPSE,
62 "pc"},
63 {MSM_PM_SLEEP_MODE_RETENTION,
64 "retention"},
65 {MSM_PM_SLEEP_MODE_POWER_COLLAPSE_SUSPEND,
66 "pc_suspend"},
67 {MSM_PM_SLEEP_MODE_POWER_COLLAPSE_NO_XO_SHUTDOWN,
68 "pc_no_xo_shutdown"}
69 };
70 int ret;
71 const char *mode_name;
72
73 ret = of_property_read_string(node, key, &mode_name);
74 if (!ret) {
75 ret = -EINVAL;
76 for (i = 0; i < ARRAY_SIZE(pm_sm_lookup); i++) {
77 if (!strncmp(mode_name, pm_sm_lookup[i].mode_name,
78 MAX_STR_LEN)) {
79 *sleep_mode_val = pm_sm_lookup[i].modes;
80 ret = 0;
81 break;
82 }
83 }
84 }
85 return ret;
86}
87
Girish Mahadevan40abbe12012-04-25 14:58:13 -060088static void msm_lpm_level_update(void)
89{
90 unsigned int lpm_level;
91 struct msm_rpmrs_level *level = NULL;
92
93 for (lpm_level = 0; lpm_level < msm_lpm_level_count; lpm_level++) {
94 level = &msm_lpm_levels[lpm_level];
95 level->available =
96 !msm_lpm_level_beyond_limit(&level->rs_limits);
97 }
98}
99
100int msm_lpm_enter_sleep(uint32_t sclk_count, void *limits,
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600101 bool from_idle, bool notify_rpm)
102{
Girish Mahadevan40abbe12012-04-25 14:58:13 -0600103 int ret = 0;
Mahesh Sivasubramanian9b0f4122013-02-15 14:20:52 -0700104 int debug_mask;
105 struct msm_rpmrs_limits *l = (struct msm_rpmrs_limits *)limits;
Priyanka Mathur3abfd442013-01-11 12:58:51 -0800106 struct msm_lpm_sleep_data sleep_data;
107
108 sleep_data.limits = limits;
109 sleep_data.kernel_sleep = __get_cpu_var(msm_lpm_sleep_time);
110 atomic_notifier_call_chain(&__get_cpu_var(lpm_notify_head),
111 MSM_LPM_STATE_ENTER, &sleep_data);
Girish Mahadevan40abbe12012-04-25 14:58:13 -0600112
Mahesh Sivasubramanian9b0f4122013-02-15 14:20:52 -0700113 if (from_idle)
114 debug_mask = msm_lpm_lvl_dbg_msk &
Priyanka Mathur86cfc762013-01-10 17:03:04 -0800115 MSM_LPM_LVL_DBG_IDLE_LIMITS;
Mahesh Sivasubramanian9b0f4122013-02-15 14:20:52 -0700116 else
117 debug_mask = msm_lpm_lvl_dbg_msk &
Priyanka Mathur86cfc762013-01-10 17:03:04 -0800118 MSM_LPM_LVL_DBG_SUSPEND_LIMITS;
Mahesh Sivasubramanian9b0f4122013-02-15 14:20:52 -0700119
120 if (debug_mask)
121 pr_info("%s(): pxo:%d l2:%d mem:0x%x(0x%x) dig:0x%x(0x%x)\n",
122 __func__, l->pxo, l->l2_cache,
123 l->vdd_mem_lower_bound,
124 l->vdd_mem_upper_bound,
125 l->vdd_dig_lower_bound,
126 l->vdd_dig_upper_bound);
127
128 ret = msm_lpmrs_enter_sleep(sclk_count, l, from_idle, notify_rpm);
Mahesh Sivasubramanian0558d4b2012-10-12 18:05:28 -0600129 if (ret) {
130 pr_warn("%s() LPM resources failed to enter sleep\n",
131 __func__);
132 goto bail;
133 }
Priyanka Mathur86cfc762013-01-10 17:03:04 -0800134 if (notify_rpm) {
135 ret = msm_rpm_enter_sleep(debug_mask);
136 if (ret) {
137 pr_warn("%s(): RPM failed to enter sleep err:%d\n",
138 __func__, ret);
139 goto bail;
140 }
141 }
Mahesh Sivasubramanian11dad772012-07-13 14:00:01 -0600142bail:
Girish Mahadevan40abbe12012-04-25 14:58:13 -0600143 return ret;
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600144}
145
Mahesh Sivasubramanian6d06e3a2012-05-16 13:41:07 -0600146static void msm_lpm_exit_sleep(void *limits, bool from_idle,
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600147 bool notify_rpm, bool collapsed)
148{
Mahesh Sivasubramanian0558d4b2012-10-12 18:05:28 -0600149
Girish Mahadevana9964a52012-06-29 10:14:09 -0600150 msm_lpmrs_exit_sleep((struct msm_rpmrs_limits *)limits,
151 from_idle, notify_rpm, collapsed);
Priyanka Mathur86cfc762013-01-10 17:03:04 -0800152 if (notify_rpm)
153 msm_rpm_exit_sleep();
Priyanka Mathur3abfd442013-01-11 12:58:51 -0800154 atomic_notifier_call_chain(&__get_cpu_var(lpm_notify_head),
155 MSM_LPM_STATE_EXIT, NULL);
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600156}
157
Girish Mahadevan40abbe12012-04-25 14:58:13 -0600158void msm_lpm_show_resources(void)
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600159{
160 /* TODO */
161 return;
162}
163
Priyanka Mathur3abfd442013-01-11 12:58:51 -0800164uint32_t msm_pm_get_pxo(struct msm_rpmrs_limits *limits)
165{
166 return limits->pxo;
167}
168
169uint32_t msm_pm_get_l2_cache(struct msm_rpmrs_limits *limits)
170{
171 return limits->l2_cache;
172}
173
174uint32_t msm_pm_get_vdd_mem(struct msm_rpmrs_limits *limits)
175{
176 return limits->vdd_mem_upper_bound;
177}
178
179uint32_t msm_pm_get_vdd_dig(struct msm_rpmrs_limits *limits)
180{
181 return limits->vdd_dig_upper_bound;
182}
183
184static bool lpm_level_permitted(int cur_level_count)
185{
186 if (__get_cpu_var(lpm_permitted_level) == msm_lpm_level_count + 1)
187 return true;
188 return (__get_cpu_var(lpm_permitted_level) == cur_level_count);
189}
190
191int msm_lpm_register_notifier(int cpu, int level_iter,
192 struct notifier_block *nb, bool is_latency_measure)
193{
194 per_cpu(lpm_permitted_level, cpu) = level_iter;
195 return atomic_notifier_chain_register(&per_cpu(lpm_notify_head,
196 cpu), nb);
197}
198
199int msm_lpm_unregister_notifier(int cpu, struct notifier_block *nb)
200{
201 per_cpu(lpm_permitted_level, cpu) = msm_lpm_level_count + 1;
202 return atomic_notifier_chain_unregister(&per_cpu(lpm_notify_head, cpu),
203 nb);
204}
205
Stephen Boyd3f4bac22012-05-30 10:03:13 -0700206s32 msm_cpuidle_get_deep_idle_latency(void)
207{
208 int i;
209 struct msm_rpmrs_level *level = msm_lpm_levels, *best = level;
210
211 if (!level)
212 return 0;
213
214 for (i = 0; i < msm_lpm_level_count; i++, level++) {
215 if (!level->available)
216 continue;
217 if (level->sleep_mode != MSM_PM_SLEEP_MODE_POWER_COLLAPSE)
218 continue;
219 /* Pick the first power collapse mode by default */
220 if (best->sleep_mode != MSM_PM_SLEEP_MODE_POWER_COLLAPSE)
221 best = level;
222 /* Find the lowest latency for power collapse */
223 if (level->latency_us < best->latency_us)
224 best = level;
225 }
226 return best->latency_us - 1;
227}
Mahesh Sivasubramanianf1ddf042013-01-08 14:03:32 -0700228static bool msm_lpm_irqs_detectable(struct msm_rpmrs_limits *limits,
229 bool irqs_detectable, bool gpio_detectable)
230{
231 if (!limits->irqs_detectable)
232 return irqs_detectable;
233
234 if (!limits->gpio_detectable)
235 return gpio_detectable;
236
237 return true;
238
239}
Stephen Boyd3f4bac22012-05-30 10:03:13 -0700240
Mahesh Sivasubramanian6d06e3a2012-05-16 13:41:07 -0600241static void *msm_lpm_lowest_limits(bool from_idle,
Girish Mahadevandc318fd2012-08-17 16:48:05 -0600242 enum msm_pm_sleep_mode sleep_mode,
243 struct msm_pm_time_params *time_param, uint32_t *power)
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600244{
245 unsigned int cpu = smp_processor_id();
246 struct msm_rpmrs_level *best_level = NULL;
Mahesh Sivasubramanian6d06e3a2012-05-16 13:41:07 -0600247 uint32_t pwr;
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600248 int i;
Priyanka Mathur3abfd442013-01-11 12:58:51 -0800249 int best_level_iter = msm_lpm_level_count + 1;
Mahesh Sivasubramanianf1ddf042013-01-08 14:03:32 -0700250 bool irqs_detect = false;
251 bool gpio_detect = false;
Girish Mahadevana351c0b2013-02-22 11:06:00 -0700252 bool modify_event_timer;
253 uint32_t next_wakeup_us = time_param->sleep_us;
Mahesh Sivasubramanianf1ddf042013-01-08 14:03:32 -0700254
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600255 if (!msm_lpm_levels)
256 return NULL;
257
Girish Mahadevan40abbe12012-04-25 14:58:13 -0600258 msm_lpm_level_update();
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600259
Mahesh Sivasubramanianf1ddf042013-01-08 14:03:32 -0700260 if (sleep_mode == MSM_PM_SLEEP_MODE_POWER_COLLAPSE) {
261 irqs_detect = msm_mpm_irqs_detectable(from_idle);
262 gpio_detect = msm_mpm_gpio_irqs_detectable(from_idle);
263 }
264
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600265 for (i = 0; i < msm_lpm_level_count; i++) {
266 struct msm_rpmrs_level *level = &msm_lpm_levels[i];
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600267
Girish Mahadevana351c0b2013-02-22 11:06:00 -0700268 modify_event_timer = false;
269
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600270 if (!level->available)
271 continue;
272
273 if (sleep_mode != level->sleep_mode)
274 continue;
275
Girish Mahadevandc318fd2012-08-17 16:48:05 -0600276 if (time_param->latency_us < level->latency_us)
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600277 continue;
278
Girish Mahadevana351c0b2013-02-22 11:06:00 -0700279 if (time_param->next_event_us &&
280 time_param->next_event_us < level->latency_us)
281 continue;
282
283 if (time_param->next_event_us) {
284 if ((time_param->next_event_us < time_param->sleep_us)
285 || ((time_param->next_event_us - level->latency_us) <
286 time_param->sleep_us)) {
287 modify_event_timer = true;
288 next_wakeup_us = time_param->next_event_us -
289 level->latency_us;
290 }
291 }
292
293 if (next_wakeup_us <= level->time_overhead_us)
294 continue;
295
Mahesh Sivasubramanianf1ddf042013-01-08 14:03:32 -0700296 if ((sleep_mode == MSM_PM_SLEEP_MODE_POWER_COLLAPSE) &&
297 !msm_lpm_irqs_detectable(&level->rs_limits,
298 irqs_detect, gpio_detect))
299 continue;
300
Mahesh Sivasubramanian9063a292012-11-09 09:15:30 -0700301 if ((MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE == sleep_mode)
302 || (MSM_PM_SLEEP_MODE_POWER_COLLAPSE == sleep_mode))
303 if (!cpu && msm_rpm_waiting_for_ack())
304 break;
305
Girish Mahadevana351c0b2013-02-22 11:06:00 -0700306 if (next_wakeup_us <= 1) {
Mahesh Sivasubramanian6d06e3a2012-05-16 13:41:07 -0600307 pwr = level->energy_overhead;
Girish Mahadevana351c0b2013-02-22 11:06:00 -0700308 } else if (next_wakeup_us <= level->time_overhead_us) {
309 pwr = level->energy_overhead / next_wakeup_us;
310 } else if ((next_wakeup_us >> 10)
Girish Mahadevandc318fd2012-08-17 16:48:05 -0600311 > level->time_overhead_us) {
Mahesh Sivasubramanian6d06e3a2012-05-16 13:41:07 -0600312 pwr = level->steady_state_power;
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600313 } else {
Mahesh Sivasubramanian6d06e3a2012-05-16 13:41:07 -0600314 pwr = level->steady_state_power;
315 pwr -= (level->time_overhead_us *
Girish Mahadevandc318fd2012-08-17 16:48:05 -0600316 level->steady_state_power) /
Girish Mahadevana351c0b2013-02-22 11:06:00 -0700317 next_wakeup_us;
318 pwr += level->energy_overhead / next_wakeup_us;
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600319 }
320
Mahesh Sivasubramanian6d06e3a2012-05-16 13:41:07 -0600321 if (!best_level || best_level->rs_limits.power[cpu] >= pwr) {
322
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600323 level->rs_limits.latency_us[cpu] = level->latency_us;
Mahesh Sivasubramanian6d06e3a2012-05-16 13:41:07 -0600324 level->rs_limits.power[cpu] = pwr;
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600325 best_level = level;
Priyanka Mathur3abfd442013-01-11 12:58:51 -0800326 best_level_iter = i;
Mahesh Sivasubramanian6d06e3a2012-05-16 13:41:07 -0600327 if (power)
328 *power = pwr;
Girish Mahadevana351c0b2013-02-22 11:06:00 -0700329 if (modify_event_timer &&
330 (sleep_mode !=
331 MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT))
332 time_param->modified_time_us =
333 time_param->next_event_us -
334 best_level->latency_us;
335 else
336 time_param->modified_time_us = 0;
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600337 }
338 }
Priyanka Mathur3abfd442013-01-11 12:58:51 -0800339 if (best_level && !lpm_level_permitted(best_level_iter))
340 best_level = NULL;
341 else
342 per_cpu(msm_lpm_sleep_time, cpu) =
343 time_param->modified_time_us ?
344 time_param->modified_time_us : time_param->sleep_us;
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600345
346 return best_level ? &best_level->rs_limits : NULL;
347}
Priyanka Mathur3abfd442013-01-11 12:58:51 -0800348
349static struct lpm_test_platform_data lpm_test_pdata;
350
351static struct platform_device msm_lpm_test_device = {
352 .name = "lpm_test",
353 .id = -1,
354 .dev = {
355 .platform_data = &lpm_test_pdata,
356 },
357};
358
Mahesh Sivasubramanian6d06e3a2012-05-16 13:41:07 -0600359static struct msm_pm_sleep_ops msm_lpm_ops = {
360 .lowest_limits = msm_lpm_lowest_limits,
361 .enter_sleep = msm_lpm_enter_sleep,
362 .exit_sleep = msm_lpm_exit_sleep,
363};
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600364
365static int __devinit msm_lpm_levels_probe(struct platform_device *pdev)
366{
367 struct msm_rpmrs_level *levels = NULL;
368 struct msm_rpmrs_level *level = NULL;
369 struct device_node *node = NULL;
370 char *key = NULL;
371 uint32_t val = 0;
372 int ret = 0;
373 uint32_t num_levels = 0;
374 int idx = 0;
Priyanka Mathur3abfd442013-01-11 12:58:51 -0800375 unsigned int m_cpu = 0;
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600376
377 for_each_child_of_node(pdev->dev.of_node, node)
378 num_levels++;
379
380 levels = kzalloc(num_levels * sizeof(struct msm_rpmrs_level),
381 GFP_KERNEL);
382 if (!levels)
383 return -ENOMEM;
384
385 for_each_child_of_node(pdev->dev.of_node, node) {
386 level = &levels[idx++];
387 level->available = false;
388
389 key = "qcom,mode";
Archana Sathyakumare6a35102013-01-31 16:18:49 -0700390 ret = msm_pm_get_sleep_mode_value(node, key, &val);
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600391 if (ret)
392 goto fail;
393 level->sleep_mode = val;
394
395 key = "qcom,xo";
Archana Sathyakumare6a35102013-01-31 16:18:49 -0700396 ret = msm_lpm_get_xo_value(node, key, &val);
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600397 if (ret)
398 goto fail;
399 level->rs_limits.pxo = val;
400
401 key = "qcom,l2";
Archana Sathyakumare6a35102013-01-31 16:18:49 -0700402 ret = msm_lpm_get_l2_cache_value(node, key, &val);
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600403 if (ret)
404 goto fail;
405 level->rs_limits.l2_cache = val;
406
407 key = "qcom,vdd-dig-upper-bound";
408 ret = of_property_read_u32(node, key, &val);
409 if (ret)
410 goto fail;
411 level->rs_limits.vdd_dig_upper_bound = val;
412
413 key = "qcom,vdd-dig-lower-bound";
414 ret = of_property_read_u32(node, key, &val);
415 if (ret)
416 goto fail;
Girish Mahadevan40abbe12012-04-25 14:58:13 -0600417 level->rs_limits.vdd_dig_lower_bound = val;
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600418
419 key = "qcom,vdd-mem-upper-bound";
420 ret = of_property_read_u32(node, key, &val);
421 if (ret)
422 goto fail;
423 level->rs_limits.vdd_mem_upper_bound = val;
424
425 key = "qcom,vdd-mem-lower-bound";
426 ret = of_property_read_u32(node, key, &val);
427 if (ret)
428 goto fail;
Girish Mahadevan40abbe12012-04-25 14:58:13 -0600429 level->rs_limits.vdd_mem_lower_bound = val;
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600430
Mahesh Sivasubramanianb71ce092013-01-08 13:44:23 -0700431 key = "qcom,gpio-detectable";
432 level->rs_limits.gpio_detectable =
433 of_property_read_bool(node, key);
434
435 key = "qcom,irqs-detectable";
436 level->rs_limits.irqs_detectable =
437 of_property_read_bool(node, key);
438
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600439 key = "qcom,latency-us";
440 ret = of_property_read_u32(node, key, &val);
441 if (ret)
442 goto fail;
443 level->latency_us = val;
444
445 key = "qcom,ss-power";
446 ret = of_property_read_u32(node, key, &val);
447 if (ret)
448 goto fail;
449 level->steady_state_power = val;
450
451 key = "qcom,energy-overhead";
452 ret = of_property_read_u32(node, key, &val);
453 if (ret)
454 goto fail;
455 level->energy_overhead = val;
456
457 key = "qcom,time-overhead";
458 ret = of_property_read_u32(node, key, &val);
459 if (ret)
460 goto fail;
461 level->time_overhead_us = val;
462
463 level->available = true;
464 }
465
466 msm_lpm_levels = levels;
467 msm_lpm_level_count = idx;
468
Priyanka Mathur3abfd442013-01-11 12:58:51 -0800469 lpm_test_pdata.msm_lpm_test_levels = msm_lpm_levels;
470 lpm_test_pdata.msm_lpm_test_level_count = msm_lpm_level_count;
Priyanka Mathur32d51ce2013-01-17 10:38:05 -0800471 key = "qcom,use-qtimer";
472 lpm_test_pdata.use_qtimer =
473 of_property_read_bool(pdev->dev.of_node, key);
Priyanka Mathur3abfd442013-01-11 12:58:51 -0800474
475 for_each_possible_cpu(m_cpu)
476 per_cpu(lpm_permitted_level, m_cpu) =
477 msm_lpm_level_count + 1;
478
479 platform_device_register(&msm_lpm_test_device);
Mahesh Sivasubramanian6d06e3a2012-05-16 13:41:07 -0600480 msm_pm_set_sleep_ops(&msm_lpm_ops);
481
Praveen Chidambaram85b7b282012-04-16 13:45:15 -0600482 return 0;
483fail:
484 pr_err("%s: Error in name %s key %s\n", __func__, node->full_name, key);
485 kfree(levels);
486 return -EFAULT;
487}
488
489static struct of_device_id msm_lpm_levels_match_table[] = {
490 {.compatible = "qcom,lpm-levels"},
491 {},
492};
493
494static struct platform_driver msm_lpm_levels_driver = {
495 .probe = msm_lpm_levels_probe,
496 .driver = {
497 .name = "lpm-levels",
498 .owner = THIS_MODULE,
499 .of_match_table = msm_lpm_levels_match_table,
500 },
501};
502
503static int __init msm_lpm_levels_module_init(void)
504{
505 return platform_driver_register(&msm_lpm_levels_driver);
506}
507late_initcall(msm_lpm_levels_module_init);