2 * Board specific setup info
4 * (C) Copyright 2004-2006
5 * Texas Instruments, <www.ti.com>
6 * Richard Woodruff <r-woodruff2@ti.com>
8 * See file CREDITS for list of people who contributed to this
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.
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.
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,
28 #include <asm/arch/cpu.h>
29 #include <asm/arch/mem.h>
30 #include <asm/arch/clocks.h>
33 .word TEXT_BASE /* sdram load addr from config.mk */
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 *************************************************************************/
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 */
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] */
52 mov pc, lr /* back to caller */
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.
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
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 ******************************************************************************/
74 /* move into fast relock bypass */
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 */
83 /* set new dpll dividers _after_ in bypass */
85 str r1, [r5] /* set m, n, m2 */
87 str r2, [r5] /* set l3/l4/.. dividers*/
88 ldr r5, pll_div_add3 /* wkup */
89 ldr r2, pll_div_val3 /* rsm val */
91 ldr r5, pll_div_add4 /* gfx */
94 ldr r5, pll_div_add5 /* emu */
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
103 ldr r5, flash_cfg4_addr
104 ldr r2, flash_cfg4_val
106 ldr r5, flash_cfg5_addr
107 ldr r2, flash_cfg5_val
109 ldr r5, flash_cfg1_addr
111 orr r2, r2, #0x3 /* up gpmc divider */
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 */
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 */
131 mov pc, lr /* back to caller, locked */
133 _go_to_speed: .word go_to_speed
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 */
138 .word (GPMC_CONFIG_CS0 + GPMC_CONFIG1)
140 .word (GPMC_CONFIG_CS0 + GPMC_CONFIG3)
142 .word STNOR_GPMC_CONFIG3
144 .word (GPMC_CONFIG_CS0 + GPMC_CONFIG4)
146 .word STNOR_GPMC_CONFIG4
148 .word STNOR_GPMC_CONFIG5
150 .word (GPMC_CONFIG_CS0 + GPMC_CONFIG5)
160 .word (WKUP_RSM << 1)
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 */
181 /* back to arch calling code */
184 /* the literal pools origin */
190 .word LOW_LEVEL_SRAM_STACK
192 /* DPLL(1-4) PARAM TABLES */
193 /* Each of the tables has M, N, FREQSEL, M2 values defined for nominal
194 * OPP (1.2V). The fields are defined according to dpll_param struct(clock.c).
195 * The values are defined for all possible sysclk and for ES1 and ES2.
201 .word 0x0FE,0x07,0x05,0x01
203 .word 0x0FA,0x05,0x07,0x01
205 .word 0x085,0x05,0x07,0x01
209 .word 0x17D,0x0C,0x03,0x01
211 .word 0x1F4,0x0C,0x03,0x01
213 .word 0x10A,0x0C,0x03,0x01
217 .word 0x179,0x12,0x04,0x01
219 .word 0x271,0x17,0x03,0x01
221 .word 0x14C,0x17,0x03,0x01
225 .word 0x17D,0x19,0x03,0x01
227 .word 0x0FA,0x0C,0x07,0x01
229 .word 0x085,0x0C,0x07,0x01
233 .word 0x1FA,0x32,0x03,0x01
235 .word 0x271,0x2F,0x03,0x01
237 .word 0x14C,0x2F,0x03,0x01
240 .globl get_mpu_dpll_param
242 adr r0, mpu_dpll_param
248 .word 0x07D,0x05,0x07,0x01
250 .word 0x0B4,0x05,0x07,0x01
252 .word 0x085,0x05,0x07,0x01
256 .word 0x0FA,0x0C,0x03,0x01
258 .word 0x168,0x0C,0x03,0x01
260 .word 0x10A,0x0C,0x03,0x01
264 .word 0x082,0x09,0x07,0x01
266 .word 0x0E1,0x0B,0x06,0x01
268 .word 0x14C,0x17,0x03,0x01
272 .word 0x07D,0x0C,0x07,0x01
274 .word 0x0B4,0x0C,0x07,0x01
276 .word 0x085,0x0C,0x07,0x01
280 .word 0x13F,0x30,0x03,0x01
282 .word 0x0E1,0x17,0x06,0x01
284 .word 0x14C,0x2F,0x03,0x01
287 .globl get_iva_dpll_param
289 adr r0, iva_dpll_param
292 /* Core DPLL targets for L3 at 166 & L133 */
296 .word M_12_ES1,M_12_ES1,FSL_12_ES1,M2_12_ES1
298 .word M_12,N_12,FSEL_12,M2_12
300 .word M_12,N_12,FSEL_12,M2_12
304 .word M_13_ES1,N_13_ES1,FSL_13_ES1,M2_13_ES1
306 .word M_13,N_13,FSEL_13,M2_13
308 .word M_13,N_13,FSEL_13,M2_13
312 .word M_19p2_ES1,N_19p2_ES1,FSL_19p2_ES1,M2_19p2_ES1
314 .word M_19p2,N_19p2,FSEL_19p2,M2_19p2
316 .word M_19p2,N_19p2,FSEL_19p2,M2_19p2
320 .word M_26_ES1,N_26_ES1,FSL_26_ES1,M2_26_ES1
322 .word M_26,N_26,FSEL_26,M2_26
324 .word M_26,N_26,FSEL_26,M2_26
328 .word M_38p4_ES1,N_38p4_ES1,FSL_38p4_ES1,M2_38p4_ES1
330 .word M_38p4,N_38p4,FSEL_38p4,M2_38p4
332 .word M_38p4,N_38p4,FSEL_38p4,M2_38p4
334 .globl get_core_dpll_param
336 adr r0, core_dpll_param
339 /* PER DPLL values are same for both ES1 and ES2 */
342 .word 0xD8,0x05,0x07,0x09
345 .word 0x1B0,0x0C,0x03,0x09
348 .word 0xE1,0x09,0x07,0x09
351 .word 0xD8,0x0C,0x07,0x09
354 .word 0xE1,0x13,0x07,0x09
356 .globl get_per_dpll_param
358 adr r0, per_dpll_param