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

clk: ti: generalize the init sequence of clk_hw_omap clocks

Add a generic API for initializing clocks of clk_hw_omap type clocks,
and convert the whole TI clock driver suite to use this for registering
the clocks. Also, get rid of the now redundant API for adding the clocks
to the OMAP HW clocks list; instead this is used directly from the
register API.

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

+31 -24
+2 -2
drivers/clk/ti/apll.c
··· 165 165 166 166 ad->clk_bypass = __clk_get_hw(clk); 167 167 168 - clk = ti_clk_register(NULL, &clk_hw->hw, node->name); 168 + clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, node->name); 169 169 if (!IS_ERR(clk)) { 170 170 of_clk_add_provider(node, of_clk_src_simple_get, clk); 171 171 kfree(clk_hw->hw.init->parent_names); ··· 402 402 if (ret) 403 403 goto cleanup; 404 404 405 - clk = clk_register(NULL, &clk_hw->hw); 405 + clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, node->name); 406 406 if (!IS_ERR(clk)) { 407 407 of_clk_add_provider(node, of_clk_src_simple_get, clk); 408 408 kfree(init);
+21 -10
drivers/clk/ti/clk.c
··· 520 520 } 521 521 522 522 /** 523 - * omap2_init_clk_hw_omap_clocks - initialize an OMAP clock 524 - * @hw: struct clk_hw * to initialize 523 + * ti_clk_register_omap_hw - register a clk_hw_omap to the clock framework 524 + * @dev: device for this clock 525 + * @hw: hardware clock handle 526 + * @con: connection ID for this clock 525 527 * 526 - * Add an OMAP clock @clk to the internal list of OMAP clocks. Used 527 - * temporarily for autoidle handling, until this support can be 528 - * integrated into the common clock framework code in some way. No 529 - * return value. 528 + * Registers a clk_hw_omap clock to the clock framewor, adds a clock alias 529 + * for it, and adds the list to the available clk_hw_omap type clocks. 530 + * Returns a handle to the registered clock if successful, ERR_PTR value 531 + * in failure. 530 532 */ 531 - void omap2_init_clk_hw_omap_clocks(struct clk_hw *hw) 533 + struct clk *ti_clk_register_omap_hw(struct device *dev, struct clk_hw *hw, 534 + const char *con) 532 535 { 533 - struct clk_hw_omap *c; 536 + struct clk *clk; 537 + struct clk_hw_omap *oclk; 534 538 535 - c = to_clk_hw_omap(hw); 536 - list_add(&c->node, &clk_hw_omap_clocks); 539 + clk = ti_clk_register(dev, hw, con); 540 + if (IS_ERR(clk)) 541 + return clk; 542 + 543 + oclk = to_clk_hw_omap(hw); 544 + 545 + list_add(&oclk->node, &clk_hw_omap_clocks); 546 + 547 + return clk; 537 548 } 538 549 539 550 /**
+2 -1
drivers/clk/ti/clock.h
··· 203 203 204 204 struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw, 205 205 const char *con); 206 + struct clk *ti_clk_register_omap_hw(struct device *dev, struct clk_hw *hw, 207 + const char *con); 206 208 int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con); 207 209 void ti_clk_add_aliases(void); 208 210 ··· 223 221 ti_of_clk_init_cb_t func); 224 222 int ti_clk_add_component(struct device_node *node, struct clk_hw *hw, int type); 225 223 226 - void omap2_init_clk_hw_omap_clocks(struct clk_hw *hw); 227 224 int of_ti_clk_autoidle_setup(struct device_node *node); 228 225 void omap2_clk_enable_init_clocks(const char **clk_names, u8 num_clocks); 229 226
+4 -7
drivers/clk/ti/dpll.c
··· 192 192 dd->clk_bypass = __clk_get_hw(clk); 193 193 194 194 /* register the clock */ 195 - clk = ti_clk_register(NULL, &clk_hw->hw, node->name); 195 + clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, node->name); 196 196 197 197 if (!IS_ERR(clk)) { 198 - omap2_init_clk_hw_omap_clocks(&clk_hw->hw); 199 198 of_clk_add_provider(node, of_clk_src_simple_get, clk); 200 199 kfree(clk_hw->hw.init->parent_names); 201 200 kfree(clk_hw->hw.init); ··· 264 265 #endif 265 266 266 267 /* register the clock */ 267 - clk = ti_clk_register(NULL, &clk_hw->hw, name); 268 + clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name); 268 269 269 - if (IS_ERR(clk)) { 270 + if (IS_ERR(clk)) 270 271 kfree(clk_hw); 271 - } else { 272 - omap2_init_clk_hw_omap_clocks(&clk_hw->hw); 272 + else 273 273 of_clk_add_provider(node, of_clk_src_simple_get, clk); 274 - } 275 274 } 276 275 #endif 277 276
+1 -1
drivers/clk/ti/gate.c
··· 123 123 124 124 init.flags = flags; 125 125 126 - clk = ti_clk_register(NULL, &clk_hw->hw, name); 126 + clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name); 127 127 128 128 if (IS_ERR(clk)) 129 129 kfree(clk_hw);
+1 -3
drivers/clk/ti/interface.c
··· 57 57 init.num_parents = 1; 58 58 init.parent_names = &parent_name; 59 59 60 - clk = ti_clk_register(NULL, &clk_hw->hw, name); 60 + clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name); 61 61 62 62 if (IS_ERR(clk)) 63 63 kfree(clk_hw); 64 - else 65 - omap2_init_clk_hw_omap_clocks(&clk_hw->hw); 66 64 67 65 return clk; 68 66 }