]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/freescale/mx53_evk/lowlevel_init.S
applied patches from Freescale and Ka-Ro
[karo-tx-uboot.git] / board / freescale / mx53_evk / lowlevel_init.S
1 /*
2  * Copyright (C) 2007, Guennadi Liakhovetski <lg@denx.de>
3  *
4  * Copyright (C) 2010 Freescale Semiconductor, Inc.
5  *
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.
10  *
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.
15  *
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,
19  * MA 02111-1307 USA
20  */
21
22 #include <config.h>
23 #include <asm/arch/mx53.h>
24
25 /*
26  * L2CC Cache setup/invalidation/disable
27  */
28 .macro init_l2cc
29         /* explicitly disable L2 cache */
30         mrc 15, 0, r0, c1, c0, 1
31         bic r0, r0, #0x2
32         mcr 15, 0, r0, c1, c0, 1
33
34         /* reconfigure L2 cache aux control reg */
35         mov r0, #0xC0                   /* tag RAM */
36         add r0, r0, #0x4                /* data RAM */
37         orr r0, r0, #(1 << 24)          /* disable write allocate delay */
38         orr r0, r0, #(1 << 23)          /* disable write allocate combine */
39         orr r0, r0, #(1 << 22)          /* disable write allocate */
40
41         mcr 15, 1, r0, c9, c0, 2
42 .endm /* init_l2cc */
43
44 /* AIPS setup - Only setup MPROTx registers.
45  * The PACR default values are good.*/
46 .macro init_aips
47         /*
48          * Set all MPROTx to be non-bufferable, trusted for R/W,
49          * not forced to user-mode.
50          */
51         ldr r0, =AIPS1_BASE_ADDR
52         ldr r1, =0x77777777
53         str r1, [r0, #0x0]
54         str r1, [r0, #0x4]
55         ldr r0, =AIPS2_BASE_ADDR
56         str r1, [r0, #0x0]
57         str r1, [r0, #0x4]
58 .endm /* init_aips */
59
60 .macro setup_pll pll, freq
61         ldr r0, =\pll
62         ldr r1, =0x00001232
63         str r1, [r0, #PLL_DP_CTL]
64         mov r1, #0x2
65         str r1, [r0, #PLL_DP_CONFIG]
66
67         ldr r1, W_DP_OP_\freq
68         str r1, [r0, #PLL_DP_OP]
69         str r1, [r0, #PLL_DP_HFS_OP]
70
71         ldr r1, W_DP_MFD_\freq
72         str r1, [r0, #PLL_DP_MFD]
73         str r1, [r0, #PLL_DP_HFS_MFD]
74
75         ldr r1,  W_DP_MFN_\freq
76         str r1, [r0, #PLL_DP_MFN]
77         str r1, [r0, #PLL_DP_HFS_MFN]
78
79         ldr r1, =0x00001232
80         str r1, [r0, #PLL_DP_CTL]
81 1:      ldr r1, [r0, #PLL_DP_CTL]
82         ands r1, r1, #0x1
83         beq 1b
84 .endm
85
86 .macro init_clock
87         ldr r0, CCM_BASE_ADDR_W
88
89         /* Switch ARM to step clock */
90         mov r1, #0x4
91         str r1, [r0, #CLKCTL_CCSR]
92
93         setup_pll PLL1_BASE_ADDR, 800
94
95         setup_pll PLL3_BASE_ADDR, 400
96
97         /* Switch peripheral to PLL3 */
98         ldr r0, CCM_BASE_ADDR_W
99         ldr r1, CCM_VAL_0x00015154
100         str r1, [r0, #CLKCTL_CBCMR]
101         ldr r1, CCM_VAL_0x02888945
102         orr r1, r1, #(1 << 16)
103         str r1, [r0, #CLKCTL_CBCDR]
104         /* make sure change is effective */
105 1:      ldr r1, [r0, #CLKCTL_CDHIPR]
106         cmp r1, #0x0
107         bne 1b
108
109         setup_pll PLL2_BASE_ADDR, CONFIG_SYS_PLL2_FREQ
110
111         /* Switch peripheral to PLL2 */
112         ldr r0, CCM_BASE_ADDR_W
113         ldr r1, CCM_VAL_0x00808145
114         orr r1, r1, #(CONFIG_SYS_AHB_PODF << 10)
115         orr r1, r1, #(CONFIG_SYS_AXIA_PODF << 16)
116         orr r1, r1, #(CONFIG_SYS_AXIB_PODF << 19)
117         str r1, [r0, #CLKCTL_CBCDR]
118
119         ldr r1, CCM_VAL_0x00016154
120         str r1, [r0, #CLKCTL_CBCMR]
121
122         /* make sure change is effective */
123 1:      ldr r1, [r0, #CLKCTL_CDHIPR]
124         cmp r1, #0x0
125         bne 1b
126
127         setup_pll PLL3_BASE_ADDR, 216
128
129         /* Set the platform clock dividers */
130         ldr r0, PLATFORM_BASE_ADDR_W
131         ldr r1, PLATFORM_CLOCK_DIV_W
132         str r1, [r0, #PLATFORM_ICGC]
133
134         ldr r0, CCM_BASE_ADDR_W
135         mov r1, #1
136         str r1, [r0, #CLKCTL_CACRR]
137
138         /* Switch ARM back to PLL 1. */
139         mov r1, #0x0
140         str r1, [r0, #CLKCTL_CCSR]
141
142         ldr r1, [r0, #CLKCTL_CSCDR1]
143         orr r1, r1, #0x3f
144         eor r1, r1, #0x3f
145         orr r1, r1, #0x21
146         str r1, [r0, #CLKCTL_CSCDR1]
147
148         /* Restore the default values in the Gate registers */
149         ldr r1, =0xFFFFFFFF
150         str r1, [r0, #CLKCTL_CCGR0]
151         str r1, [r0, #CLKCTL_CCGR1]
152         str r1, [r0, #CLKCTL_CCGR2]
153         str r1, [r0, #CLKCTL_CCGR3]
154         str r1, [r0, #CLKCTL_CCGR4]
155         str r1, [r0, #CLKCTL_CCGR5]
156         str r1, [r0, #CLKCTL_CCGR6]
157         str r1, [r0, #CLKCTL_CCGR7]
158
159         mov r1, #0x00000
160         str r1, [r0, #CLKCTL_CCDR]
161
162         /* for cko - for ARM div by 8 */
163         mov r1, #0x000A0000
164         add r1, r1, #0x00000F0
165         str r1, [r0, #CLKCTL_CCOSR]
166 .endm
167
168 .section ".text.init", "x"
169
170 .globl lowlevel_init
171 lowlevel_init:
172
173 #ifdef ENABLE_IMPRECISE_ABORT
174         mrs r1, spsr            /* save old spsr */
175         mrs r0, cpsr            /* read out the cpsr */
176         bic r0, r0, #0x100      /* clear the A bit */
177         msr spsr, r0            /* update spsr */
178         add lr, pc, #0x8        /* update lr */
179         movs pc, lr             /* update cpsr */
180         nop
181         nop
182         nop
183         nop
184         msr spsr, r1            /* restore old spsr */
185 #endif
186
187         /* ARM errata ID #468414 */
188         mrc 15, 0, r1, c1, c0, 1
189         orr r1, r1, #(1 << 5)    /* enable L1NEON bit */
190         mcr 15, 0, r1, c1, c0, 1
191
192         init_l2cc
193
194         init_aips
195
196         init_clock
197
198         mov pc, lr
199
200 /* Board level setting value */
201 CCM_BASE_ADDR_W:        .word CCM_BASE_ADDR
202 CCM_VAL_0x00016154:     .word 0x00016154
203 CCM_VAL_0x00808145:     .word 0x00808145
204 CCM_VAL_0x00015154:     .word 0x00015154
205 CCM_VAL_0x02888945:     .word 0x02888945
206 W_DP_OP_800:            .word DP_OP_800
207 W_DP_MFD_800:           .word DP_MFD_800
208 W_DP_MFN_800:           .word DP_MFN_800
209 W_DP_OP_600:            .word DP_OP_600
210 W_DP_MFD_600:           .word DP_MFD_600
211 W_DP_MFN_600:           .word DP_MFN_600
212 W_DP_OP_400:            .word DP_OP_400
213 W_DP_MFD_400:           .word DP_MFD_400
214 W_DP_MFN_400:           .word DP_MFN_400
215 W_DP_OP_216:            .word DP_OP_216
216 W_DP_MFD_216:           .word DP_MFD_216
217 W_DP_MFN_216:           .word DP_MFN_216
218 PLATFORM_BASE_ADDR_W:   .word ARM_BASE_ADDR
219 PLATFORM_CLOCK_DIV_W:   .word 0x00000124