diff options
author | Boris Brezillon <boris.brezillon@free-electrons.com> | 2015-05-28 08:01:08 -0400 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@free-electrons.com> | 2015-06-19 08:43:40 -0400 |
commit | 86e4404af2a812935f6c71e7a33e4d0c3aab6538 (patch) | |
tree | 50de87bbacd3665c6bfcc5c3a59f3b6ac63923c4 /drivers/clk | |
parent | 6c7b03e1aef2e92176435f4fa562cc483422d20f (diff) |
clk: at91: fix PERIPHERAL_MAX_SHIFT definition
Fix the PERIPHERAL_MAX_SHIFT definition (3 instead of 4) and adapt the
round_rate and set_rate logic accordingly.
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Reported-by: "Wu, Songjun" <Songjun.Wu@atmel.com>
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/at91/clk-peripheral.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/clk/at91/clk-peripheral.c b/drivers/clk/at91/clk-peripheral.c index 597fed423d7d..df2c1afa52b4 100644 --- a/drivers/clk/at91/clk-peripheral.c +++ b/drivers/clk/at91/clk-peripheral.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #define PERIPHERAL_RSHIFT_MASK 0x3 | 29 | #define PERIPHERAL_RSHIFT_MASK 0x3 |
30 | #define PERIPHERAL_RSHIFT(val) (((val) >> 16) & PERIPHERAL_RSHIFT_MASK) | 30 | #define PERIPHERAL_RSHIFT(val) (((val) >> 16) & PERIPHERAL_RSHIFT_MASK) |
31 | 31 | ||
32 | #define PERIPHERAL_MAX_SHIFT 4 | 32 | #define PERIPHERAL_MAX_SHIFT 3 |
33 | 33 | ||
34 | struct clk_peripheral { | 34 | struct clk_peripheral { |
35 | struct clk_hw hw; | 35 | struct clk_hw hw; |
@@ -242,7 +242,7 @@ static long clk_sam9x5_peripheral_round_rate(struct clk_hw *hw, | |||
242 | return *parent_rate; | 242 | return *parent_rate; |
243 | 243 | ||
244 | if (periph->range.max) { | 244 | if (periph->range.max) { |
245 | for (; shift < PERIPHERAL_MAX_SHIFT; shift++) { | 245 | for (; shift <= PERIPHERAL_MAX_SHIFT; shift++) { |
246 | cur_rate = *parent_rate >> shift; | 246 | cur_rate = *parent_rate >> shift; |
247 | if (cur_rate <= periph->range.max) | 247 | if (cur_rate <= periph->range.max) |
248 | break; | 248 | break; |
@@ -254,7 +254,7 @@ static long clk_sam9x5_peripheral_round_rate(struct clk_hw *hw, | |||
254 | 254 | ||
255 | best_diff = cur_rate - rate; | 255 | best_diff = cur_rate - rate; |
256 | best_rate = cur_rate; | 256 | best_rate = cur_rate; |
257 | for (; shift < PERIPHERAL_MAX_SHIFT; shift++) { | 257 | for (; shift <= PERIPHERAL_MAX_SHIFT; shift++) { |
258 | cur_rate = *parent_rate >> shift; | 258 | cur_rate = *parent_rate >> shift; |
259 | if (cur_rate < rate) | 259 | if (cur_rate < rate) |
260 | cur_diff = rate - cur_rate; | 260 | cur_diff = rate - cur_rate; |
@@ -289,7 +289,7 @@ static int clk_sam9x5_peripheral_set_rate(struct clk_hw *hw, | |||
289 | if (periph->range.max && rate > periph->range.max) | 289 | if (periph->range.max && rate > periph->range.max) |
290 | return -EINVAL; | 290 | return -EINVAL; |
291 | 291 | ||
292 | for (shift = 0; shift < PERIPHERAL_MAX_SHIFT; shift++) { | 292 | for (shift = 0; shift <= PERIPHERAL_MAX_SHIFT; shift++) { |
293 | if (parent_rate >> shift == rate) { | 293 | if (parent_rate >> shift == rate) { |
294 | periph->auto_div = false; | 294 | periph->auto_div = false; |
295 | periph->div = shift; | 295 | periph->div = shift; |