Skip to content

Commit 33958ad

Browse files
Ansuelandersson
authored andcommitted
clk: qcom: clk-rcg: add clk_rcg_floor_ops ops
Add clk_rcg_floor_ops for clock that can't provide a stable freq and require to use a floor freq to provide the requested frequency. Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Reviewed-by: Stephen Boyd <sboyd@kernel.org> Tested-by: Jonathan McDowell <noodles@earth.li> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Link: https://lore.kernel.org/r/20220226135235.10051-10-ansuelsmth@gmail.com
1 parent 28aa450 commit 33958ad

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

drivers/clk/qcom/clk-rcg.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,19 @@ static int clk_rcg_set_rate(struct clk_hw *hw, unsigned long rate,
526526
return __clk_rcg_set_rate(rcg, f);
527527
}
528528

529+
static int clk_rcg_set_floor_rate(struct clk_hw *hw, unsigned long rate,
530+
unsigned long parent_rate)
531+
{
532+
struct clk_rcg *rcg = to_clk_rcg(hw);
533+
const struct freq_tbl *f;
534+
535+
f = qcom_find_freq_floor(rcg->freq_tbl, rate);
536+
if (!f)
537+
return -EINVAL;
538+
539+
return __clk_rcg_set_rate(rcg, f);
540+
}
541+
529542
static int clk_rcg_bypass_set_rate(struct clk_hw *hw, unsigned long rate,
530543
unsigned long parent_rate)
531544
{
@@ -816,6 +829,17 @@ const struct clk_ops clk_rcg_ops = {
816829
};
817830
EXPORT_SYMBOL_GPL(clk_rcg_ops);
818831

832+
const struct clk_ops clk_rcg_floor_ops = {
833+
.enable = clk_enable_regmap,
834+
.disable = clk_disable_regmap,
835+
.get_parent = clk_rcg_get_parent,
836+
.set_parent = clk_rcg_set_parent,
837+
.recalc_rate = clk_rcg_recalc_rate,
838+
.determine_rate = clk_rcg_determine_rate,
839+
.set_rate = clk_rcg_set_floor_rate,
840+
};
841+
EXPORT_SYMBOL_GPL(clk_rcg_floor_ops);
842+
819843
const struct clk_ops clk_rcg_bypass_ops = {
820844
.enable = clk_enable_regmap,
821845
.disable = clk_disable_regmap,

drivers/clk/qcom/clk-rcg.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct clk_rcg {
8686
};
8787

8888
extern const struct clk_ops clk_rcg_ops;
89+
extern const struct clk_ops clk_rcg_floor_ops;
8990
extern const struct clk_ops clk_rcg_bypass_ops;
9091
extern const struct clk_ops clk_rcg_bypass2_ops;
9192
extern const struct clk_ops clk_rcg_pixel_ops;

0 commit comments

Comments
 (0)