aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/pm.c
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2013-01-29 15:45:09 -0500
committerPaul Walmsley <paul@pwsan.com>2013-01-29 16:59:57 -0500
commitc4978fba6b2d4e3a584d72c067a371871fecbedc (patch)
tree75add16022eb4e71ae50e1aecb42d1d5a9f420ab /arch/arm/mach-omap2/pm.c
parentf8457c2d8be94779c8c460060e536d3a2a02c8d8 (diff)
ARM: OMAP2+: PM/powerdomain: move omap_set_pwrdm_state() to powerdomain code
Move omap_set_pwrdm_state() from the PM code to the powerdomain code, and refactor it to split it up into several functions. A subsequent patch will rename it to conform with the existing powerdomain function names. This version includes some additional documentation, based on a suggestion from Jean Pihet. It also modifies omap_set_pwrdm_state() to not bail out early unless both the powerdomain current power state and the next power state are equal. (Previously it would terminate early if the next power state was equal to the target power state, which was insufficiently rigorous.) Signed-off-by: Paul Walmsley <paul@pwsan.com> Cc: Jean Pihet <jean.pihet@newoldbits.com> Cc: Kevin Hilman <khilman@deeprootsystems.com> Cc: Tero Kristo <t-kristo@ti.com>
Diffstat (limited to 'arch/arm/mach-omap2/pm.c')
-rw-r--r--arch/arm/mach-omap2/pm.c61
1 files changed, 0 insertions, 61 deletions
diff --git a/arch/arm/mach-omap2/pm.c b/arch/arm/mach-omap2/pm.c
index f18afc9cbd8e..48d6d5d2c926 100644
--- a/arch/arm/mach-omap2/pm.c
+++ b/arch/arm/mach-omap2/pm.c
@@ -108,10 +108,6 @@ static void __init omap2_init_processor_devices(void)
108 } 108 }
109} 109}
110 110
111/* Types of sleep_switch used in omap_set_pwrdm_state */
112#define FORCEWAKEUP_SWITCH 0
113#define LOWPOWERSTATE_SWITCH 1
114
115int __init omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused) 111int __init omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused)
116{ 112{
117 if ((clkdm->flags & CLKDM_CAN_ENABLE_AUTO) && 113 if ((clkdm->flags & CLKDM_CAN_ENABLE_AUTO) &&
@@ -124,63 +120,6 @@ int __init omap_pm_clkdms_setup(struct clockdomain *clkdm, void *unused)
124} 120}
125 121
126/* 122/*
127 * This sets pwrdm state (other than mpu & core. Currently only ON &
128 * RET are supported.
129 */
130int omap_set_pwrdm_state(struct powerdomain *pwrdm, u32 pwrst)
131{
132 u8 curr_pwrst, next_pwrst;
133 int sleep_switch = -1, ret = 0, hwsup = 0;
134
135 if (!pwrdm || IS_ERR(pwrdm))
136 return -EINVAL;
137
138 while (!(pwrdm->pwrsts & (1 << pwrst))) {
139 if (pwrst == PWRDM_POWER_OFF)
140 return ret;
141 pwrst--;
142 }
143
144 next_pwrst = pwrdm_read_next_pwrst(pwrdm);
145 if (next_pwrst == pwrst)
146 return ret;
147
148 curr_pwrst = pwrdm_read_pwrst(pwrdm);
149 if (curr_pwrst < PWRDM_POWER_ON) {
150 if ((curr_pwrst > pwrst) &&
151 (pwrdm->flags & PWRDM_HAS_LOWPOWERSTATECHANGE)) {
152 sleep_switch = LOWPOWERSTATE_SWITCH;
153 } else {
154 hwsup = clkdm_in_hwsup(pwrdm->pwrdm_clkdms[0]);
155 clkdm_wakeup(pwrdm->pwrdm_clkdms[0]);
156 sleep_switch = FORCEWAKEUP_SWITCH;
157 }
158 }
159
160 ret = pwrdm_set_next_pwrst(pwrdm, pwrst);
161 if (ret)
162 pr_err("%s: unable to set power state of powerdomain: %s\n",
163 __func__, pwrdm->name);
164
165 switch (sleep_switch) {
166 case FORCEWAKEUP_SWITCH:
167 if (hwsup)
168 clkdm_allow_idle(pwrdm->pwrdm_clkdms[0]);
169 else
170 clkdm_sleep(pwrdm->pwrdm_clkdms[0]);
171 break;
172 case LOWPOWERSTATE_SWITCH:
173 pwrdm_set_lowpwrstchange(pwrdm);
174 pwrdm_state_switch(pwrdm);
175 break;
176 }
177
178 return ret;
179}
180
181
182
183/*
184 * This API is to be called during init to set the various voltage 123 * This API is to be called during init to set the various voltage
185 * domains to the voltage as per the opp table. Typically we boot up 124 * domains to the voltage as per the opp table. Typically we boot up
186 * at the nominal voltage. So this function finds out the rate of 125 * at the nominal voltage. So this function finds out the rate of