]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/cpu/armv7/omap3/lowlevel_init.S
start.S: remove omap3 specific code from start.S
[karo-tx-uboot.git] / arch / arm / cpu / armv7 / omap3 / lowlevel_init.S
1 /*
2  * Board specific setup info
3  *
4  * (C) Copyright 2008
5  * Texas Instruments, <www.ti.com>
6  *
7  * Initial Code by:
8  * Richard Woodruff <r-woodruff2@ti.com>
9  * Syed Mohammed Khasim <khasim@ti.com>
10  *
11  * See file CREDITS for list of people who contributed to this
12  * project.
13  *
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License as
16  * published by the Free Software Foundation; either version 2 of
17  * the License, or (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27  * MA 02111-1307 USA
28  */
29
30 #include <config.h>
31 #include <version.h>
32 #include <asm/arch/mem.h>
33 #include <asm/arch/clocks_omap3.h>
34
35 _TEXT_BASE:
36         .word   CONFIG_SYS_TEXT_BASE    /* sdram load addr from config.mk */
37
38 .global save_boot_params
39 save_boot_params:
40 #ifdef CONFIG_SPL_BUILD
41         ldr     r4, =omap3_boot_device
42         ldr     r5, [r0, #0x4]
43         and     r5, r5, #0xff
44         str     r5, [r4]
45 #endif
46         bx      lr
47
48 .global omap3_gp_romcode_call
49 omap3_gp_romcode_call:
50         PUSH {r4-r12, lr} @ Save all registers from ROM code!
51         MOV r12, r0     @ Copy the Service ID in R12
52         MOV r0, r1      @ Copy parameter to R0
53         mcr     p15, 0, r0, c7, c10, 4  @ DSB
54         mcr     p15, 0, r0, c7, c10, 5  @ DMB
55         .word   0xe1600070      @ SMC #0 to enter monitor - hand assembled
56                                 @ because we use -march=armv5
57         POP {r4-r12, pc}
58
59 /*
60  * Funtion for making PPA HAL API calls in secure devices
61  * Input:
62  *      R0 - Service ID
63  *      R1 - paramer list
64  */
65 .global do_omap3_emu_romcode_call
66 do_omap3_emu_romcode_call:
67         PUSH {r4-r12, lr} @ Save all registers from ROM code!
68         MOV r12, r0     @ Copy the Secure Service ID in R12
69         MOV r3, r1      @ Copy the pointer to va_list in R3
70         MOV r1, #0      @ Process ID - 0
71         MOV r2, #OMAP3_EMU_HAL_START_HAL_CRITICAL       @ Copy the pointer
72                                                         @ to va_list in R3
73         MOV r6, #0xFF   @ Indicate new Task call
74         mcr     p15, 0, r0, c7, c10, 4  @ DSB
75         mcr     p15, 0, r0, c7, c10, 5  @ DMB
76         .word   0xe1600071      @ SMC #1 to call PPA service - hand assembled
77                                 @ because we use -march=armv5
78         POP {r4-r12, pc}
79
80 #if !defined(CONFIG_SYS_NAND_BOOT) && !defined(CONFIG_SYS_NAND_BOOT)
81 /**************************************************************************
82  * cpy_clk_code: relocates clock code into SRAM where its safer to execute
83  * R1 = SRAM destination address.
84  *************************************************************************/
85 .global cpy_clk_code
86  cpy_clk_code:
87         /* Copy DPLL code into SRAM */
88         adr     r0, go_to_speed         /* get addr of clock setting code */
89         mov     r2, #384                /* r2 size to copy (div by 32 bytes) */
90         mov     r1, r1                  /* r1 <- dest address (passed in) */
91         add     r2, r2, r0              /* r2 <- source end address */
92 next2:
93         ldmia   r0!, {r3 - r10}         /* copy from source address [r0] */
94         stmia   r1!, {r3 - r10}         /* copy to   target address [r1] */
95         cmp     r0, r2                  /* until source end address [r2] */
96         bne     next2
97         mov     pc, lr                  /* back to caller */
98
99 /* ***************************************************************************
100  *  go_to_speed: -Moves to bypass, -Commits clock dividers, -puts dpll at speed
101  *               -executed from SRAM.
102  *  R0 = CM_CLKEN_PLL-bypass value
103  *  R1 = CM_CLKSEL1_PLL-m, n, and divider values
104  *  R2 = CM_CLKSEL_CORE-divider values
105  *  R3 = CM_IDLEST_CKGEN - addr dpll lock wait
106  *
107  *  Note: If core unlocks/relocks and SDRAM is running fast already it gets
108  *        confused.  A reset of the controller gets it back.  Taking away its
109  *        L3 when its not in self refresh seems bad for it.  Normally, this
110  *        code runs from flash before SDR is init so that should be ok.
111  ****************************************************************************/
112 .global go_to_speed
113  go_to_speed:
114         stmfd sp!, {r4 - r6}
115
116         /* move into fast relock bypass */
117         ldr     r4, pll_ctl_add
118         str     r0, [r4]
119 wait1:
120         ldr     r5, [r3]                /* get status */
121         and     r5, r5, #0x1            /* isolate core status */
122         cmp     r5, #0x1                /* still locked? */
123         beq     wait1                   /* if lock, loop */
124
125         /* set new dpll dividers _after_ in bypass */
126         ldr     r5, pll_div_add1
127         str     r1, [r5]                /* set m, n, m2 */
128         ldr     r5, pll_div_add2
129         str     r2, [r5]                /* set l3/l4/.. dividers*/
130         ldr     r5, pll_div_add3        /* wkup */
131         ldr     r2, pll_div_val3        /* rsm val */
132         str     r2, [r5]
133         ldr     r5, pll_div_add4        /* gfx */
134         ldr     r2, pll_div_val4
135         str     r2, [r5]
136         ldr     r5, pll_div_add5        /* emu */
137         ldr     r2, pll_div_val5
138         str     r2, [r5]
139
140         /* now prepare GPMC (flash) for new dpll speed */
141         /* flash needs to be stable when we jump back to it */
142         ldr     r5, flash_cfg3_addr
143         ldr     r2, flash_cfg3_val
144         str     r2, [r5]
145         ldr     r5, flash_cfg4_addr
146         ldr     r2, flash_cfg4_val
147         str     r2, [r5]
148         ldr     r5, flash_cfg5_addr
149         ldr     r2, flash_cfg5_val
150         str     r2, [r5]
151         ldr     r5, flash_cfg1_addr
152         ldr     r2, [r5]
153         orr     r2, r2, #0x3            /* up gpmc divider */
154         str     r2, [r5]
155
156         /* lock DPLL3 and wait a bit */
157         orr     r0, r0, #0x7    /* set up for lock mode */
158         str     r0, [r4]        /* lock */
159         nop                     /* ARM slow at this point working at sys_clk */
160         nop
161         nop
162         nop
163 wait2:
164         ldr     r5, [r3]        /* get status */
165         and     r5, r5, #0x1    /* isolate core status */
166         cmp     r5, #0x1        /* still locked? */
167         bne     wait2           /* if lock, loop */
168         nop
169         nop
170         nop
171         nop
172         ldmfd   sp!, {r4 - r6}
173         mov     pc, lr          /* back to caller, locked */
174
175 _go_to_speed: .word go_to_speed
176
177 /* these constants need to be close for PIC code */
178 /* The Nor has to be in the Flash Base CS0 for this condition to happen */
179 flash_cfg1_addr:
180         .word (GPMC_CONFIG_CS0_BASE + GPMC_CONFIG1)
181 flash_cfg3_addr:
182         .word (GPMC_CONFIG_CS0_BASE + GPMC_CONFIG3)
183 flash_cfg3_val:
184         .word STNOR_GPMC_CONFIG3
185 flash_cfg4_addr:
186         .word (GPMC_CONFIG_CS0_BASE + GPMC_CONFIG4)
187 flash_cfg4_val:
188         .word STNOR_GPMC_CONFIG4
189 flash_cfg5_val:
190         .word STNOR_GPMC_CONFIG5
191 flash_cfg5_addr:
192         .word (GPMC_CONFIG_CS0_BASE + GPMC_CONFIG5)
193 pll_ctl_add:
194         .word CM_CLKEN_PLL
195 pll_div_add1:
196         .word CM_CLKSEL1_PLL
197 pll_div_add2:
198         .word CM_CLKSEL_CORE
199 pll_div_add3:
200         .word CM_CLKSEL_WKUP
201 pll_div_val3:
202         .word (WKUP_RSM << 1)
203 pll_div_add4:
204         .word CM_CLKSEL_GFX
205 pll_div_val4:
206         .word (GFX_DIV << 0)
207 pll_div_add5:
208         .word CM_CLKSEL1_EMU
209 pll_div_val5:
210         .word CLSEL1_EMU_VAL
211
212 #endif
213
214 .globl lowlevel_init
215 lowlevel_init:
216         ldr     sp, SRAM_STACK
217         str     ip, [sp]        /* stash old link register */
218         mov     ip, lr          /* save link reg across call */
219 #if !defined(CONFIG_SYS_NAND_BOOT) && !defined(CONFIG_SYS_ONENAND_BOOT)
220 /*
221  * No need to copy/exec the clock code - DPLL adjust already done
222  * in NAND/oneNAND Boot.
223  */
224         ldr     r1, =SRAM_CLK_CODE
225         bl      cpy_clk_code
226 #endif /* NAND Boot */
227         bl      s_init          /* go setup pll, mux, memory */
228         ldr     ip, [sp]        /* restore save ip */
229         mov     lr, ip          /* restore link reg */
230
231         /* back to arch calling code */
232         mov     pc, lr
233
234         /* the literal pools origin */
235         .ltorg
236
237 REG_CONTROL_STATUS:
238         .word CONTROL_STATUS
239 SRAM_STACK:
240         .word LOW_LEVEL_SRAM_STACK
241
242 /* DPLL(1-4) PARAM TABLES */
243
244 /*
245  * Each of the tables has M, N, FREQSEL, M2 values defined for nominal
246  * OPP (1.2V). The fields are defined according to dpll_param struct (clock.c).
247  * The values are defined for all possible sysclk and for ES1 and ES2.
248  */
249
250 mpu_dpll_param:
251 /* 12MHz */
252 /* ES1 */
253 .word MPU_M_12_ES1, MPU_N_12_ES1, MPU_FSEL_12_ES1, MPU_M2_12_ES1
254 /* ES2 */
255 .word MPU_M_12_ES2, MPU_N_12_ES2, MPU_FSEL_12_ES2, MPU_M2_ES2
256 /* 3410 */
257 .word MPU_M_12, MPU_N_12, MPU_FSEL_12, MPU_M2_12
258
259 /* 13MHz */
260 /* ES1 */
261 .word MPU_M_13_ES1, MPU_N_13_ES1, MPU_FSEL_13_ES1, MPU_M2_13_ES1
262 /* ES2 */
263 .word MPU_M_13_ES2, MPU_N_13_ES2, MPU_FSEL_13_ES2, MPU_M2_13_ES2
264 /* 3410 */
265 .word MPU_M_13, MPU_N_13, MPU_FSEL_13, MPU_M2_13
266
267 /* 19.2MHz */
268 /* ES1 */
269 .word MPU_M_19P2_ES1, MPU_N_19P2_ES1, MPU_FSEL_19P2_ES1, MPU_M2_19P2_ES1
270 /* ES2 */
271 .word MPU_M_19P2_ES2, MPU_N_19P2_ES2, MPU_FSEL_19P2_ES2, MPU_M2_19P2_ES2
272 /* 3410 */
273 .word MPU_M_19P2, MPU_N_19P2, MPU_FSEL_19P2, MPU_M2_19P2
274
275 /* 26MHz */
276 /* ES1 */
277 .word MPU_M_26_ES1, MPU_N_26_ES1, MPU_FSEL_26_ES1, MPU_M2_26_ES1
278 /* ES2 */
279 .word MPU_M_26_ES2, MPU_N_26_ES2, MPU_FSEL_26_ES2, MPU_M2_26_ES2
280 /* 3410 */
281 .word MPU_M_26, MPU_N_26, MPU_FSEL_26, MPU_M2_26
282
283 /* 38.4MHz */
284 /* ES1 */
285 .word MPU_M_38P4_ES1, MPU_N_38P4_ES1, MPU_FSEL_38P4_ES1, MPU_M2_38P4_ES1
286 /* ES2 */
287 .word MPU_M_38P4_ES2, MPU_N_38P4_ES2, MPU_FSEL_38P4_ES2, MPU_M2_38P4_ES2
288 /* 3410 */
289 .word MPU_M_38P4, MPU_N_38P4, MPU_FSEL_38P4, MPU_M2_38P4
290
291
292 .globl get_mpu_dpll_param
293 get_mpu_dpll_param:
294         adr     r0, mpu_dpll_param
295         mov     pc, lr
296
297 iva_dpll_param:
298 /* 12MHz */
299 /* ES1 */
300 .word IVA_M_12_ES1, IVA_N_12_ES1, IVA_FSEL_12_ES1, IVA_M2_12_ES1
301 /* ES2 */
302 .word IVA_M_12_ES2, IVA_N_12_ES2, IVA_FSEL_12_ES2, IVA_M2_12_ES2
303 /* 3410 */
304 .word IVA_M_12, IVA_N_12, IVA_FSEL_12, IVA_M2_12
305
306 /* 13MHz */
307 /* ES1 */
308 .word IVA_M_13_ES1, IVA_N_13_ES1, IVA_FSEL_13_ES1, IVA_M2_13_ES1
309 /* ES2 */
310 .word IVA_M_13_ES2, IVA_N_13_ES2,  IVA_FSEL_13_ES2, IVA_M2_13_ES2
311 /* 3410 */
312 .word IVA_M_13, IVA_N_13, IVA_FSEL_13, IVA_M2_13
313
314 /* 19.2MHz */
315 /* ES1 */
316 .word IVA_M_19P2_ES1, IVA_N_19P2_ES1, IVA_FSEL_19P2_ES1, IVA_M2_19P2_ES1
317 /* ES2 */
318 .word IVA_M_19P2_ES2, IVA_N_19P2_ES2, IVA_FSEL_19P2_ES2, IVA_M2_19P2_ES2
319 /* 3410 */
320 .word IVA_M_19P2, IVA_N_19P2, IVA_FSEL_19P2, IVA_M2_19P2
321
322 /* 26MHz */
323 /* ES1 */
324 .word IVA_M_26_ES1, IVA_N_26_ES1, IVA_FSEL_26_ES1, IVA_M2_26_ES1
325 /* ES2 */
326 .word IVA_M_26_ES2, IVA_N_26_ES2, IVA_FSEL_26_ES2, IVA_M2_26_ES2
327 /* 3410 */
328 .word IVA_M_26, IVA_N_26, IVA_FSEL_26, IVA_M2_26
329
330 /* 38.4MHz */
331 /* ES1 */
332 .word IVA_M_38P4_ES1, IVA_N_38P4_ES1, IVA_FSEL_38P4_ES1, IVA_M2_38P4_ES1
333 /* ES2 */
334 .word IVA_M_38P4_ES2, IVA_N_38P4_ES2, IVA_FSEL_38P4_ES2, IVA_M2_38P4_ES2
335 /* 3410 */
336 .word IVA_M_38P4, IVA_N_38P4, IVA_FSEL_38P4, IVA_M2_38P4
337
338
339 .globl get_iva_dpll_param
340 get_iva_dpll_param:
341         adr     r0, iva_dpll_param
342         mov     pc, lr
343
344 /* Core DPLL targets for L3 at 166 & L133 */
345 core_dpll_param:
346 /* 12MHz */
347 /* ES1 */
348 .word CORE_M_12_ES1, CORE_N_12_ES1, CORE_FSL_12_ES1, CORE_M2_12_ES1
349 /* ES2 */
350 .word CORE_M_12, CORE_N_12, CORE_FSEL_12, CORE_M2_12
351 /* 3410 */
352 .word CORE_M_12, CORE_N_12, CORE_FSEL_12, CORE_M2_12
353
354 /* 13MHz */
355 /* ES1 */
356 .word CORE_M_13_ES1, CORE_N_13_ES1, CORE_FSL_13_ES1, CORE_M2_13_ES1
357 /* ES2 */
358 .word CORE_M_13, CORE_N_13, CORE_FSEL_13, CORE_M2_13
359 /* 3410 */
360 .word CORE_M_13, CORE_N_13, CORE_FSEL_13, CORE_M2_13
361
362 /* 19.2MHz */
363 /* ES1 */
364 .word CORE_M_19P2_ES1, CORE_N_19P2_ES1, CORE_FSL_19P2_ES1, CORE_M2_19P2_ES1
365 /* ES2 */
366 .word CORE_M_19P2, CORE_N_19P2, CORE_FSEL_19P2, CORE_M2_19P2
367 /* 3410 */
368 .word CORE_M_19P2, CORE_N_19P2, CORE_FSEL_19P2, CORE_M2_19P2
369
370 /* 26MHz */
371 /* ES1 */
372 .word CORE_M_26_ES1, CORE_N_26_ES1, CORE_FSL_26_ES1, CORE_M2_26_ES1
373 /* ES2 */
374 .word CORE_M_26, CORE_N_26, CORE_FSEL_26, CORE_M2_26
375 /* 3410 */
376 .word CORE_M_26, CORE_N_26, CORE_FSEL_26, CORE_M2_26
377
378 /* 38.4MHz */
379 /* ES1 */
380 .word CORE_M_38P4_ES1, CORE_N_38P4_ES1, CORE_FSL_38P4_ES1, CORE_M2_38P4_ES1
381 /* ES2 */
382 .word CORE_M_38P4, CORE_N_38P4, CORE_FSEL_38P4, CORE_M2_38P4
383 /* 3410 */
384 .word CORE_M_38P4, CORE_N_38P4, CORE_FSEL_38P4, CORE_M2_38P4
385
386 .globl get_core_dpll_param
387 get_core_dpll_param:
388         adr     r0, core_dpll_param
389         mov     pc, lr
390
391 /* PER DPLL values are same for both ES1 and ES2 */
392 per_dpll_param:
393 /* 12MHz */
394 .word PER_M_12, PER_N_12, PER_FSEL_12, PER_M2_12
395
396 /* 13MHz */
397 .word PER_M_13, PER_N_13, PER_FSEL_13, PER_M2_13
398
399 /* 19.2MHz */
400 .word PER_M_19P2, PER_N_19P2, PER_FSEL_19P2, PER_M2_19P2
401
402 /* 26MHz */
403 .word PER_M_26, PER_N_26, PER_FSEL_26, PER_M2_26
404
405 /* 38.4MHz */
406 .word PER_M_38P4, PER_N_38P4, PER_FSEL_38P4, PER_M2_38P4
407
408 .globl get_per_dpll_param
409 get_per_dpll_param:
410         adr     r0, per_dpll_param
411         mov     pc, lr
412
413 /* PER2 DPLL values */
414 per2_dpll_param:
415 /* 12MHz */
416 .word PER2_M_12, PER2_N_12, PER2_FSEL_12, PER2_M2_12
417
418 /* 13MHz */
419 .word PER2_M_13, PER2_N_13, PER2_FSEL_13, PER2_M2_13
420
421 /* 19.2MHz */
422 .word PER2_M_19P2, PER2_N_19P2, PER2_FSEL_19P2, PER2_M2_19P2
423
424 /* 26MHz */
425 .word PER2_M_26, PER2_N_26, PER2_FSEL_26, PER2_M2_26
426
427 /* 38.4MHz */
428 .word PER2_M_38P4, PER2_N_38P4, PER2_FSEL_38P4, PER2_M2_38P4
429
430 .globl get_per2_dpll_param
431 get_per2_dpll_param:
432         adr     r0, per2_dpll_param
433         mov     pc, lr
434
435 /*
436  * Tables for 36XX/37XX devices
437  *
438  */
439 mpu_36x_dpll_param:
440 /* 12MHz */
441 .word 50, 0, 0, 1
442 /* 13MHz */
443 .word 600, 12, 0, 1
444 /* 19.2MHz */
445 .word 125, 3, 0, 1
446 /* 26MHz */
447 .word 300, 12, 0, 1
448 /* 38.4MHz */
449 .word 125, 7, 0, 1
450
451 iva_36x_dpll_param:
452 /* 12MHz */
453 .word 130, 2, 0, 1
454 /* 13MHz */
455 .word 20, 0, 0, 1
456 /* 19.2MHz */
457 .word 325, 11, 0, 1
458 /* 26MHz */
459 .word 10, 0, 0, 1
460 /* 38.4MHz */
461 .word 325, 23, 0, 1
462
463 core_36x_dpll_param:
464 /* 12MHz */
465 .word 100, 2, 0, 1
466 /* 13MHz */
467 .word 400, 12, 0, 1
468 /* 19.2MHz */
469 .word 375, 17, 0, 1
470 /* 26MHz */
471 .word 200, 12, 0, 1
472 /* 38.4MHz */
473 .word 375, 35, 0, 1
474
475 per_36x_dpll_param:
476 /*    SYSCLK    M       N      M2      M3      M4     M5      M6      m2DIV */
477 .word 12000,    360,    4,     9,      16,     5,     4,      3,      1
478 .word 13000,    864,   12,     9,      16,     9,     4,      3,      1
479 .word 19200,    360,    7,     9,      16,     5,     4,      3,      1
480 .word 26000,    432,   12,     9,      16,     9,     4,      3,      1
481 .word 38400,    360,   15,     9,      16,     5,     4,      3,      1
482
483 .globl get_36x_mpu_dpll_param
484 get_36x_mpu_dpll_param:
485         adr     r0, mpu_36x_dpll_param
486         mov     pc, lr
487
488 .globl get_36x_iva_dpll_param
489 get_36x_iva_dpll_param:
490         adr     r0, iva_36x_dpll_param
491         mov     pc, lr
492
493 .globl get_36x_core_dpll_param
494 get_36x_core_dpll_param:
495         adr     r0, core_36x_dpll_param
496         mov     pc, lr
497
498 .globl get_36x_per_dpll_param
499 get_36x_per_dpll_param:
500         adr     r0, per_36x_dpll_param
501         mov     pc, lr