diff options
author | Stephen Boyd <sboyd@codeaurora.org> | 2015-07-28 14:51:30 -0400 |
---|---|---|
committer | Stephen Boyd <sboyd@codeaurora.org> | 2015-07-28 14:51:30 -0400 |
commit | 19aab273083fa10c2262b8c8e3315bacb054d75d (patch) | |
tree | 65097982915b51acdf8d5576d63153085b779ceb /drivers/clk/bcm | |
parent | 86665d2897209429a7e4a003764b9fc5034dbfa1 (diff) | |
parent | 57d866e606ddf2a0cd51f7140cfd8df1fdaa48f6 (diff) |
Merge branch 'clk-determine-rate-struct' into clk-next
* clk-determine-rate-struct:
clk: fix some determine_rate implementations
clk: change clk_ops' ->determine_rate() prototype
Diffstat (limited to 'drivers/clk/bcm')
-rw-r--r-- | drivers/clk/bcm/clk-kona.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/drivers/clk/bcm/clk-kona.c b/drivers/clk/bcm/clk-kona.c index 79a98506c433..d9c039c1902c 100644 --- a/drivers/clk/bcm/clk-kona.c +++ b/drivers/clk/bcm/clk-kona.c | |||
@@ -1017,10 +1017,8 @@ static long kona_peri_clk_round_rate(struct clk_hw *hw, unsigned long rate, | |||
1017 | rate ? rate : 1, *parent_rate, NULL); | 1017 | rate ? rate : 1, *parent_rate, NULL); |
1018 | } | 1018 | } |
1019 | 1019 | ||
1020 | static long kona_peri_clk_determine_rate(struct clk_hw *hw, unsigned long rate, | 1020 | static int kona_peri_clk_determine_rate(struct clk_hw *hw, |
1021 | unsigned long min_rate, | 1021 | struct clk_rate_request *req) |
1022 | unsigned long max_rate, | ||
1023 | unsigned long *best_parent_rate, struct clk_hw **best_parent) | ||
1024 | { | 1022 | { |
1025 | struct kona_clk *bcm_clk = to_kona_clk(hw); | 1023 | struct kona_clk *bcm_clk = to_kona_clk(hw); |
1026 | struct clk *clk = hw->clk; | 1024 | struct clk *clk = hw->clk; |
@@ -1029,6 +1027,7 @@ static long kona_peri_clk_determine_rate(struct clk_hw *hw, unsigned long rate, | |||
1029 | unsigned long best_delta; | 1027 | unsigned long best_delta; |
1030 | unsigned long best_rate; | 1028 | unsigned long best_rate; |
1031 | u32 parent_count; | 1029 | u32 parent_count; |
1030 | long rate; | ||
1032 | u32 which; | 1031 | u32 which; |
1033 | 1032 | ||
1034 | /* | 1033 | /* |
@@ -1037,14 +1036,21 @@ static long kona_peri_clk_determine_rate(struct clk_hw *hw, unsigned long rate, | |||
1037 | */ | 1036 | */ |
1038 | WARN_ON_ONCE(bcm_clk->init_data.flags & CLK_SET_RATE_NO_REPARENT); | 1037 | WARN_ON_ONCE(bcm_clk->init_data.flags & CLK_SET_RATE_NO_REPARENT); |
1039 | parent_count = (u32)bcm_clk->init_data.num_parents; | 1038 | parent_count = (u32)bcm_clk->init_data.num_parents; |
1040 | if (parent_count < 2) | 1039 | if (parent_count < 2) { |
1041 | return kona_peri_clk_round_rate(hw, rate, best_parent_rate); | 1040 | rate = kona_peri_clk_round_rate(hw, req->rate, |
1041 | &req->best_parent_rate); | ||
1042 | if (rate < 0) | ||
1043 | return rate; | ||
1044 | |||
1045 | req->rate = rate; | ||
1046 | return 0; | ||
1047 | } | ||
1042 | 1048 | ||
1043 | /* Unless we can do better, stick with current parent */ | 1049 | /* Unless we can do better, stick with current parent */ |
1044 | current_parent = clk_get_parent(clk); | 1050 | current_parent = clk_get_parent(clk); |
1045 | parent_rate = __clk_get_rate(current_parent); | 1051 | parent_rate = __clk_get_rate(current_parent); |
1046 | best_rate = kona_peri_clk_round_rate(hw, rate, &parent_rate); | 1052 | best_rate = kona_peri_clk_round_rate(hw, req->rate, &parent_rate); |
1047 | best_delta = abs(best_rate - rate); | 1053 | best_delta = abs(best_rate - req->rate); |
1048 | 1054 | ||
1049 | /* Check whether any other parent clock can produce a better result */ | 1055 | /* Check whether any other parent clock can produce a better result */ |
1050 | for (which = 0; which < parent_count; which++) { | 1056 | for (which = 0; which < parent_count; which++) { |
@@ -1058,17 +1064,19 @@ static long kona_peri_clk_determine_rate(struct clk_hw *hw, unsigned long rate, | |||
1058 | 1064 | ||
1059 | /* We don't support CLK_SET_RATE_PARENT */ | 1065 | /* We don't support CLK_SET_RATE_PARENT */ |
1060 | parent_rate = __clk_get_rate(parent); | 1066 | parent_rate = __clk_get_rate(parent); |
1061 | other_rate = kona_peri_clk_round_rate(hw, rate, &parent_rate); | 1067 | other_rate = kona_peri_clk_round_rate(hw, req->rate, |
1062 | delta = abs(other_rate - rate); | 1068 | &parent_rate); |
1069 | delta = abs(other_rate - req->rate); | ||
1063 | if (delta < best_delta) { | 1070 | if (delta < best_delta) { |
1064 | best_delta = delta; | 1071 | best_delta = delta; |
1065 | best_rate = other_rate; | 1072 | best_rate = other_rate; |
1066 | *best_parent = __clk_get_hw(parent); | 1073 | req->best_parent_hw = __clk_get_hw(parent); |
1067 | *best_parent_rate = parent_rate; | 1074 | req->best_parent_rate = parent_rate; |
1068 | } | 1075 | } |
1069 | } | 1076 | } |
1070 | 1077 | ||
1071 | return best_rate; | 1078 | req->rate = best_rate; |
1079 | return 0; | ||
1072 | } | 1080 | } |
1073 | 1081 | ||
1074 | static int kona_peri_clk_set_parent(struct clk_hw *hw, u8 index) | 1082 | static int kona_peri_clk_set_parent(struct clk_hw *hw, u8 index) |