aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/clockdomain.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-omap2/clockdomain.c')
-rw-r--r--arch/arm/mach-omap2/clockdomain.c110
1 files changed, 15 insertions, 95 deletions
diff --git a/arch/arm/mach-omap2/clockdomain.c b/arch/arm/mach-omap2/clockdomain.c
index 5d80cb897489..6fb61b1a0d46 100644
--- a/arch/arm/mach-omap2/clockdomain.c
+++ b/arch/arm/mach-omap2/clockdomain.c
@@ -258,97 +258,6 @@ static void _omap2_clkdm_set_hwsup(struct clockdomain *clkdm, int enable)
258 258
259} 259}
260 260
261/**
262 * _init_wkdep_usecount - initialize wkdep usecounts to match hardware
263 * @clkdm: clockdomain to initialize wkdep usecounts
264 *
265 * Initialize the wakeup dependency usecount variables for clockdomain @clkdm.
266 * If a wakeup dependency is present in the hardware, the usecount will be
267 * set to 1; otherwise, it will be set to 0. Software should clear all
268 * software wakeup dependencies prior to calling this function if it wishes
269 * to ensure that all usecounts start at 0. No return value.
270 */
271static void _init_wkdep_usecount(struct clockdomain *clkdm)
272{
273 u32 v;
274 struct clkdm_dep *cd;
275
276 if (!clkdm->wkdep_srcs)
277 return;
278
279 for (cd = clkdm->wkdep_srcs; cd->clkdm_name; cd++) {
280 if (!omap_chip_is(cd->omap_chip))
281 continue;
282
283 if (!cd->clkdm && cd->clkdm_name)
284 cd->clkdm = _clkdm_lookup(cd->clkdm_name);
285
286 if (!cd->clkdm) {
287 WARN(!cd->clkdm, "clockdomain: %s: wkdep clkdm %s not "
288 "found\n", clkdm->name, cd->clkdm_name);
289 continue;
290 }
291
292 v = prm_read_mod_bits_shift(clkdm->pwrdm.ptr->prcm_offs,
293 PM_WKDEP,
294 (1 << cd->clkdm->dep_bit));
295
296 if (v)
297 pr_debug("clockdomain: %s: wakeup dependency already "
298 "set to wake up when %s wakes\n",
299 clkdm->name, cd->clkdm->name);
300
301 atomic_set(&cd->wkdep_usecount, (v) ? 1 : 0);
302 }
303}
304
305/**
306 * _init_sleepdep_usecount - initialize sleepdep usecounts to match hardware
307 * @clkdm: clockdomain to initialize sleepdep usecounts
308 *
309 * Initialize the sleep dependency usecount variables for clockdomain @clkdm.
310 * If a sleep dependency is present in the hardware, the usecount will be
311 * set to 1; otherwise, it will be set to 0. Software should clear all
312 * software sleep dependencies prior to calling this function if it wishes
313 * to ensure that all usecounts start at 0. No return value.
314 */
315static void _init_sleepdep_usecount(struct clockdomain *clkdm)
316{
317 u32 v;
318 struct clkdm_dep *cd;
319
320 if (!cpu_is_omap34xx())
321 return;
322
323 if (!clkdm->sleepdep_srcs)
324 return;
325
326 for (cd = clkdm->sleepdep_srcs; cd->clkdm_name; cd++) {
327 if (!omap_chip_is(cd->omap_chip))
328 continue;
329
330 if (!cd->clkdm && cd->clkdm_name)
331 cd->clkdm = _clkdm_lookup(cd->clkdm_name);
332
333 if (!cd->clkdm) {
334 WARN(!cd->clkdm, "clockdomain: %s: sleepdep clkdm %s "
335 "not found\n", clkdm->name, cd->clkdm_name);
336 continue;
337 }
338
339 v = prm_read_mod_bits_shift(clkdm->pwrdm.ptr->prcm_offs,
340 OMAP3430_CM_SLEEPDEP,
341 (1 << cd->clkdm->dep_bit));
342
343 if (v)
344 pr_debug("clockdomain: %s: sleep dependency already "
345 "set to prevent from idling until %s "
346 "idles\n", clkdm->name, cd->clkdm->name);
347
348 atomic_set(&cd->sleepdep_usecount, (v) ? 1 : 0);
349 }
350};
351
352/* Public functions */ 261/* Public functions */
353 262
354/** 263/**
@@ -379,12 +288,17 @@ void clkdm_init(struct clockdomain **clkdms,
379 _autodep_lookup(autodep); 288 _autodep_lookup(autodep);
380 289
381 /* 290 /*
382 * Ensure that the *dep_usecount registers reflect the current 291 * Put all clockdomains into software-supervised mode; PM code
383 * state of the PRCM. 292 * should later enable hardware-supervised mode as appropriate
384 */ 293 */
385 list_for_each_entry(clkdm, &clkdm_list, node) { 294 list_for_each_entry(clkdm, &clkdm_list, node) {
386 _init_wkdep_usecount(clkdm); 295 if (clkdm->flags & CLKDM_CAN_FORCE_WAKEUP)
387 _init_sleepdep_usecount(clkdm); 296 omap2_clkdm_wakeup(clkdm);
297 else if (clkdm->flags & CLKDM_CAN_DISABLE_AUTO)
298 omap2_clkdm_deny_idle(clkdm);
299
300 clkdm_clear_all_wkdeps(clkdm);
301 clkdm_clear_all_sleepdeps(clkdm);
388 } 302 }
389} 303}
390 304
@@ -592,6 +506,9 @@ int clkdm_clear_all_wkdeps(struct clockdomain *clkdm)
592 if (!omap_chip_is(cd->omap_chip)) 506 if (!omap_chip_is(cd->omap_chip))
593 continue; 507 continue;
594 508
509 if (!cd->clkdm && cd->clkdm_name)
510 cd->clkdm = _clkdm_lookup(cd->clkdm_name);
511
595 /* PRM accesses are slow, so minimize them */ 512 /* PRM accesses are slow, so minimize them */
596 mask |= 1 << cd->clkdm->dep_bit; 513 mask |= 1 << cd->clkdm->dep_bit;
597 atomic_set(&cd->wkdep_usecount, 0); 514 atomic_set(&cd->wkdep_usecount, 0);
@@ -752,6 +669,9 @@ int clkdm_clear_all_sleepdeps(struct clockdomain *clkdm)
752 if (!omap_chip_is(cd->omap_chip)) 669 if (!omap_chip_is(cd->omap_chip))
753 continue; 670 continue;
754 671
672 if (!cd->clkdm && cd->clkdm_name)
673 cd->clkdm = _clkdm_lookup(cd->clkdm_name);
674
755 /* PRM accesses are slow, so minimize them */ 675 /* PRM accesses are slow, so minimize them */
756 mask |= 1 << cd->clkdm->dep_bit; 676 mask |= 1 << cd->clkdm->dep_bit;
757 atomic_set(&cd->sleepdep_usecount, 0); 677 atomic_set(&cd->sleepdep_usecount, 0);