diff options
Diffstat (limited to 'arch/arm/mach-omap2/pm-debug.c')
-rw-r--r-- | arch/arm/mach-omap2/pm-debug.c | 75 |
1 files changed, 56 insertions, 19 deletions
diff --git a/arch/arm/mach-omap2/pm-debug.c b/arch/arm/mach-omap2/pm-debug.c index 723b44e252fd..e01da45c0537 100644 --- a/arch/arm/mach-omap2/pm-debug.c +++ b/arch/arm/mach-omap2/pm-debug.c | |||
@@ -29,21 +29,27 @@ | |||
29 | 29 | ||
30 | #include <plat/clock.h> | 30 | #include <plat/clock.h> |
31 | #include <plat/board.h> | 31 | #include <plat/board.h> |
32 | #include <plat/powerdomain.h> | 32 | #include "powerdomain.h" |
33 | #include <plat/clockdomain.h> | 33 | #include "clockdomain.h" |
34 | #include <plat/dmtimer.h> | ||
35 | #include <plat/omap-pm.h> | ||
34 | 36 | ||
35 | #include "prm.h" | 37 | #include "cm2xxx_3xxx.h" |
36 | #include "cm.h" | 38 | #include "prm2xxx_3xxx.h" |
37 | #include "pm.h" | 39 | #include "pm.h" |
38 | 40 | ||
39 | int omap2_pm_debug; | 41 | int omap2_pm_debug; |
42 | u32 enable_off_mode; | ||
43 | u32 sleep_while_idle; | ||
44 | u32 wakeup_timer_seconds; | ||
45 | u32 wakeup_timer_milliseconds; | ||
40 | 46 | ||
41 | #define DUMP_PRM_MOD_REG(mod, reg) \ | 47 | #define DUMP_PRM_MOD_REG(mod, reg) \ |
42 | regs[reg_count].name = #mod "." #reg; \ | 48 | regs[reg_count].name = #mod "." #reg; \ |
43 | regs[reg_count++].val = prm_read_mod_reg(mod, reg) | 49 | regs[reg_count++].val = omap2_prm_read_mod_reg(mod, reg) |
44 | #define DUMP_CM_MOD_REG(mod, reg) \ | 50 | #define DUMP_CM_MOD_REG(mod, reg) \ |
45 | regs[reg_count].name = #mod "." #reg; \ | 51 | regs[reg_count].name = #mod "." #reg; \ |
46 | regs[reg_count++].val = cm_read_mod_reg(mod, reg) | 52 | regs[reg_count++].val = omap2_cm_read_mod_reg(mod, reg) |
47 | #define DUMP_PRM_REG(reg) \ | 53 | #define DUMP_PRM_REG(reg) \ |
48 | regs[reg_count].name = #reg; \ | 54 | regs[reg_count].name = #reg; \ |
49 | regs[reg_count++].val = __raw_readl(reg) | 55 | regs[reg_count++].val = __raw_readl(reg) |
@@ -156,17 +162,34 @@ void omap2_pm_dump(int mode, int resume, unsigned int us) | |||
156 | printk(KERN_INFO "%-20s: 0x%08x\n", regs[i].name, regs[i].val); | 162 | printk(KERN_INFO "%-20s: 0x%08x\n", regs[i].name, regs[i].val); |
157 | } | 163 | } |
158 | 164 | ||
165 | void omap2_pm_wakeup_on_timer(u32 seconds, u32 milliseconds) | ||
166 | { | ||
167 | u32 tick_rate, cycles; | ||
168 | |||
169 | if (!seconds && !milliseconds) | ||
170 | return; | ||
171 | |||
172 | tick_rate = clk_get_rate(omap_dm_timer_get_fclk(gptimer_wakeup)); | ||
173 | cycles = tick_rate * seconds + tick_rate * milliseconds / 1000; | ||
174 | omap_dm_timer_stop(gptimer_wakeup); | ||
175 | omap_dm_timer_set_load_start(gptimer_wakeup, 0, 0xffffffff - cycles); | ||
176 | |||
177 | pr_info("PM: Resume timer in %u.%03u secs" | ||
178 | " (%d ticks at %d ticks/sec.)\n", | ||
179 | seconds, milliseconds, cycles, tick_rate); | ||
180 | } | ||
181 | |||
159 | #ifdef CONFIG_DEBUG_FS | 182 | #ifdef CONFIG_DEBUG_FS |
160 | #include <linux/debugfs.h> | 183 | #include <linux/debugfs.h> |
161 | #include <linux/seq_file.h> | 184 | #include <linux/seq_file.h> |
162 | 185 | ||
163 | static void pm_dbg_regset_store(u32 *ptr); | 186 | static void pm_dbg_regset_store(u32 *ptr); |
164 | 187 | ||
165 | struct dentry *pm_dbg_dir; | 188 | static struct dentry *pm_dbg_dir; |
166 | 189 | ||
167 | static int pm_dbg_init_done; | 190 | static int pm_dbg_init_done; |
168 | 191 | ||
169 | static int __init pm_dbg_init(void); | 192 | static int pm_dbg_init(void); |
170 | 193 | ||
171 | enum { | 194 | enum { |
172 | DEBUG_FILE_COUNTERS = 0, | 195 | DEBUG_FILE_COUNTERS = 0, |
@@ -306,10 +329,10 @@ static void pm_dbg_regset_store(u32 *ptr) | |||
306 | for (j = pm_dbg_reg_modules[i].low; | 329 | for (j = pm_dbg_reg_modules[i].low; |
307 | j <= pm_dbg_reg_modules[i].high; j += 4) { | 330 | j <= pm_dbg_reg_modules[i].high; j += 4) { |
308 | if (pm_dbg_reg_modules[i].type == MOD_CM) | 331 | if (pm_dbg_reg_modules[i].type == MOD_CM) |
309 | val = cm_read_mod_reg( | 332 | val = omap2_cm_read_mod_reg( |
310 | pm_dbg_reg_modules[i].offset, j); | 333 | pm_dbg_reg_modules[i].offset, j); |
311 | else | 334 | else |
312 | val = prm_read_mod_reg( | 335 | val = omap2_prm_read_mod_reg( |
313 | pm_dbg_reg_modules[i].offset, j); | 336 | pm_dbg_reg_modules[i].offset, j); |
314 | *(ptr++) = val; | 337 | *(ptr++) = val; |
315 | } | 338 | } |
@@ -494,8 +517,10 @@ int pm_dbg_regset_init(int reg_set) | |||
494 | 517 | ||
495 | static int pwrdm_suspend_get(void *data, u64 *val) | 518 | static int pwrdm_suspend_get(void *data, u64 *val) |
496 | { | 519 | { |
497 | int ret; | 520 | int ret = -EINVAL; |
498 | ret = omap3_pm_get_suspend_state((struct powerdomain *)data); | 521 | |
522 | if (cpu_is_omap34xx()) | ||
523 | ret = omap3_pm_get_suspend_state((struct powerdomain *)data); | ||
499 | *val = ret; | 524 | *val = ret; |
500 | 525 | ||
501 | if (ret >= 0) | 526 | if (ret >= 0) |
@@ -505,7 +530,10 @@ static int pwrdm_suspend_get(void *data, u64 *val) | |||
505 | 530 | ||
506 | static int pwrdm_suspend_set(void *data, u64 val) | 531 | static int pwrdm_suspend_set(void *data, u64 val) |
507 | { | 532 | { |
508 | return omap3_pm_set_suspend_state((struct powerdomain *)data, (int)val); | 533 | if (cpu_is_omap34xx()) |
534 | return omap3_pm_set_suspend_state( | ||
535 | (struct powerdomain *)data, (int)val); | ||
536 | return -EINVAL; | ||
509 | } | 537 | } |
510 | 538 | ||
511 | DEFINE_SIMPLE_ATTRIBUTE(pwrdm_suspend_fops, pwrdm_suspend_get, | 539 | DEFINE_SIMPLE_ATTRIBUTE(pwrdm_suspend_fops, pwrdm_suspend_get, |
@@ -553,15 +581,21 @@ static int option_set(void *data, u64 val) | |||
553 | 581 | ||
554 | *option = val; | 582 | *option = val; |
555 | 583 | ||
556 | if (option == &enable_off_mode) | 584 | if (option == &enable_off_mode) { |
557 | omap3_pm_off_mode_enable(val); | 585 | if (val) |
586 | omap_pm_enable_off_mode(); | ||
587 | else | ||
588 | omap_pm_disable_off_mode(); | ||
589 | if (cpu_is_omap34xx()) | ||
590 | omap3_pm_off_mode_enable(val); | ||
591 | } | ||
558 | 592 | ||
559 | return 0; | 593 | return 0; |
560 | } | 594 | } |
561 | 595 | ||
562 | DEFINE_SIMPLE_ATTRIBUTE(pm_dbg_option_fops, option_get, option_set, "%llu\n"); | 596 | DEFINE_SIMPLE_ATTRIBUTE(pm_dbg_option_fops, option_get, option_set, "%llu\n"); |
563 | 597 | ||
564 | static int __init pm_dbg_init(void) | 598 | static int pm_dbg_init(void) |
565 | { | 599 | { |
566 | int i; | 600 | int i; |
567 | struct dentry *d; | 601 | struct dentry *d; |
@@ -603,12 +637,15 @@ static int __init pm_dbg_init(void) | |||
603 | 637 | ||
604 | } | 638 | } |
605 | 639 | ||
606 | (void) debugfs_create_file("enable_off_mode", S_IRUGO | S_IWUGO, d, | 640 | (void) debugfs_create_file("enable_off_mode", S_IRUGO | S_IWUSR, d, |
607 | &enable_off_mode, &pm_dbg_option_fops); | 641 | &enable_off_mode, &pm_dbg_option_fops); |
608 | (void) debugfs_create_file("sleep_while_idle", S_IRUGO | S_IWUGO, d, | 642 | (void) debugfs_create_file("sleep_while_idle", S_IRUGO | S_IWUSR, d, |
609 | &sleep_while_idle, &pm_dbg_option_fops); | 643 | &sleep_while_idle, &pm_dbg_option_fops); |
610 | (void) debugfs_create_file("wakeup_timer_seconds", S_IRUGO | S_IWUGO, d, | 644 | (void) debugfs_create_file("wakeup_timer_seconds", S_IRUGO | S_IWUSR, d, |
611 | &wakeup_timer_seconds, &pm_dbg_option_fops); | 645 | &wakeup_timer_seconds, &pm_dbg_option_fops); |
646 | (void) debugfs_create_file("wakeup_timer_milliseconds", | ||
647 | S_IRUGO | S_IWUSR, d, &wakeup_timer_milliseconds, | ||
648 | &pm_dbg_option_fops); | ||
612 | pm_dbg_init_done = 1; | 649 | pm_dbg_init_done = 1; |
613 | 650 | ||
614 | return 0; | 651 | return 0; |