aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2009-01-27 21:12:47 -0500
committerRussell King <rmk+kernel@arm.linux.org.uk>2009-02-08 12:50:24 -0500
commit16c90f020034d3cd38b3dab280001e728e6b19e5 (patch)
tree71b142bdf83578688b4844b0b65414f2b3d6c3df /arch
parent6f7607ccd175518a3ee7dccc1620f3a086689668 (diff)
[ARM] OMAP2/3: Add non-CORE DPLL rate set code and M, N programming
Add non-CORE DPLL rate set code and M,N programming for OMAP3. Connect it to OMAP34xx DPLLs 1, 2, 4, 5 via the clock framework. You may see some warnings on rate sets from the freqsel code. The table that TI presented in the 3430 TRM Rev F does not cover Fint < 750000, which definitely occurs in practice. However, the lack of this freqsel case does not appear to impair the DPLL rate change. linux-omap source commit is 689fe67c6d1ad8f52f7f7b139a3274b79bf3e784. Signed-off-by: Paul Walmsley <paul@pwsan.com> Signed-off-by: Tony Lindgren <tony@atomide.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/mach-omap2/clock34xx.c137
-rw-r--r--arch/arm/mach-omap2/clock34xx.h11
-rw-r--r--arch/arm/plat-omap/include/mach/clock.h1
3 files changed, 148 insertions, 1 deletions
diff --git a/arch/arm/mach-omap2/clock34xx.c b/arch/arm/mach-omap2/clock34xx.c
index 245a7b9b560c..943ac63fc6f8 100644
--- a/arch/arm/mach-omap2/clock34xx.c
+++ b/arch/arm/mach-omap2/clock34xx.c
@@ -340,6 +340,42 @@ static int _omap3_wait_dpll_status(struct clk *clk, u8 state)
340 return ret; 340 return ret;
341} 341}
342 342
343/* From 3430 TRM ES2 4.7.6.2 */
344static u16 _omap3_dpll_compute_freqsel(struct clk *clk, u8 n)
345{
346 unsigned long fint;
347 u16 f = 0;
348
349 fint = clk->parent->rate / (n + 1);
350
351 pr_debug("clock: fint is %lu\n", fint);
352
353 if (fint >= 750000 && fint <= 1000000)
354 f = 0x3;
355 else if (fint > 1000000 && fint <= 1250000)
356 f = 0x4;
357 else if (fint > 1250000 && fint <= 1500000)
358 f = 0x5;
359 else if (fint > 1500000 && fint <= 1750000)
360 f = 0x6;
361 else if (fint > 1750000 && fint <= 2100000)
362 f = 0x7;
363 else if (fint > 7500000 && fint <= 10000000)
364 f = 0xB;
365 else if (fint > 10000000 && fint <= 12500000)
366 f = 0xC;
367 else if (fint > 12500000 && fint <= 15000000)
368 f = 0xD;
369 else if (fint > 15000000 && fint <= 17500000)
370 f = 0xE;
371 else if (fint > 17500000 && fint <= 21000000)
372 f = 0xF;
373 else
374 pr_debug("clock: unknown freqsel setting for %d\n", n);
375
376 return f;
377}
378
343/* Non-CORE DPLL (e.g., DPLLs that do not control SDRC) clock functions */ 379/* Non-CORE DPLL (e.g., DPLLs that do not control SDRC) clock functions */
344 380
345/* 381/*
@@ -476,7 +512,7 @@ static int omap3_noncore_dpll_enable(struct clk *clk)
476 if (clk == &dpll3_ck) 512 if (clk == &dpll3_ck)
477 return -EINVAL; 513 return -EINVAL;
478 514
479 if (clk->parent->rate == clk_get_rate(clk)) 515 if (clk->parent->rate == omap2_get_dpll_rate(clk))
480 r = _omap3_noncore_dpll_bypass(clk); 516 r = _omap3_noncore_dpll_bypass(clk);
481 else 517 else
482 r = _omap3_noncore_dpll_lock(clk); 518 r = _omap3_noncore_dpll_lock(clk);
@@ -506,11 +542,110 @@ static void omap3_noncore_dpll_disable(struct clk *clk)
506 _omap3_noncore_dpll_stop(clk); 542 _omap3_noncore_dpll_stop(clk);
507} 543}
508 544
545
546/* Non-CORE DPLL rate set code */
547
548/*
549 * omap3_noncore_dpll_program - set non-core DPLL M,N values directly
550 * @clk: struct clk * of DPLL to set
551 * @m: DPLL multiplier to set
552 * @n: DPLL divider to set
553 * @freqsel: FREQSEL value to set
554 *
555 * Program the DPLL with the supplied M, N values, and wait for the DPLL to
556 * lock.. Returns -EINVAL upon error, or 0 upon success.
557 */
558static int omap3_noncore_dpll_program(struct clk *clk, u16 m, u8 n, u16 freqsel)
559{
560 struct dpll_data *dd = clk->dpll_data;
561 u32 v;
562
563 /* 3430 ES2 TRM: 4.7.6.9 DPLL Programming Sequence */
564 _omap3_noncore_dpll_bypass(clk);
565
566 v = __raw_readl(dd->mult_div1_reg);
567 v &= ~(dd->mult_mask | dd->div1_mask);
568
569 /* Set mult (M), div1 (N), freqsel */
570 v |= m << __ffs(dd->mult_mask);
571 v |= n << __ffs(dd->div1_mask);
572 v |= freqsel << __ffs(dd->freqsel_mask);
573
574 __raw_writel(v, dd->mult_div1_reg);
575
576 /* We let the clock framework set the other output dividers later */
577
578 /* REVISIT: Set ramp-up delay? */
579
580 _omap3_noncore_dpll_lock(clk);
581
582 return 0;
583}
584
585/**
586 * omap3_noncore_dpll_set_rate - set non-core DPLL rate
587 * @clk: struct clk * of DPLL to set
588 * @rate: rounded target rate
589 *
590 * Program the DPLL with the rounded target rate. Returns -EINVAL upon
591 * error, or 0 upon success.
592 */
593static int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate)
594{
595 u16 freqsel;
596 struct dpll_data *dd;
597
598 if (!clk || !rate)
599 return -EINVAL;
600
601 dd = clk->dpll_data;
602 if (!dd)
603 return -EINVAL;
604
605 if (rate == omap2_get_dpll_rate(clk))
606 return 0;
607
608 if (dd->last_rounded_rate != rate)
609 omap2_dpll_round_rate(clk, rate);
610
611 if (dd->last_rounded_rate == 0)
612 return -EINVAL;
613
614 freqsel = _omap3_dpll_compute_freqsel(clk, dd->last_rounded_n);
615 if (!freqsel)
616 WARN_ON(1);
617
618 omap3_noncore_dpll_program(clk, dd->last_rounded_m, dd->last_rounded_n,
619 freqsel);
620
621 omap3_dpll_recalc(clk);
622
623 return 0;
624}
625
626static int omap3_dpll4_set_rate(struct clk *clk, unsigned long rate)
627{
628 /*
629 * According to the 12-5 CDP code from TI, "Limitation 2.5"
630 * on 3430ES1 prevents us from changing DPLL multipliers or dividers
631 * on DPLL4.
632 */
633 if (omap_rev() == OMAP3430_REV_ES1_0) {
634 printk(KERN_ERR "clock: DPLL4 cannot change rate due to "
635 "silicon 'Limitation 2.5' on 3430ES1.\n");
636 return -EINVAL;
637 }
638 return omap3_noncore_dpll_set_rate(clk, rate);
639}
640
509static const struct clkops clkops_noncore_dpll_ops = { 641static const struct clkops clkops_noncore_dpll_ops = {
510 .enable = &omap3_noncore_dpll_enable, 642 .enable = &omap3_noncore_dpll_enable,
511 .disable = &omap3_noncore_dpll_disable, 643 .disable = &omap3_noncore_dpll_disable,
512}; 644};
513 645
646/* DPLL autoidle read/set code */
647
648
514/** 649/**
515 * omap3_dpll_autoidle_read - read a DPLL's autoidle bits 650 * omap3_dpll_autoidle_read - read a DPLL's autoidle bits
516 * @clk: struct clk * of the DPLL to read 651 * @clk: struct clk * of the DPLL to read
diff --git a/arch/arm/mach-omap2/clock34xx.h b/arch/arm/mach-omap2/clock34xx.h
index 6bd8c6d5a4e7..f811a0978512 100644
--- a/arch/arm/mach-omap2/clock34xx.h
+++ b/arch/arm/mach-omap2/clock34xx.h
@@ -32,6 +32,8 @@ static void omap3_clkoutx2_recalc(struct clk *clk);
32static void omap3_dpll_allow_idle(struct clk *clk); 32static void omap3_dpll_allow_idle(struct clk *clk);
33static void omap3_dpll_deny_idle(struct clk *clk); 33static void omap3_dpll_deny_idle(struct clk *clk);
34static u32 omap3_dpll_autoidle_read(struct clk *clk); 34static u32 omap3_dpll_autoidle_read(struct clk *clk);
35static int omap3_noncore_dpll_set_rate(struct clk *clk, unsigned long rate);
36static int omap3_dpll4_set_rate(struct clk *clk, unsigned long rate);
35 37
36/* Maximum DPLL multiplier, divider values for OMAP3 */ 38/* Maximum DPLL multiplier, divider values for OMAP3 */
37#define OMAP3_MAX_DPLL_MULT 2048 39#define OMAP3_MAX_DPLL_MULT 2048
@@ -254,6 +256,7 @@ static struct dpll_data dpll1_dd = {
254 .mult_div1_reg = OMAP_CM_REGADDR(MPU_MOD, OMAP3430_CM_CLKSEL1_PLL), 256 .mult_div1_reg = OMAP_CM_REGADDR(MPU_MOD, OMAP3430_CM_CLKSEL1_PLL),
255 .mult_mask = OMAP3430_MPU_DPLL_MULT_MASK, 257 .mult_mask = OMAP3430_MPU_DPLL_MULT_MASK,
256 .div1_mask = OMAP3430_MPU_DPLL_DIV_MASK, 258 .div1_mask = OMAP3430_MPU_DPLL_DIV_MASK,
259 .freqsel_mask = OMAP3430_MPU_DPLL_FREQSEL_MASK,
257 .control_reg = OMAP_CM_REGADDR(MPU_MOD, OMAP3430_CM_CLKEN_PLL), 260 .control_reg = OMAP_CM_REGADDR(MPU_MOD, OMAP3430_CM_CLKEN_PLL),
258 .enable_mask = OMAP3430_EN_MPU_DPLL_MASK, 261 .enable_mask = OMAP3430_EN_MPU_DPLL_MASK,
259 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED), 262 .modes = (1 << DPLL_LOW_POWER_BYPASS) | (1 << DPLL_LOCKED),
@@ -276,6 +279,7 @@ static struct clk dpll1_ck = {
276 .dpll_data = &dpll1_dd, 279 .dpll_data = &dpll1_dd,
277 .flags = RATE_PROPAGATES, 280 .flags = RATE_PROPAGATES,
278 .round_rate = &omap2_dpll_round_rate, 281 .round_rate = &omap2_dpll_round_rate,
282 .set_rate = &omap3_noncore_dpll_set_rate,
279 .recalc = &omap3_dpll_recalc, 283 .recalc = &omap3_dpll_recalc,
280}; 284};
281 285
@@ -321,6 +325,7 @@ static struct dpll_data dpll2_dd = {
321 .mult_div1_reg = OMAP_CM_REGADDR(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKSEL1_PLL), 325 .mult_div1_reg = OMAP_CM_REGADDR(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKSEL1_PLL),
322 .mult_mask = OMAP3430_IVA2_DPLL_MULT_MASK, 326 .mult_mask = OMAP3430_IVA2_DPLL_MULT_MASK,
323 .div1_mask = OMAP3430_IVA2_DPLL_DIV_MASK, 327 .div1_mask = OMAP3430_IVA2_DPLL_DIV_MASK,
328 .freqsel_mask = OMAP3430_IVA2_DPLL_FREQSEL_MASK,
324 .control_reg = OMAP_CM_REGADDR(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKEN_PLL), 329 .control_reg = OMAP_CM_REGADDR(OMAP3430_IVA2_MOD, OMAP3430_CM_CLKEN_PLL),
325 .enable_mask = OMAP3430_EN_IVA2_DPLL_MASK, 330 .enable_mask = OMAP3430_EN_IVA2_DPLL_MASK,
326 .modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED) | 331 .modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED) |
@@ -344,6 +349,7 @@ static struct clk dpll2_ck = {
344 .dpll_data = &dpll2_dd, 349 .dpll_data = &dpll2_dd,
345 .flags = RATE_PROPAGATES, 350 .flags = RATE_PROPAGATES,
346 .round_rate = &omap2_dpll_round_rate, 351 .round_rate = &omap2_dpll_round_rate,
352 .set_rate = &omap3_noncore_dpll_set_rate,
347 .recalc = &omap3_dpll_recalc, 353 .recalc = &omap3_dpll_recalc,
348}; 354};
349 355
@@ -378,6 +384,7 @@ static struct dpll_data dpll3_dd = {
378 .mult_div1_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL1), 384 .mult_div1_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL1),
379 .mult_mask = OMAP3430_CORE_DPLL_MULT_MASK, 385 .mult_mask = OMAP3430_CORE_DPLL_MULT_MASK,
380 .div1_mask = OMAP3430_CORE_DPLL_DIV_MASK, 386 .div1_mask = OMAP3430_CORE_DPLL_DIV_MASK,
387 .freqsel_mask = OMAP3430_CORE_DPLL_FREQSEL_MASK,
381 .control_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN), 388 .control_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN),
382 .enable_mask = OMAP3430_EN_CORE_DPLL_MASK, 389 .enable_mask = OMAP3430_EN_CORE_DPLL_MASK,
383 .auto_recal_bit = OMAP3430_EN_CORE_DPLL_DRIFTGUARD_SHIFT, 390 .auto_recal_bit = OMAP3430_EN_CORE_DPLL_DRIFTGUARD_SHIFT,
@@ -558,6 +565,7 @@ static struct dpll_data dpll4_dd = {
558 .mult_div1_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL2), 565 .mult_div1_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKSEL2),
559 .mult_mask = OMAP3430_PERIPH_DPLL_MULT_MASK, 566 .mult_mask = OMAP3430_PERIPH_DPLL_MULT_MASK,
560 .div1_mask = OMAP3430_PERIPH_DPLL_DIV_MASK, 567 .div1_mask = OMAP3430_PERIPH_DPLL_DIV_MASK,
568 .freqsel_mask = OMAP3430_PERIPH_DPLL_FREQSEL_MASK,
561 .control_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN), 569 .control_reg = OMAP_CM_REGADDR(PLL_MOD, CM_CLKEN),
562 .enable_mask = OMAP3430_EN_PERIPH_DPLL_MASK, 570 .enable_mask = OMAP3430_EN_PERIPH_DPLL_MASK,
563 .modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED), 571 .modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED),
@@ -580,6 +588,7 @@ static struct clk dpll4_ck = {
580 .dpll_data = &dpll4_dd, 588 .dpll_data = &dpll4_dd,
581 .flags = RATE_PROPAGATES, 589 .flags = RATE_PROPAGATES,
582 .round_rate = &omap2_dpll_round_rate, 590 .round_rate = &omap2_dpll_round_rate,
591 .set_rate = &omap3_dpll4_set_rate,
583 .recalc = &omap3_dpll_recalc, 592 .recalc = &omap3_dpll_recalc,
584}; 593};
585 594
@@ -864,6 +873,7 @@ static struct dpll_data dpll5_dd = {
864 .mult_div1_reg = OMAP_CM_REGADDR(PLL_MOD, OMAP3430ES2_CM_CLKSEL4), 873 .mult_div1_reg = OMAP_CM_REGADDR(PLL_MOD, OMAP3430ES2_CM_CLKSEL4),
865 .mult_mask = OMAP3430ES2_PERIPH2_DPLL_MULT_MASK, 874 .mult_mask = OMAP3430ES2_PERIPH2_DPLL_MULT_MASK,
866 .div1_mask = OMAP3430ES2_PERIPH2_DPLL_DIV_MASK, 875 .div1_mask = OMAP3430ES2_PERIPH2_DPLL_DIV_MASK,
876 .freqsel_mask = OMAP3430ES2_PERIPH2_DPLL_FREQSEL_MASK,
867 .control_reg = OMAP_CM_REGADDR(PLL_MOD, OMAP3430ES2_CM_CLKEN2), 877 .control_reg = OMAP_CM_REGADDR(PLL_MOD, OMAP3430ES2_CM_CLKEN2),
868 .enable_mask = OMAP3430ES2_EN_PERIPH2_DPLL_MASK, 878 .enable_mask = OMAP3430ES2_EN_PERIPH2_DPLL_MASK,
869 .modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED), 879 .modes = (1 << DPLL_LOW_POWER_STOP) | (1 << DPLL_LOCKED),
@@ -886,6 +896,7 @@ static struct clk dpll5_ck = {
886 .dpll_data = &dpll5_dd, 896 .dpll_data = &dpll5_dd,
887 .flags = RATE_PROPAGATES, 897 .flags = RATE_PROPAGATES,
888 .round_rate = &omap2_dpll_round_rate, 898 .round_rate = &omap2_dpll_round_rate,
899 .set_rate = &omap3_noncore_dpll_set_rate,
889 .recalc = &omap3_dpll_recalc, 900 .recalc = &omap3_dpll_recalc,
890}; 901};
891 902
diff --git a/arch/arm/plat-omap/include/mach/clock.h b/arch/arm/plat-omap/include/mach/clock.h
index 3895ba729792..f147aec91f12 100644
--- a/arch/arm/plat-omap/include/mach/clock.h
+++ b/arch/arm/plat-omap/include/mach/clock.h
@@ -53,6 +53,7 @@ struct dpll_data {
53 void __iomem *idlest_reg; 53 void __iomem *idlest_reg;
54 u32 enable_mask; 54 u32 enable_mask;
55 u32 autoidle_mask; 55 u32 autoidle_mask;
56 u32 freqsel_mask;
56 u8 auto_recal_bit; 57 u8 auto_recal_bit;
57 u8 recal_en_bit; 58 u8 recal_en_bit;
58 u8 recal_st_bit; 59 u8 recal_st_bit;