2 * Copyright (C) 2007, Guennadi Liakhovetski <lg@denx.de>
4 * (C) Copyright 2009 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/imx-regs.h>
24 #include <generated/asm-offsets.h>
25 #include <linux/linkage.h>
27 .section ".text.init", "x"
30 * L2CC Cache setup/invalidation/disable
33 /* explicitly disable L2 cache */
34 mrc 15, 0, r0, c1, c0, 1
36 mcr 15, 0, r0, c1, c0, 1
38 /* reconfigure L2 cache aux control reg */
39 ldr r0, =0xC0 | /* tag RAM */ \
40 0x4 | /* data RAM */ \
41 1 << 24 | /* disable write allocate delay */ \
42 1 << 23 | /* disable write allocate combine */ \
43 1 << 22 /* disable write allocate */
45 #if defined(CONFIG_MX51)
46 ldr r3, [r4, #ROM_SI_REV]
49 /* disable write combine for TO 2 and lower revs */
50 orrls r0, r0, #1 << 25
53 mcr 15, 1, r0, c9, c0, 2
56 /* AIPS setup - Only setup MPROTx registers.
57 * The PACR default values are good.*/
60 * Set all MPROTx to be non-bufferable, trusted for R/W,
61 * not forced to user-mode.
63 ldr r0, =AIPS1_BASE_ADDR
67 ldr r0, =AIPS2_BASE_ADDR
71 * Clear the on and off peripheral modules Supervisor Protect bit
72 * for SDMA to access them. Did not change the AIPS control registers
73 * (offset 0x20) access type
80 /* VPU and IPU given higher priority (0x4)
81 * IPU accesses with ID=0x1 given highest priority (=0xA)
83 ldr r0, =M4IF_BASE_ADDR
99 .macro setup_pll pll, freq
111 str r1, [r0, #PLL_DP_CTL] /* Set DPLL ON (set UPEN bit): BRMO=1 */
113 str r1, [r0, #PLL_DP_CONFIG] /* Enable auto-restart AREN bit */
115 ldr r1, [r2, #W_DP_OP]
116 str r1, [r0, #PLL_DP_OP]
117 str r1, [r0, #PLL_DP_HFS_OP]
119 ldr r1, [r2, #W_DP_MFD]
120 str r1, [r0, #PLL_DP_MFD]
121 str r1, [r0, #PLL_DP_HFS_MFD]
123 ldr r1, [r2, #W_DP_MFN]
124 str r1, [r0, #PLL_DP_MFN]
125 str r1, [r0, #PLL_DP_HFS_MFN]
128 str r1, [r0, #PLL_DP_CTL]
129 1: ldr r1, [r0, #PLL_DP_CTL]
133 /* r10 saved upper lr */
136 .macro setup_pll_errata pll, freq
138 str r4, [r2, #PLL_DP_CONFIG] /* Disable auto-restart AREN bit */
140 str r1, [r2, #PLL_DP_CTL] /* Restart PLL with PLM=1 */
141 1: ldr r1, [r2, #PLL_DP_CTL] /* Wait for lock */
146 str r5, [r2, #PLL_DP_MFN] /* Modify MFN value */
147 str r5, [r2, #PLL_DP_HFS_MFN]
150 str r1, [r2, #PLL_DP_CONFIG] /* Reload MFN value */
152 2: ldr r1, [r2, #PLL_DP_CONFIG]
156 ldr r1, =100 /* Wait at least 4 us */
161 str r1, [r2, #PLL_DP_CONFIG] /* Enable auto-restart AREN bit */
165 ldr r0, =CCM_BASE_ADDR
167 #if defined(CONFIG_MX51)
168 /* Gate of clocks to the peripherals first */
170 str r1, [r0, #CLKCTL_CCGR0]
171 str r4, [r0, #CLKCTL_CCGR1]
172 str r4, [r0, #CLKCTL_CCGR2]
173 str r4, [r0, #CLKCTL_CCGR3]
176 str r1, [r0, #CLKCTL_CCGR4]
178 str r1, [r0, #CLKCTL_CCGR5]
180 str r1, [r0, #CLKCTL_CCGR6]
182 /* Disable IPU and HSC dividers */
184 str r1, [r0, #CLKCTL_CCDR]
186 /* Make sure to switch the DDR away from PLL 1 */
188 str r1, [r0, #CLKCTL_CBCDR]
189 /* make sure divider effective */
190 1: ldr r1, [r0, #CLKCTL_CDHIPR]
195 str r1, [r0, #CLKCTL_CCGR0]
196 str r4, [r0, #CLKCTL_CCGR1]
197 str r4, [r0, #CLKCTL_CCGR2]
198 str r4, [r0, #CLKCTL_CCGR3]
199 str r4, [r0, #CLKCTL_CCGR7]
202 str r1, [r0, #CLKCTL_CCGR4]
204 str r1, [r0, #CLKCTL_CCGR5]
206 str r1, [r0, #CLKCTL_CCGR6]
209 /* Switch ARM to step clock */
211 str r1, [r0, #CLKCTL_CCSR]
213 #if defined(CONFIG_MX51_PLL_ERRATA)
214 setup_pll PLL1_BASE_ADDR, 864
215 setup_pll_errata PLL1_BASE_ADDR, W_DP_MFN_800_DIT
217 setup_pll PLL1_BASE_ADDR, 800
220 #if defined(CONFIG_MX51)
221 setup_pll PLL3_BASE_ADDR, 665
223 /* Switch peripheral to PLL 3 */
224 ldr r0, =CCM_BASE_ADDR
225 ldr r1, =0x000010C0 | CONFIG_SYS_DDR_CLKSEL
226 str r1, [r0, #CLKCTL_CBCMR]
228 str r1, [r0, #CLKCTL_CBCDR]
229 setup_pll PLL2_BASE_ADDR, 665
231 /* Switch peripheral to PLL2 */
232 ldr r0, =CCM_BASE_ADDR
234 str r1, [r0, #CLKCTL_CBCDR]
235 ldr r1, =0x000020C0 | CONFIG_SYS_DDR_CLKSEL
236 str r1, [r0, #CLKCTL_CBCMR]
238 setup_pll PLL3_BASE_ADDR, 216
240 /* Set the platform clock dividers */
241 ldr r0, =ARM_BASE_ADDR
245 ldr r0, =CCM_BASE_ADDR
247 #if defined(CONFIG_MX51)
248 /* Run 3.0 at Full speed, for other TO's wait till we increase VDDGP */
249 ldr r3, [r4, #ROM_SI_REV]
256 str r1, [r0, #CLKCTL_CACRR]
258 /* Switch ARM back to PLL 1 */
259 str r4, [r0, #CLKCTL_CCSR]
261 #if defined(CONFIG_MX51)
263 /* Use lp_apm (24MHz) source for perclk */
264 ldr r1, =0x000020C2 | CONFIG_SYS_DDR_CLKSEL
265 str r1, [r0, #CLKCTL_CBCMR]
266 /* ddr clock from PLL 1, all perclk dividers are 1 since using 24MHz */
267 ldr r1, =CONFIG_SYS_CLKTL_CBCDR
268 str r1, [r0, #CLKCTL_CBCDR]
271 /* Restore the default values in the Gate registers */
273 str r1, [r0, #CLKCTL_CCGR0]
274 str r1, [r0, #CLKCTL_CCGR1]
275 str r1, [r0, #CLKCTL_CCGR2]
276 str r1, [r0, #CLKCTL_CCGR3]
277 str r1, [r0, #CLKCTL_CCGR4]
278 str r1, [r0, #CLKCTL_CCGR5]
279 str r1, [r0, #CLKCTL_CCGR6]
280 #if defined(CONFIG_MX53)
281 str r1, [r0, #CLKCTL_CCGR7]
284 #if defined(CONFIG_MX51)
285 /* Use PLL 2 for UART's, get 66.5MHz from it */
287 str r1, [r0, #CLKCTL_CSCMR1]
289 str r1, [r0, #CLKCTL_CSCDR1]
290 #elif defined(CONFIG_MX53)
291 /* Switch peripheral to PLL2 */
292 ldr r0, =CCM_BASE_ADDR
296 str r1, [r0, #CLKCTL_CBCDR]
299 str r1, [r0, #CLKCTL_CBCMR]
300 /* Change uart clk parent to pll2*/
301 ldr r1, [r0, #CLKCTL_CSCMR1]
302 and r1, r1, #0xfcffffff
303 orr r1, r1, #0x01000000
304 str r1, [r0, #CLKCTL_CSCMR1]
305 ldr r1, [r0, #CLKCTL_CSCDR1]
306 and r1, r1, #0xffffffc0
308 str r1, [r0, #CLKCTL_CSCDR1]
310 /* make sure divider effective */
311 1: ldr r1, [r0, #CLKCTL_CDHIPR]
315 str r4, [r0, #CLKCTL_CCDR]
317 /* for cko - for ARM div by 8 */
319 add r1, r1, #0x00000F0
320 str r1, [r0, #CLKCTL_CCOSR]
324 ldr r0, =WDOG1_BASE_ADDR
331 mov r4, #0 /* Fix R4 to 0 */
333 #if defined(CONFIG_MX51)
334 ldr r0, =GPIO1_BASE_ADDR
352 ENDPROC(lowlevel_init)
354 /* Board level setting value */
355 #if defined(CONFIG_MX51_PLL_ERRATA)
356 W_DP_864: .word DP_OP_864
359 W_DP_MFN_800_DIT: .word DP_MFN_800_DIT
361 W_DP_800: .word DP_OP_800
365 #if defined(CONFIG_MX51)
366 W_DP_665: .word DP_OP_665
370 W_DP_216: .word DP_OP_216