Lines Matching defs:clkdm
42 /* array of clockdomain deps to be added/removed when clkdm in hwsup mode */
50 struct clockdomain *clkdm, *temp_clkdm;
55 clkdm = NULL;
59 clkdm = temp_clkdm;
64 return clkdm;
69 * @clkdm: struct clockdomain * to register
75 static int _clkdm_register(struct clockdomain *clkdm)
79 if (!clkdm || !clkdm->name)
82 if (!omap_chip_is(clkdm->omap_chip))
85 pwrdm = pwrdm_lookup(clkdm->pwrdm.name);
88 clkdm->name, clkdm->pwrdm.name);
91 clkdm->pwrdm.ptr = pwrdm;
94 if (_clkdm_lookup(clkdm->name))
97 list_add(&clkdm->node, &clkdm_list);
99 pwrdm_add_clkdm(pwrdm, clkdm);
101 pr_debug("clockdomain: registered %s\n", clkdm->name);
106 /* _clkdm_deps_lookup - look up the specified clockdomain in a clkdm list */
107 static struct clkdm_dep *_clkdm_deps_lookup(struct clockdomain *clkdm,
112 if (!clkdm || !deps || !omap_chip_is(clkdm->omap_chip))
119 if (!cd->clkdm && cd->clkdm_name)
120 cd->clkdm = _clkdm_lookup(cd->clkdm_name);
122 if (cd->clkdm == clkdm)
133 * _autodep_lookup - resolve autodep clkdm names to clkdm pointers; store
147 struct clockdomain *clkdm;
155 clkdm = clkdm_lookup(autodep->clkdm.name);
156 if (!clkdm) {
158 autodep->clkdm.name);
159 clkdm = ERR_PTR(-ENOENT);
161 autodep->clkdm.ptr = clkdm;
165 * _clkdm_add_autodeps - add auto sleepdeps/wkdeps to clkdm upon clock enable
166 * @clkdm: struct clockdomain *
168 * Add the "autodep" sleep & wakeup dependencies to clockdomain 'clkdm'
170 * when a clock inside clockdomain 'clkdm' is enabled. No return value.
172 static void _clkdm_add_autodeps(struct clockdomain *clkdm)
179 for (autodep = autodeps; autodep->clkdm.ptr; autodep++) {
180 if (IS_ERR(autodep->clkdm.ptr))
187 "clkdm %s\n", autodep->clkdm.ptr->name,
188 clkdm->name);
190 clkdm_add_sleepdep(clkdm, autodep->clkdm.ptr);
191 clkdm_add_wkdep(clkdm, autodep->clkdm.ptr);
196 * _clkdm_add_autodeps - remove auto sleepdeps/wkdeps from clkdm
197 * @clkdm: struct clockdomain *
199 * Remove the "autodep" sleep & wakeup dependencies from clockdomain 'clkdm'
201 * when a clock inside clockdomain 'clkdm' is disabled. No return value.
203 static void _clkdm_del_autodeps(struct clockdomain *clkdm)
210 for (autodep = autodeps; autodep->clkdm.ptr; autodep++) {
211 if (IS_ERR(autodep->clkdm.ptr))
218 "clkdm %s\n", autodep->clkdm.ptr->name,
219 clkdm->name);
221 clkdm_del_sleepdep(clkdm, autodep->clkdm.ptr);
222 clkdm_del_wkdep(clkdm, autodep->clkdm.ptr);
228 * @clkdm: struct clockdomain *
232 * idle transitions for clkdm.
234 static void _omap2_clkdm_set_hwsup(struct clockdomain *clkdm, int enable)
252 bits = bits << __ffs(clkdm->clktrctrl_mask);
254 v = __raw_readl(clkdm->clkstctrl_reg);
255 v &= ~(clkdm->clktrctrl_mask);
257 __raw_writel(v, clkdm->clkstctrl_reg);
263 * @clkdm: clockdomain to initialize wkdep usecounts
265 * Initialize the wakeup dependency usecount variables for clockdomain @clkdm.
271 static void _init_wkdep_usecount(struct clockdomain *clkdm)
276 if (!clkdm->wkdep_srcs)
279 for (cd = clkdm->wkdep_srcs; cd->clkdm_name; cd++) {
283 if (!cd->clkdm && cd->clkdm_name)
284 cd->clkdm = _clkdm_lookup(cd->clkdm_name);
286 if (!cd->clkdm) {
287 WARN(!cd->clkdm, "clockdomain: %s: wkdep clkdm %s not "
288 "found\n", clkdm->name, cd->clkdm_name);
292 v = prm_read_mod_bits_shift(clkdm->pwrdm.ptr->prcm_offs,
294 (1 << cd->clkdm->dep_bit));
299 clkdm->name, cd->clkdm->name);
307 * @clkdm: clockdomain to initialize sleepdep usecounts
309 * Initialize the sleep dependency usecount variables for clockdomain @clkdm.
315 static void _init_sleepdep_usecount(struct clockdomain *clkdm)
323 if (!clkdm->sleepdep_srcs)
326 for (cd = clkdm->sleepdep_srcs; cd->clkdm_name; cd++) {
330 if (!cd->clkdm && cd->clkdm_name)
331 cd->clkdm = _clkdm_lookup(cd->clkdm_name);
333 if (!cd->clkdm) {
334 WARN(!cd->clkdm, "clockdomain: %s: sleepdep clkdm %s "
335 "not found\n", clkdm->name, cd->clkdm_name);
339 v = prm_read_mod_bits_shift(clkdm->pwrdm.ptr->prcm_offs,
341 (1 << cd->clkdm->dep_bit));
346 "idles\n", clkdm->name, cd->clkdm->name);
369 struct clockdomain *clkdm;
378 for (autodep = autodeps; autodep->clkdm.ptr; autodep++)
385 list_for_each_entry(clkdm, &clkdm_list, node) {
386 _init_wkdep_usecount(clkdm);
387 _init_sleepdep_usecount(clkdm);
400 struct clockdomain *clkdm, *temp_clkdm;
405 clkdm = NULL;
409 clkdm = temp_clkdm;
414 return clkdm;
431 int clkdm_for_each(int (*fn)(struct clockdomain *clkdm, void *user),
434 struct clockdomain *clkdm;
440 list_for_each_entry(clkdm, &clkdm_list, node) {
441 ret = (*fn)(clkdm, user);
451 * clkdm_get_pwrdm - return a ptr to the pwrdm that this clkdm resides in
452 * @clkdm: struct clockdomain *
455 * @clkdm exists in, or returns NULL if @clkdm is NULL.
457 struct powerdomain *clkdm_get_pwrdm(struct clockdomain *clkdm)
459 if (!clkdm)
462 return clkdm->pwrdm.ptr;
573 * clkdm_clear_all_wkdeps - remove all wakeup dependencies from target clkdm
574 * @clkdm: struct clockdomain * to remove all wakeup dependencies from
577 * @clkdm to wake. Intended to be used during boot to initialize the
579 * and woken up. Returns -EINVAL if @clkdm pointer is invalid, or
582 int clkdm_clear_all_wkdeps(struct clockdomain *clkdm)
587 if (!clkdm)
590 for (cd = clkdm->wkdep_srcs; cd && cd->clkdm_name; cd++) {
595 mask |= 1 << cd->clkdm->dep_bit;
599 prm_clear_mod_reg_bits(mask, clkdm->pwrdm.ptr->prcm_offs, PM_WKDEP);
729 * clkdm_clear_all_sleepdeps - remove all sleep dependencies from target clkdm
730 * @clkdm: struct clockdomain * to remove all sleep dependencies from
733 * @clkdm from idling. Intended to be used during boot to initialize the
735 * and woken up. Returns -EINVAL if @clkdm pointer is invalid, or
738 int clkdm_clear_all_sleepdeps(struct clockdomain *clkdm)
746 if (!clkdm)
749 for (cd = clkdm->sleepdep_srcs; cd && cd->clkdm_name; cd++) {
754 mask |= 1 << cd->clkdm->dep_bit;
758 prm_clear_mod_reg_bits(mask, clkdm->pwrdm.ptr->prcm_offs,
765 * omap2_clkdm_clktrctrl_read - read the clkdm's current state transition mode
766 * @clkdm: struct clkdm * of a clockdomain
768 * Return the clockdomain @clkdm current state transition mode from the
769 * corresponding domain CM_CLKSTCTRL register. Returns -EINVAL if @clkdm
772 static int omap2_clkdm_clktrctrl_read(struct clockdomain *clkdm)
776 if (!clkdm)
779 v = __raw_readl(clkdm->clkstctrl_reg);
780 v &= clkdm->clktrctrl_mask;
781 v >>= __ffs(clkdm->clktrctrl_mask);
788 * @clkdm: struct clockdomain *
791 * clockdomain @clkdm. Returns -EINVAL if @clkdm is NULL or if
795 int omap2_clkdm_sleep(struct clockdomain *clkdm)
797 if (!clkdm)
800 if (!(clkdm->flags & CLKDM_CAN_FORCE_SLEEP)) {
802 "sleep via software\n", clkdm->name);
806 pr_debug("clockdomain: forcing sleep on %s\n", clkdm->name);
811 clkdm->pwrdm.ptr->prcm_offs, OMAP2_PM_PWSTCTRL);
816 __ffs(clkdm->clktrctrl_mask));
818 u32 v = __raw_readl(clkdm->clkstctrl_reg);
819 v &= ~(clkdm->clktrctrl_mask);
821 __raw_writel(v, clkdm->clkstctrl_reg);
832 * @clkdm: struct clockdomain *
835 * clockdomain @clkdm. Returns -EINVAL if @clkdm is NULL or if the
839 int omap2_clkdm_wakeup(struct clockdomain *clkdm)
841 if (!clkdm)
844 if (!(clkdm->flags & CLKDM_CAN_FORCE_WAKEUP)) {
846 "wakeup via software\n", clkdm->name);
850 pr_debug("clockdomain: forcing wakeup on %s\n", clkdm->name);
855 clkdm->pwrdm.ptr->prcm_offs, OMAP2_PM_PWSTCTRL);
860 __ffs(clkdm->clktrctrl_mask));
862 u32 v = __raw_readl(clkdm->clkstctrl_reg);
863 v &= ~(clkdm->clktrctrl_mask);
865 __raw_writel(v, clkdm->clkstctrl_reg);
875 * omap2_clkdm_allow_idle - enable hwsup idle transitions for clkdm
876 * @clkdm: struct clockdomain *
878 * Allow the hardware to automatically switch the clockdomain @clkdm into
884 void omap2_clkdm_allow_idle(struct clockdomain *clkdm)
886 if (!clkdm)
889 if (!(clkdm->flags & CLKDM_CAN_ENABLE_AUTO)) {
891 "on clockdomain %s\n", clkdm->name);
896 clkdm->name);
902 if (atomic_read(&clkdm->usecount) > 0)
903 _clkdm_add_autodeps(clkdm);
906 _omap2_clkdm_set_hwsup(clkdm, 1);
908 pwrdm_clkdm_state_switch(clkdm);
912 * omap2_clkdm_deny_idle - disable hwsup idle transitions for clkdm
913 * @clkdm: struct clockdomain *
916 * @clkdm into inactive or idle states. If the clockdomain has
920 void omap2_clkdm_deny_idle(struct clockdomain *clkdm)
922 if (!clkdm)
925 if (!(clkdm->flags & CLKDM_CAN_DISABLE_AUTO)) {
927 "disabled on %s\n", clkdm->name);
932 clkdm->name);
934 _omap2_clkdm_set_hwsup(clkdm, 0);
940 if (atomic_read(&clkdm->usecount) > 0)
941 _clkdm_del_autodeps(clkdm);
949 * omap2_clkdm_clk_enable - add an enabled downstream clock to this clkdm
950 * @clkdm: struct clockdomain *
953 * Increment the usecount of the clockdomain @clkdm and ensure that it
957 * hardware-supervised idle mode, add clkdm-pwrdm autodependencies, to
962 int omap2_clkdm_clk_enable(struct clockdomain *clkdm, struct clk *clk)
967 if (!clkdm || !clk)
970 if (atomic_inc_return(&clkdm->usecount) > 1)
975 pr_debug("clockdomain: clkdm %s: clk %s now enabled\n", clkdm->name,
978 if (!clkdm->clkstctrl_reg)
981 v = omap2_clkdm_clktrctrl_read(clkdm);
986 _omap2_clkdm_set_hwsup(clkdm, 0);
987 _clkdm_add_autodeps(clkdm);
988 _omap2_clkdm_set_hwsup(clkdm, 1);
990 omap2_clkdm_wakeup(clkdm);
993 pwrdm_wait_transition(clkdm->pwrdm.ptr);
994 pwrdm_clkdm_state_switch(clkdm);
1000 * omap2_clkdm_clk_disable - remove an enabled downstream clock from this clkdm
1001 * @clkdm: struct clockdomain *
1004 * Decrement the usecount of this clockdomain @clkdm when @clk is
1007 * (software-supervised mode) or remove the clkdm autodependencies
1009 * pointers; -ERANGE if the @clkdm usecount underflows and debugging
1013 int omap2_clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk)
1018 if (!clkdm || !clk)
1022 if (atomic_read(&clkdm->usecount) == 0) {
1028 if (atomic_dec_return(&clkdm->usecount) > 0)
1033 pr_debug("clockdomain: clkdm %s: clk %s now disabled\n", clkdm->name,
1036 if (!clkdm->clkstctrl_reg)
1039 v = omap2_clkdm_clktrctrl_read(clkdm);
1044 _omap2_clkdm_set_hwsup(clkdm, 0);
1045 _clkdm_del_autodeps(clkdm);
1046 _omap2_clkdm_set_hwsup(clkdm, 1);
1048 omap2_clkdm_sleep(clkdm);
1051 pwrdm_clkdm_state_switch(clkdm);