2 * Copyright (C) 2007, Guennadi Liakhovetski <lg@denx.de>
4 * (C) Copyright 2009-2010 Freescale Semiconductor, Inc.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of
9 * the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
23 #include <asm/arch/mx51.h>
24 #include "board-mx51_3stack.h"
32 .macro check_soc_version ret, tmp
36 * L2CC Cache setup/invalidation/disable
39 /* explicitly disable L2 cache */
40 mrc 15, 0, r0, c1, c0, 1
42 mcr 15, 0, r0, c1, c0, 1
44 /* reconfigure L2 cache aux control reg */
45 mov r0, #0xC0 /* tag RAM */
46 add r0, r0, #0x4 /* data RAM */
47 orr r0, r0, #(1 << 24) /* disable write allocate delay */
48 orr r0, r0, #(1 << 23) /* disable write allocate combine */
49 orr r0, r0, #(1 << 22) /* disable write allocate */
52 ldr r3, [r1, #ROM_SI_REV]
53 cmp r3, #0x10 /* r3 contains the silicon rev */
54 /* disable write combine for TO 2 and lower */
55 orrls r0, r0, #(1 << 25)
57 mcr 15, 1, r0, c9, c0, 2
60 /* AIPS setup - Only setup MPROTx registers.
61 * The PACR default values are good.*/
64 * Set all MPROTx to be non-bufferable, trusted for R/W,
65 * not forced to user-mode.
67 ldr r0, =AIPS1_BASE_ADDR
71 ldr r0, =AIPS2_BASE_ADDR
75 * Clear the on and off peripheral modules Supervisor Protect bit
76 * for SDMA to access them. Did not change the AIPS control registers
77 * (offset 0x20) access type
81 /* MAX (Multi-Layer AHB Crossbar Switch) setup */
87 /* VPU and IPU given higher priority (0x4)
88 * IPU accesses with ID=0x1 given highest priority (=0xA)
90 ldr r0, =M4IF_BASE_ADDR
103 .endm /* init_m4if */
105 /* To support 133MHz DDR */
106 .macro init_drive_strength
107 .endm /* init_drive_strength */
109 /* CPLD on CS5 setup */
110 .macro init_debug_board
111 .endm /* init_debug_board */
113 .macro setup_pll pll, freq
116 str r1, [r2, #PLL_DP_CTL] /* Set DPLL ON (set UPEN bit): BRMO=1 */
118 str r1, [r2, #PLL_DP_CONFIG] /* Enable auto-restart AREN bit */
120 str r3, [r2, #PLL_DP_OP]
121 str r3, [r2, #PLL_DP_HFS_OP]
123 str r4, [r2, #PLL_DP_MFD]
124 str r4, [r2, #PLL_DP_HFS_MFD]
126 str r5, [r2, #PLL_DP_MFN]
127 str r5, [r2, #PLL_DP_HFS_MFN]
130 str r1, [r2, #PLL_DP_CTL]
131 1: ldr r1, [r2, #PLL_DP_CTL]
137 ldr r0, =CCM_BASE_ADDR
139 /* Gate of clocks to the peripherals first */
141 str r1, [r0, #CLKCTL_CCGR0]
143 str r1, [r0, #CLKCTL_CCGR1]
144 str r1, [r0, #CLKCTL_CCGR2]
145 str r1, [r0, #CLKCTL_CCGR3]
148 str r1, [r0, #CLKCTL_CCGR4]
150 str r1, [r0, #CLKCTL_CCGR5]
152 str r1, [r0, #CLKCTL_CCGR6]
154 /* Disable IPU and HSC dividers */
156 str r1, [r0, #CLKCTL_CCDR]
158 /* Make sure to switch the DDR away from PLL 1 */
160 str r1, [r0, #CLKCTL_CBCDR]
161 /* make sure divider effective */
162 1: ldr r1, [r0, #CLKCTL_CDHIPR]
166 /* Switch ARM to step clock */
168 str r1, [r0, #CLKCTL_CCSR]
173 setup_pll PLL1_BASE_ADDR
177 setup_pll PLL3_BASE_ADDR
179 /* Switch peripheral to PLL 3 */
180 ldr r0, =CCM_BASE_ADDR
182 str r1, [r0, #CLKCTL_CBCMR]
184 str r1, [r0, #CLKCTL_CBCDR]
189 setup_pll PLL2_BASE_ADDR
191 /* Switch peripheral to PLL2 */
192 ldr r0, =CCM_BASE_ADDR
194 str r1, [r0, #CLKCTL_CBCDR]
196 str r1, [r0, #CLKCTL_CBCMR]
201 setup_pll PLL3_BASE_ADDR
203 /* Set the platform clock dividers */
204 ldr r0, =ARM_BASE_ADDR
208 ldr r0, =CCM_BASE_ADDR
209 /* Run TO 3.0 at Full speed, for other TO's wait
210 till we increase VDDGP */
212 ldr r3, [r1, #ROM_SI_REV]
216 str r1, [r0, #CLKCTL_CACRR]
218 /* Switch ARM back to PLL 1 */
220 str r1, [r0, #CLKCTL_CCSR]
223 /* Use lp_apm (24MHz) source for perclk */
225 str r1, [r0, #CLKCTL_CBCMR]
226 /* ddr clock from PLL 1, all perclk dividers are 1 since using 24MHz */
227 #ifdef CONFIG_IMX51_MDDR
232 str r1, [r0, #CLKCTL_CBCDR]
234 /* Restore the default values in the Gate registers */
236 str r1, [r0, #CLKCTL_CCGR0]
237 str r1, [r0, #CLKCTL_CCGR1]
238 str r1, [r0, #CLKCTL_CCGR2]
239 str r1, [r0, #CLKCTL_CCGR3]
240 str r1, [r0, #CLKCTL_CCGR4]
241 str r1, [r0, #CLKCTL_CCGR5]
242 str r1, [r0, #CLKCTL_CCGR6]
244 /* Use PLL 2 for UART's, get 66.5MHz from it */
246 str r1, [r0, #CLKCTL_CSCMR1]
248 str r1, [r0, #CLKCTL_CSCDR1]
250 /* make sure divider effective */
251 1: ldr r1, [r0, #CLKCTL_CDHIPR]
256 str r1, [r0, #CLKCTL_CCDR]
258 /* for cko - for ARM div by 8 */
260 add r1, r1, #0x00000F0
261 str r1, [r0, #CLKCTL_CCOSR]
265 ldr r0, =WDOG1_BASE_ADDR
271 ldr r0, =ESDCTL_BASE_ADDR
274 str r1, [r0, #ESDCTL_ESDCTL0]
275 /* Precharge command */
276 ldr r1, DDR_PERCHARGE_CMD
277 str r1, [r0, #ESDCTL_ESDSCR]
278 /* 2 refresh commands */
279 ldr r1, DDR_REFRESH_CMD
280 str r1, [r0, #ESDCTL_ESDSCR]
281 str r1, [r0, #ESDCTL_ESDSCR]
282 /* LMR with CAS=3 and BL=3 */
284 str r1, [r0, #ESDCTL_ESDSCR]
285 /* 13 ROW, 10 COL, 32Bit, SREF=4 Micron Model */
287 str r1, [r0, #ESDCTL_ESDCTL0]
288 /* Timing parameters */
290 str r1, [r0, #ESDCTL_ESDCFG0]
291 /* MDDR enable, RLAT=2 */
293 str r1, [r0, #ESDCTL_ESDMISC]
296 str r1, [r0, #ESDCTL_ESDSCR]
298 .endm /* setup_sdram */
300 .section ".text.init", "x"
305 ldr r3, [r1, #ROM_SI_REV]
306 ldr r0, =GPC_BASE_ADDR
307 cmp r3, #0x10 // r3 contains the silicon rev
308 ldrls r1, =0x1FC00000
309 ldrhi r1, =0x1A800000
312 #ifdef ENABLE_IMPRECISE_ABORT
313 mrs r1, spsr /* save old spsr */
314 mrs r0, cpsr /* read out the cpsr */
315 bic r0, r0, #0x100 /* clear the A bit */
316 msr spsr, r0 /* update spsr */
317 add lr, pc, #0x8 /* update lr */
318 movs pc, lr /* update cpsr */
323 msr spsr, r1 /* restore old spsr */
326 /* ARM errata ID #468414 */
327 mrc 15, 0, r1, c1, c0, 1
328 orr r1, r1, #(1 << 5) /* enable L1NEON bit */
329 mcr 15, 0, r1, c1, c0, 1
342 cmp pc, #PHYS_SDRAM_1
344 cmp pc, #(PHYS_SDRAM_1 + PHYS_SDRAM_1_SIZE)
355 /* return from mxc_nand_load */
356 /* r12 saved upper lr*/
359 /* Board level setting value */
360 DDR_PERCHARGE_CMD: .word 0x04008008
361 DDR_REFRESH_CMD: .word 0x00008010
362 DDR_LMR1_W: .word 0x00338018
363 DDR_LMR_CMD: .word 0xB2220000
364 DDR_TIMING_W: .word 0xB02567A9
365 DDR_MISC_W: .word 0x000A0104