diff options
Diffstat (limited to 'arch/arm/mach-omap2/clock.c')
-rw-r--r-- | arch/arm/mach-omap2/clock.c | 79 |
1 files changed, 14 insertions, 65 deletions
diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c index 180f675c9064..72eb4bf571ac 100644 --- a/arch/arm/mach-omap2/clock.c +++ b/arch/arm/mach-omap2/clock.c | |||
@@ -28,14 +28,14 @@ | |||
28 | 28 | ||
29 | #include <asm/arch/clock.h> | 29 | #include <asm/arch/clock.h> |
30 | #include <asm/arch/sram.h> | 30 | #include <asm/arch/sram.h> |
31 | #include <asm/arch/prcm.h> | ||
32 | 31 | ||
32 | #include "prcm-regs.h" | ||
33 | #include "memory.h" | ||
33 | #include "clock.h" | 34 | #include "clock.h" |
34 | 35 | ||
35 | //#define DOWN_VARIABLE_DPLL 1 /* Experimental */ | 36 | //#define DOWN_VARIABLE_DPLL 1 /* Experimental */ |
36 | 37 | ||
37 | static struct prcm_config *curr_prcm_set; | 38 | static struct prcm_config *curr_prcm_set; |
38 | static struct memory_timings mem_timings; | ||
39 | static u32 curr_perf_level = PRCM_FULL_SPEED; | 39 | static u32 curr_perf_level = PRCM_FULL_SPEED; |
40 | 40 | ||
41 | /*------------------------------------------------------------------------- | 41 | /*------------------------------------------------------------------------- |
@@ -54,11 +54,13 @@ static void omap2_sys_clk_recalc(struct clk * clk) | |||
54 | 54 | ||
55 | static u32 omap2_get_dpll_rate(struct clk * tclk) | 55 | static u32 omap2_get_dpll_rate(struct clk * tclk) |
56 | { | 56 | { |
57 | int dpll_clk, dpll_mult, dpll_div, amult; | 57 | long long dpll_clk; |
58 | int dpll_mult, dpll_div, amult; | ||
58 | 59 | ||
59 | dpll_mult = (CM_CLKSEL1_PLL >> 12) & 0x03ff; /* 10 bits */ | 60 | dpll_mult = (CM_CLKSEL1_PLL >> 12) & 0x03ff; /* 10 bits */ |
60 | dpll_div = (CM_CLKSEL1_PLL >> 8) & 0x0f; /* 4 bits */ | 61 | dpll_div = (CM_CLKSEL1_PLL >> 8) & 0x0f; /* 4 bits */ |
61 | dpll_clk = (tclk->parent->rate * dpll_mult) / (dpll_div + 1); | 62 | dpll_clk = (long long)tclk->parent->rate * dpll_mult; |
63 | do_div(dpll_clk, dpll_div + 1); | ||
62 | amult = CM_CLKSEL2_PLL & 0x3; | 64 | amult = CM_CLKSEL2_PLL & 0x3; |
63 | dpll_clk *= amult; | 65 | dpll_clk *= amult; |
64 | 66 | ||
@@ -385,75 +387,23 @@ static u32 omap2_dll_force_needed(void) | |||
385 | return 0; | 387 | return 0; |
386 | } | 388 | } |
387 | 389 | ||
388 | static void omap2_init_memory_params(u32 force_lock_to_unlock_mode) | ||
389 | { | ||
390 | unsigned long dll_cnt; | ||
391 | u32 fast_dll = 0; | ||
392 | |||
393 | mem_timings.m_type = !((SDRC_MR_0 & 0x3) == 0x1); /* DDR = 1, SDR = 0 */ | ||
394 | |||
395 | /* 2422 es2.05 and beyond has a single SIP DDR instead of 2 like others. | ||
396 | * In the case of 2422, its ok to use CS1 instead of CS0. | ||
397 | */ | ||
398 | |||
399 | #if 0 /* FIXME: Enable after 24xx cpu detection works */ | ||
400 | ctype = get_cpu_type(); | ||
401 | if (cpu_is_omap2422()) | ||
402 | mem_timings.base_cs = 1; | ||
403 | else | ||
404 | #endif | ||
405 | mem_timings.base_cs = 0; | ||
406 | |||
407 | if (mem_timings.m_type != M_DDR) | ||
408 | return; | ||
409 | |||
410 | /* With DDR we need to determine the low frequency DLL value */ | ||
411 | if (((mem_timings.fast_dll_ctrl & (1 << 2)) == M_LOCK_CTRL)) | ||
412 | mem_timings.dll_mode = M_UNLOCK; | ||
413 | else | ||
414 | mem_timings.dll_mode = M_LOCK; | ||
415 | |||
416 | if (mem_timings.base_cs == 0) { | ||
417 | fast_dll = SDRC_DLLA_CTRL; | ||
418 | dll_cnt = SDRC_DLLA_STATUS & 0xff00; | ||
419 | } else { | ||
420 | fast_dll = SDRC_DLLB_CTRL; | ||
421 | dll_cnt = SDRC_DLLB_STATUS & 0xff00; | ||
422 | } | ||
423 | if (force_lock_to_unlock_mode) { | ||
424 | fast_dll &= ~0xff00; | ||
425 | fast_dll |= dll_cnt; /* Current lock mode */ | ||
426 | } | ||
427 | mem_timings.fast_dll_ctrl = fast_dll; | ||
428 | |||
429 | /* No disruptions, DDR will be offline & C-ABI not followed */ | ||
430 | omap2_sram_ddr_init(&mem_timings.slow_dll_ctrl, | ||
431 | mem_timings.fast_dll_ctrl, | ||
432 | mem_timings.base_cs, | ||
433 | force_lock_to_unlock_mode); | ||
434 | mem_timings.slow_dll_ctrl &= 0xff00; /* Keep lock value */ | ||
435 | |||
436 | /* Turn status into unlock ctrl */ | ||
437 | mem_timings.slow_dll_ctrl |= | ||
438 | ((mem_timings.fast_dll_ctrl & 0xF) | (1 << 2)); | ||
439 | |||
440 | /* 90 degree phase for anything below 133Mhz */ | ||
441 | mem_timings.slow_dll_ctrl |= (1 << 1); | ||
442 | } | ||
443 | |||
444 | static u32 omap2_reprogram_sdrc(u32 level, u32 force) | 390 | static u32 omap2_reprogram_sdrc(u32 level, u32 force) |
445 | { | 391 | { |
392 | u32 slow_dll_ctrl, fast_dll_ctrl, m_type; | ||
446 | u32 prev = curr_perf_level, flags; | 393 | u32 prev = curr_perf_level, flags; |
447 | 394 | ||
448 | if ((curr_perf_level == level) && !force) | 395 | if ((curr_perf_level == level) && !force) |
449 | return prev; | 396 | return prev; |
450 | 397 | ||
398 | m_type = omap2_memory_get_type(); | ||
399 | slow_dll_ctrl = omap2_memory_get_slow_dll_ctrl(); | ||
400 | fast_dll_ctrl = omap2_memory_get_fast_dll_ctrl(); | ||
401 | |||
451 | if (level == PRCM_HALF_SPEED) { | 402 | if (level == PRCM_HALF_SPEED) { |
452 | local_irq_save(flags); | 403 | local_irq_save(flags); |
453 | PRCM_VOLTSETUP = 0xffff; | 404 | PRCM_VOLTSETUP = 0xffff; |
454 | omap2_sram_reprogram_sdrc(PRCM_HALF_SPEED, | 405 | omap2_sram_reprogram_sdrc(PRCM_HALF_SPEED, |
455 | mem_timings.slow_dll_ctrl, | 406 | slow_dll_ctrl, m_type); |
456 | mem_timings.m_type); | ||
457 | curr_perf_level = PRCM_HALF_SPEED; | 407 | curr_perf_level = PRCM_HALF_SPEED; |
458 | local_irq_restore(flags); | 408 | local_irq_restore(flags); |
459 | } | 409 | } |
@@ -461,8 +411,7 @@ static u32 omap2_reprogram_sdrc(u32 level, u32 force) | |||
461 | local_irq_save(flags); | 411 | local_irq_save(flags); |
462 | PRCM_VOLTSETUP = 0xffff; | 412 | PRCM_VOLTSETUP = 0xffff; |
463 | omap2_sram_reprogram_sdrc(PRCM_FULL_SPEED, | 413 | omap2_sram_reprogram_sdrc(PRCM_FULL_SPEED, |
464 | mem_timings.fast_dll_ctrl, | 414 | fast_dll_ctrl, m_type); |
465 | mem_timings.m_type); | ||
466 | curr_perf_level = PRCM_FULL_SPEED; | 415 | curr_perf_level = PRCM_FULL_SPEED; |
467 | local_irq_restore(flags); | 416 | local_irq_restore(flags); |
468 | } | 417 | } |
@@ -650,7 +599,7 @@ static u32 omap2_get_clksel(u32 *div_sel, u32 *field_mask, | |||
650 | case 13: /* dss2 */ | 599 | case 13: /* dss2 */ |
651 | mask = 0x1; break; | 600 | mask = 0x1; break; |
652 | case 25: /* usb */ | 601 | case 25: /* usb */ |
653 | mask = 0xf; break; | 602 | mask = 0x7; break; |
654 | } | 603 | } |
655 | } | 604 | } |
656 | 605 | ||