aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/sram242x.S
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2008-07-03 05:24:38 -0400
committerTony Lindgren <tony@atomide.com>2008-07-03 05:24:38 -0400
commit373a67021d00a8b8c86bfa19f8914377de05b4bd (patch)
treed4e3eb112070fce04e163fba46b81f5712719ee4 /arch/arm/mach-omap2/sram242x.S
parent99f143b316b056a86c8226c15882cc0718f0b3b0 (diff)
ARM: OMAP: SRAM: Move omap2 sram-fn.S to sram242x.S
This file will get split between sram242x.S and sram243x.S in following patch. Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap2/sram242x.S')
-rw-r--r--arch/arm/mach-omap2/sram242x.S324
1 files changed, 324 insertions, 0 deletions
diff --git a/arch/arm/mach-omap2/sram242x.S b/arch/arm/mach-omap2/sram242x.S
new file mode 100644
index 000000000000..4a9e49140716
--- /dev/null
+++ b/arch/arm/mach-omap2/sram242x.S
@@ -0,0 +1,324 @@
1/*
2 * linux/arch/arm/mach-omap2/sram-fn.S
3 *
4 * Omap2 specific functions that need to be run in internal SRAM
5 *
6 * (C) Copyright 2004
7 * Texas Instruments, <www.ti.com>
8 * Richard Woodruff <r-woodruff2@ti.com>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 * MA 02111-1307 USA
24 */
25#include <linux/linkage.h>
26#include <asm/assembler.h>
27#include <asm/arch/io.h>
28#include <asm/hardware.h>
29
30#include "sdrc.h"
31#include "prm.h"
32#include "cm.h"
33
34#define TIMER_32KSYNCT_CR_V IO_ADDRESS(OMAP2420_32KSYNCT_BASE + 0x010)
35
36 .text
37
38ENTRY(sram_ddr_init)
39 stmfd sp!, {r0 - r12, lr} @ save registers on stack
40
41 mov r12, r2 @ capture CS1 vs CS0
42 mov r8, r3 @ capture force parameter
43
44 /* frequency shift down */
45 ldr r2, cm_clksel2_pll @ get address of dpllout reg
46 mov r3, #0x1 @ value for 1x operation
47 str r3, [r2] @ go to L1-freq operation
48
49 /* voltage shift down */
50 mov r9, #0x1 @ set up for L1 voltage call
51 bl voltage_shift @ go drop voltage
52
53 /* dll lock mode */
54 ldr r11, sdrc_dlla_ctrl @ addr of dlla ctrl
55 ldr r10, [r11] @ get current val
56 cmp r12, #0x1 @ cs1 base (2422 es2.05/1)
57 addeq r11, r11, #0x8 @ if cs1 base, move to DLLB
58 mvn r9, #0x4 @ mask to get clear bit2
59 and r10, r10, r9 @ clear bit2 for lock mode.
60 orr r10, r10, #0x8 @ make sure DLL on (es2 bit pos)
61 orr r10, r10, #0x2 @ 90 degree phase for all below 133Mhz
62 str r10, [r11] @ commit to DLLA_CTRL
63 bl i_dll_wait @ wait for dll to lock
64
65 /* get dll value */
66 add r11, r11, #0x4 @ get addr of status reg
67 ldr r10, [r11] @ get locked value
68
69 /* voltage shift up */
70 mov r9, #0x0 @ shift back to L0-voltage
71 bl voltage_shift @ go raise voltage
72
73 /* frequency shift up */
74 mov r3, #0x2 @ value for 2x operation
75 str r3, [r2] @ go to L0-freq operation
76
77 /* reset entry mode for dllctrl */
78 sub r11, r11, #0x4 @ move from status to ctrl
79 cmp r12, #0x1 @ normalize if cs1 based
80 subeq r11, r11, #0x8 @ possibly back to DLLA
81 cmp r8, #0x1 @ if forced unlock exit
82 orreq r1, r1, #0x4 @ make sure exit with unlocked value
83 str r1, [r11] @ restore DLLA_CTRL high value
84 add r11, r11, #0x8 @ move to DLLB_CTRL addr
85 str r1, [r11] @ set value DLLB_CTRL
86 bl i_dll_wait @ wait for possible lock
87
88 /* set up for return, DDR should be good */
89 str r10, [r0] @ write dll_status and return counter
90 ldmfd sp!, {r0 - r12, pc} @ restore regs and return
91
92 /* ensure the DLL has relocked */
93i_dll_wait:
94 mov r4, #0x800 @ delay DLL relock, min 0x400 L3 clocks
95i_dll_delay:
96 subs r4, r4, #0x1
97 bne i_dll_delay
98 mov pc, lr
99
100 /*
101 * shift up or down voltage, use R9 as input to tell level.
102 * wait for it to finish, use 32k sync counter, 1tick=31uS.
103 */
104voltage_shift:
105 ldr r4, prcm_voltctrl @ get addr of volt ctrl.
106 ldr r5, [r4] @ get value.
107 ldr r6, prcm_mask_val @ get value of mask
108 and r5, r5, r6 @ apply mask to clear bits
109 orr r5, r5, r9 @ bulld value for L0/L1-volt operation.
110 str r5, [r4] @ set up for change.
111 mov r3, #0x4000 @ get val for force
112 orr r5, r5, r3 @ build value for force
113 str r5, [r4] @ Force transition to L1
114
115 ldr r3, timer_32ksynct_cr @ get addr of counter
116 ldr r5, [r3] @ get value
117 add r5, r5, #0x3 @ give it at most 93uS
118volt_delay:
119 ldr r7, [r3] @ get timer value
120 cmp r5, r7 @ time up?
121 bhi volt_delay @ not yet->branch
122 mov pc, lr @ back to caller.
123
124/* relative load constants */
125cm_clksel2_pll:
126 .word OMAP2420_CM_REGADDR(PLL_MOD, CM_CLKSEL2)
127sdrc_dlla_ctrl:
128 .word OMAP242X_SDRC_REGADDR(SDRC_DLLA_CTRL)
129prcm_voltctrl:
130 .word OMAP2420_PRM_REGADDR(OCP_MOD, 0x50)
131prcm_mask_val:
132 .word 0xFFFF3FFC
133timer_32ksynct_cr:
134 .word TIMER_32KSYNCT_CR_V
135ENTRY(sram_ddr_init_sz)
136 .word . - sram_ddr_init
137
138/*
139 * Reprograms memory timings.
140 * r0 = [PRCM_FULL | PRCM_HALF] r1 = SDRC_DLLA_CTRL value r2 = [DDR | SDR]
141 * PRCM_FULL = 2, PRCM_HALF = 1, DDR = 1, SDR = 0
142 */
143ENTRY(sram_reprogram_sdrc)
144 stmfd sp!, {r0 - r10, lr} @ save registers on stack
145 mov r3, #0x0 @ clear for mrc call
146 mcr p15, 0, r3, c7, c10, 4 @ memory barrier, finish ARM SDR/DDR
147 nop
148 nop
149 ldr r6, ddr_sdrc_rfr_ctrl @ get addr of refresh reg
150 ldr r5, [r6] @ get value
151 mov r5, r5, lsr #8 @ isolate rfr field and drop burst
152
153 cmp r0, #0x1 @ going to half speed?
154 movne r9, #0x0 @ if up set flag up for pre up, hi volt
155
156 blne voltage_shift_c @ adjust voltage
157
158 cmp r0, #0x1 @ going to half speed (post branch link)
159 moveq r5, r5, lsr #1 @ divide by 2 if to half
160 movne r5, r5, lsl #1 @ mult by 2 if to full
161 mov r5, r5, lsl #8 @ put rfr field back into place
162 add r5, r5, #0x1 @ turn on burst of 1
163 ldr r4, ddr_cm_clksel2_pll @ get address of out reg
164 ldr r3, [r4] @ get curr value
165 orr r3, r3, #0x3
166 bic r3, r3, #0x3 @ clear lower bits
167 orr r3, r3, r0 @ new state value
168 str r3, [r4] @ set new state (pll/x, x=1 or 2)
169 nop
170 nop
171
172 moveq r9, #0x1 @ if speed down, post down, drop volt
173 bleq voltage_shift_c
174
175 mcr p15, 0, r3, c7, c10, 4 @ memory barrier
176 str r5, [r6] @ set new RFR_1 value
177 add r6, r6, #0x30 @ get RFR_2 addr
178 str r5, [r6] @ set RFR_2
179 nop
180 cmp r2, #0x1 @ (SDR or DDR) do we need to adjust DLL
181 bne freq_out @ leave if SDR, no DLL function
182
183 /* With DDR, we need to take care of the DLL for the frequency change */
184 ldr r2, ddr_sdrc_dlla_ctrl @ addr of dlla ctrl
185 str r1, [r2] @ write out new SDRC_DLLA_CTRL
186 add r2, r2, #0x8 @ addr to SDRC_DLLB_CTRL
187 str r1, [r2] @ commit to SDRC_DLLB_CTRL
188 mov r1, #0x2000 @ wait DLL relock, min 0x400 L3 clocks
189dll_wait:
190 subs r1, r1, #0x1
191 bne dll_wait
192freq_out:
193 ldmfd sp!, {r0 - r10, pc} @ restore regs and return
194
195 /*
196 * shift up or down voltage, use R9 as input to tell level.
197 * wait for it to finish, use 32k sync counter, 1tick=31uS.
198 */
199voltage_shift_c:
200 ldr r10, ddr_prcm_voltctrl @ get addr of volt ctrl
201 ldr r8, [r10] @ get value
202 ldr r7, ddr_prcm_mask_val @ get value of mask
203 and r8, r8, r7 @ apply mask to clear bits
204 orr r8, r8, r9 @ bulld value for L0/L1-volt operation.
205 str r8, [r10] @ set up for change.
206 mov r7, #0x4000 @ get val for force
207 orr r8, r8, r7 @ build value for force
208 str r8, [r10] @ Force transition to L1
209
210 ldr r10, ddr_timer_32ksynct @ get addr of counter
211 ldr r8, [r10] @ get value
212 add r8, r8, #0x2 @ give it at most 62uS (min 31+)
213volt_delay_c:
214 ldr r7, [r10] @ get timer value
215 cmp r8, r7 @ time up?
216 bhi volt_delay_c @ not yet->branch
217 mov pc, lr @ back to caller
218
219ddr_cm_clksel2_pll:
220 .word OMAP2420_CM_REGADDR(PLL_MOD, CM_CLKSEL2)
221ddr_sdrc_dlla_ctrl:
222 .word OMAP242X_SDRC_REGADDR(SDRC_DLLA_CTRL)
223ddr_sdrc_rfr_ctrl:
224 .word OMAP242X_SDRC_REGADDR(SDRC_RFR_CTRL_0)
225ddr_prcm_voltctrl:
226 .word OMAP2420_PRM_REGADDR(OCP_MOD, 0x50)
227ddr_prcm_mask_val:
228 .word 0xFFFF3FFC
229ddr_timer_32ksynct:
230 .word TIMER_32KSYNCT_CR_V
231
232ENTRY(sram_reprogram_sdrc_sz)
233 .word . - sram_reprogram_sdrc
234
235/*
236 * Set dividers and pll. Also recalculate DLL value for DDR and unlock mode.
237 */
238ENTRY(sram_set_prcm)
239 stmfd sp!, {r0-r12, lr} @ regs to stack
240 adr r4, pbegin @ addr of preload start
241 adr r8, pend @ addr of preload end
242 mcrr p15, 1, r8, r4, c12 @ preload into icache
243pbegin:
244 /* move into fast relock bypass */
245 ldr r8, pll_ctl @ get addr
246 ldr r5, [r8] @ get val
247 mvn r6, #0x3 @ clear mask
248 and r5, r5, r6 @ clear field
249 orr r7, r5, #0x2 @ fast relock val
250 str r7, [r8] @ go to fast relock
251 ldr r4, pll_stat @ addr of stat
252block:
253 /* wait for bypass */
254 ldr r8, [r4] @ stat value
255 and r8, r8, #0x3 @ mask for stat
256 cmp r8, #0x1 @ there yet
257 bne block @ loop if not
258
259 /* set new dpll dividers _after_ in bypass */
260 ldr r4, pll_div @ get addr
261 str r0, [r4] @ set dpll ctrl val
262
263 ldr r4, set_config @ get addr
264 mov r8, #1 @ valid cfg msk
265 str r8, [r4] @ make dividers take
266
267 mov r4, #100 @ dead spin a bit
268wait_a_bit:
269 subs r4, r4, #1 @ dec loop
270 bne wait_a_bit @ delay done?
271
272 /* check if staying in bypass */
273 cmp r2, #0x1 @ stay in bypass?
274 beq pend @ jump over dpll relock
275
276 /* relock DPLL with new vals */
277 ldr r5, pll_stat @ get addr
278 ldr r4, pll_ctl @ get addr
279 orr r8, r7, #0x3 @ val for lock dpll
280 str r8, [r4] @ set val
281 mov r0, #1000 @ dead spin a bit
282wait_more:
283 subs r0, r0, #1 @ dec loop
284 bne wait_more @ delay done?
285wait_lock:
286 ldr r8, [r5] @ get lock val
287 and r8, r8, #3 @ isolate field
288 cmp r8, #2 @ locked?
289 bne wait_lock @ wait if not
290pend:
291 /* update memory timings & briefly lock dll */
292 ldr r4, sdrc_rfr @ get addr
293 str r1, [r4] @ update refresh timing
294 ldr r11, dlla_ctrl @ get addr of DLLA ctrl
295 ldr r10, [r11] @ get current val
296 mvn r9, #0x4 @ mask to get clear bit2
297 and r10, r10, r9 @ clear bit2 for lock mode
298 orr r10, r10, #0x8 @ make sure DLL on (es2 bit pos)
299 str r10, [r11] @ commit to DLLA_CTRL
300 add r11, r11, #0x8 @ move to dllb
301 str r10, [r11] @ hit DLLB also
302
303 mov r4, #0x800 @ relock time (min 0x400 L3 clocks)
304wait_dll_lock:
305 subs r4, r4, #0x1
306 bne wait_dll_lock
307 nop
308 ldmfd sp!, {r0-r12, pc} @ restore regs and return
309
310set_config:
311 .word OMAP2420_PRM_REGADDR(OCP_MOD, 0x80)
312pll_ctl:
313 .word OMAP2420_CM_REGADDR(PLL_MOD, CM_FCLKEN1)
314pll_stat:
315 .word OMAP2420_CM_REGADDR(PLL_MOD, CM_IDLEST1)
316pll_div:
317 .word OMAP2420_CM_REGADDR(PLL_MOD, CM_CLKSEL)
318sdrc_rfr:
319 .word OMAP242X_SDRC_REGADDR(SDRC_RFR_CTRL_0)
320dlla_ctrl:
321 .word OMAP242X_SDRC_REGADDR(SDRC_DLLA_CTRL)
322
323ENTRY(sram_set_prcm_sz)
324 .word . - sram_set_prcm