aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2012-01-30 04:47:24 -0500
committerKevin Hilman <khilman@ti.com>2012-03-05 18:38:02 -0500
commite68e8093ed570f9272665112d13d4c5811536680 (patch)
treedb72b5962b7991e0bfba2f0d182b4c13de9be23a /arch
parent506c7d7931317813b3142f57d44bf113102a2a8f (diff)
ARM: OMAP2+: PM: clean up omap_set_pwrdm_state()
Clean up a few different parts of omap_set_pwrdm_state(): - Remove a superfluous call to pwrdm_state_switch(). Not needed unless LOWPOWERSTATECHANGE is used, because the state switch code is called by either clkdm_sleep() or clkdm_allow_idle(). - Add code to wait for the power state transition in the OMAP4+ low power state change. This is speculative, so I would particularly appreciate feedback on this part. - Remove a superfluous call to pwrdm_read_pwrst(). - Update variable names to be more meaningful (hopefully) and precise. - Fix an error path bug that would not place the clockdomain back into hardware-supervised idle or sleep mode if the power state could not be programmed. The documentation for this function still needs major improvements; that's left for a later patch. Signed-off-by: Paul Walmsley <paul@pwsan.com> Cc: Rajendra Nayak <rnayak@ti.com> Tested-by: Tero Kristo <t-kristo@ti.com> Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Tested-by: Kevin Hilman <khilman@ti.com> Signed-off-by: Kevin Hilman <khilman@ti.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-omap2/pm.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index fb9b85bfc308..c3fe8eada2cc 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -72,28 +72,27 @@ static void omap2_init_processor_devices(void)
72 * This sets pwrdm state (other than mpu & core. Currently only ON & 72 * This sets pwrdm state (other than mpu & core. Currently only ON &
73 * RET are supported. 73 * RET are supported.
74 */ 74 */
75int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state) 75int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 pwrst)
76{ 76{
77 u32 cur_state; 77 u8 curr_pwrst, next_pwrst;
78 int sleep_switch = -1; 78 int sleep_switch = -1, ret = 0, hwsup = 0;
79 int ret = 0;
80 int hwsup = 0;
81 79
82 if (pwrdm == NULL || IS_ERR(pwrdm)) 80 if (!pwrdm || IS_ERR(pwrdm))
83 return -EINVAL; 81 return -EINVAL;
84 82
85 while (!(pwrdm->pwrsts & (1 << state))) { 83 while (!(pwrdm->pwrsts & (1 << pwrst))) {
86 if (state == PWRDM_POWER_OFF) 84 if (pwrst == PWRDM_POWER_OFF)
87 return ret; 85 return ret;
88 state--; 86 pwrst--;
89 } 87 }
90 88
91 cur_state = pwrdm_read_next_pwrst(pwrdm); 89 next_pwrst = pwrdm_read_next_pwrst(pwrdm);
92 if (cur_state == state) 90 if (next_pwrst == pwrst)
93 return ret; 91 return ret;
94 92
95 if (pwrdm_read_pwrst(pwrdm) < PWRDM_POWER_ON) { 93 curr_pwrst = pwrdm_read_pwrst(pwrdm);
96 if ((pwrdm_read_pwrst(pwrdm) > state) && 94 if (curr_pwrst < PWRDM_POWER_ON) {
95 if ((curr_pwrst > pwrst) &&
97 (pwrdm->flags & PWRDM_HAS_LOWPOWERSTATECHANGE)) { 96 (pwrdm->flags & PWRDM_HAS_LOWPOWERSTATECHANGE)) {
98 sleep_switch = LOWPOWERSTATE_SWITCH; 97 sleep_switch = LOWPOWERSTATE_SWITCH;
99 } else { 98 } else {
@@ -103,12 +102,10 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
103 } 102 }
104 } 103 }
105 104
106 ret = pwrdm_set_next_pwrst(pwrdm, state); 105 ret = pwrdm_set_next_pwrst(pwrdm, pwrst);
107 if (ret) { 106 if (ret)
108 pr_err("%s: unable to set state of powerdomain: %s\n", 107 pr_err("%s: unable to set power state of powerdomain: %s\n",
109 __func__, pwrdm->name); 108 __func__, pwrdm->name);
110 goto err;
111 }
112 109
113 switch (sleep_switch) { 110 switch (sleep_switch) {
114 case FORCEWAKEUP_SWITCH: 111 case FORCEWAKEUP_SWITCH:
@@ -119,13 +116,11 @@ int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 state)
119 break; 116 break;
120 case LOWPOWERSTATE_SWITCH: 117 case LOWPOWERSTATE_SWITCH:
121 pwrdm_set_lowpwrstchange(pwrdm); 118 pwrdm_set_lowpwrstchange(pwrdm);
119 pwrdm_wait_transition(pwrdm);
120 pwrdm_state_switch(pwrdm);
122 break; 121 break;
123 default:
124 return ret;
125 } 122 }
126 123
127 pwrdm_state_switch(pwrdm);
128err:
129 return ret; 124 return ret;
130} 125}
131 126