TI tarball had execute permissions set on a number of source files -- change these...
[pandora-x-loader.git] / board / omap3evm / platform.S
1 /*
2  * Board specific setup info
3  *
4  * (C) Copyright 2004-2006
5  * Texas Instruments, <www.ti.com>
6  * Richard Woodruff <r-woodruff2@ti.com>
7  *
8  * See file CREDITS for list of people who contributed to this
9  * project.
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License as
13  * published by the Free Software Foundation; either version 2 of
14  * the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24  * MA 02111-1307 USA
25  */
26
27 #include <config.h>
28 #include <asm/arch/cpu.h>
29 #include <asm/arch/mem.h>
30 #include <asm/arch/clocks.h>
31
32 _TEXT_BASE:
33         .word   TEXT_BASE       /* sdram load addr from config.mk */
34
35 #if !defined(CFG_NAND_BOOT) && !defined(CFG_NAND_BOOT)
36 /**************************************************************************
37  * cpy_clk_code: relocates clock code into SRAM where its safer to execute
38  * R1 = SRAM destination address.
39  *************************************************************************/
40 .global cpy_clk_code
41  cpy_clk_code:
42         /* Copy DPLL code into SRAM */ 
43         adr     r0, go_to_speed         /* get addr of clock setting code */
44         mov     r2, #384                /* r2 size to copy (div by 32 bytes) */
45         mov     r1, r1                  /* r1 <- dest address (passed in) */
46         add     r2, r2, r0              /* r2 <- source end address */
47 next2:
48         ldmia   r0!, {r3-r10}           /* copy from source address [r0]    */
49         stmia   r1!, {r3-r10}           /* copy to   target address [r1]    */
50         cmp     r0, r2                  /* until source end address [r2]    */
51         bne     next2
52         mov     pc, lr                  /* back to caller */
53
54 /* **************************************************************************** 
55  * NOTE: 3430 X-loader currently does not use this code.  
56 *   It could be removed its is kept for compatabily with u-boot.
57  *
58  *  go_to_speed: -Moves to bypass, -Commits clock dividers, -puts dpll at speed
59  *               -executed from SRAM.
60  *  R0 = CM_CLKEN_PLL-bypass value
61  *  R1 = CM_CLKSEL1_PLL-m, n, and divider values
62  *  R2 = CM_CLKSEL_CORE-divider values
63  *  R3 = CM_IDLEST_CKGEN - addr dpll lock wait
64  *
65  *  Note: If core unlocks/relocks and SDRAM is running fast already it gets
66  *        confused.  A reset of the controller gets it back.  Taking away its
67  *        L3 when its not in self refresh seems bad for it.  Normally, this code
68  *        runs from flash before SDR is init so that should be ok.
69  ******************************************************************************/    
70 .global go_to_speed
71  go_to_speed:
72         stmfd sp!, {r4-r6}
73
74         /* move into fast relock bypass */
75         ldr     r4, pll_ctl_add
76         str     r0, [r4]
77 wait1:
78         ldr     r5, [r3]       /* get status */
79         and     r5, r5, #0x1   /* isolate core status */
80         cmp     r5, #0x1       /* still locked? */
81         beq     wait1          /* if lock, loop */
82
83         /* set new dpll dividers _after_ in bypass */
84         ldr     r5, pll_div_add1
85         str     r1, [r5]          /* set m, n, m2 */
86         ldr     r5, pll_div_add2
87         str     r2, [r5]          /* set l3/l4/.. dividers*/
88         ldr     r5, pll_div_add3  /* wkup */
89         ldr     r2, pll_div_val3  /* rsm val */
90         str     r2, [r5]          
91         ldr     r5, pll_div_add4  /* gfx */
92         ldr     r2, pll_div_val4 
93         str     r2, [r5]         
94         ldr     r5, pll_div_add5  /* emu */
95         ldr     r2, pll_div_val5 
96         str     r2, [r5]     
97
98         /* now prepare GPMC (flash) for new dpll speed */
99         /* flash needs to be stable when we jump back to it */
100         ldr     r5, flash_cfg3_addr
101         ldr     r2, flash_cfg3_val
102         str     r2, [r5]
103         ldr     r5, flash_cfg4_addr
104         ldr     r2, flash_cfg4_val
105         str     r2, [r5]
106         ldr     r5, flash_cfg5_addr
107         ldr     r2, flash_cfg5_val
108         str     r2, [r5]
109         ldr     r5, flash_cfg1_addr
110         ldr     r2, [r5]
111         orr     r2, r2, #0x3     /* up gpmc divider */
112         str     r2, [r5]
113
114         /* lock DPLL3 and wait a bit */
115         orr     r0, r0, #0x7   /* set up for lock mode */     
116         str     r0, [r4]       /* lock */
117         nop                    /* ARM slow at this point working at sys_clk */
118         nop
119         nop
120         nop
121 wait2:
122         ldr     r5, [r3]       /* get status */
123         and     r5, r5, #0x1   /* isolate core status */
124         cmp     r5, #0x1       /* still locked? */
125         bne     wait2          /* if lock, loop */
126         nop
127         nop
128         nop
129         nop
130         ldmfd sp!, {r4-r6}
131         mov     pc, lr           /* back to caller, locked */        
132
133 _go_to_speed: .word go_to_speed
134
135 /* these constants need to be close for PIC code */
136 /* The Nor has to be in the Flash Base CS0 for this condition to happen */
137 flash_cfg1_addr:
138     .word (GPMC_CONFIG_CS0 + GPMC_CONFIG1)
139 flash_cfg3_addr:
140     .word  (GPMC_CONFIG_CS0 + GPMC_CONFIG3)
141 flash_cfg3_val: 
142     .word  STNOR_GPMC_CONFIG3
143 flash_cfg4_addr:
144     .word (GPMC_CONFIG_CS0 + GPMC_CONFIG4)
145 flash_cfg4_val:
146     .word  STNOR_GPMC_CONFIG4
147 flash_cfg5_val:
148     .word  STNOR_GPMC_CONFIG5
149 flash_cfg5_addr:
150     .word (GPMC_CONFIG_CS0 + GPMC_CONFIG5)
151 pll_ctl_add:
152     .word CM_CLKEN_PLL
153 pll_div_add1:
154     .word CM_CLKSEL1_PLL 
155 pll_div_add2:
156     .word CM_CLKSEL_CORE
157 pll_div_add3:
158     .word CM_CLKSEL_WKUP
159 pll_div_val3:
160     .word (WKUP_RSM << 1) 
161 pll_div_add4:
162     .word CM_CLKSEL_GFX
163 pll_div_val4:
164     .word (GFX_DIV << 0) 
165 pll_div_add5:
166     .word CM_CLKSEL1_EMU
167 pll_div_val5:
168     .word CLSEL1_EMU_VAL
169
170 #endif
171
172 .globl lowlevel_init
173 lowlevel_init:
174         ldr     sp,     SRAM_STACK
175         str     ip,     [sp]    /* stash old link register */
176         mov     ip,     lr      /* save link reg across call */
177         bl      s_init          /* go setup pll,mux,memory */
178         ldr     ip,     [sp]    /* restore save ip */
179         mov     lr,     ip      /* restore link reg */
180
181         /* back to arch calling code */
182         mov     pc,     lr
183
184         /* the literal pools origin */
185         .ltorg
186
187 REG_CONTROL_STATUS:
188         .word CONTROL_STATUS
189 SRAM_STACK:
190         .word LOW_LEVEL_SRAM_STACK
191
192
193 /* DPLL(1-4) PARAM TABLES */
194 /* Each of the tables has M, N, FREQSEL, M2 values defined for nominal
195  * OPP (1.2V). The fields are defined according to dpll_param struct(clock.c). 
196  * The values are defined for all possible sysclk and for ES1 and ES2.
197  */
198
199 mpu_dpll_param:
200 /* 12MHz */
201 /* ES1 */
202 .word 0x0FE
203 .word 0x07
204 .word 0x05
205 .word 0x01
206 /* ES2 */
207 .word 0x0FA
208 .word 0x05
209 .word 0x07
210 .word 0x01
211
212 /* 13MHz */
213 /* ES1 */
214 .word 0x17D
215 .word 0x0C
216 .word 0x03
217 .word 0x01
218 /* ES2 */
219 .word 0x1F4
220 .word 0x0C
221 .word 0x03
222 .word 0x01
223  
224 /* 19.2MHz */
225 /* ES1 */
226 .word 0x179
227 .word 0x12
228 .word 0x04
229 .word 0x01
230 /* ES2 */
231 .word 0x271
232 .word 0x17
233 .word 0x03
234 .word 0x01
235
236 /* 26MHz */
237 /* ES1 */
238 .word 0x17D
239 .word 0x19
240 .word 0x03
241 .word 0x01
242 /* ES2 */
243 .word 0x0FA
244 .word 0x0C
245 .word 0x07
246 .word 0x01
247
248 /* 38.4MHz */
249 /* ES1 */
250 .word 0x1FA
251 .word 0x32
252 .word 0x03
253 .word 0x01
254 /* ES2 */
255 .word 0x271
256 .word 0x2F
257 .word 0x03
258 .word 0x01
259
260
261 .globl get_mpu_dpll_param
262 get_mpu_dpll_param:
263         adr r0, mpu_dpll_param
264         mov pc, lr
265
266 iva_dpll_param:
267 /* 12MHz */
268 /* ES1 */
269 .word 0x07D
270 .word 0x05
271 .word 0x07
272 .word 0x01
273 /* ES2 */
274 .word 0x0B4
275 .word 0x05
276 .word 0x07
277 .word 0x01
278
279 /* 13MHz */
280 /* ES1 */
281 .word 0x0FA
282 .word 0x0C
283 .word 0x03
284 .word 0x01
285 /* ES2 */
286 .word 0x168
287 .word 0x0C
288 .word 0x03
289 .word 0x01
290
291 /* 19.2MHz */
292 /* ES1 */
293 .word 0x082
294 .word 0x09
295 .word 0x07
296 .word 0x01
297 /* ES2 */
298 .word 0x0E1
299 .word 0x0B
300 .word 0x06
301 .word 0x01
302
303 /* 26MHz */
304 /* ES1 */
305 .word 0x07D
306 .word 0x0C
307 .word 0x07
308 .word 0x01
309 /* ES2 */
310 .word 0x0B4
311 .word 0x0C
312 .word 0x07
313 .word 0x01
314
315 /* 38.4MHz */
316 /* ES1 */
317 .word 0x13F
318 .word 0x30
319 .word 0x03
320 .word 0x01
321 /* ES2 */
322 .word 0x0E1
323 .word 0x17
324 .word 0x06
325 .word 0x01
326
327
328 .globl get_iva_dpll_param
329 get_iva_dpll_param:
330         adr r0, iva_dpll_param
331         mov pc, lr
332
333 core_dpll_param:
334 /* 12MHz */
335 /* ES1 */
336 .word 0x19F
337 .word 0x0E
338 .word 0x03
339 .word 0x01
340 /* ES2 */
341 .word 0x0A6
342 .word 0x05
343 .word 0x07
344 .word 0x01
345
346 /* 13MHz */
347 /* ES1 */
348 .word 0x1B2
349 .word 0x10
350 .word 0x03
351 .word 0x01
352 /* ES2 */
353 .word 0x14C
354 .word 0x0C
355 .word 0x03
356 .word 0x01
357
358 /* 19.2MHz */
359 /* ES1 */
360 .word 0x19F
361 .word 0x17
362 .word 0x03
363 .word 0x01
364 /* ES2 */
365 .word 0x19F
366 .word 0x17
367 .word 0x03
368 .word 0x01
369
370 /* 26MHz */
371 /* ES1 */
372 .word 0x1B2
373 .word 0x21
374 .word 0x03
375 .word 0x01
376 /* ES2 */
377 .word 0x0A6
378 .word 0x0C
379 .word 0x07
380 .word 0x01
381
382 /* 38.4MHz */
383 /* ES1 */
384 .word 0x19F
385 .word 0x2F
386 .word 0x03
387 .word 0x01
388 /* ES2 */
389 .word 0x19F
390 .word 0x2F
391 .word 0x03
392 .word 0x01
393
394 .globl get_core_dpll_param
395 get_core_dpll_param:
396         adr r0, core_dpll_param
397         mov pc, lr
398
399 /* PER DPLL values are same for both ES1 and ES2 */
400 per_dpll_param:
401 /* 12MHz */
402 .word 0xD8
403 .word 0x05
404 .word 0x07
405 .word 0x09
406
407 /* 13MHz */
408 .word 0x1B0
409 .word 0x0C
410 .word 0x03
411 .word 0x09
412
413 /* 19.2MHz */
414 .word 0xE1
415 .word 0x09
416 .word 0x07
417 .word 0x09
418
419 /* 26MHz */
420 .word 0xD8
421 .word 0x0C
422 .word 0x07
423 .word 0x09
424
425 /* 38.4MHz */
426 .word 0xE1
427 .word 0x13
428 .word 0x07
429 .word 0x09
430
431 .globl get_per_dpll_param
432 get_per_dpll_param:
433         adr r0, per_dpll_param
434         mov pc, lr
435