Commit 4ad69b80 authored by Jerome Brunet's avatar Jerome Brunet Committed by Stephen Boyd

clk: honor CLK_MUX_ROUND_CLOSEST in generic clk mux

CLK_MUX_ROUND_CLOSEST is part of the clk_mux documentation but clk_mux
directly calls __clk_mux_determine_rate(), which overrides the flag.
As result, if clk_mux is instantiated with CLK_MUX_ROUND_CLOSEST, the
flag will be ignored and the clock rounded down.

To solve this, this patch expose clk_mux_determine_rate_flags() in the
clk-provider API and uses it in the determine_rate() callback of clk_mux.

Fixes: 15a02c1f ("clk: Add __clk_mux_determine_rate_closest")
Signed-off-by: default avatarJerome Brunet <jbrunet@baylibre.com>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent a21b8594
...@@ -112,10 +112,18 @@ static int clk_mux_set_parent(struct clk_hw *hw, u8 index) ...@@ -112,10 +112,18 @@ static int clk_mux_set_parent(struct clk_hw *hw, u8 index)
return 0; return 0;
} }
static int clk_mux_determine_rate(struct clk_hw *hw,
struct clk_rate_request *req)
{
struct clk_mux *mux = to_clk_mux(hw);
return clk_mux_determine_rate_flags(hw, req, mux->flags);
}
const struct clk_ops clk_mux_ops = { const struct clk_ops clk_mux_ops = {
.get_parent = clk_mux_get_parent, .get_parent = clk_mux_get_parent,
.set_parent = clk_mux_set_parent, .set_parent = clk_mux_set_parent,
.determine_rate = __clk_mux_determine_rate, .determine_rate = clk_mux_determine_rate,
}; };
EXPORT_SYMBOL_GPL(clk_mux_ops); EXPORT_SYMBOL_GPL(clk_mux_ops);
......
...@@ -426,9 +426,9 @@ static bool mux_is_better_rate(unsigned long rate, unsigned long now, ...@@ -426,9 +426,9 @@ static bool mux_is_better_rate(unsigned long rate, unsigned long now,
return now <= rate && now > best; return now <= rate && now > best;
} }
static int int clk_mux_determine_rate_flags(struct clk_hw *hw,
clk_mux_determine_rate_flags(struct clk_hw *hw, struct clk_rate_request *req, struct clk_rate_request *req,
unsigned long flags) unsigned long flags)
{ {
struct clk_core *core = hw->core, *parent, *best_parent = NULL; struct clk_core *core = hw->core, *parent, *best_parent = NULL;
int i, num_parents, ret; int i, num_parents, ret;
...@@ -488,6 +488,7 @@ clk_mux_determine_rate_flags(struct clk_hw *hw, struct clk_rate_request *req, ...@@ -488,6 +488,7 @@ clk_mux_determine_rate_flags(struct clk_hw *hw, struct clk_rate_request *req,
return 0; return 0;
} }
EXPORT_SYMBOL_GPL(clk_mux_determine_rate_flags);
struct clk *__clk_lookup(const char *name) struct clk *__clk_lookup(const char *name)
{ {
......
...@@ -765,6 +765,9 @@ int __clk_mux_determine_rate(struct clk_hw *hw, ...@@ -765,6 +765,9 @@ int __clk_mux_determine_rate(struct clk_hw *hw,
int __clk_determine_rate(struct clk_hw *core, struct clk_rate_request *req); int __clk_determine_rate(struct clk_hw *core, struct clk_rate_request *req);
int __clk_mux_determine_rate_closest(struct clk_hw *hw, int __clk_mux_determine_rate_closest(struct clk_hw *hw,
struct clk_rate_request *req); struct clk_rate_request *req);
int clk_mux_determine_rate_flags(struct clk_hw *hw,
struct clk_rate_request *req,
unsigned long flags);
void clk_hw_reparent(struct clk_hw *hw, struct clk_hw *new_parent); void clk_hw_reparent(struct clk_hw *hw, struct clk_hw *new_parent);
void clk_hw_set_rate_range(struct clk_hw *hw, unsigned long min_rate, void clk_hw_set_rate_range(struct clk_hw *hw, unsigned long min_rate,
unsigned long max_rate); unsigned long max_rate);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment