Skip to content

Commit 4d78bd8

Browse files
mripardbebarino
authored andcommitted
clk: tegra: periph: Switch to determine_rate
The Tegra periph clocks implements a mux with a set_parent hook, but doesn't provide a determine_rate implementation. This is a bit odd, since set_parent() is there to, as its name implies, change the parent of a clock. However, the most likely candidate to trigger that parent change is a call to clk_set_rate(), with determine_rate() figuring out which parent is the best suited for a given rate. The other trigger would be a call to clk_set_parent(), but it's far less used, and it doesn't look like there's any obvious user for that clock. So, the set_parent hook is effectively unused, possibly because of an oversight. However, it could also be an explicit decision by the original author to avoid any reparenting but through an explicit call to clk_set_parent(). The driver does implement round_rate() though, which means that we can change the rate of the clock, but we will never get to change the parent. However, It's hard to tell whether it's been done on purpose or not. Since we'll start mandating a determine_rate() implementation, let's convert the round_rate() implementation to a determine_rate(), which will also make the current behavior explicit. And if it was an oversight, the clock behaviour can be adjusted later on. Cc: Jonathan Hunter <[email protected]> Cc: Peter De Schrijver <[email protected]> Cc: Prashant Gaikwad <[email protected]> Cc: Thierry Reding <[email protected]> Cc: [email protected] Signed-off-by: Maxime Ripard <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Stephen Boyd <[email protected]>
1 parent 06ed0fc commit 4d78bd8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

drivers/clk/tegra/clk-periph.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,22 @@ static unsigned long clk_periph_recalc_rate(struct clk_hw *hw,
4545
return div_ops->recalc_rate(div_hw, parent_rate);
4646
}
4747

48-
static long clk_periph_round_rate(struct clk_hw *hw, unsigned long rate,
49-
unsigned long *prate)
48+
static int clk_periph_determine_rate(struct clk_hw *hw,
49+
struct clk_rate_request *req)
5050
{
5151
struct tegra_clk_periph *periph = to_clk_periph(hw);
5252
const struct clk_ops *div_ops = periph->div_ops;
5353
struct clk_hw *div_hw = &periph->divider.hw;
54+
unsigned long rate;
5455

5556
__clk_hw_set_clk(div_hw, hw);
5657

57-
return div_ops->round_rate(div_hw, rate, prate);
58+
rate = div_ops->round_rate(div_hw, req->rate, &req->best_parent_rate);
59+
if (rate < 0)
60+
return rate;
61+
62+
req->rate = rate;
63+
return 0;
5864
}
5965

6066
static int clk_periph_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -130,7 +136,7 @@ const struct clk_ops tegra_clk_periph_ops = {
130136
.get_parent = clk_periph_get_parent,
131137
.set_parent = clk_periph_set_parent,
132138
.recalc_rate = clk_periph_recalc_rate,
133-
.round_rate = clk_periph_round_rate,
139+
.determine_rate = clk_periph_determine_rate,
134140
.set_rate = clk_periph_set_rate,
135141
.is_enabled = clk_periph_is_enabled,
136142
.enable = clk_periph_enable,
@@ -154,7 +160,7 @@ static const struct clk_ops tegra_clk_periph_no_gate_ops = {
154160
.get_parent = clk_periph_get_parent,
155161
.set_parent = clk_periph_set_parent,
156162
.recalc_rate = clk_periph_recalc_rate,
157-
.round_rate = clk_periph_round_rate,
163+
.determine_rate = clk_periph_determine_rate,
158164
.set_rate = clk_periph_set_rate,
159165
.restore_context = clk_periph_restore_context,
160166
};

0 commit comments

Comments
 (0)