diff options
Diffstat (limited to 'drivers/clk/clk.c')
-rw-r--r-- | drivers/clk/clk.c | 57 |
1 files changed, 38 insertions, 19 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index efdfd009c270..56e4495ebeb1 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c | |||
@@ -558,25 +558,6 @@ int clk_enable(struct clk *clk) | |||
558 | EXPORT_SYMBOL_GPL(clk_enable); | 558 | EXPORT_SYMBOL_GPL(clk_enable); |
559 | 559 | ||
560 | /** | 560 | /** |
561 | * clk_get_rate - return the rate of clk | ||
562 | * @clk: the clk whose rate is being returned | ||
563 | * | ||
564 | * Simply returns the cached rate of the clk. Does not query the hardware. If | ||
565 | * clk is NULL then returns 0. | ||
566 | */ | ||
567 | unsigned long clk_get_rate(struct clk *clk) | ||
568 | { | ||
569 | unsigned long rate; | ||
570 | |||
571 | mutex_lock(&prepare_lock); | ||
572 | rate = __clk_get_rate(clk); | ||
573 | mutex_unlock(&prepare_lock); | ||
574 | |||
575 | return rate; | ||
576 | } | ||
577 | EXPORT_SYMBOL_GPL(clk_get_rate); | ||
578 | |||
579 | /** | ||
580 | * __clk_round_rate - round the given rate for a clk | 561 | * __clk_round_rate - round the given rate for a clk |
581 | * @clk: round the rate of this clock | 562 | * @clk: round the rate of this clock |
582 | * | 563 | * |
@@ -702,6 +683,30 @@ static void __clk_recalc_rates(struct clk *clk, unsigned long msg) | |||
702 | } | 683 | } |
703 | 684 | ||
704 | /** | 685 | /** |
686 | * clk_get_rate - return the rate of clk | ||
687 | * @clk: the clk whose rate is being returned | ||
688 | * | ||
689 | * Simply returns the cached rate of the clk, unless CLK_GET_RATE_NOCACHE flag | ||
690 | * is set, which means a recalc_rate will be issued. | ||
691 | * If clk is NULL then returns 0. | ||
692 | */ | ||
693 | unsigned long clk_get_rate(struct clk *clk) | ||
694 | { | ||
695 | unsigned long rate; | ||
696 | |||
697 | mutex_lock(&prepare_lock); | ||
698 | |||
699 | if (clk && (clk->flags & CLK_GET_RATE_NOCACHE)) | ||
700 | __clk_recalc_rates(clk, 0); | ||
701 | |||
702 | rate = __clk_get_rate(clk); | ||
703 | mutex_unlock(&prepare_lock); | ||
704 | |||
705 | return rate; | ||
706 | } | ||
707 | EXPORT_SYMBOL_GPL(clk_get_rate); | ||
708 | |||
709 | /** | ||
705 | * __clk_speculate_rates | 710 | * __clk_speculate_rates |
706 | * @clk: first clk in the subtree | 711 | * @clk: first clk in the subtree |
707 | * @parent_rate: the "future" rate of clk's parent | 712 | * @parent_rate: the "future" rate of clk's parent |
@@ -1582,6 +1587,20 @@ struct clk *of_clk_src_simple_get(struct of_phandle_args *clkspec, | |||
1582 | } | 1587 | } |
1583 | EXPORT_SYMBOL_GPL(of_clk_src_simple_get); | 1588 | EXPORT_SYMBOL_GPL(of_clk_src_simple_get); |
1584 | 1589 | ||
1590 | struct clk *of_clk_src_onecell_get(struct of_phandle_args *clkspec, void *data) | ||
1591 | { | ||
1592 | struct clk_onecell_data *clk_data = data; | ||
1593 | unsigned int idx = clkspec->args[0]; | ||
1594 | |||
1595 | if (idx >= clk_data->clk_num) { | ||
1596 | pr_err("%s: invalid clock index %d\n", __func__, idx); | ||
1597 | return ERR_PTR(-EINVAL); | ||
1598 | } | ||
1599 | |||
1600 | return clk_data->clks[idx]; | ||
1601 | } | ||
1602 | EXPORT_SYMBOL_GPL(of_clk_src_onecell_get); | ||
1603 | |||
1585 | /** | 1604 | /** |
1586 | * of_clk_add_provider() - Register a clock provider for a node | 1605 | * of_clk_add_provider() - Register a clock provider for a node |
1587 | * @np: Device node pointer associated with clock provider | 1606 | * @np: Device node pointer associated with clock provider |