Skip to content

Commit 80cb2b6

Browse files
committed
clk: scmi: migrate round_rate() to determine_rate()
This driver implements both the determine_rate() and round_rate() clk ops, and the round_rate() clk ops is deprecated. When both are defined, clk_core_determine_round_nolock() from the clk core will only use the determine_rate() clk ops. The existing scmi_clk_determine_rate() is a noop implementation that lets the firmware round the rate as appropriate. Drop the existing determine_rate implementation and convert the existing round_rate() implementation over to determine_rate(). scmi_clk_determine_rate() was added recently when the clock parent support was added, so it's not expected that this change will regress anything. Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> Reviewed-by: Peng Fan <peng.fan@nxp.com> Tested-by: Peng Fan <peng.fan@nxp.com> #i.MX95-19x19-EVK Signed-off-by: Brian Masney <bmasney@redhat.com>
1 parent d8a9774 commit 80cb2b6

1 file changed

Lines changed: 16 additions & 19 deletions

File tree

drivers/clk/clk-scmi.c

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ static unsigned long scmi_clk_recalc_rate(struct clk_hw *hw,
5454
return rate;
5555
}
5656

57-
static long scmi_clk_round_rate(struct clk_hw *hw, unsigned long rate,
58-
unsigned long *parent_rate)
57+
static int scmi_clk_determine_rate(struct clk_hw *hw,
58+
struct clk_rate_request *req)
5959
{
6060
u64 fmin, fmax, ftmp;
6161
struct scmi_clk *clk = to_scmi_clk(hw);
@@ -67,20 +67,27 @@ static long scmi_clk_round_rate(struct clk_hw *hw, unsigned long rate,
6767
* running at then.
6868
*/
6969
if (clk->info->rate_discrete)
70-
return rate;
70+
return 0;
7171

7272
fmin = clk->info->range.min_rate;
7373
fmax = clk->info->range.max_rate;
74-
if (rate <= fmin)
75-
return fmin;
76-
else if (rate >= fmax)
77-
return fmax;
74+
if (req->rate <= fmin) {
75+
req->rate = fmin;
76+
77+
return 0;
78+
} else if (req->rate >= fmax) {
79+
req->rate = fmax;
7880

79-
ftmp = rate - fmin;
81+
return 0;
82+
}
83+
84+
ftmp = req->rate - fmin;
8085
ftmp += clk->info->range.step_size - 1; /* to round up */
8186
do_div(ftmp, clk->info->range.step_size);
8287

83-
return ftmp * clk->info->range.step_size + fmin;
88+
req->rate = ftmp * clk->info->range.step_size + fmin;
89+
90+
return 0;
8491
}
8592

8693
static int scmi_clk_set_rate(struct clk_hw *hw, unsigned long rate,
@@ -119,15 +126,6 @@ static u8 scmi_clk_get_parent(struct clk_hw *hw)
119126
return p_idx;
120127
}
121128

122-
static int scmi_clk_determine_rate(struct clk_hw *hw, struct clk_rate_request *req)
123-
{
124-
/*
125-
* Suppose all the requested rates are supported, and let firmware
126-
* to handle the left work.
127-
*/
128-
return 0;
129-
}
130-
131129
static int scmi_clk_enable(struct clk_hw *hw)
132130
{
133131
struct scmi_clk *clk = to_scmi_clk(hw);
@@ -300,7 +298,6 @@ scmi_clk_ops_alloc(struct device *dev, unsigned long feats_key)
300298

301299
/* Rate ops */
302300
ops->recalc_rate = scmi_clk_recalc_rate;
303-
ops->round_rate = scmi_clk_round_rate;
304301
ops->determine_rate = scmi_clk_determine_rate;
305302
if (feats_key & BIT(SCMI_CLK_RATE_CTRL_SUPPORTED))
306303
ops->set_rate = scmi_clk_set_rate;

0 commit comments

Comments
 (0)