2 * Board specific setup info
5 * Texas Instruments, <www.ti.com>
8 * Richard Woodruff <r-woodruff2@ti.com>
9 * Syed Mohammed Khasim <khasim@ti.com>
11 * SPDX-License-Identifier: GPL-2.0+
16 #include <asm/arch/mem.h>
17 #include <asm/arch/clocks_omap3.h>
18 #include <linux/linkage.h>
20 #ifdef CONFIG_SPL_BUILD
21 ENTRY(save_boot_params)
22 ldr r4, =omap3_boot_device
26 b save_boot_params_ret
27 ENDPROC(save_boot_params)
31 * Funtion for making PPA HAL API calls in secure devices
36 ENTRY(do_omap3_emu_romcode_call)
37 PUSH {r4-r12, lr} @ Save all registers from ROM code!
38 MOV r12, r0 @ Copy the Secure Service ID in R12
39 MOV r3, r1 @ Copy the pointer to va_list in R3
40 MOV r1, #0 @ Process ID - 0
41 MOV r2, #OMAP3_EMU_HAL_START_HAL_CRITICAL @ Copy the pointer
43 MOV r6, #0xFF @ Indicate new Task call
44 mcr p15, 0, r0, c7, c10, 4 @ DSB
45 mcr p15, 0, r0, c7, c10, 5 @ DMB
46 .word 0xe1600071 @ SMC #1 to call PPA service - hand assembled
47 @ because we use -march=armv5
49 ENDPROC(do_omap3_emu_romcode_call)
51 #if !defined(CONFIG_SYS_NAND_BOOT) && !defined(CONFIG_SYS_NAND_BOOT)
52 /**************************************************************************
53 * cpy_clk_code: relocates clock code into SRAM where its safer to execute
54 * R1 = SRAM destination address.
55 *************************************************************************/
57 /* Copy DPLL code into SRAM */
58 adr r0, go_to_speed /* copy from start of go_to_speed... */
59 adr r2, lowlevel_init /* ... up to start of low_level_init */
61 ldmia r0!, {r3 - r10} /* copy from source address [r0] */
62 stmia r1!, {r3 - r10} /* copy to target address [r1] */
63 cmp r0, r2 /* until source end address [r2] */
65 mov pc, lr /* back to caller */
68 /* ***************************************************************************
69 * go_to_speed: -Moves to bypass, -Commits clock dividers, -puts dpll at speed
70 * -executed from SRAM.
71 * R0 = CM_CLKEN_PLL-bypass value
72 * R1 = CM_CLKSEL1_PLL-m, n, and divider values
73 * R2 = CM_CLKSEL_CORE-divider values
74 * R3 = CM_IDLEST_CKGEN - addr dpll lock wait
76 * Note: If core unlocks/relocks and SDRAM is running fast already it gets
77 * confused. A reset of the controller gets it back. Taking away its
78 * L3 when its not in self refresh seems bad for it. Normally, this
79 * code runs from flash before SDR is init so that should be ok.
80 ****************************************************************************/
84 /* move into fast relock bypass */
88 ldr r5, [r3] /* get status */
89 and r5, r5, #0x1 /* isolate core status */
90 cmp r5, #0x1 /* still locked? */
91 beq wait1 /* if lock, loop */
93 /* set new dpll dividers _after_ in bypass */
95 str r1, [r5] /* set m, n, m2 */
97 str r2, [r5] /* set l3/l4/.. dividers*/
98 ldr r5, pll_div_add3 /* wkup */
99 ldr r2, pll_div_val3 /* rsm val */
101 ldr r5, pll_div_add4 /* gfx */
104 ldr r5, pll_div_add5 /* emu */
108 /* now prepare GPMC (flash) for new dpll speed */
109 /* flash needs to be stable when we jump back to it */
110 ldr r5, flash_cfg3_addr
111 ldr r2, flash_cfg3_val
113 ldr r5, flash_cfg4_addr
114 ldr r2, flash_cfg4_val
116 ldr r5, flash_cfg5_addr
117 ldr r2, flash_cfg5_val
119 ldr r5, flash_cfg1_addr
121 orr r2, r2, #0x3 /* up gpmc divider */
124 /* lock DPLL3 and wait a bit */
125 orr r0, r0, #0x7 /* set up for lock mode */
126 str r0, [r4] /* lock */
127 nop /* ARM slow at this point working at sys_clk */
132 ldr r5, [r3] /* get status */
133 and r5, r5, #0x1 /* isolate core status */
134 cmp r5, #0x1 /* still locked? */
135 bne wait2 /* if lock, loop */
141 mov pc, lr /* back to caller, locked */
144 _go_to_speed: .word go_to_speed
146 /* these constants need to be close for PIC code */
147 /* The Nor has to be in the Flash Base CS0 for this condition to happen */
149 .word (GPMC_CONFIG_CS0_BASE + GPMC_CONFIG1)
151 .word (GPMC_CONFIG_CS0_BASE + GPMC_CONFIG3)
153 .word STNOR_GPMC_CONFIG3
155 .word (GPMC_CONFIG_CS0_BASE + GPMC_CONFIG4)
157 .word STNOR_GPMC_CONFIG4
159 .word STNOR_GPMC_CONFIG5
161 .word (GPMC_CONFIG_CS0_BASE + GPMC_CONFIG5)
171 .word (WKUP_RSM << 1)
185 str ip, [sp] /* stash ip register */
186 mov ip, lr /* save link reg across call */
187 #if !defined(CONFIG_SYS_NAND_BOOT) && !defined(CONFIG_SYS_ONENAND_BOOT)
189 * No need to copy/exec the clock code - DPLL adjust already done
190 * in NAND/oneNAND Boot.
192 ldr r1, =SRAM_CLK_CODE
194 #endif /* NAND Boot */
195 mov lr, ip /* restore link reg */
196 ldr ip, [sp] /* restore save ip */
197 /* tail-call s_init to setup pll, mux, memory */
200 ENDPROC(lowlevel_init)
202 /* the literal pools origin */
208 .word LOW_LEVEL_SRAM_STACK
210 /* DPLL(1-4) PARAM TABLES */
213 * Each of the tables has M, N, FREQSEL, M2 values defined for nominal
214 * OPP (1.2V). The fields are defined according to dpll_param struct (clock.c).
215 * The values are defined for all possible sysclk and for ES1 and ES2.
221 .word MPU_M_12_ES1, MPU_N_12_ES1, MPU_FSEL_12_ES1, MPU_M2_12_ES1
223 .word MPU_M_12_ES2, MPU_N_12_ES2, MPU_FSEL_12_ES2, MPU_M2_ES2
225 .word MPU_M_12, MPU_N_12, MPU_FSEL_12, MPU_M2_12
229 .word MPU_M_13_ES1, MPU_N_13_ES1, MPU_FSEL_13_ES1, MPU_M2_13_ES1
231 .word MPU_M_13_ES2, MPU_N_13_ES2, MPU_FSEL_13_ES2, MPU_M2_13_ES2
233 .word MPU_M_13, MPU_N_13, MPU_FSEL_13, MPU_M2_13
237 .word MPU_M_19P2_ES1, MPU_N_19P2_ES1, MPU_FSEL_19P2_ES1, MPU_M2_19P2_ES1
239 .word MPU_M_19P2_ES2, MPU_N_19P2_ES2, MPU_FSEL_19P2_ES2, MPU_M2_19P2_ES2
241 .word MPU_M_19P2, MPU_N_19P2, MPU_FSEL_19P2, MPU_M2_19P2
245 .word MPU_M_26_ES1, MPU_N_26_ES1, MPU_FSEL_26_ES1, MPU_M2_26_ES1
247 .word MPU_M_26_ES2, MPU_N_26_ES2, MPU_FSEL_26_ES2, MPU_M2_26_ES2
249 .word MPU_M_26, MPU_N_26, MPU_FSEL_26, MPU_M2_26
253 .word MPU_M_38P4_ES1, MPU_N_38P4_ES1, MPU_FSEL_38P4_ES1, MPU_M2_38P4_ES1
255 .word MPU_M_38P4_ES2, MPU_N_38P4_ES2, MPU_FSEL_38P4_ES2, MPU_M2_38P4_ES2
257 .word MPU_M_38P4, MPU_N_38P4, MPU_FSEL_38P4, MPU_M2_38P4
260 .globl get_mpu_dpll_param
262 adr r0, mpu_dpll_param
268 .word IVA_M_12_ES1, IVA_N_12_ES1, IVA_FSEL_12_ES1, IVA_M2_12_ES1
270 .word IVA_M_12_ES2, IVA_N_12_ES2, IVA_FSEL_12_ES2, IVA_M2_12_ES2
272 .word IVA_M_12, IVA_N_12, IVA_FSEL_12, IVA_M2_12
276 .word IVA_M_13_ES1, IVA_N_13_ES1, IVA_FSEL_13_ES1, IVA_M2_13_ES1
278 .word IVA_M_13_ES2, IVA_N_13_ES2, IVA_FSEL_13_ES2, IVA_M2_13_ES2
280 .word IVA_M_13, IVA_N_13, IVA_FSEL_13, IVA_M2_13
284 .word IVA_M_19P2_ES1, IVA_N_19P2_ES1, IVA_FSEL_19P2_ES1, IVA_M2_19P2_ES1
286 .word IVA_M_19P2_ES2, IVA_N_19P2_ES2, IVA_FSEL_19P2_ES2, IVA_M2_19P2_ES2
288 .word IVA_M_19P2, IVA_N_19P2, IVA_FSEL_19P2, IVA_M2_19P2
292 .word IVA_M_26_ES1, IVA_N_26_ES1, IVA_FSEL_26_ES1, IVA_M2_26_ES1
294 .word IVA_M_26_ES2, IVA_N_26_ES2, IVA_FSEL_26_ES2, IVA_M2_26_ES2
296 .word IVA_M_26, IVA_N_26, IVA_FSEL_26, IVA_M2_26
300 .word IVA_M_38P4_ES1, IVA_N_38P4_ES1, IVA_FSEL_38P4_ES1, IVA_M2_38P4_ES1
302 .word IVA_M_38P4_ES2, IVA_N_38P4_ES2, IVA_FSEL_38P4_ES2, IVA_M2_38P4_ES2
304 .word IVA_M_38P4, IVA_N_38P4, IVA_FSEL_38P4, IVA_M2_38P4
307 .globl get_iva_dpll_param
309 adr r0, iva_dpll_param
312 /* Core DPLL targets for L3 at 166 & L133 */
316 .word CORE_M_12_ES1, CORE_N_12_ES1, CORE_FSL_12_ES1, CORE_M2_12_ES1
318 .word CORE_M_12, CORE_N_12, CORE_FSEL_12, CORE_M2_12
320 .word CORE_M_12, CORE_N_12, CORE_FSEL_12, CORE_M2_12
324 .word CORE_M_13_ES1, CORE_N_13_ES1, CORE_FSL_13_ES1, CORE_M2_13_ES1
326 .word CORE_M_13, CORE_N_13, CORE_FSEL_13, CORE_M2_13
328 .word CORE_M_13, CORE_N_13, CORE_FSEL_13, CORE_M2_13
332 .word CORE_M_19P2_ES1, CORE_N_19P2_ES1, CORE_FSL_19P2_ES1, CORE_M2_19P2_ES1
334 .word CORE_M_19P2, CORE_N_19P2, CORE_FSEL_19P2, CORE_M2_19P2
336 .word CORE_M_19P2, CORE_N_19P2, CORE_FSEL_19P2, CORE_M2_19P2
340 .word CORE_M_26_ES1, CORE_N_26_ES1, CORE_FSL_26_ES1, CORE_M2_26_ES1
342 .word CORE_M_26, CORE_N_26, CORE_FSEL_26, CORE_M2_26
344 .word CORE_M_26, CORE_N_26, CORE_FSEL_26, CORE_M2_26
348 .word CORE_M_38P4_ES1, CORE_N_38P4_ES1, CORE_FSL_38P4_ES1, CORE_M2_38P4_ES1
350 .word CORE_M_38P4, CORE_N_38P4, CORE_FSEL_38P4, CORE_M2_38P4
352 .word CORE_M_38P4, CORE_N_38P4, CORE_FSEL_38P4, CORE_M2_38P4
354 .globl get_core_dpll_param
356 adr r0, core_dpll_param
359 /* PER DPLL values are same for both ES1 and ES2 */
362 .word PER_M_12, PER_N_12, PER_FSEL_12, PER_M2_12
365 .word PER_M_13, PER_N_13, PER_FSEL_13, PER_M2_13
368 .word PER_M_19P2, PER_N_19P2, PER_FSEL_19P2, PER_M2_19P2
371 .word PER_M_26, PER_N_26, PER_FSEL_26, PER_M2_26
374 .word PER_M_38P4, PER_N_38P4, PER_FSEL_38P4, PER_M2_38P4
376 .globl get_per_dpll_param
378 adr r0, per_dpll_param
381 /* PER2 DPLL values */
384 .word PER2_M_12, PER2_N_12, PER2_FSEL_12, PER2_M2_12
387 .word PER2_M_13, PER2_N_13, PER2_FSEL_13, PER2_M2_13
390 .word PER2_M_19P2, PER2_N_19P2, PER2_FSEL_19P2, PER2_M2_19P2
393 .word PER2_M_26, PER2_N_26, PER2_FSEL_26, PER2_M2_26
396 .word PER2_M_38P4, PER2_N_38P4, PER2_FSEL_38P4, PER2_M2_38P4
398 .globl get_per2_dpll_param
400 adr r0, per2_dpll_param
404 * Tables for 36XX/37XX devices
444 /* SYSCLK M N M2 M3 M4 M5 M6 m2DIV */
445 .word 12000, 360, 4, 9, 16, 5, 4, 3, 1
446 .word 13000, 864, 12, 9, 16, 9, 4, 3, 1
447 .word 19200, 360, 7, 9, 16, 5, 4, 3, 1
448 .word 26000, 432, 12, 9, 16, 9, 4, 3, 1
449 .word 38400, 360, 15, 9, 16, 5, 4, 3, 1
453 .word PER2_36XX_M_12, PER2_36XX_N_12, 0, PER2_36XX_M2_12
455 .word PER2_36XX_M_13, PER2_36XX_N_13, 0, PER2_36XX_M2_13
457 .word PER2_36XX_M_19P2, PER2_36XX_N_19P2, 0, PER2_36XX_M2_19P2
459 .word PER2_36XX_M_26, PER2_36XX_N_26, 0, PER2_36XX_M2_26
461 .word PER2_36XX_M_38P4, PER2_36XX_N_38P4, 0, PER2_36XX_M2_38P4
464 ENTRY(get_36x_mpu_dpll_param)
465 adr r0, mpu_36x_dpll_param
467 ENDPROC(get_36x_mpu_dpll_param)
469 ENTRY(get_36x_iva_dpll_param)
470 adr r0, iva_36x_dpll_param
472 ENDPROC(get_36x_iva_dpll_param)
474 ENTRY(get_36x_core_dpll_param)
475 adr r0, core_36x_dpll_param
477 ENDPROC(get_36x_core_dpll_param)
479 ENTRY(get_36x_per_dpll_param)
480 adr r0, per_36x_dpll_param
482 ENDPROC(get_36x_per_dpll_param)
484 ENTRY(get_36x_per2_dpll_param)
485 adr r0, per2_36x_dpll_param
487 ENDPROC(get_36x_per2_dpll_param)