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-imx51.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 orrls r0, r0, #(1 << 25) /* disable write combine for TO 2 and lower revs */
56 mcr 15, 1, r0, c9, c0, 2
59 /* AIPS setup - Only setup MPROTx registers.
60 * The PACR default values are good.*/
63 * Set all MPROTx to be non-bufferable, trusted for R/W,
64 * not forced to user-mode.
66 ldr r0, =AIPS1_BASE_ADDR
70 ldr r0, =AIPS2_BASE_ADDR
74 * Clear the on and off peripheral modules Supervisor Protect bit
75 * for SDMA to access them. Did not change the AIPS control registers
76 * (offset 0x20) access type
80 /* MAX (Multi-Layer AHB Crossbar Switch) setup */
86 /* VPU and IPU given higher priority (0x4)
87 * IPU accesses with ID=0x1 given highest priority (=0xA)
89 ldr r0, =M4IF_BASE_ADDR
109 .endm /* init_m4if */
111 /* To support 133MHz DDR */
112 .macro init_drive_strength
113 .endm /* init_drive_strength */
115 /* CPLD on CS5 setup */
116 .macro init_debug_board
117 .endm /* init_debug_board */
119 .macro setup_pll pll, freq
122 str r1, [r2, #PLL_DP_CTL] /* Set DPLL ON (set UPEN bit): BRMO=1 */
124 str r1, [r2, #PLL_DP_CONFIG] /* Enable auto-restart AREN bit */
126 str r3, [r2, #PLL_DP_OP]
127 str r3, [r2, #PLL_DP_HFS_OP]
129 str r4, [r2, #PLL_DP_MFD]
130 str r4, [r2, #PLL_DP_HFS_MFD]
132 str r5, [r2, #PLL_DP_MFN]
133 str r5, [r2, #PLL_DP_HFS_MFN]
136 str r1, [r2, #PLL_DP_CTL]
137 1: ldr r1, [r2, #PLL_DP_CTL]
143 ldr r0, =CCM_BASE_ADDR
145 /* Gate of clocks to the peripherals first */
147 str r1, [r0, #CLKCTL_CCGR0]
149 str r1, [r0, #CLKCTL_CCGR1]
150 str r1, [r0, #CLKCTL_CCGR2]
151 str r1, [r0, #CLKCTL_CCGR3]
154 str r1, [r0, #CLKCTL_CCGR4]
156 str r1, [r0, #CLKCTL_CCGR5]
158 str r1, [r0, #CLKCTL_CCGR6]
160 /* Disable IPU and HSC dividers */
162 str r1, [r0, #CLKCTL_CCDR]
164 /* Make sure to switch the DDR away from PLL 1 */
166 str r1, [r0, #CLKCTL_CBCDR]
167 /* make sure divider effective */
168 1: ldr r1, [r0, #CLKCTL_CDHIPR]
172 /* Switch ARM to step clock */
174 str r1, [r0, #CLKCTL_CCSR]
178 setup_pll PLL1_BASE_ADDR
183 setup_pll PLL3_BASE_ADDR
185 /* Switch peripheral to PLL 3 */
186 ldr r0, =CCM_BASE_ADDR
188 str r1, [r0, #CLKCTL_CBCMR]
190 str r1, [r0, #CLKCTL_CBCDR]
194 setup_pll PLL2_BASE_ADDR
196 /* Switch peripheral to PLL2 */
197 ldr r0, =CCM_BASE_ADDR
199 str r1, [r0, #CLKCTL_CBCDR]
201 str r1, [r0, #CLKCTL_CBCMR]
206 setup_pll PLL3_BASE_ADDR
209 /* Set the platform clock dividers */
210 ldr r0, =ARM_BASE_ADDR
214 ldr r0, =CCM_BASE_ADDR
215 /* Run TO 3.0 at Full speed, for other TO's wait till we increase VDDGP */
217 ldr r3, [r1, #ROM_SI_REV]
221 str r1, [r0, #CLKCTL_CACRR]
223 /* Switch ARM back to PLL 1 */
225 str r1, [r0, #CLKCTL_CCSR]
228 /* Use lp_apm (24MHz) source for perclk */
230 str r1, [r0, #CLKCTL_CBCMR]
231 /* ddr clock from PLL 1, all perclk dividers are 1 since using 24MHz */
233 str r1, [r0, #CLKCTL_CBCDR]
235 /* Restore the default values in the Gate registers */
237 str r1, [r0, #CLKCTL_CCGR0]
238 str r1, [r0, #CLKCTL_CCGR1]
239 str r1, [r0, #CLKCTL_CCGR2]
240 str r1, [r0, #CLKCTL_CCGR3]
241 str r1, [r0, #CLKCTL_CCGR4]
242 str r1, [r0, #CLKCTL_CCGR5]
243 str r1, [r0, #CLKCTL_CCGR6]
245 /* Use PLL 2 for UART's, get 66.5MHz from it */
247 str r1, [r0, #CLKCTL_CSCMR1]
249 str r1, [r0, #CLKCTL_CSCDR1]
251 /* make sure divider effective */
252 1: ldr r1, [r0, #CLKCTL_CDHIPR]
257 str r1, [r0, #CLKCTL_CCDR]
259 /* for cko - for ARM div by 8 */
261 add r1, r1, #0x00000F0
262 str r1, [r0, #CLKCTL_CCOSR]
266 ldr r0, =WDOG1_BASE_ADDR
271 .section ".text.init", "x"
275 ldr r0, =GPIO1_BASE_ADDR
277 orr r1, r1, #(1 << 23)
280 orr r1, r1, #(1 << 23)
283 #ifdef ENABLE_IMPRECISE_ABORT
284 mrs r1, spsr /* save old spsr */
285 mrs r0, cpsr /* read out the cpsr */
286 bic r0, r0, #0x100 /* clear the A bit */
287 msr spsr, r0 /* update spsr */
288 add lr, pc, #0x8 /* update lr */
289 movs pc, lr /* update cpsr */
294 msr spsr, r1 /* restore old spsr */
297 /* ARM errata ID #468414 */
298 mrc 15, 0, r1, c1, c0, 1
299 orr r1, r1, #(1 << 5) /* enable L1NEON bit */
300 mcr 15, 0, r1, c1, c0, 1
316 /* return from mxc_nand_load */
317 /* r12 saved upper lr*/
320 /* Board level setting value */
321 DDR_PERCHARGE_CMD: .word 0x04008008
322 DDR_REFRESH_CMD: .word 0x00008010
323 DDR_LMR1_W: .word 0x00338018
324 DDR_LMR_CMD: .word 0xB2220000
325 DDR_TIMING_W: .word 0xB02567A9
326 DDR_MISC_W: .word 0x000A0104