Skip to content

Commit 1c8e600

Browse files
tomeuvMichael Turquette
authored andcommitted
clk: Add rate constraints to clocks
Adds a way for clock consumers to set maximum and minimum rates. This can be used for thermal drivers to set minimum rates, or by misc. drivers to set maximum rates to assure a minimum performance level. Changes the signature of the determine_rate callback by adding the parameters min_rate and max_rate. Signed-off-by: Tomeu Vizoso <[email protected]> Signed-off-by: Stephen Boyd <[email protected]> [[email protected]: set req_rate in __clk_init] Signed-off-by: Michael Turquette <[email protected]> [[email protected]: min/max rate for sun6i_ahb1_clk_determine_rate migrated clk-private.h changes to clk.c]
1 parent b09d6d9 commit 1c8e600

File tree

19 files changed

+314
-61
lines changed

19 files changed

+314
-61
lines changed

Documentation/clk.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ the operations defined in clk.h:
7373
unsigned long *parent_rate);
7474
long (*determine_rate)(struct clk_hw *hw,
7575
unsigned long rate,
76+
unsigned long min_rate,
77+
unsigned long max_rate,
7678
unsigned long *best_parent_rate,
7779
struct clk_hw **best_parent_clk);
7880
int (*set_parent)(struct clk_hw *hw, u8 index);

arch/arm/mach-omap2/dpll3xxx.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,8 @@ void omap3_noncore_dpll_disable(struct clk_hw *hw)
473473
* in failure.
474474
*/
475475
long omap3_noncore_dpll_determine_rate(struct clk_hw *hw, unsigned long rate,
476+
unsigned long min_rate,
477+
unsigned long max_rate,
476478
unsigned long *best_parent_rate,
477479
struct clk_hw **best_parent_clk)
478480
{

arch/arm/mach-omap2/dpll44xx.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ long omap4_dpll_regm4xen_round_rate(struct clk_hw *hw,
222222
* in failure.
223223
*/
224224
long omap4_dpll_regm4xen_determine_rate(struct clk_hw *hw, unsigned long rate,
225+
unsigned long min_rate,
226+
unsigned long max_rate,
225227
unsigned long *best_parent_rate,
226228
struct clk_hw **best_parent_clk)
227229
{

arch/mips/alchemy/common/clock.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ static long alchemy_calc_div(unsigned long rate, unsigned long prate,
373373
}
374374

375375
static long alchemy_clk_fgcs_detr(struct clk_hw *hw, unsigned long rate,
376+
unsigned long min_rate,
377+
unsigned long max_rate,
376378
unsigned long *best_parent_rate,
377379
struct clk_hw **best_parent_clk,
378380
int scale, int maxdiv)
@@ -546,6 +548,8 @@ static unsigned long alchemy_clk_fgv1_recalc(struct clk_hw *hw,
546548
}
547549

548550
static long alchemy_clk_fgv1_detr(struct clk_hw *hw, unsigned long rate,
551+
unsigned long min_rate,
552+
unsigned long max_rate,
549553
unsigned long *best_parent_rate,
550554
struct clk_hw **best_parent_clk)
551555
{
@@ -678,6 +682,8 @@ static unsigned long alchemy_clk_fgv2_recalc(struct clk_hw *hw,
678682
}
679683

680684
static long alchemy_clk_fgv2_detr(struct clk_hw *hw, unsigned long rate,
685+
unsigned long min_rate,
686+
unsigned long max_rate,
681687
unsigned long *best_parent_rate,
682688
struct clk_hw **best_parent_clk)
683689
{
@@ -897,6 +903,8 @@ static int alchemy_clk_csrc_setr(struct clk_hw *hw, unsigned long rate,
897903
}
898904

899905
static long alchemy_clk_csrc_detr(struct clk_hw *hw, unsigned long rate,
906+
unsigned long min_rate,
907+
unsigned long max_rate,
900908
unsigned long *best_parent_rate,
901909
struct clk_hw **best_parent_clk)
902910
{

drivers/clk/at91/clk-programmable.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ static unsigned long clk_programmable_recalc_rate(struct clk_hw *hw,
5656

5757
static long clk_programmable_determine_rate(struct clk_hw *hw,
5858
unsigned long rate,
59+
unsigned long min_rate,
60+
unsigned long max_rate,
5961
unsigned long *best_parent_rate,
6062
struct clk_hw **best_parent_hw)
6163
{

drivers/clk/bcm/clk-kona.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,8 @@ static long kona_peri_clk_round_rate(struct clk_hw *hw, unsigned long rate,
10321032
}
10331033

10341034
static long kona_peri_clk_determine_rate(struct clk_hw *hw, unsigned long rate,
1035+
unsigned long min_rate,
1036+
unsigned long max_rate,
10351037
unsigned long *best_parent_rate, struct clk_hw **best_parent)
10361038
{
10371039
struct kona_clk *bcm_clk = to_kona_clk(hw);

drivers/clk/clk-composite.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ static unsigned long clk_composite_recalc_rate(struct clk_hw *hw,
5656
}
5757

5858
static long clk_composite_determine_rate(struct clk_hw *hw, unsigned long rate,
59+
unsigned long min_rate,
60+
unsigned long max_rate,
5961
unsigned long *best_parent_rate,
6062
struct clk_hw **best_parent_p)
6163
{
@@ -73,7 +75,9 @@ static long clk_composite_determine_rate(struct clk_hw *hw, unsigned long rate,
7375

7476
if (rate_hw && rate_ops && rate_ops->determine_rate) {
7577
rate_hw->clk = hw->clk;
76-
return rate_ops->determine_rate(rate_hw, rate, best_parent_rate,
78+
return rate_ops->determine_rate(rate_hw, rate, min_rate,
79+
max_rate,
80+
best_parent_rate,
7781
best_parent_p);
7882
} else if (rate_hw && rate_ops && rate_ops->round_rate &&
7983
mux_hw && mux_ops && mux_ops->set_parent) {
@@ -117,7 +121,8 @@ static long clk_composite_determine_rate(struct clk_hw *hw, unsigned long rate,
117121
return best_rate;
118122
} else if (mux_hw && mux_ops && mux_ops->determine_rate) {
119123
mux_hw->clk = hw->clk;
120-
return mux_ops->determine_rate(mux_hw, rate, best_parent_rate,
124+
return mux_ops->determine_rate(mux_hw, rate, min_rate,
125+
max_rate, best_parent_rate,
121126
best_parent_p);
122127
} else {
123128
pr_err("clk: clk_composite_determine_rate function called, but no mux or rate callback set!\n");

0 commit comments

Comments
 (0)