~ubuntu-branches/debian/wheezy/linux-2.6/wheezy

« back to all changes in this revision

Viewing changes to arch/arm/mach-omap2/clkt_dpll.c

  • Committer: Bazaar Package Importer
  • Author(s): Ben Hutchings, Ben Hutchings, Aurelien Jarno
  • Date: 2011-06-07 12:14:05 UTC
  • mfrom: (43.1.9 sid)
  • Revision ID: james.westby@ubuntu.com-20110607121405-i3h1rd7nrnd2b73h
Tags: 2.6.39-2
[ Ben Hutchings ]
* [x86] Enable BACKLIGHT_APPLE, replacing BACKLIGHT_MBP_NVIDIA
  (Closes: #627492)
* cgroups: Disable memory resource controller by default. Allow it
  to be enabled using kernel parameter 'cgroup_enable=memory'.
* rt2800usb: Enable support for more USB devices including
  Linksys WUSB600N (Closes: #596626) (this change was accidentally
  omitted from 2.6.39-1)
* [x86] Remove Celeron from list of processors supporting PAE. Most
  'Celeron M' models do not.
* Update debconf template translations:
  - Swedish (Martin Bagge) (Closes: #628932)
  - French (David Prévot) (Closes: #628191)
* aufs: Update for 2.6.39 (Closes: #627837)
* Add stable 2.6.39.1, including:
  - ext4: dont set PageUptodate in ext4_end_bio()
  - pata_cmd64x: fix boot crash on parisc (Closes: #622997, #622745)
  - ext3: Fix fs corruption when make_indexed_dir() fails
  - netfilter: nf_ct_sip: validate Content-Length in TCP SIP messages
  - sctp: fix race between sctp_bind_addr_free() and
    sctp_bind_addr_conflict()
  - sctp: fix memory leak of the ASCONF queue when free asoc
  - md/bitmap: fix saving of events_cleared and other state
  - cdc_acm: Fix oops when Droids MuIn LCD is connected
  - cx88: Fix conversion from BKL to fine-grained locks (Closes: #619827)
  - keys: Set cred->user_ns in key_replace_session_keyring (CVE-2011-2184)
  - tmpfs: fix race between truncate and writepage
  - nfs41: Correct offset for LAYOUTCOMMIT
  - xen/mmu: fix a race window causing leave_mm BUG()
  - ext4: fix possible use-after-free in ext4_remove_li_request()
  For the complete list of changes, see:
   http://www.kernel.org/pub/linux/kernel/v2.6/ChangeLog-2.6.39.1
* Bump ABI to 2
* netfilter: Enable IP_SET, IP_SET_BITMAP_IP, IP_SET_BITMAP_IPMAC,
  IP_SET_BITMAP_PORT, IP_SET_HASH_IP, IP_SET_HASH_IPPORT,
  IP_SET_HASH_IPPORTIP, IP_SET_HASH_IPPORTNET, IP_SET_HASH_NET,
  IP_SET_HASH_NETPORT, IP_SET_LIST_SET, NETFILTER_XT_SET as modules
  (Closes: #629401)

[ Aurelien Jarno ]
* [mipsel/loongson-2f] Disable_SCSI_LPFC to workaround GCC ICE.

Show diffs side-by-side

added added

removed removed

Lines of Context:
178
178
        if (!dd)
179
179
                return;
180
180
 
181
 
        /* Return bypass rate if DPLL is bypassed */
182
181
        v = __raw_readl(dd->control_reg);
183
182
        v &= dd->enable_mask;
184
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
186
        if (cpu_is_omap24xx()) {
188
187
                if (v == OMAP2XXX_EN_DPLL_LPBYPASS ||
189
188
                    v == OMAP2XXX_EN_DPLL_FRBYPASS)
260
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
262
 * omap2_dpll_round_rate - round a target rate for an OMAP DPLL
288
263
 * @clk: struct clk * for a DPLL
289
264
 * @target_rate: desired DPLL clock rate
290
265
 *
291
 
 * Given a DPLL, a desired target rate, and a rate tolerance, round
292
 
 * the target rate to a possible, programmable rate for this DPLL.
293
 
 * Rate tolerance is assumed to be set by the caller before this
294
 
 * function is called.  Attempts to select the minimum possible n
295
 
 * within the tolerance to reduce power consumption.  Stores the
296
 
 * computed (m, n) in the DPLL's dpll_data structure so set_rate()
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.
 
266
 * Given a DPLL and a desired target rate, round the target rate to a
 
267
 * possible, programmable rate for this DPLL.  Attempts to select the
 
268
 * minimum possible n.  Stores the computed (m, n) in the DPLL's
 
269
 * dpll_data structure so set_rate() will not need to call this
 
270
 * (expensive) function again.  Returns ~0 if the target rate cannot
 
271
 * be rounded, or the rounded rate upon success.
301
272
 */
302
273
long omap2_dpll_round_rate(struct clk *clk, unsigned long target_rate)
303
274
{
304
 
        int m, n, r, e, scaled_max_m;
305
 
        unsigned long scaled_rt_rp, new_rate;
306
 
        int min_e = -1, min_e_m = -1, min_e_n = -1;
 
275
        int m, n, r, scaled_max_m;
 
276
        unsigned long scaled_rt_rp;
 
277
        unsigned long new_rate = 0;
307
278
        struct dpll_data *dd;
308
279
 
309
280
        if (!clk || !clk->dpll_data)
311
282
 
312
283
        dd = clk->dpll_data;
313
284
 
314
 
        pr_debug("clock: starting DPLL round_rate for clock %s, target rate "
315
 
                 "%ld\n", clk->name, target_rate);
 
285
        pr_debug("clock: %s: starting DPLL round_rate, target rate %ld\n",
 
286
                 clk->name, target_rate);
316
287
 
317
288
        scaled_rt_rp = target_rate / (dd->clk_ref->rate / DPLL_SCALE_FACTOR);
318
289
        scaled_max_m = dd->max_multiplier * DPLL_SCALE_FACTOR;
347
318
                if (r == DPLL_MULT_UNDERFLOW)
348
319
                        continue;
349
320
 
350
 
                e = target_rate - new_rate;
351
 
                pr_debug("clock: n = %d: m = %d: rate error is %d "
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
 
 
362
 
                        /* We found good settings -- bail out now */
363
 
                        if (min_e <= dd->rate_tolerance)
364
 
                                break;
 
321
                pr_debug("clock: %s: m = %d: n = %d: new_rate = %ld\n",
 
322
                         clk->name, m, n, new_rate);
 
323
 
 
324
                if (target_rate == new_rate) {
 
325
                        dd->last_rounded_m = m;
 
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) {
369
 
                pr_debug("clock: error: target rate or tolerance too low\n");
 
332
        if (target_rate != new_rate) {
 
333
                pr_debug("clock: %s: cannot round to rate %ld\n", clk->name,
 
334
                         target_rate);
370
335
                return ~0;
371
336
        }
372
337
 
373
 
        dd->last_rounded_m = min_e_m;
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;
 
338
        return target_rate;
384
339
}
385
340