summaryrefslogtreecommitdiffstats
path: root/drivers/clk/clk.c
diff options
context:
space:
mode:
authorStephen Boyd <sboyd@codeaurora.org>2015-06-25 18:55:14 -0400
committerMichael Turquette <mturquette@baylibre.com>2015-08-24 19:48:42 -0400
commit1a9c069cb2d28bb72fefee509e0d26f92d7f7166 (patch)
tree79d1002ccc0982637da9404aa5f45e0302240729 /drivers/clk/clk.c
parentbea047e075784471461c4338d0ffa45cb1378d67 (diff)
clk: Add clk_hw_*() APIs for use by clk providers
clk providers shouldn't need to use the consumer APIs (clk.h). Add provider APIs to replace the __clk_*() APIs that take a struct clk_hw as their first argument instead of a struct clk. Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r--drivers/clk/clk.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 4912c2e55e2c..a30fd30f4948 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -278,6 +278,12 @@ const char *__clk_get_name(struct clk *clk)
278} 278}
279EXPORT_SYMBOL_GPL(__clk_get_name); 279EXPORT_SYMBOL_GPL(__clk_get_name);
280 280
281const char *clk_hw_get_name(struct clk_hw *hw)
282{
283 return hw->core->name;
284}
285EXPORT_SYMBOL_GPL(clk_hw_get_name);
286
281struct clk_hw *__clk_get_hw(struct clk *clk) 287struct clk_hw *__clk_get_hw(struct clk *clk)
282{ 288{
283 return !clk ? NULL : clk->core->hw; 289 return !clk ? NULL : clk->core->hw;
@@ -290,6 +296,12 @@ u8 __clk_get_num_parents(struct clk *clk)
290} 296}
291EXPORT_SYMBOL_GPL(__clk_get_num_parents); 297EXPORT_SYMBOL_GPL(__clk_get_num_parents);
292 298
299unsigned int clk_hw_get_num_parents(struct clk_hw *hw)
300{
301 return hw->core->num_parents;
302}
303EXPORT_SYMBOL_GPL(clk_hw_get_num_parents);
304
293struct clk *__clk_get_parent(struct clk *clk) 305struct clk *__clk_get_parent(struct clk *clk)
294{ 306{
295 if (!clk) 307 if (!clk)
@@ -300,6 +312,12 @@ struct clk *__clk_get_parent(struct clk *clk)
300} 312}
301EXPORT_SYMBOL_GPL(__clk_get_parent); 313EXPORT_SYMBOL_GPL(__clk_get_parent);
302 314
315struct clk_hw *clk_hw_get_parent(struct clk_hw *hw)
316{
317 return hw->core->parent ? hw->core->parent->hw : NULL;
318}
319EXPORT_SYMBOL_GPL(clk_hw_get_parent);
320
303static struct clk_core *__clk_lookup_subtree(const char *name, 321static struct clk_core *__clk_lookup_subtree(const char *name,
304 struct clk_core *core) 322 struct clk_core *core)
305{ 323{
@@ -370,6 +388,16 @@ struct clk *clk_get_parent_by_index(struct clk *clk, u8 index)
370} 388}
371EXPORT_SYMBOL_GPL(clk_get_parent_by_index); 389EXPORT_SYMBOL_GPL(clk_get_parent_by_index);
372 390
391struct clk_hw *clk_hw_get_parent_by_index(struct clk_hw *hw, unsigned int index)
392{
393 struct clk_core *parent;
394
395 parent = clk_core_get_parent_by_index(hw->core, index);
396
397 return !parent ? NULL : parent->hw;
398}
399EXPORT_SYMBOL_GPL(clk_hw_get_parent_by_index);
400
373unsigned int __clk_get_enable_count(struct clk *clk) 401unsigned int __clk_get_enable_count(struct clk *clk)
374{ 402{
375 return !clk ? 0 : clk->core->enable_count; 403 return !clk ? 0 : clk->core->enable_count;
@@ -405,6 +433,12 @@ unsigned long __clk_get_rate(struct clk *clk)
405} 433}
406EXPORT_SYMBOL_GPL(__clk_get_rate); 434EXPORT_SYMBOL_GPL(__clk_get_rate);
407 435
436unsigned long clk_hw_get_rate(struct clk_hw *hw)
437{
438 return clk_core_get_rate_nolock(hw->core);
439}
440EXPORT_SYMBOL_GPL(clk_hw_get_rate);
441
408static unsigned long __clk_get_accuracy(struct clk_core *core) 442static unsigned long __clk_get_accuracy(struct clk_core *core)
409{ 443{
410 if (!core) 444 if (!core)
@@ -419,6 +453,12 @@ unsigned long __clk_get_flags(struct clk *clk)
419} 453}
420EXPORT_SYMBOL_GPL(__clk_get_flags); 454EXPORT_SYMBOL_GPL(__clk_get_flags);
421 455
456unsigned long clk_hw_get_flags(struct clk_hw *hw)
457{
458 return hw->core->flags;
459}
460EXPORT_SYMBOL_GPL(clk_hw_get_flags);
461
422bool __clk_is_prepared(struct clk *clk) 462bool __clk_is_prepared(struct clk *clk)
423{ 463{
424 if (!clk) 464 if (!clk)
@@ -427,6 +467,11 @@ bool __clk_is_prepared(struct clk *clk)
427 return clk_core_is_prepared(clk->core); 467 return clk_core_is_prepared(clk->core);
428} 468}
429 469
470bool clk_hw_is_prepared(struct clk_hw *hw)
471{
472 return clk_core_is_prepared(hw->core);
473}
474
430bool __clk_is_enabled(struct clk *clk) 475bool __clk_is_enabled(struct clk *clk)
431{ 476{
432 if (!clk) 477 if (!clk)
@@ -861,6 +906,22 @@ unsigned long __clk_round_rate(struct clk *clk, unsigned long rate)
861} 906}
862EXPORT_SYMBOL_GPL(__clk_round_rate); 907EXPORT_SYMBOL_GPL(__clk_round_rate);
863 908
909unsigned long clk_hw_round_rate(struct clk_hw *hw, unsigned long rate)
910{
911 int ret;
912 struct clk_rate_request req;
913
914 clk_core_get_boundaries(hw->core, &req.min_rate, &req.max_rate);
915 req.rate = rate;
916
917 ret = clk_core_round_rate_nolock(hw->core, &req);
918 if (ret)
919 return 0;
920
921 return req.rate;
922}
923EXPORT_SYMBOL_GPL(clk_hw_round_rate);
924
864/** 925/**
865 * clk_round_rate - round the given rate for a clk 926 * clk_round_rate - round the given rate for a clk
866 * @clk: the clk for which we are rounding a rate 927 * @clk: the clk for which we are rounding a rate