Skip to content

Commit 77b773a

Browse files
author
Tero Kristo
committed
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>
1 parent bfeffd1 commit 77b773a

3 files changed

Lines changed: 69 additions & 39 deletions

File tree

‎drivers/clk/ti/autoidle.c‎

Lines changed: 26 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,20 @@ struct clk_ti_autoidle {
3535
#define AUTOIDLE_LOW 0x1
3636

3737
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+
}
3952

4053
/**
4154
* omap2_clk_deny_idle - disable autoidle on an OMAP clock
@@ -45,12 +58,9 @@ static LIST_HEAD(clk_hw_omap_clocks);
4558
*/
4659
int omap2_clk_deny_idle(struct clk *clk)
4760
{
48-
struct clk_hw_omap *c;
61+
struct clk_hw_omap *c = to_clk_hw_omap(__clk_get_hw(clk));
4962

50-
c = to_clk_hw_omap(__clk_get_hw(clk));
51-
if (c->ops && c->ops->deny_idle)
52-
c->ops->deny_idle(c);
53-
return 0;
63+
return _omap2_clk_deny_idle(c);
5464
}
5565

5666
/**
@@ -61,12 +71,9 @@ int omap2_clk_deny_idle(struct clk *clk)
6171
*/
6272
int omap2_clk_allow_idle(struct clk *clk)
6373
{
64-
struct clk_hw_omap *c;
74+
struct clk_hw_omap *c = to_clk_hw_omap(__clk_get_hw(clk));
6575

66-
c = to_clk_hw_omap(__clk_get_hw(clk));
67-
if (c->ops && c->ops->allow_idle)
68-
c->ops->allow_idle(c);
69-
return 0;
76+
return _omap2_clk_allow_idle(c);
7077
}
7178

7279
static void _allow_autoidle(struct clk_ti_autoidle *clk)
@@ -167,26 +174,6 @@ int __init of_ti_clk_autoidle_setup(struct device_node *node)
167174
return 0;
168175
}
169176

170-
/**
171-
* omap2_init_clk_hw_omap_clocks - initialize an OMAP clock
172-
* @hw: struct clk_hw * to initialize
173-
*
174-
* Add an OMAP clock @clk to the internal list of OMAP clocks. Used
175-
* temporarily for autoidle handling, until this support can be
176-
* integrated into the common clock framework code in some way. No
177-
* return value.
178-
*/
179-
void omap2_init_clk_hw_omap_clocks(struct clk_hw *hw)
180-
{
181-
struct clk_hw_omap *c;
182-
183-
if (clk_hw_get_flags(hw) & CLK_IS_BASIC)
184-
return;
185-
186-
c = to_clk_hw_omap(hw);
187-
list_add(&c->node, &clk_hw_omap_clocks);
188-
}
189-
190177
/**
191178
* omap2_clk_enable_autoidle_all - enable autoidle on all OMAP clocks that
192179
* support it
@@ -198,11 +185,11 @@ void omap2_init_clk_hw_omap_clocks(struct clk_hw *hw)
198185
*/
199186
int omap2_clk_enable_autoidle_all(void)
200187
{
201-
struct clk_hw_omap *c;
188+
int ret;
202189

203-
list_for_each_entry(c, &clk_hw_omap_clocks, node)
204-
if (c->ops && c->ops->allow_idle)
205-
c->ops->allow_idle(c);
190+
ret = omap2_clk_for_each(_omap2_clk_allow_idle);
191+
if (ret)
192+
return ret;
206193

207194
_clk_generic_allow_autoidle_all();
208195

@@ -220,11 +207,11 @@ int omap2_clk_enable_autoidle_all(void)
220207
*/
221208
int omap2_clk_disable_autoidle_all(void)
222209
{
223-
struct clk_hw_omap *c;
210+
int ret;
224211

225-
list_for_each_entry(c, &clk_hw_omap_clocks, node)
226-
if (c->ops && c->ops->deny_idle)
227-
c->ops->deny_idle(c);
212+
ret = omap2_clk_for_each(_omap2_clk_deny_idle);
213+
if (ret)
214+
return ret;
228215

229216
_clk_generic_deny_autoidle_all();
230217

‎drivers/clk/ti/clk.c‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#undef pr_fmt
3232
#define pr_fmt(fmt) "%s: " fmt, __func__
3333

34+
static LIST_HEAD(clk_hw_omap_clocks);
3435
struct ti_clk_ll_ops *ti_clk_ll_ops;
3536
static struct device_node *clocks_node_ptr[CLK_MAX_MEMMAPS];
3637

@@ -517,3 +518,44 @@ struct clk *ti_clk_register(struct device *dev, struct clk_hw *hw,
517518

518519
return clk;
519520
}
521+
522+
/**
523+
* omap2_init_clk_hw_omap_clocks - initialize an OMAP clock
524+
* @hw: struct clk_hw * to initialize
525+
*
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.
530+
*/
531+
void omap2_init_clk_hw_omap_clocks(struct clk_hw *hw)
532+
{
533+
struct clk_hw_omap *c;
534+
535+
c = to_clk_hw_omap(hw);
536+
list_add(&c->node, &clk_hw_omap_clocks);
537+
}
538+
539+
/**
540+
* omap2_clk_for_each - call function for each registered clk_hw_omap
541+
* @fn: pointer to a callback function
542+
*
543+
* Call @fn for each registered clk_hw_omap, passing @hw to each
544+
* function. @fn must return 0 for success or any other value for
545+
* failure. If @fn returns non-zero, the iteration across clocks
546+
* will stop and the non-zero return value will be passed to the
547+
* caller of omap2_clk_for_each().
548+
*/
549+
int omap2_clk_for_each(int (*fn)(struct clk_hw_omap *hw))
550+
{
551+
int ret;
552+
struct clk_hw_omap *hw;
553+
554+
list_for_each_entry(hw, &clk_hw_omap_clocks, node) {
555+
ret = (*fn)(hw);
556+
if (ret)
557+
break;
558+
}
559+
560+
return ret;
561+
}

‎drivers/clk/ti/clock.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ long omap4_dpll_regm4xen_round_rate(struct clk_hw *hw,
301301
unsigned long *parent_rate);
302302
int omap4_dpll_regm4xen_determine_rate(struct clk_hw *hw,
303303
struct clk_rate_request *req);
304+
int omap2_clk_for_each(int (*fn)(struct clk_hw_omap *hw));
304305

305306
extern struct ti_clk_ll_ops *ti_clk_ll_ops;
306307

0 commit comments

Comments
 (0)