Skip to content

Commit 2539932

Browse files
mripardbebarino
authored andcommitted
clk: Introduce the clk_hw_get_rate_range function
Some clock providers are hand-crafting their clk_rate_request, and need to figure out the current boundaries of their clk_hw to fill it properly. Let's create such a function for clock providers. Signed-off-by: Maxime Ripard <maxime@cerno.tech> Link: https://lore.kernel.org/r/20220816112530.1837489-24-maxime@cerno.tech Tested-by: Linux Kernel Functional Testing <lkft@linaro.org> Tested-by: Naresh Kamboju <naresh.kamboju@linaro.org> Signed-off-by: Stephen Boyd <sboyd@kernel.org>
1 parent b46fd8d commit 2539932

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

drivers/clk/clk.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,22 @@ static void clk_core_get_boundaries(struct clk_core *core,
684684
*max_rate = min(*max_rate, clk_user->max_rate);
685685
}
686686

687+
/*
688+
* clk_hw_get_rate_range() - returns the clock rate range for a hw clk
689+
* @hw: the hw clk we want to get the range from
690+
* @min_rate: pointer to the variable that will hold the minimum
691+
* @max_rate: pointer to the variable that will hold the maximum
692+
*
693+
* Fills the @min_rate and @max_rate variables with the minimum and
694+
* maximum that clock can reach.
695+
*/
696+
void clk_hw_get_rate_range(struct clk_hw *hw, unsigned long *min_rate,
697+
unsigned long *max_rate)
698+
{
699+
clk_core_get_boundaries(hw->core, min_rate, max_rate);
700+
}
701+
EXPORT_SYMBOL_GPL(clk_hw_get_rate_range);
702+
687703
static bool clk_core_check_boundaries(struct clk_core *core,
688704
unsigned long min_rate,
689705
unsigned long max_rate)

include/linux/clk-provider.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,6 +1267,8 @@ int clk_mux_determine_rate_flags(struct clk_hw *hw,
12671267
struct clk_rate_request *req,
12681268
unsigned long flags);
12691269
void clk_hw_reparent(struct clk_hw *hw, struct clk_hw *new_parent);
1270+
void clk_hw_get_rate_range(struct clk_hw *hw, unsigned long *min_rate,
1271+
unsigned long *max_rate);
12701272
void clk_hw_set_rate_range(struct clk_hw *hw, unsigned long min_rate,
12711273
unsigned long max_rate);
12721274

0 commit comments

Comments
 (0)