aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-omap2/memory.c')
-rw-r--r--arch/arm/mach-omap2/memory.c74
1 files changed, 63 insertions, 11 deletions
diff --git a/arch/arm/mach-omap2/memory.c b/arch/arm/mach-omap2/memory.c
index 3e5d8cd4ea4f..12479081881a 100644
--- a/arch/arm/mach-omap2/memory.c
+++ b/arch/arm/mach-omap2/memory.c
@@ -27,11 +27,16 @@
27#include <asm/arch/clock.h> 27#include <asm/arch/clock.h>
28#include <asm/arch/sram.h> 28#include <asm/arch/sram.h>
29 29
30#include "prcm-regs.h" 30#include "prm.h"
31
31#include "memory.h" 32#include "memory.h"
33#include "sdrc.h"
32 34
35unsigned long omap2_sdrc_base;
36unsigned long omap2_sms_base;
33 37
34static struct memory_timings mem_timings; 38static struct memory_timings mem_timings;
39static u32 curr_perf_level = CORE_CLK_SRC_DPLL_X2;
35 40
36u32 omap2_memory_get_slow_dll_ctrl(void) 41u32 omap2_memory_get_slow_dll_ctrl(void)
37{ 42{
@@ -48,12 +53,60 @@ u32 omap2_memory_get_type(void)
48 return mem_timings.m_type; 53 return mem_timings.m_type;
49} 54}
50 55
56/*
57 * Check the DLL lock state, and return tue if running in unlock mode.
58 * This is needed to compensate for the shifted DLL value in unlock mode.
59 */
60u32 omap2_dll_force_needed(void)
61{
62 /* dlla and dllb are a set */
63 u32 dll_state = sdrc_read_reg(SDRC_DLLA_CTRL);
64
65 if ((dll_state & (1 << 2)) == (1 << 2))
66 return 1;
67 else
68 return 0;
69}
70
71/*
72 * 'level' is the value to store to CM_CLKSEL2_PLL.CORE_CLK_SRC.
73 * Practical values are CORE_CLK_SRC_DPLL (for CORE_CLK = DPLL_CLK) or
74 * CORE_CLK_SRC_DPLL_X2 (for CORE_CLK = * DPLL_CLK * 2)
75 */
76u32 omap2_reprogram_sdrc(u32 level, u32 force)
77{
78 u32 dll_ctrl, m_type;
79 u32 prev = curr_perf_level;
80 unsigned long flags;
81
82 if ((curr_perf_level == level) && !force)
83 return prev;
84
85 if (level == CORE_CLK_SRC_DPLL) {
86 dll_ctrl = omap2_memory_get_slow_dll_ctrl();
87 } else if (level == CORE_CLK_SRC_DPLL_X2) {
88 dll_ctrl = omap2_memory_get_fast_dll_ctrl();
89 } else {
90 return prev;
91 }
92
93 m_type = omap2_memory_get_type();
94
95 local_irq_save(flags);
96 __raw_writel(0xffff, OMAP24XX_PRCM_VOLTSETUP);
97 omap2_sram_reprogram_sdrc(level, dll_ctrl, m_type);
98 curr_perf_level = level;
99 local_irq_restore(flags);
100
101 return prev;
102}
103
51void omap2_init_memory_params(u32 force_lock_to_unlock_mode) 104void omap2_init_memory_params(u32 force_lock_to_unlock_mode)
52{ 105{
53 unsigned long dll_cnt; 106 unsigned long dll_cnt;
54 u32 fast_dll = 0; 107 u32 fast_dll = 0;
55 108
56 mem_timings.m_type = !((SDRC_MR_0 & 0x3) == 0x1); /* DDR = 1, SDR = 0 */ 109 mem_timings.m_type = !((sdrc_read_reg(SDRC_MR_0) & 0x3) == 0x1); /* DDR = 1, SDR = 0 */
57 110
58 /* 2422 es2.05 and beyond has a single SIP DDR instead of 2 like others. 111 /* 2422 es2.05 and beyond has a single SIP DDR instead of 2 like others.
59 * In the case of 2422, its ok to use CS1 instead of CS0. 112 * In the case of 2422, its ok to use CS1 instead of CS0.
@@ -73,11 +126,11 @@ void omap2_init_memory_params(u32 force_lock_to_unlock_mode)
73 mem_timings.dll_mode = M_LOCK; 126 mem_timings.dll_mode = M_LOCK;
74 127
75 if (mem_timings.base_cs == 0) { 128 if (mem_timings.base_cs == 0) {
76 fast_dll = SDRC_DLLA_CTRL; 129 fast_dll = sdrc_read_reg(SDRC_DLLA_CTRL);
77 dll_cnt = SDRC_DLLA_STATUS & 0xff00; 130 dll_cnt = sdrc_read_reg(SDRC_DLLA_STATUS) & 0xff00;
78 } else { 131 } else {
79 fast_dll = SDRC_DLLB_CTRL; 132 fast_dll = sdrc_read_reg(SDRC_DLLB_CTRL);
80 dll_cnt = SDRC_DLLB_STATUS & 0xff00; 133 dll_cnt = sdrc_read_reg(SDRC_DLLB_STATUS) & 0xff00;
81 } 134 }
82 if (force_lock_to_unlock_mode) { 135 if (force_lock_to_unlock_mode) {
83 fast_dll &= ~0xff00; 136 fast_dll &= ~0xff00;
@@ -106,14 +159,13 @@ void __init omap2_init_memory(void)
106{ 159{
107 u32 l; 160 u32 l;
108 161
109 l = SMS_SYSCONFIG; 162 l = sms_read_reg(SMS_SYSCONFIG);
110 l &= ~(0x3 << 3); 163 l &= ~(0x3 << 3);
111 l |= (0x2 << 3); 164 l |= (0x2 << 3);
112 SMS_SYSCONFIG = l; 165 sms_write_reg(l, SMS_SYSCONFIG);
113 166
114 l = SDRC_SYSCONFIG; 167 l = sdrc_read_reg(SDRC_SYSCONFIG);
115 l &= ~(0x3 << 3); 168 l &= ~(0x3 << 3);
116 l |= (0x2 << 3); 169 l |= (0x2 << 3);
117 SDRC_SYSCONFIG = l; 170 sdrc_write_reg(l, SDRC_SYSCONFIG);
118
119} 171}