diff options
| -rw-r--r-- | Documentation/devicetree/bindings/clock/at91-clock.txt | 2 | ||||
| -rw-r--r-- | drivers/clk/at91/clk-peripheral.c | 8 | ||||
| -rw-r--r-- | drivers/clk/at91/clk-pll.c | 12 | ||||
| -rw-r--r-- | drivers/clk/at91/pmc.h | 2 |
4 files changed, 16 insertions, 8 deletions
diff --git a/Documentation/devicetree/bindings/clock/at91-clock.txt b/Documentation/devicetree/bindings/clock/at91-clock.txt index 7a4d4926f44e..5ba6450693b9 100644 --- a/Documentation/devicetree/bindings/clock/at91-clock.txt +++ b/Documentation/devicetree/bindings/clock/at91-clock.txt | |||
| @@ -248,7 +248,7 @@ Required properties for peripheral clocks: | |||
| 248 | - #address-cells : shall be 1 (reg is used to encode clk id). | 248 | - #address-cells : shall be 1 (reg is used to encode clk id). |
| 249 | - clocks : shall be the master clock phandle. | 249 | - clocks : shall be the master clock phandle. |
| 250 | e.g. clocks = <&mck>; | 250 | e.g. clocks = <&mck>; |
| 251 | - name: device tree node describing a specific system clock. | 251 | - name: device tree node describing a specific peripheral clock. |
| 252 | * #clock-cells : from common clock binding; shall be set to 0. | 252 | * #clock-cells : from common clock binding; shall be set to 0. |
| 253 | * reg: peripheral id. See Atmel's datasheets to get a full | 253 | * reg: peripheral id. See Atmel's datasheets to get a full |
| 254 | list of peripheral ids. | 254 | list of peripheral ids. |
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; |
diff --git a/drivers/clk/at91/clk-pll.c b/drivers/clk/at91/clk-pll.c index 6ec79dbc0840..cbbe40377ad6 100644 --- a/drivers/clk/at91/clk-pll.c +++ b/drivers/clk/at91/clk-pll.c | |||
| @@ -173,8 +173,7 @@ static long clk_pll_get_best_div_mul(struct clk_pll *pll, unsigned long rate, | |||
| 173 | int i = 0; | 173 | int i = 0; |
| 174 | 174 | ||
| 175 | /* Check if parent_rate is a valid input rate */ | 175 | /* Check if parent_rate is a valid input rate */ |
| 176 | if (parent_rate < characteristics->input.min || | 176 | if (parent_rate < characteristics->input.min) |
| 177 | parent_rate > characteristics->input.max) | ||
| 178 | return -ERANGE; | 177 | return -ERANGE; |
| 179 | 178 | ||
| 180 | /* | 179 | /* |
| @@ -187,6 +186,15 @@ static long clk_pll_get_best_div_mul(struct clk_pll *pll, unsigned long rate, | |||
| 187 | if (!mindiv) | 186 | if (!mindiv) |
| 188 | mindiv = 1; | 187 | mindiv = 1; |
| 189 | 188 | ||
| 189 | if (parent_rate > characteristics->input.max) { | ||
| 190 | tmpdiv = DIV_ROUND_UP(parent_rate, characteristics->input.max); | ||
| 191 | if (tmpdiv > PLL_DIV_MAX) | ||
| 192 | return -ERANGE; | ||
| 193 | |||
| 194 | if (tmpdiv > mindiv) | ||
| 195 | mindiv = tmpdiv; | ||
| 196 | } | ||
| 197 | |||
| 190 | /* | 198 | /* |
| 191 | * Calculate the maximum divider which is limited by PLL register | 199 | * Calculate the maximum divider which is limited by PLL register |
| 192 | * layout (limited by the MUL or DIV field size). | 200 | * layout (limited by the MUL or DIV field size). |
diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h index 69abb08cf146..eb8e5dc9076d 100644 --- a/drivers/clk/at91/pmc.h +++ b/drivers/clk/at91/pmc.h | |||
| @@ -121,7 +121,7 @@ extern void __init of_at91sam9x5_clk_smd_setup(struct device_node *np, | |||
| 121 | struct at91_pmc *pmc); | 121 | struct at91_pmc *pmc); |
| 122 | #endif | 122 | #endif |
| 123 | 123 | ||
| 124 | #if defined(CONFIG_HAVE_AT91_SMD) | 124 | #if defined(CONFIG_HAVE_AT91_H32MX) |
| 125 | extern void __init of_sama5d4_clk_h32mx_setup(struct device_node *np, | 125 | extern void __init of_sama5d4_clk_h32mx_setup(struct device_node *np, |
| 126 | struct at91_pmc *pmc); | 126 | struct at91_pmc *pmc); |
| 127 | #endif | 127 | #endif |
