aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-omap2/pm.c50
-rw-r--r--arch/arm/mach-omap2/pm.h2
-rw-r--r--arch/arm/mach-omap2/pm34xx.c53
3 files changed, 55 insertions, 50 deletions
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index c93921d5cc20..4477d5d7a3b5 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -18,6 +18,9 @@
18#include <plat/omap_device.h> 18#include <plat/omap_device.h>
19#include <plat/common.h> 19#include <plat/common.h>
20 20
21#include <plat/powerdomain.h>
22#include <plat/clockdomain.h>
23
21static struct omap_device_pm_latency *pm_lats; 24static struct omap_device_pm_latency *pm_lats;
22 25
23static struct device *mpu_dev; 26static struct device *mpu_dev;
@@ -83,6 +86,53 @@ static void omap2_init_processor_devices(void)
83 _init_omap_device("l3_main", &l3_dev); 86 _init_omap_device("l3_main", &l3_dev);
84} 87}
85 88
89/*
90 * This sets pwrdm state (other than mpu & core. Currently only ON &
91 * RET are supported. Function is assuming that clkdm doesn't have
92 * hw_sup mode enabled.
93 */
94int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
95{
96 u32 cur_state;
97 int sleep_switch = 0;
98 int ret = 0;
99
100 if (pwrdm == NULL || IS_ERR(pwrdm))
101 return -EINVAL;
102
103 while (!(pwrdm->pwrsts & (1 << state))) {
104 if (state == PWRDM_POWER_OFF)
105 return ret;
106 state--;
107 }
108
109 cur_state = pwrdm_read_next_pwrst(pwrdm);
110 if (cur_state == state)
111 return ret;
112
113 if (pwrdm_read_pwrst(pwrdm) < PWRDM_POWER_ON) {
114 omap2_clkdm_wakeup(pwrdm->pwrdm_clkdms[0]);
115 sleep_switch = 1;
116 pwrdm_wait_transition(pwrdm);
117 }
118
119 ret = pwrdm_set_next_pwrst(pwrdm, state);
120 if (ret) {
121 printk(KERN_ERR "Unable to set state of powerdomain: %s\n",
122 pwrdm->name);
123 goto err;
124 }
125
126 if (sleep_switch) {
127 omap2_clkdm_allow_idle(pwrdm->pwrdm_clkdms[0]);
128 pwrdm_wait_transition(pwrdm);
129 pwrdm_state_switch(pwrdm);
130 }
131
132err:
133 return ret;
134}
135
86static int __init omap2_common_pm_init(void) 136static int __init omap2_common_pm_init(void)
87{ 137{
88 omap2_init_processor_devices(); 138 omap2_init_processor_devices();
diff --git a/arch/arm/mach-omap2/pm.h b/arch/arm/mach-omap2/pm.h
index 4fd021f31e25..77770a13cea8 100644
--- a/arch/arm/mach-omap2/pm.h
+++ b/arch/arm/mach-omap2/pm.h
@@ -20,7 +20,7 @@ extern void *omap3_secure_ram_storage;
20extern void omap3_pm_off_mode_enable(int); 20extern void omap3_pm_off_mode_enable(int);
21extern void omap_sram_idle(void); 21extern void omap_sram_idle(void);
22extern int omap3_can_sleep(void); 22extern int omap3_can_sleep(void);
23extern int set_pwrdm_state(struct powerdomain *pwrdm, u32 state); 23extern int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state);
24extern int omap3_idle_init(void); 24extern int omap3_idle_init(void);
25 25
26struct cpuidle_params { 26struct cpuidle_params {
diff --git a/arch/arm/mach-omap2/pm34xx.c b/arch/arm/mach-omap2/pm34xx.c
index bc24fbd2e983..f5f1dbd3c17a 100644
--- a/arch/arm/mach-omap2/pm34xx.c
+++ b/arch/arm/mach-omap2/pm34xx.c
@@ -483,51 +483,6 @@ int omap3_can_sleep(void)
483 return 1; 483 return 1;
484} 484}
485 485
486/* This sets pwrdm state (other than mpu & core. Currently only ON &
487 * RET are supported. Function is assuming that clkdm doesn't have
488 * hw_sup mode enabled. */
489int set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
490{
491 u32 cur_state;
492 int sleep_switch = 0;
493 int ret = 0;
494
495 if (pwrdm == NULL || IS_ERR(pwrdm))
496 return -EINVAL;
497
498 while (!(pwrdm->pwrsts & (1 << state))) {
499 if (state == PWRDM_POWER_OFF)
500 return ret;
501 state--;
502 }
503
504 cur_state = pwrdm_read_next_pwrst(pwrdm);
505 if (cur_state == state)
506 return ret;
507
508 if (pwrdm_read_pwrst(pwrdm) < PWRDM_POWER_ON) {
509 omap2_clkdm_wakeup(pwrdm->pwrdm_clkdms[0]);
510 sleep_switch = 1;
511 pwrdm_wait_transition(pwrdm);
512 }
513
514 ret = pwrdm_set_next_pwrst(pwrdm, state);
515 if (ret) {
516 printk(KERN_ERR "Unable to set state of powerdomain: %s\n",
517 pwrdm->name);
518 goto err;
519 }
520
521 if (sleep_switch) {
522 omap2_clkdm_allow_idle(pwrdm->pwrdm_clkdms[0]);
523 pwrdm_wait_transition(pwrdm);
524 pwrdm_state_switch(pwrdm);
525 }
526
527err:
528 return ret;
529}
530
531static void omap3_pm_idle(void) 486static void omap3_pm_idle(void)
532{ 487{
533 local_irq_disable(); 488 local_irq_disable();
@@ -569,7 +524,7 @@ static int omap3_pm_suspend(void)
569 pwrst->saved_state = pwrdm_read_next_pwrst(pwrst->pwrdm); 524 pwrst->saved_state = pwrdm_read_next_pwrst(pwrst->pwrdm);
570 /* Set ones wanted by suspend */ 525 /* Set ones wanted by suspend */
571 list_for_each_entry(pwrst, &pwrst_list, node) { 526 list_for_each_entry(pwrst, &pwrst_list, node) {
572 if (set_pwrdm_state(pwrst->pwrdm, pwrst->next_state)) 527 if (omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state))
573 goto restore; 528 goto restore;
574 if (pwrdm_clear_all_prev_pwrst(pwrst->pwrdm)) 529 if (pwrdm_clear_all_prev_pwrst(pwrst->pwrdm))
575 goto restore; 530 goto restore;
@@ -590,7 +545,7 @@ restore:
590 pwrst->pwrdm->name, pwrst->next_state); 545 pwrst->pwrdm->name, pwrst->next_state);
591 ret = -1; 546 ret = -1;
592 } 547 }
593 set_pwrdm_state(pwrst->pwrdm, pwrst->saved_state); 548 omap_set_pwrdm_state(pwrst->pwrdm, pwrst->saved_state);
594 } 549 }
595 if (ret) 550 if (ret)
596 printk(KERN_ERR "Could not enter target state in pm_suspend\n"); 551 printk(KERN_ERR "Could not enter target state in pm_suspend\n");
@@ -939,7 +894,7 @@ void omap3_pm_off_mode_enable(int enable)
939 894
940 list_for_each_entry(pwrst, &pwrst_list, node) { 895 list_for_each_entry(pwrst, &pwrst_list, node) {
941 pwrst->next_state = state; 896 pwrst->next_state = state;
942 set_pwrdm_state(pwrst->pwrdm, state); 897 omap_set_pwrdm_state(pwrst->pwrdm, state);
943 } 898 }
944} 899}
945 900
@@ -984,7 +939,7 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
984 if (pwrdm_has_hdwr_sar(pwrdm)) 939 if (pwrdm_has_hdwr_sar(pwrdm))
985 pwrdm_enable_hdwr_sar(pwrdm); 940 pwrdm_enable_hdwr_sar(pwrdm);
986 941
987 return set_pwrdm_state(pwrst->pwrdm, pwrst->next_state); 942 return omap_set_pwrdm_state(pwrst->pwrdm, pwrst->next_state);
988} 943}
989 944
990/* 945/*