Lines Matching +full:auto +full:- +full:sleep +full:- +full:disabled
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 2008-2011 Texas Instruments, Inc.
6 * Copyright (C) 2008-2011 Nokia Corporation
22 #include <linux/clk-provider.h>
56 if (!strcmp(name, temp_clkdm->name)) { in _clkdm_lookup()
66 * _clkdm_register - register a clockdomain
70 * Returns -EINVAL if given a null pointer, -EEXIST if a clockdomain is
77 if (!clkdm || !clkdm->name) in _clkdm_register()
78 return -EINVAL; in _clkdm_register()
80 pwrdm = pwrdm_lookup(clkdm->pwrdm.name); in _clkdm_register()
83 clkdm->name, clkdm->pwrdm.name); in _clkdm_register()
84 return -EINVAL; in _clkdm_register()
86 clkdm->pwrdm.ptr = pwrdm; in _clkdm_register()
89 if (_clkdm_lookup(clkdm->name)) in _clkdm_register()
90 return -EEXIST; in _clkdm_register()
92 list_add(&clkdm->node, &clkdm_list); in _clkdm_register()
96 pr_debug("clockdomain: registered %s\n", clkdm->name); in _clkdm_register()
101 /* _clkdm_deps_lookup - look up the specified clockdomain in a clkdm list */
108 return ERR_PTR(-EINVAL); in _clkdm_deps_lookup()
110 for (cd = deps; cd->clkdm_name; cd++) { in _clkdm_deps_lookup()
111 if (!cd->clkdm && cd->clkdm_name) in _clkdm_deps_lookup()
112 cd->clkdm = _clkdm_lookup(cd->clkdm_name); in _clkdm_deps_lookup()
114 if (cd->clkdm == clkdm) in _clkdm_deps_lookup()
118 if (!cd->clkdm_name) in _clkdm_deps_lookup()
119 return ERR_PTR(-ENOENT); in _clkdm_deps_lookup()
125 * _autodep_lookup - resolve autodep clkdm names to clkdm pointers; store
130 * "autodep" is a clockdomain sleep/wakeup dependency that is
132 * clockdomain are enabled or disabled (respectively) when the
133 * clockdomain is in hardware-supervised mode. Meant to be called
147 clkdm = clkdm_lookup(autodep->clkdm.name); in _autodep_lookup()
150 autodep->clkdm.name); in _autodep_lookup()
151 clkdm = ERR_PTR(-ENOENT); in _autodep_lookup()
153 autodep->clkdm.ptr = clkdm; in _autodep_lookup()
157 * _resolve_clkdm_deps() - resolve clkdm_names in @clkdm_deps to clkdms
170 for (cd = clkdm_deps; cd && cd->clkdm_name; cd++) { in _resolve_clkdm_deps()
171 if (cd->clkdm) in _resolve_clkdm_deps()
173 cd->clkdm = _clkdm_lookup(cd->clkdm_name); in _resolve_clkdm_deps()
175 …WARN(!cd->clkdm, "clockdomain: %s: could not find clkdm %s while resolving dependencies - should n… in _resolve_clkdm_deps()
176 clkdm->name, cd->clkdm_name); in _resolve_clkdm_deps()
181 * _clkdm_add_wkdep - add a wakeup dependency from clkdm2 to clkdm1 (lockless)
188 * Returns -EINVAL if presented with invalid clockdomain pointers,
189 * -ENOENT if @clkdm2 cannot wake up clkdm1 in hardware, or 0 upon
199 return -EINVAL; in _clkdm_add_wkdep()
201 cd = _clkdm_deps_lookup(clkdm2, clkdm1->wkdep_srcs); in _clkdm_add_wkdep()
205 if (!arch_clkdm || !arch_clkdm->clkdm_add_wkdep) in _clkdm_add_wkdep()
206 ret = -EINVAL; in _clkdm_add_wkdep()
210 clkdm1->name, clkdm2->name); in _clkdm_add_wkdep()
214 cd->wkdep_usecount++; in _clkdm_add_wkdep()
215 if (cd->wkdep_usecount == 1) { in _clkdm_add_wkdep()
217 clkdm1->name, clkdm2->name); in _clkdm_add_wkdep()
219 ret = arch_clkdm->clkdm_add_wkdep(clkdm1, clkdm2); in _clkdm_add_wkdep()
226 * _clkdm_del_wkdep - remove a wakeup dep from clkdm2 to clkdm1 (lockless)
231 * wakes up. Returns -EINVAL if presented with invalid clockdomain
232 * pointers, -ENOENT if @clkdm2 cannot wake up clkdm1 in hardware, or
242 return -EINVAL; in _clkdm_del_wkdep()
244 cd = _clkdm_deps_lookup(clkdm2, clkdm1->wkdep_srcs); in _clkdm_del_wkdep()
248 if (!arch_clkdm || !arch_clkdm->clkdm_del_wkdep) in _clkdm_del_wkdep()
249 ret = -EINVAL; in _clkdm_del_wkdep()
253 clkdm1->name, clkdm2->name); in _clkdm_del_wkdep()
257 cd->wkdep_usecount--; in _clkdm_del_wkdep()
258 if (cd->wkdep_usecount == 0) { in _clkdm_del_wkdep()
260 clkdm1->name, clkdm2->name); in _clkdm_del_wkdep()
262 ret = arch_clkdm->clkdm_del_wkdep(clkdm1, clkdm2); in _clkdm_del_wkdep()
269 * _clkdm_add_sleepdep - add a sleep dependency from clkdm2 to clkdm1 (lockless)
274 * retention or off) if @clkdm2 is active. Returns -EINVAL if
276 * that does not support software-configurable hardware sleep
277 * dependencies, -ENOENT if the specified dependency cannot be set in
287 return -EINVAL; in _clkdm_add_sleepdep()
289 cd = _clkdm_deps_lookup(clkdm2, clkdm1->sleepdep_srcs); in _clkdm_add_sleepdep()
293 if (!arch_clkdm || !arch_clkdm->clkdm_add_sleepdep) in _clkdm_add_sleepdep()
294 ret = -EINVAL; in _clkdm_add_sleepdep()
297 pr_debug("clockdomain: hardware cannot set/clear sleep dependency affecting %s from %s\n", in _clkdm_add_sleepdep()
298 clkdm1->name, clkdm2->name); in _clkdm_add_sleepdep()
302 cd->sleepdep_usecount++; in _clkdm_add_sleepdep()
303 if (cd->sleepdep_usecount == 1) { in _clkdm_add_sleepdep()
305 clkdm1->name, clkdm2->name); in _clkdm_add_sleepdep()
307 ret = arch_clkdm->clkdm_add_sleepdep(clkdm1, clkdm2); in _clkdm_add_sleepdep()
314 * _clkdm_del_sleepdep - remove a sleep dep from clkdm2 to clkdm1 (lockless)
319 * off), independent of the activity state of @clkdm2. Returns -EINVAL
321 * that does not support software-configurable hardware sleep dependencies,
322 * -ENOENT if the specified dependency cannot be cleared in hardware, or
332 return -EINVAL; in _clkdm_del_sleepdep()
334 cd = _clkdm_deps_lookup(clkdm2, clkdm1->sleepdep_srcs); in _clkdm_del_sleepdep()
338 if (!arch_clkdm || !arch_clkdm->clkdm_del_sleepdep) in _clkdm_del_sleepdep()
339 ret = -EINVAL; in _clkdm_del_sleepdep()
342 pr_debug("clockdomain: hardware cannot set/clear sleep dependency affecting %s from %s\n", in _clkdm_del_sleepdep()
343 clkdm1->name, clkdm2->name); in _clkdm_del_sleepdep()
347 cd->sleepdep_usecount--; in _clkdm_del_sleepdep()
348 if (cd->sleepdep_usecount == 0) { in _clkdm_del_sleepdep()
350 clkdm1->name, clkdm2->name); in _clkdm_del_sleepdep()
352 ret = arch_clkdm->clkdm_del_sleepdep(clkdm1, clkdm2); in _clkdm_del_sleepdep()
361 * clkdm_register_platform_funcs - register clockdomain implementation fns
366 * before any other clkdm_register*() function. Returns -EINVAL if
367 * @co is null, -EEXIST if platform functions have already been
373 return -EINVAL; in clkdm_register_platform_funcs()
376 return -EEXIST; in clkdm_register_platform_funcs()
384 * clkdm_register_clkdms - register SoC clockdomains
389 * multiple times. Returns -EACCES if called before
390 * clkdm_register_platform_funcs(); -EINVAL if the argument @cs is
398 return -EACCES; in clkdm_register_clkdms()
401 return -EINVAL; in clkdm_register_clkdms()
410 * clkdm_register_autodeps - register autodeps (if required)
414 * clockdomain wakeup and sleep dependencies that are automatically
416 * removed whenever the last clock inside a clockdomain is disabled.
429 * Returns -EACCES if called before any clockdomains have been
430 * registered, -EINVAL if called with a null @ia argument, -EEXIST if
438 return -EACCES; in clkdm_register_autodeps()
441 return -EINVAL; in clkdm_register_autodeps()
444 return -EEXIST; in clkdm_register_autodeps()
447 for (a = autodeps; a->clkdm.ptr; a++) in clkdm_register_autodeps()
470 * clkdm_complete_init - set up the clockdomain layer
472 * Put all clockdomains into software-supervised mode; PM code should
473 * later enable hardware-supervised mode as appropriate. Must be
474 * called after clkdm_register_clkdms(). Returns -EACCES if called
483 return -EACCES; in clkdm_complete_init()
488 _resolve_clkdm_deps(clkdm, clkdm->wkdep_srcs); in clkdm_complete_init()
491 _resolve_clkdm_deps(clkdm, clkdm->sleepdep_srcs); in clkdm_complete_init()
495 /* Only AM43XX can lose clkdm context during rtc-ddr suspend */ in clkdm_complete_init()
505 * clkdm_lookup - look up a clockdomain by name, return a pointer
521 if (!strcmp(name, temp_clkdm->name)) { in clkdm_lookup()
531 * clkdm_for_each - call function on each registered clockdomain
541 * anything else to indicate failure; or -EINVAL if the function pointer
551 return -EINVAL; in clkdm_for_each()
564 * clkdm_get_pwrdm - return a ptr to the pwrdm that this clkdm resides in
575 return clkdm->pwrdm.ptr; in clkdm_get_pwrdm()
582 * clkdm_add_wkdep - add a wakeup dependency from clkdm2 to clkdm1
589 * Returns -EINVAL if presented with invalid clockdomain pointers,
590 * -ENOENT if @clkdm2 cannot wake up clkdm1 in hardware, or 0 upon
599 return -EINVAL; in clkdm_add_wkdep()
601 cd = _clkdm_deps_lookup(clkdm2, clkdm1->wkdep_srcs); in clkdm_add_wkdep()
605 pwrdm_lock(cd->clkdm->pwrdm.ptr); in clkdm_add_wkdep()
607 pwrdm_unlock(cd->clkdm->pwrdm.ptr); in clkdm_add_wkdep()
613 * clkdm_del_wkdep - remove a wakeup dependency from clkdm2 to clkdm1
618 * wakes up. Returns -EINVAL if presented with invalid clockdomain
619 * pointers, -ENOENT if @clkdm2 cannot wake up clkdm1 in hardware, or
628 return -EINVAL; in clkdm_del_wkdep()
630 cd = _clkdm_deps_lookup(clkdm2, clkdm1->wkdep_srcs); in clkdm_del_wkdep()
634 pwrdm_lock(cd->clkdm->pwrdm.ptr); in clkdm_del_wkdep()
636 pwrdm_unlock(cd->clkdm->pwrdm.ptr); in clkdm_del_wkdep()
642 * clkdm_read_wkdep - read wakeup dependency state from clkdm2 to clkdm1
647 * awoken when @clkdm2 wakes up; 0 if dependency is not set; -EINVAL
648 * if either clockdomain pointer is invalid; or -ENOENT if the hardware
651 * REVISIT: Currently this function only represents software-controllable
661 return -EINVAL; in clkdm_read_wkdep()
663 cd = _clkdm_deps_lookup(clkdm2, clkdm1->wkdep_srcs); in clkdm_read_wkdep()
667 if (!arch_clkdm || !arch_clkdm->clkdm_read_wkdep) in clkdm_read_wkdep()
668 ret = -EINVAL; in clkdm_read_wkdep()
672 clkdm1->name, clkdm2->name); in clkdm_read_wkdep()
677 return arch_clkdm->clkdm_read_wkdep(clkdm1, clkdm2); in clkdm_read_wkdep()
681 * clkdm_clear_all_wkdeps - remove all wakeup dependencies from target clkdm
684 * Remove all inter-clockdomain wakeup dependencies that could cause
687 * and woken up. Returns -EINVAL if @clkdm pointer is invalid, or
693 return -EINVAL; in clkdm_clear_all_wkdeps()
695 if (!arch_clkdm || !arch_clkdm->clkdm_clear_all_wkdeps) in clkdm_clear_all_wkdeps()
696 return -EINVAL; in clkdm_clear_all_wkdeps()
698 return arch_clkdm->clkdm_clear_all_wkdeps(clkdm); in clkdm_clear_all_wkdeps()
702 * clkdm_add_sleepdep - add a sleep dependency from clkdm2 to clkdm1
707 * retention or off) if @clkdm2 is active. Returns -EINVAL if
709 * that does not support software-configurable hardware sleep
710 * dependencies, -ENOENT if the specified dependency cannot be set in
719 return -EINVAL; in clkdm_add_sleepdep()
721 cd = _clkdm_deps_lookup(clkdm2, clkdm1->wkdep_srcs); in clkdm_add_sleepdep()
725 pwrdm_lock(cd->clkdm->pwrdm.ptr); in clkdm_add_sleepdep()
727 pwrdm_unlock(cd->clkdm->pwrdm.ptr); in clkdm_add_sleepdep()
733 * clkdm_del_sleepdep - remove a sleep dependency from clkdm2 to clkdm1
738 * off), independent of the activity state of @clkdm2. Returns -EINVAL
740 * that does not support software-configurable hardware sleep dependencies,
741 * -ENOENT if the specified dependency cannot be cleared in hardware, or
750 return -EINVAL; in clkdm_del_sleepdep()
752 cd = _clkdm_deps_lookup(clkdm2, clkdm1->wkdep_srcs); in clkdm_del_sleepdep()
756 pwrdm_lock(cd->clkdm->pwrdm.ptr); in clkdm_del_sleepdep()
758 pwrdm_unlock(cd->clkdm->pwrdm.ptr); in clkdm_del_sleepdep()
764 * clkdm_read_sleepdep - read sleep dependency state from clkdm2 to clkdm1
768 * Return 1 if a hardware sleep dependency exists wherein @clkdm1 will
771 * of @clkdm2's; -EINVAL if either clockdomain pointer is invalid or called
772 * on a machine that does not support software-configurable hardware sleep
773 * dependencies; or -ENOENT if the hardware is incapable.
775 * REVISIT: Currently this function only represents software-controllable
776 * sleep dependencies. Sleep dependencies fixed in hardware are not
785 return -EINVAL; in clkdm_read_sleepdep()
787 cd = _clkdm_deps_lookup(clkdm2, clkdm1->sleepdep_srcs); in clkdm_read_sleepdep()
791 if (!arch_clkdm || !arch_clkdm->clkdm_read_sleepdep) in clkdm_read_sleepdep()
792 ret = -EINVAL; in clkdm_read_sleepdep()
795 pr_debug("clockdomain: hardware cannot set/clear sleep dependency affecting %s from %s\n", in clkdm_read_sleepdep()
796 clkdm1->name, clkdm2->name); in clkdm_read_sleepdep()
801 return arch_clkdm->clkdm_read_sleepdep(clkdm1, clkdm2); in clkdm_read_sleepdep()
805 * clkdm_clear_all_sleepdeps - remove all sleep dependencies from target clkdm
806 * @clkdm: struct clockdomain * to remove all sleep dependencies from
808 * Remove all inter-clockdomain sleep dependencies that could prevent
811 * and woken up. Returns -EINVAL if @clkdm pointer is invalid, or
817 return -EINVAL; in clkdm_clear_all_sleepdeps()
819 if (!arch_clkdm || !arch_clkdm->clkdm_clear_all_sleepdeps) in clkdm_clear_all_sleepdeps()
820 return -EINVAL; in clkdm_clear_all_sleepdeps()
822 return arch_clkdm->clkdm_clear_all_sleepdeps(clkdm); in clkdm_clear_all_sleepdeps()
826 * clkdm_sleep_nolock - force clockdomain sleep transition (lockless)
829 * Instruct the CM to force a sleep transition on the specified
831 * -EINVAL if @clkdm is NULL or if clockdomain does not support
832 * software-initiated sleep; 0 upon success.
839 return -EINVAL; in clkdm_sleep_nolock()
841 if (!(clkdm->flags & CLKDM_CAN_FORCE_SLEEP)) { in clkdm_sleep_nolock()
842 pr_debug("clockdomain: %s does not support forcing sleep via software\n", in clkdm_sleep_nolock()
843 clkdm->name); in clkdm_sleep_nolock()
844 return -EINVAL; in clkdm_sleep_nolock()
847 if (!arch_clkdm || !arch_clkdm->clkdm_sleep) in clkdm_sleep_nolock()
848 return -EINVAL; in clkdm_sleep_nolock()
850 pr_debug("clockdomain: forcing sleep on %s\n", clkdm->name); in clkdm_sleep_nolock()
852 clkdm->_flags &= ~_CLKDM_FLAG_HWSUP_ENABLED; in clkdm_sleep_nolock()
853 ret = arch_clkdm->clkdm_sleep(clkdm); in clkdm_sleep_nolock()
854 ret |= pwrdm_state_switch_nolock(clkdm->pwrdm.ptr); in clkdm_sleep_nolock()
860 * clkdm_sleep - force clockdomain sleep transition
863 * Instruct the CM to force a sleep transition on the specified
864 * clockdomain @clkdm. Returns -EINVAL if @clkdm is NULL or if
865 * clockdomain does not support software-initiated sleep; 0 upon
872 pwrdm_lock(clkdm->pwrdm.ptr); in clkdm_sleep()
874 pwrdm_unlock(clkdm->pwrdm.ptr); in clkdm_sleep()
880 * clkdm_wakeup_nolock - force clockdomain wakeup transition (lockless)
885 * -EINVAL if @clkdm is NULL or if the clockdomain does not support
886 * software-controlled wakeup; 0 upon success.
893 return -EINVAL; in clkdm_wakeup_nolock()
895 if (!(clkdm->flags & CLKDM_CAN_FORCE_WAKEUP)) { in clkdm_wakeup_nolock()
897 clkdm->name); in clkdm_wakeup_nolock()
898 return -EINVAL; in clkdm_wakeup_nolock()
901 if (!arch_clkdm || !arch_clkdm->clkdm_wakeup) in clkdm_wakeup_nolock()
902 return -EINVAL; in clkdm_wakeup_nolock()
904 pr_debug("clockdomain: forcing wakeup on %s\n", clkdm->name); in clkdm_wakeup_nolock()
906 clkdm->_flags &= ~_CLKDM_FLAG_HWSUP_ENABLED; in clkdm_wakeup_nolock()
907 ret = arch_clkdm->clkdm_wakeup(clkdm); in clkdm_wakeup_nolock()
908 ret |= pwrdm_state_switch_nolock(clkdm->pwrdm.ptr); in clkdm_wakeup_nolock()
914 * clkdm_wakeup - force clockdomain wakeup transition
918 * clockdomain @clkdm. Returns -EINVAL if @clkdm is NULL or if the
919 * clockdomain does not support software-controlled wakeup; 0 upon
926 pwrdm_lock(clkdm->pwrdm.ptr); in clkdm_wakeup()
928 pwrdm_unlock(clkdm->pwrdm.ptr); in clkdm_wakeup()
934 * clkdm_allow_idle_nolock - enable hwsup idle transitions for clkdm
949 if (!WARN_ON(!clkdm->forcewake_count)) in clkdm_allow_idle_nolock()
950 clkdm->forcewake_count--; in clkdm_allow_idle_nolock()
952 if (clkdm->forcewake_count) in clkdm_allow_idle_nolock()
955 if (!clkdm->usecount && (clkdm->flags & CLKDM_CAN_FORCE_SLEEP)) in clkdm_allow_idle_nolock()
958 if (!(clkdm->flags & CLKDM_CAN_ENABLE_AUTO)) in clkdm_allow_idle_nolock()
961 if (clkdm->flags & CLKDM_MISSING_IDLE_REPORTING) in clkdm_allow_idle_nolock()
964 if (!arch_clkdm || !arch_clkdm->clkdm_allow_idle) in clkdm_allow_idle_nolock()
968 clkdm->name); in clkdm_allow_idle_nolock()
970 clkdm->_flags |= _CLKDM_FLAG_HWSUP_ENABLED; in clkdm_allow_idle_nolock()
971 arch_clkdm->clkdm_allow_idle(clkdm); in clkdm_allow_idle_nolock()
972 pwrdm_state_switch_nolock(clkdm->pwrdm.ptr); in clkdm_allow_idle_nolock()
976 * clkdm_allow_idle - enable hwsup idle transitions for clkdm
987 pwrdm_lock(clkdm->pwrdm.ptr); in clkdm_allow_idle()
989 pwrdm_unlock(clkdm->pwrdm.ptr); in clkdm_allow_idle()
993 * clkdm_deny_idle_nolock - disable hwsup idle transitions for clkdm
1007 if (clkdm->forcewake_count++) in clkdm_deny_idle_nolock()
1010 if (clkdm->flags & CLKDM_CAN_FORCE_WAKEUP) in clkdm_deny_idle_nolock()
1013 if (!(clkdm->flags & CLKDM_CAN_DISABLE_AUTO)) in clkdm_deny_idle_nolock()
1016 if (clkdm->flags & CLKDM_MISSING_IDLE_REPORTING) in clkdm_deny_idle_nolock()
1019 if (!arch_clkdm || !arch_clkdm->clkdm_deny_idle) in clkdm_deny_idle_nolock()
1023 clkdm->name); in clkdm_deny_idle_nolock()
1025 clkdm->_flags &= ~_CLKDM_FLAG_HWSUP_ENABLED; in clkdm_deny_idle_nolock()
1026 arch_clkdm->clkdm_deny_idle(clkdm); in clkdm_deny_idle_nolock()
1027 pwrdm_state_switch_nolock(clkdm->pwrdm.ptr); in clkdm_deny_idle_nolock()
1031 * clkdm_deny_idle - disable hwsup idle transitions for clkdm
1041 pwrdm_lock(clkdm->pwrdm.ptr); in clkdm_deny_idle()
1043 pwrdm_unlock(clkdm->pwrdm.ptr); in clkdm_deny_idle()
1049 * clkdm_add_autodeps - add auto sleepdeps/wkdeps to clkdm upon clock enable
1052 * Add the "autodep" sleep & wakeup dependencies to clockdomain 'clkdm'
1053 * in hardware-supervised mode. Meant to be called from clock framework
1063 if (!autodeps || clkdm->flags & CLKDM_NO_AUTODEPS) in clkdm_add_autodeps()
1066 for (autodep = autodeps; autodep->clkdm.ptr; autodep++) { in clkdm_add_autodeps()
1067 if (IS_ERR(autodep->clkdm.ptr)) in clkdm_add_autodeps()
1071 clkdm->name, autodep->clkdm.ptr->name); in clkdm_add_autodeps()
1073 _clkdm_add_sleepdep(clkdm, autodep->clkdm.ptr); in clkdm_add_autodeps()
1074 _clkdm_add_wkdep(clkdm, autodep->clkdm.ptr); in clkdm_add_autodeps()
1079 * clkdm_del_autodeps - remove auto sleepdeps/wkdeps from clkdm
1082 * Remove the "autodep" sleep & wakeup dependencies from clockdomain 'clkdm'
1083 * in hardware-supervised mode. Meant to be called from clock framework
1084 * when a clock inside clockdomain 'clkdm' is disabled. No return value.
1093 if (!autodeps || clkdm->flags & CLKDM_NO_AUTODEPS) in clkdm_del_autodeps()
1096 for (autodep = autodeps; autodep->clkdm.ptr; autodep++) { in clkdm_del_autodeps()
1097 if (IS_ERR(autodep->clkdm.ptr)) in clkdm_del_autodeps()
1101 clkdm->name, autodep->clkdm.ptr->name); in clkdm_del_autodeps()
1103 _clkdm_del_sleepdep(clkdm, autodep->clkdm.ptr); in clkdm_del_autodeps()
1104 _clkdm_del_wkdep(clkdm, autodep->clkdm.ptr); in clkdm_del_autodeps()
1108 /* Clockdomain-to-clock/hwmod framework interface code */
1111 * clkdm_clk_enable - add an enabled downstream clock to this clkdm
1117 * clk_enable() code. If the clockdomain is in software-supervised
1119 * hardware-supervised idle mode, add clkdm-pwrdm autodependencies, to
1121 * by on-chip processors. Returns -EINVAL if passed null pointers;
1126 if (!clkdm || !arch_clkdm || !arch_clkdm->clkdm_clk_enable) in clkdm_clk_enable()
1127 return -EINVAL; in clkdm_clk_enable()
1129 pwrdm_lock(clkdm->pwrdm.ptr); in clkdm_clk_enable()
1136 clkdm->usecount++; in clkdm_clk_enable()
1137 if (clkdm->usecount > 1 && autodeps) { in clkdm_clk_enable()
1138 pwrdm_unlock(clkdm->pwrdm.ptr); in clkdm_clk_enable()
1142 arch_clkdm->clkdm_clk_enable(clkdm); in clkdm_clk_enable()
1143 pwrdm_state_switch_nolock(clkdm->pwrdm.ptr); in clkdm_clk_enable()
1144 pwrdm_unlock(clkdm->pwrdm.ptr); in clkdm_clk_enable()
1146 pr_debug("clockdomain: %s: enabled\n", clkdm->name); in clkdm_clk_enable()
1152 * clkdm_clk_disable - remove an enabled downstream clock from this clkdm
1154 * @clk: struct clk * of the disabled downstream clock
1157 * disabled. Intended to be called by clk_disable() code. If the
1158 * clockdomain usecount goes to 0, put the clockdomain to sleep
1159 * (software-supervised mode) or remove the clkdm autodependencies
1160 * (hardware-supervised mode). Returns -EINVAL if passed null
1161 * pointers; -ERANGE if the @clkdm usecount underflows; or returns 0
1166 if (!clkdm || !arch_clkdm || !arch_clkdm->clkdm_clk_disable) in clkdm_clk_disable()
1167 return -EINVAL; in clkdm_clk_disable()
1169 pwrdm_lock(clkdm->pwrdm.ptr); in clkdm_clk_disable()
1172 if (clk && (__clk_get_enable_count(clk) == 0) && clkdm->usecount == 0) in clkdm_clk_disable()
1175 if (clkdm->usecount == 0) { in clkdm_clk_disable()
1176 pwrdm_unlock(clkdm->pwrdm.ptr); in clkdm_clk_disable()
1178 return -ERANGE; in clkdm_clk_disable()
1181 clkdm->usecount--; in clkdm_clk_disable()
1182 if (clkdm->usecount > 0) { in clkdm_clk_disable()
1183 pwrdm_unlock(clkdm->pwrdm.ptr); in clkdm_clk_disable()
1187 arch_clkdm->clkdm_clk_disable(clkdm); in clkdm_clk_disable()
1188 pwrdm_state_switch_nolock(clkdm->pwrdm.ptr); in clkdm_clk_disable()
1190 pr_debug("clockdomain: %s: disabled\n", clkdm->name); in clkdm_clk_disable()
1193 pwrdm_unlock(clkdm->pwrdm.ptr); in clkdm_clk_disable()
1199 * clkdm_hwmod_enable - add an enabled downstream hwmod to this clkdm
1206 * If the clockdomain is in software-supervised idle mode, force the
1207 * clockdomain to wake. If the clockdomain is in hardware-supervised idle
1208 * mode, add clkdm-pwrdm autodependencies, to ensure that devices in the
1209 * clockdomain can be read from/written to by on-chip processors.
1210 * Returns -EINVAL if passed null pointers;
1225 return -EINVAL; in clkdm_hwmod_enable()
1231 * clkdm_hwmod_disable - remove an enabled downstream hwmod from this clkdm
1233 * @oh: struct omap_hwmod * of the disabled downstream hwmod
1236 * disabled. Intended to be called by module_disable() code.
1237 * If the clockdomain usecount goes to 0, put the clockdomain to sleep
1238 * (software-supervised mode) or remove the clkdm autodependencies
1239 * (hardware-supervised mode).
1240 * Returns -EINVAL if passed null pointers; -ERANGE if the @clkdm usecount
1251 return -EINVAL; in clkdm_hwmod_disable()
1257 * _clkdm_save_context - save the context for the control of this clkdm
1264 if (!arch_clkdm || !arch_clkdm->clkdm_save_context) in _clkdm_save_context()
1265 return -EINVAL; in _clkdm_save_context()
1267 return arch_clkdm->clkdm_save_context(clkdm); in _clkdm_save_context()
1271 * _clkdm_restore_context - restore context for control of this clkdm
1277 if (!arch_clkdm || !arch_clkdm->clkdm_restore_context) in _clkdm_restore_context()
1278 return -EINVAL; in _clkdm_restore_context()
1280 return arch_clkdm->clkdm_restore_context(clkdm); in _clkdm_restore_context()
1284 * clkdm_save_context - Saves the context for each registered clkdm
1294 * clkdm_restore_context - Restores the context for each registered clkdm