Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: ti: move clk_hw_omap list handling under generic part of the driver

Currently the clk_hw_omap list is handled under the autoidle code, but
it should be accessible generically. Add a few APIs towards this, and
update the autoidle code to use the generic implementations.

Signed-off-by: Tero Kristo <t-kristo@ti.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Tested-by: Keerthy <j-keerthy@ti.com>

+69 -39
+26 -39
drivers/clk/ti/autoidle.c
··· 35 35 #define AUTOIDLE_LOW 0x1 36 36 37 37 static LIST_HEAD(autoidle_clks); 38 - static LIST_HEAD(clk_hw_omap_clocks); 38 + 39 + static int _omap2_clk_deny_idle(struct clk_hw_omap *clk) 40 + { 41 + if (clk->ops && clk->ops->deny_idle) 42 + clk->ops->deny_idle(clk); 43 + return 0; 44 + } 45 + 46 + static int _omap2_clk_allow_idle(struct clk_hw_omap *clk) 47 + { 48 + if (clk->ops && clk->ops->allow_idle) 49 + clk->ops->allow_idle(clk); 50 + return 0; 51 + } 39 52 40 53 /** 41 54 * omap2_clk_deny_idle - disable autoidle on an OMAP clock ··· 58 45 */ 59 46 int omap2_clk_deny_idle(struct clk *clk) 60 47 { 61 - struct clk_hw_omap *c; 48 + struct clk_hw_omap *c = to_clk_hw_omap(__clk_get_hw(clk)); 62 49 63 - c = to_clk_hw_omap(__clk_get_hw(clk)); 64 - if (c->ops && c->ops->deny_idle) 65 - c->ops->deny_idle(c); 66 - return 0; 50 + return _omap2_clk_deny_idle(c); 67 51 } 68 52 69 53 /** ··· 71 61 */ 72 62 int omap2_clk_allow_idle(struct clk *clk) 73 63 { 74 - struct clk_hw_omap *c; 64 + struct clk_hw_omap *c = to_clk_hw_omap(__clk_get_hw(clk)); 75 65 76 - c = to_clk_hw_omap(__clk_get_hw(clk)); 77 - if (c->ops && c->ops->allow_idle) 78 - c->ops->allow_idle(c); 79 - return 0; 66 + return _omap2_clk_allow_idle(c); 80 67 } 81 68 82 69 static void _allow_autoidle(struct clk_ti_autoidle *clk) ··· 175 168 } 176 169 177 170 /** 178 - * omap2_init_clk_hw_omap_clocks - initialize an OMAP clock 179 - * @hw: struct clk_hw * to initialize 180 - * 181 - * Add an OMAP clock @clk to the internal list of OMAP clocks. Used 182 - * temporarily for autoidle handling, until this support can be 183 - * integrated into the common clock framework code in some way. No 184 - * return value. 185 - */ 186 - void omap2_init_clk_hw_omap_clocks(struct clk_hw *hw) 187 - { 188 - struct clk_hw_omap *c; 189 - 190 - if (clk_hw_get_flags(hw) & CLK_IS_BASIC) 191 - return; 192 - 193 - c = to_clk_hw_omap(hw); 194 - list_add(&c->node, &clk_hw_omap_clocks); 195 - } 196 - 197 - /** 198 171 * omap2_clk_enable_autoidle_all - enable autoidle on all OMAP clocks that 199 172 * support it 200 173 * ··· 185 198 */ 186 199 int omap2_clk_enable_autoidle_all(void) 187 200 { 188 - struct clk_hw_omap *c; 201 + int ret; 189 202 190 - list_for_each_entry(c, &clk_hw_omap_clocks, node) 191 - if (c->ops && c->ops->allow_idle) 192 - c->ops->allow_idle(c); 203 + ret = omap2_clk_for_each(_omap2_clk_allow_idle); 204 + if (ret) 205 + return ret; 193 206 194 207 _clk_generic_allow_autoidle_all(); 195 208 ··· 207 220 */ 208 221 int omap2_clk_disable_autoidle_all(void) 209 222 { 210 - struct clk_hw_omap *c; 223 + int ret; 211 224 212 - list_for_each_entry(c, &clk_hw_omap_clocks, node) 213 - if (c->ops && c->ops->deny_idle) 214 - c->ops->deny_idle(c); 225 + ret = omap2_clk_for_each(_omap2_clk_deny_idle); 226 + if (ret) 227 + return ret; 215 228 216 229 _clk_generic_deny_autoidle_all(); 217 230
+42
drivers/clk/ti/clk.c
··· 31 31 #undef pr_fmt 32 32 #define pr_fmt(fmt) "%s: " fmt, __func__ 33 33 34 + static LIST_HEAD(clk_hw_omap_clocks); 34 35 struct ti_clk_ll_ops *ti_clk_ll_ops; 35 36 static struct device_node *clocks_node_ptr[CLK_MAX_MEMMAPS]; 36 37 ··· 517 516 } 518 517 519 518 return clk; 519 + } 520 + 521 + /** 522 + * omap2_init_clk_hw_omap_clocks - initialize an OMAP clock 523 + * @hw: struct clk_hw * to initialize 524 + * 525 + * Add an OMAP clock @clk to the internal list of OMAP clocks. Used 526 + * temporarily for autoidle handling, until this support can be 527 + * integrated into the common clock framework code in some way. No 528 + * return value. 529 + */ 530 + void omap2_init_clk_hw_omap_clocks(struct clk_hw *hw) 531 + { 532 + struct clk_hw_omap *c; 533 + 534 + c = to_clk_hw_omap(hw); 535 + list_add(&c->node, &clk_hw_omap_clocks); 536 + } 537 + 538 + /** 539 + * omap2_clk_for_each - call function for each registered clk_hw_omap 540 + * @fn: pointer to a callback function 541 + * 542 + * Call @fn for each registered clk_hw_omap, passing @hw to each 543 + * function. @fn must return 0 for success or any other value for 544 + * failure. If @fn returns non-zero, the iteration across clocks 545 + * will stop and the non-zero return value will be passed to the 546 + * caller of omap2_clk_for_each(). 547 + */ 548 + int omap2_clk_for_each(int (*fn)(struct clk_hw_omap *hw)) 549 + { 550 + int ret; 551 + struct clk_hw_omap *hw; 552 + 553 + list_for_each_entry(hw, &clk_hw_omap_clocks, node) { 554 + ret = (*fn)(hw); 555 + if (ret) 556 + break; 557 + } 558 + 559 + return ret; 520 560 }
+1
drivers/clk/ti/clock.h
··· 301 301 unsigned long *parent_rate); 302 302 int omap4_dpll_regm4xen_determine_rate(struct clk_hw *hw, 303 303 struct clk_rate_request *req); 304 + int omap2_clk_for_each(int (*fn)(struct clk_hw_omap *hw)); 304 305 305 306 extern struct ti_clk_ll_ops *ti_clk_ll_ops; 306 307