16 #include <linux/kernel.h>
17 #include <linux/device.h>
18 #include <linux/list.h>
19 #include <linux/errno.h>
20 #include <linux/string.h>
28 #include <linux/bitops.h>
30 #include <plat/clock.h>
70 static int _clkdm_register(
struct clockdomain *clkdm)
74 if (!clkdm || !clkdm->
name)
79 pr_err(
"clockdomain: %s: powerdomain %s does not exist\n",
86 if (_clkdm_lookup(clkdm->
name))
89 list_add(&clkdm->
node, &clkdm_list);
113 if (cd->
clkdm == clkdm)
148 pr_err(
"clockdomain: autodeps: clockdomain %s does not exist\n",
173 for (autodep = autodeps; autodep->
clkdm.
ptr; autodep++) {
177 pr_debug(
"clockdomain: %s: adding %s sleepdep/wkdep\n",
203 for (autodep = autodeps; autodep->
clkdm.
ptr; autodep++) {
207 pr_debug(
"clockdomain: %s: removing %s sleepdep/wkdep\n",
224 static void _resolve_clkdm_deps(
struct clockdomain *clkdm,
229 for (cd = clkdm_deps; cd && cd->
clkdm_name; cd++) {
234 WARN(!cd->
clkdm,
"clockdomain: %s: could not find clkdm %s while resolving dependencies - should never happen",
284 for (c = cs; *
c; c++)
318 if (list_empty(&clkdm_list))
328 for (a = autodeps; a->
clkdm.
ptr; a++)
346 if (list_empty(&clkdm_list))
355 _resolve_clkdm_deps(clkdm, clkdm->
wkdep_srcs);
415 ret = (*fn)(clkdm,
user);
459 if (!clkdm1 || !clkdm2)
462 cd = _clkdm_deps_lookup(clkdm2, clkdm1->
wkdep_srcs);
470 pr_debug(
"clockdomain: hardware cannot set/clear wake up of %s when %s wakes up\n",
476 pr_debug(
"clockdomain: hardware will wake up %s when %s wakes up\n",
500 if (!clkdm1 || !clkdm2)
503 cd = _clkdm_deps_lookup(clkdm2, clkdm1->
wkdep_srcs);
511 pr_debug(
"clockdomain: hardware cannot set/clear wake up of %s when %s wakes up\n",
517 pr_debug(
"clockdomain: hardware will no longer wake up %s after %s wakes up\n",
545 if (!clkdm1 || !clkdm2)
548 cd = _clkdm_deps_lookup(clkdm2, clkdm1->
wkdep_srcs);
556 pr_debug(
"clockdomain: hardware cannot set/clear wake up of %s when %s wakes up\n",
603 if (!clkdm1 || !clkdm2)
614 pr_debug(
"clockdomain: hardware cannot set/clear sleep dependency affecting %s from %s\n",
620 pr_debug(
"clockdomain: will prevent %s from sleeping if %s is active\n",
646 if (!clkdm1 || !clkdm2)
657 pr_debug(
"clockdomain: hardware cannot set/clear sleep dependency affecting %s from %s\n",
663 pr_debug(
"clockdomain: will no longer prevent %s from sleeping if %s is active\n",
693 if (!clkdm1 || !clkdm2)
704 pr_debug(
"clockdomain: hardware cannot set/clear sleep dependency affecting %s from %s\n",
752 pr_debug(
"clockdomain: %s does not support forcing sleep via software\n",
760 pr_debug(
"clockdomain: forcing sleep on %s\n", clkdm->
name);
765 spin_unlock_irqrestore(&clkdm->
lock, flags);
787 pr_debug(
"clockdomain: %s does not support forcing wakeup via software\n",
795 pr_debug(
"clockdomain: forcing wakeup on %s\n", clkdm->
name);
801 spin_unlock_irqrestore(&clkdm->
lock, flags);
823 pr_debug(
"clock: %s: automatic idle transitions cannot be enabled\n",
831 pr_debug(
"clockdomain: enabling automatic idle transitions for %s\n",
838 spin_unlock_irqrestore(&clkdm->
lock, flags);
858 pr_debug(
"clockdomain: %s: automatic idle transitions cannot be disabled\n",
866 pr_debug(
"clockdomain: disabling automatic idle transitions for %s\n",
873 spin_unlock_irqrestore(&clkdm->
lock, flags);
897 spin_unlock_irqrestore(&clkdm->
lock, flags);
921 static int _clkdm_clk_hwmod_enable(
struct clockdomain *clkdm)
936 spin_unlock_irqrestore(&clkdm->
lock, flags);
942 spin_unlock_irqrestore(&clkdm->
lock, flags);
949 static int _clkdm_clk_hwmod_disable(
struct clockdomain *clkdm)
959 spin_unlock_irqrestore(&clkdm->
lock, flags);
965 spin_unlock_irqrestore(&clkdm->
lock, flags);
971 spin_unlock_irqrestore(&clkdm->
lock, flags);
1002 return _clkdm_clk_hwmod_enable(clkdm);
1028 return _clkdm_clk_hwmod_disable(clkdm);
1060 return _clkdm_clk_hwmod_enable(clkdm);
1091 return _clkdm_clk_hwmod_disable(clkdm);