Skip to content

Commit ead4782

Browse files
author
Tero Kristo
committed
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>
1 parent 8aa09cf commit ead4782

6 files changed

Lines changed: 31 additions & 24 deletions

File tree

‎drivers/clk/ti/apll.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static void __init omap_clk_register_apll(void *user,
165165

166166
ad->clk_bypass = __clk_get_hw(clk);
167167

168-
clk = ti_clk_register(NULL, &clk_hw->hw, node->name);
168+
clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, node->name);
169169
if (!IS_ERR(clk)) {
170170
of_clk_add_provider(node, of_clk_src_simple_get, clk);
171171
kfree(clk_hw->hw.init->parent_names);
@@ -402,7 +402,7 @@ static void __init of_omap2_apll_setup(struct device_node *node)
402402
if (ret)
403403
goto cleanup;
404404

405-
clk = clk_register(NULL, &clk_hw->hw);
405+
clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, node->name);
406406
if (!IS_ERR(clk)) {
407407
of_clk_add_provider(node, of_clk_src_simple_get, clk);
408408
kfree(init);

‎drivers/clk/ti/clk.c‎

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -520,20 +520,31 @@ struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw,
520520
}
521521

522522
/**
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
525527
*
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.
530532
*/
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)
532535
{
533-
struct clk_hw_omap *c;
536+
struct clk *clk;
537+
struct clk_hw_omap *oclk;
534538

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;
537548
}
538549

539550
/**

‎drivers/clk/ti/clock.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ typedef void (*ti_of_clk_init_cb_t)(void *, struct device_node *);
203203

204204
struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw,
205205
const char *con);
206+
struct clk *ti_clk_register_omap_hw(struct device *dev, struct clk_hw *hw,
207+
const char *con);
206208
int ti_clk_add_alias(struct device *dev, struct clk *clk, const char *con);
207209
void ti_clk_add_aliases(void);
208210

@@ -221,7 +223,6 @@ int ti_clk_retry_init(struct device_node *node, void *user,
221223
ti_of_clk_init_cb_t func);
222224
int ti_clk_add_component(struct device_node *node, struct clk_hw *hw, int type);
223225

224-
void omap2_init_clk_hw_omap_clocks(struct clk_hw *hw);
225226
int of_ti_clk_autoidle_setup(struct device_node *node);
226227
void omap2_clk_enable_init_clocks(const char **clk_names, u8 num_clocks);
227228

‎drivers/clk/ti/dpll.c‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,9 @@ static void __init _register_dpll(void *user,
192192
dd->clk_bypass = __clk_get_hw(clk);
193193

194194
/* 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);
196196

197197
if (!IS_ERR(clk)) {
198-
omap2_init_clk_hw_omap_clocks(&clk_hw->hw);
199198
of_clk_add_provider(node, of_clk_src_simple_get, clk);
200199
kfree(clk_hw->hw.init->parent_names);
201200
kfree(clk_hw->hw.init);
@@ -265,14 +264,12 @@ static void _register_dpll_x2(struct device_node *node,
265264
#endif
266265

267266
/* register the clock */
268-
clk = ti_clk_register(NULL, &clk_hw->hw, name);
267+
clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name);
269268

270-
if (IS_ERR(clk)) {
269+
if (IS_ERR(clk))
271270
kfree(clk_hw);
272-
} else {
273-
omap2_init_clk_hw_omap_clocks(&clk_hw->hw);
271+
else
274272
of_clk_add_provider(node, of_clk_src_simple_get, clk);
275-
}
276273
}
277274
#endif
278275

‎drivers/clk/ti/gate.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ static struct clk *_register_gate(struct device *dev, const char *name,
123123

124124
init.flags = flags;
125125

126-
clk = ti_clk_register(NULL, &clk_hw->hw, name);
126+
clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name);
127127

128128
if (IS_ERR(clk))
129129
kfree(clk_hw);

‎drivers/clk/ti/interface.c‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,10 @@ static struct clk *_register_interface(struct device *dev, const char *name,
5757
init.num_parents = 1;
5858
init.parent_names = &parent_name;
5959

60-
clk = ti_clk_register(NULL, &clk_hw->hw, name);
60+
clk = ti_clk_register_omap_hw(NULL, &clk_hw->hw, name);
6161

6262
if (IS_ERR(clk))
6363
kfree(clk_hw);
64-
else
65-
omap2_init_clk_hw_omap_clocks(&clk_hw->hw);
6664

6765
return clk;
6866
}

0 commit comments

Comments
 (0)