diff options
author | Paul Walmsley <paul@pwsan.com> | 2011-02-16 17:38:39 -0500 |
---|---|---|
committer | Paul Walmsley <paul@pwsan.com> | 2011-03-07 22:19:40 -0500 |
commit | 241d3a8dca239610d3d991bf58d4fe38c2d86fd5 (patch) | |
tree | 1a68220e34af32a811205c3b9a5aa721335bfabe /arch/arm | |
parent | e07f469d284ca3d1f5dcf5438c22982be98bc071 (diff) |
OMAP2+: clock: remove the DPLL rate tolerance code
Remove the DPLL rate tolerance code that is called during rate
rounding. As far as I know, this code is never used, since it's been
more important for callers of the DPLL round_rate()/set_rate()
functions to obtain an exact rate than it is to save a relatively
small amount of power.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Diffstat (limited to 'arch/arm')
-rw-r--r-- | arch/arm/mach-omap2/clkt_dpll.c | 91 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock.h | 4 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock2420_data.c | 1 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock2430_data.c | 1 | ||||
-rw-r--r-- | arch/arm/mach-omap2/clock3xxx_data.c | 6 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/plat/clock.h | 7 |
6 files changed, 24 insertions, 86 deletions
diff --git a/arch/arm/mach-omap2/clkt_dpll.c b/arch/arm/mach-omap2/clkt_dpll.c index 337392c3f549..17735e7f47b1 100644 --- a/arch/arm/mach-omap2/clkt_dpll.c +++ b/arch/arm/mach-omap2/clkt_dpll.c | |||
@@ -178,12 +178,11 @@ void omap2_init_dpll_parent(struct clk *clk) | |||
178 | if (!dd) | 178 | if (!dd) |
179 | return; | 179 | return; |
180 | 180 | ||
181 | /* Return bypass rate if DPLL is bypassed */ | ||
182 | v = __raw_readl(dd->control_reg); | 181 | v = __raw_readl(dd->control_reg); |
183 | v &= dd->enable_mask; | 182 | v &= dd->enable_mask; |
184 | v >>= __ffs(dd->enable_mask); | 183 | v >>= __ffs(dd->enable_mask); |
185 | 184 | ||
186 | /* Reparent in case the dpll is in bypass */ | 185 | /* Reparent the struct clk in case the dpll is in bypass */ |
187 | if (cpu_is_omap24xx()) { | 186 | if (cpu_is_omap24xx()) { |
188 | if (v == OMAP2XXX_EN_DPLL_LPBYPASS || | 187 | if (v == OMAP2XXX_EN_DPLL_LPBYPASS || |
189 | v == OMAP2XXX_EN_DPLL_FRBYPASS) | 188 | v == OMAP2XXX_EN_DPLL_FRBYPASS) |
@@ -260,50 +259,22 @@ u32 omap2_get_dpll_rate(struct clk *clk) | |||
260 | /* DPLL rate rounding code */ | 259 | /* DPLL rate rounding code */ |
261 | 260 | ||
262 | /** | 261 | /** |
263 | * omap2_dpll_set_rate_tolerance: set the error tolerance during rate rounding | ||
264 | * @clk: struct clk * of the DPLL | ||
265 | * @tolerance: maximum rate error tolerance | ||
266 | * | ||
267 | * Set the maximum DPLL rate error tolerance for the rate rounding | ||
268 | * algorithm. The rate tolerance is an attempt to balance DPLL power | ||
269 | * saving (the least divider value "n") vs. rate fidelity (the least | ||
270 | * difference between the desired DPLL target rate and the rounded | ||
271 | * rate out of the algorithm). So, increasing the tolerance is likely | ||
272 | * to decrease DPLL power consumption and increase DPLL rate error. | ||
273 | * Returns -EINVAL if provided a null clock ptr or a clk that is not a | ||
274 | * DPLL; or 0 upon success. | ||
275 | */ | ||
276 | int omap2_dpll_set_rate_tolerance(struct clk *clk, unsigned int tolerance) | ||
277 | { | ||
278 | if (!clk || !clk->dpll_data) | ||
279 | return -EINVAL; | ||
280 | |||
281 | clk->dpll_data->rate_tolerance = tolerance; | ||
282 | |||
283 | return 0; | ||
284 | } | ||
285 | |||
286 | /** | ||
287 | * omap2_dpll_round_rate - round a target rate for an OMAP DPLL | 262 | * omap2_dpll_round_rate - round a target rate for an OMAP DPLL |
288 | * @clk: struct clk * for a DPLL | 263 | * @clk: struct clk * for a DPLL |
289 | * @target_rate: desired DPLL clock rate | 264 | * @target_rate: desired DPLL clock rate |
290 | * | 265 | * |
291 | * Given a DPLL, a desired target rate, and a rate tolerance, round | 266 | * Given a DPLL and a desired target rate, round the target rate to a |
292 | * the target rate to a possible, programmable rate for this DPLL. | 267 | * possible, programmable rate for this DPLL. Attempts to select the |
293 | * Rate tolerance is assumed to be set by the caller before this | 268 | * minimum possible n. Stores the computed (m, n) in the DPLL's |
294 | * function is called. Attempts to select the minimum possible n | 269 | * dpll_data structure so set_rate() will not need to call this |
295 | * within the tolerance to reduce power consumption. Stores the | 270 | * (expensive) function again. Returns ~0 if the target rate cannot |
296 | * computed (m, n) in the DPLL's dpll_data structure so set_rate() | 271 | * be rounded, or the rounded rate upon success. |
297 | * will not need to call this (expensive) function again. Returns ~0 | ||
298 | * if the target rate cannot be rounded, either because the rate is | ||
299 | * too low or because the rate tolerance is set too tightly; or the | ||
300 | * rounded rate upon success. | ||
301 | */ | 272 | */ |
302 | long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate) | 273 | long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate) |
303 | { | 274 | { |
304 | int m, n, r, e, scaled_max_m; | 275 | int m, n, r, scaled_max_m; |
305 | unsigned long scaled_rt_rp, new_rate; | 276 | unsigned long scaled_rt_rp; |
306 | int min_e = -1, min_e_m = -1, min_e_n = -1; | 277 | unsigned long new_rate = 0; |
307 | struct dpll_data *dd; | 278 | struct dpll_data *dd; |
308 | 279 | ||
309 | if (!clk || !clk->dpll_data) | 280 | if (!clk || !clk->dpll_data) |
@@ -311,8 +282,8 @@ long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate) | |||
311 | 282 | ||
312 | dd = clk->dpll_data; | 283 | dd = clk->dpll_data; |
313 | 284 | ||
314 | pr_debug("clock: starting DPLL round_rate for clock %s, target rate " | 285 | pr_debug("clock: %s: starting DPLL round_rate, target rate %ld\n", |
315 | "%ld\n", clk->name, target_rate); | 286 | clk->name, target_rate); |
316 | 287 | ||
317 | scaled_rt_rp = target_rate / (dd->clk_ref->rate / DPLL_SCALE_FACTOR); | 288 | scaled_rt_rp = target_rate / (dd->clk_ref->rate / DPLL_SCALE_FACTOR); |
318 | scaled_max_m = dd->max_multiplier * DPLL_SCALE_FACTOR; | 289 | scaled_max_m = dd->max_multiplier * DPLL_SCALE_FACTOR; |
@@ -347,39 +318,23 @@ long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate) | |||
347 | if (r == DPLL_MULT_UNDERFLOW) | 318 | if (r == DPLL_MULT_UNDERFLOW) |
348 | continue; | 319 | continue; |
349 | 320 | ||
350 | e = target_rate - new_rate; | 321 | pr_debug("clock: %s: m = %d: n = %d: new_rate = %ld\n", |
351 | pr_debug("clock: n = %d: m = %d: rate error is %d " | 322 | clk->name, m, n, new_rate); |
352 | "(new_rate = %ld)\n", n, m, e, new_rate); | ||
353 | |||
354 | if (min_e == -1 || | ||
355 | min_e >= (int)(abs(e) - dd->rate_tolerance)) { | ||
356 | min_e = e; | ||
357 | min_e_m = m; | ||
358 | min_e_n = n; | ||
359 | |||
360 | pr_debug("clock: found new least error %d\n", min_e); | ||
361 | 323 | ||
362 | /* We found good settings -- bail out now */ | 324 | if (target_rate == new_rate) { |
363 | if (min_e <= dd->rate_tolerance) | 325 | dd->last_rounded_m = m; |
364 | break; | 326 | dd->last_rounded_n = n; |
327 | dd->last_rounded_rate = target_rate; | ||
328 | break; | ||
365 | } | 329 | } |
366 | } | 330 | } |
367 | 331 | ||
368 | if (min_e < 0) { | 332 | if (target_rate != new_rate) { |
369 | pr_debug("clock: error: target rate or tolerance too low\n"); | 333 | pr_debug("clock: %s: cannot round to rate %ld\n", clk->name, |
334 | target_rate); | ||
370 | return ~0; | 335 | return ~0; |
371 | } | 336 | } |
372 | 337 | ||
373 | dd->last_rounded_m = min_e_m; | 338 | return target_rate; |
374 | dd->last_rounded_n = min_e_n; | ||
375 | dd->last_rounded_rate = _dpll_compute_new_rate(dd->clk_ref->rate, | ||
376 | min_e_m, min_e_n); | ||
377 | |||
378 | pr_debug("clock: final least error: e = %d, m = %d, n = %d\n", | ||
379 | min_e, min_e_m, min_e_n); | ||
380 | pr_debug("clock: final rate: %ld (target rate: %ld)\n", | ||
381 | dd->last_rounded_rate, target_rate); | ||
382 | |||
383 | return dd->last_rounded_rate; | ||
384 | } | 339 | } |
385 | 340 | ||
diff --git a/arch/arm/mach-omap2/clock.h b/arch/arm/mach-omap2/clock.h index 70f8b073e69f..62cfd6cc7461 100644 --- a/arch/arm/mach-omap2/clock.h +++ b/arch/arm/mach-omap2/clock.h | |||
@@ -18,9 +18,6 @@ | |||
18 | 18 | ||
19 | #include <plat/clock.h> | 19 | #include <plat/clock.h> |
20 | 20 | ||
21 | /* The maximum error between a target DPLL rate and the rounded rate in Hz */ | ||
22 | #define DEFAULT_DPLL_RATE_TOLERANCE 50000 | ||
23 | |||
24 | /* CM_CLKSEL2_PLL.CORE_CLK_SRC bits (2XXX) */ | 21 | /* CM_CLKSEL2_PLL.CORE_CLK_SRC bits (2XXX) */ |
25 | #define CORE_CLK_SRC_32K 0x0 | 22 | #define CORE_CLK_SRC_32K 0x0 |
26 | #define CORE_CLK_SRC_DPLL 0x1 | 23 | #define CORE_CLK_SRC_DPLL 0x1 |
@@ -55,7 +52,6 @@ void omap2_clk_disable(struct clk *clk); | |||
55 | long omap2_clk_round_rate(struct clk *clk, unsigned long rate); | 52 | long omap2_clk_round_rate(struct clk *clk, unsigned long rate); |
56 | int omap2_clk_set_rate(struct clk *clk, unsigned long rate); | 53 | int omap2_clk_set_rate(struct clk *clk, unsigned long rate); |
57 | int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent); | 54 | int omap2_clk_set_parent(struct clk *clk, struct clk *new_parent); |
58 | int omap2_dpll_set_rate_tolerance(struct clk *clk, unsigned int tolerance); | ||
59 | long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate); | 55 | long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate); |
60 | unsigned long omap3_dpll_recalc(struct clk *clk); | 56 | unsigned long omap3_dpll_recalc(struct clk *clk); |
61 | unsigned long omap3_clkoutx2_recalc(struct clk *clk); | 57 | unsigned long omap3_clkoutx2_recalc(struct clk *clk); |
diff --git a/arch/arm/mach-omap2/clock2420_data.c b/arch/arm/mach-omap2/clock2420_data.c index 6e9d20dc8649..22eeafc89b9f 100644 --- a/arch/arm/mach-omap2/clock2420_data.c +++ b/arch/arm/mach-omap2/clock2420_data.c | |||
@@ -116,7 +116,6 @@ static struct dpll_data dpll_dd = { | |||
116 | .max_multiplier = 1023, | 116 | .max_multiplier = 1023, |
117 | .min_divider = 1, | 117 | .min_divider = 1, |
118 | .max_divider = 16, | 118 | .max_divider = 16, |
119 | .rate_tolerance = DEFAULT_DPLL_RATE_TOLERANCE | ||
120 | }; | 119 | }; |
121 | 120 | ||
122 | /* | 121 | /* |
diff --git a/arch/arm/mach-omap2/clock2430_data.c b/arch/arm/mach-omap2/clock2430_data.c index 3378dbf8bace..df4cac5fef06 100644 --- a/arch/arm/mach-omap2/clock2430_data.c +++ b/arch/arm/mach-omap2/clock2430_data.c | |||
@@ -116,7 +116,6 @@ static struct dpll_data dpll_dd = { | |||
116 | .max_multiplier = 1023, | 116 | .max_multiplier = 1023, |
117 | .min_divider = 1, | 117 | .min_divider = 1, |
118 | .max_divider = 16, | 118 | .max_divider = 16, |
119 | .rate_tolerance = DEFAULT_DPLL_RATE_TOLERANCE | ||
120 | }; | 119 | }; |
121 | 120 | ||
122 | /* | 121 | /* |
diff --git a/arch/arm/mach-omap2/clock3xxx_data.c b/arch/arm/mach-omap2/clock3xxx_data.c index 305b5f75c44f..3dbeb3a5813d 100644 --- a/arch/arm/mach-omap2/clock3xxx_data.c +++ b/arch/arm/mach-omap2/clock3xxx_data.c | |||
@@ -291,7 +291,6 @@ static struct dpll_data dpll1_dd = { | |||
291 | .max_multiplier = OMAP3_MAX_DPLL_MULT, | 291 | .max_multiplier = OMAP3_MAX_DPLL_MULT, |
292 | .min_divider = 1, | 292 | .min_divider = 1, |
293 | .max_divider = OMAP3_MAX_DPLL_DIV, | 293 | .max_divider = OMAP3_MAX_DPLL_DIV, |
294 | .rate_tolerance = DEFAULT_DPLL_RATE_TOLERANCE | ||
295 | }; | 294 | }; |
296 | 295 | ||
297 | static struct clk dpll1_ck = { | 296 | static struct clk dpll1_ck = { |
@@ -364,7 +363,6 @@ static struct dpll_data dpll2_dd = { | |||
364 | .max_multiplier = OMAP3_MAX_DPLL_MULT, | 363 | .max_multiplier = OMAP3_MAX_DPLL_MULT, |
365 | .min_divider = 1, | 364 | .min_divider = 1, |
366 | .max_divider = OMAP3_MAX_DPLL_DIV, | 365 | .max_divider = OMAP3_MAX_DPLL_DIV, |
367 | .rate_tolerance = DEFAULT_DPLL_RATE_TOLERANCE | ||
368 | }; | 366 | }; |
369 | 367 | ||
370 | static struct clk dpll2_ck = { | 368 | static struct clk dpll2_ck = { |
@@ -424,7 +422,6 @@ static struct dpll_data dpll3_dd = { | |||
424 | .max_multiplier = OMAP3_MAX_DPLL_MULT, | 422 | .max_multiplier = OMAP3_MAX_DPLL_MULT, |
425 | .min_divider = 1, | 423 | .min_divider = 1, |
426 | .max_divider = OMAP3_MAX_DPLL_DIV, | 424 | .max_divider = OMAP3_MAX_DPLL_DIV, |
427 | .rate_tolerance = DEFAULT_DPLL_RATE_TOLERANCE | ||
428 | }; | 425 | }; |
429 | 426 | ||
430 | static struct clk dpll3_ck = { | 427 | static struct clk dpll3_ck = { |
@@ -583,7 +580,6 @@ static struct dpll_data dpll4_dd_34xx __initdata = { | |||
583 | .max_multiplier = OMAP3_MAX_DPLL_MULT, | 580 | .max_multiplier = OMAP3_MAX_DPLL_MULT, |
584 | .min_divider = 1, | 581 | .min_divider = 1, |
585 | .max_divider = OMAP3_MAX_DPLL_DIV, | 582 | .max_divider = OMAP3_MAX_DPLL_DIV, |
586 | .rate_tolerance = DEFAULT_DPLL_RATE_TOLERANCE | ||
587 | }; | 583 | }; |
588 | 584 | ||
589 | static struct dpll_data dpll4_dd_3630 __initdata = { | 585 | static struct dpll_data dpll4_dd_3630 __initdata = { |
@@ -607,7 +603,6 @@ static struct dpll_data dpll4_dd_3630 __initdata = { | |||
607 | .max_multiplier = OMAP3630_MAX_JTYPE_DPLL_MULT, | 603 | .max_multiplier = OMAP3630_MAX_JTYPE_DPLL_MULT, |
608 | .min_divider = 1, | 604 | .min_divider = 1, |
609 | .max_divider = OMAP3_MAX_DPLL_DIV, | 605 | .max_divider = OMAP3_MAX_DPLL_DIV, |
610 | .rate_tolerance = DEFAULT_DPLL_RATE_TOLERANCE, | ||
611 | .flags = DPLL_J_TYPE | 606 | .flags = DPLL_J_TYPE |
612 | }; | 607 | }; |
613 | 608 | ||
@@ -939,7 +934,6 @@ static struct dpll_data dpll5_dd = { | |||
939 | .max_multiplier = OMAP3_MAX_DPLL_MULT, | 934 | .max_multiplier = OMAP3_MAX_DPLL_MULT, |
940 | .min_divider = 1, | 935 | .min_divider = 1, |
941 | .max_divider = OMAP3_MAX_DPLL_DIV, | 936 | .max_divider = OMAP3_MAX_DPLL_DIV, |
942 | .rate_tolerance = DEFAULT_DPLL_RATE_TOLERANCE | ||
943 | }; | 937 | }; |
944 | 938 | ||
945 | static struct clk dpll5_ck = { | 939 | static struct clk dpll5_ck = { |
diff --git a/arch/arm/plat-omap/include/plat/clock.h b/arch/arm/plat-omap/include/plat/clock.h index dcd7bb81420d..006e599c6613 100644 --- a/arch/arm/plat-omap/include/plat/clock.h +++ b/arch/arm/plat-omap/include/plat/clock.h | |||
@@ -109,7 +109,6 @@ struct clksel { | |||
109 | * @clk_ref: struct clk pointer to the clock's reference clock input | 109 | * @clk_ref: struct clk pointer to the clock's reference clock input |
110 | * @control_reg: register containing the DPLL mode bitfield | 110 | * @control_reg: register containing the DPLL mode bitfield |
111 | * @enable_mask: mask of the DPLL mode bitfield in @control_reg | 111 | * @enable_mask: mask of the DPLL mode bitfield in @control_reg |
112 | * @rate_tolerance: maximum variance allowed from target rate (in Hz) | ||
113 | * @last_rounded_rate: cache of the last rate result of omap2_dpll_round_rate() | 112 | * @last_rounded_rate: cache of the last rate result of omap2_dpll_round_rate() |
114 | * @last_rounded_m: cache of the last M result of omap2_dpll_round_rate() | 113 | * @last_rounded_m: cache of the last M result of omap2_dpll_round_rate() |
115 | * @max_multiplier: maximum valid non-bypass multiplier value (actual) | 114 | * @max_multiplier: maximum valid non-bypass multiplier value (actual) |
@@ -135,12 +134,9 @@ struct clksel { | |||
135 | * XXX Some DPLLs have multiple bypass inputs, so it's not technically | 134 | * XXX Some DPLLs have multiple bypass inputs, so it's not technically |
136 | * correct to only have one @clk_bypass pointer. | 135 | * correct to only have one @clk_bypass pointer. |
137 | * | 136 | * |
138 | * XXX @rate_tolerance should probably be deprecated - currently there | ||
139 | * don't seem to be any usecases for DPLL rounding that is not exact. | ||
140 | * | ||
141 | * XXX The runtime-variable fields (@last_rounded_rate, @last_rounded_m, | 137 | * XXX The runtime-variable fields (@last_rounded_rate, @last_rounded_m, |
142 | * @last_rounded_n) should be separated from the runtime-fixed fields | 138 | * @last_rounded_n) should be separated from the runtime-fixed fields |
143 | * and placed into a differenct structure, so that the runtime-fixed data | 139 | * and placed into a different structure, so that the runtime-fixed data |
144 | * can be placed into read-only space. | 140 | * can be placed into read-only space. |
145 | */ | 141 | */ |
146 | struct dpll_data { | 142 | struct dpll_data { |
@@ -151,7 +147,6 @@ struct dpll_data { | |||
151 | struct clk *clk_ref; | 147 | struct clk *clk_ref; |
152 | void __iomem *control_reg; | 148 | void __iomem *control_reg; |
153 | u32 enable_mask; | 149 | u32 enable_mask; |
154 | unsigned int rate_tolerance; | ||
155 | unsigned long last_rounded_rate; | 150 | unsigned long last_rounded_rate; |
156 | u16 last_rounded_m; | 151 | u16 last_rounded_m; |
157 | u16 max_multiplier; | 152 | u16 max_multiplier; |