aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBoris Brezillon <boris.brezillon@free-electrons.com>2015-03-27 18:53:15 -0400
committerBoris Brezillon <boris.brezillon@free-electrons.com>2015-06-19 08:43:39 -0400
commit6c7b03e1aef2e92176435f4fa562cc483422d20f (patch)
tree5630b97e175b6b789e152e43591388b2346ed973
parent03bc10ab5b0f9b8f81bffbe6e40c944f9d3dbcc5 (diff)
clk: at91: pll: fix input range validity check
The PLL impose a certain input range to work correctly, but it appears that this input range does not apply on the input clock (or parent clock) but on the input clock after it has passed the PLL divisor. Fix the implementation accordingly. Cc: <stable@vger.kernel.org> # v3.14+ Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Reported-by: Jonas Andersson <jonas@microbit.se>
-rw-r--r--drivers/clk/at91/clk-pll.c12
1 files changed, 10 insertions, 2 deletions
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).