]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/freescale/mx50_arm2/lowlevel_init.S
applied patches from Freescale and Ka-Ro
[karo-tx-uboot.git] / board / freescale / mx50_arm2 / 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/mx50.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
88         setup_pll PLL3_BASE_ADDR, 400
89
90         /* Switch peripheral to PLL3 */
91         /* Set periph_clk_sel[1:0]=0b10 to PLL3 */
92
93         ldr r0, CCM_BASE_ADDR_W
94         ldr r1, [r0, #CLKCTL_CBCDR]
95         orr r1, r1, #(3 << 25)
96         eor r1, r1, #(3 << 25)
97         orr r1, r1, #(2 << 25)
98         str r1, [r0, #CLKCTL_CBCDR]
99
100         /* make sure change is effective */
101 1:      ldr r1, [r0, #CLKCTL_CDHIPR]
102         cmp r1, #0x0
103         bne 1b
104
105         setup_pll PLL2_BASE_ADDR, CONFIG_SYS_PLL2_FREQ
106
107         /* Switch peripheral to PLL2 */
108         /* Set periph_clk_sel[1:0]=0b01 to PLL2 */
109
110         ldr r0, CCM_BASE_ADDR_W
111         ldr r1, [r0, #CLKCTL_CBCDR]
112         orr r1, r1, #(3 << 25)
113         eor r1, r1, #(3 << 25)
114         orr r1, r1, #(1 << 25)
115
116         orr r1, r1, #(CONFIG_SYS_AHB_PODF << 10)
117         orr r1, r1, #(CONFIG_SYS_AXIA_PODF << 16)
118         orr r1, r1, #(CONFIG_SYS_AXIB_PODF << 19)
119         str r1, [r0, #CLKCTL_CBCDR]
120
121         /* make sure change is effective */
122 1:      ldr r1, [r0, #CLKCTL_CDHIPR]
123         cmp r1, #0x0
124         bne 1b
125
126         setup_pll PLL3_BASE_ADDR, 216
127
128         /* Set the platform clock dividers */
129         ldr r0, PLATFORM_BASE_ADDR_W
130         ldr r1, PLATFORM_CLOCK_DIV_W
131         str r1, [r0, #PLATFORM_ICGC]
132
133         /* ARM2 run at full speed */
134         ldr r0, CCM_BASE_ADDR_W
135         mov r1, #0
136         str r1, [r0, #CLKCTL_CACRR]
137
138         /* make sure change is effective */
139 1:      ldr r1, [r0, #CLKCTL_CDHIPR]
140         cmp r1, #0x0
141         bne 1b
142
143         /* Restore the default values in the Gate registers */
144         ldr r1, =0xFFFFFFFF
145         str r1, [r0, #CLKCTL_CCGR0]
146         str r1, [r0, #CLKCTL_CCGR1]
147         str r1, [r0, #CLKCTL_CCGR2]
148         str r1, [r0, #CLKCTL_CCGR3]
149         str r1, [r0, #CLKCTL_CCGR4]
150         str r1, [r0, #CLKCTL_CCGR5]
151         str r1, [r0, #CLKCTL_CCGR6]
152         str r1, [r0, #CLKCTL_CCGR7]
153
154         /* for cko - for ARM div by 8 */
155         mov r1, #0x000A0000
156         add r1, r1, #0x00000F0
157         str r1, [r0, #CLKCTL_CCOSR]
158 .endm
159
160 .section ".text.init", "x"
161
162 .globl lowlevel_init
163 lowlevel_init:
164
165 #ifdef ENABLE_IMPRECISE_ABORT
166         mrs r1, spsr            /* save old spsr */
167         mrs r0, cpsr            /* read out the cpsr */
168         bic r0, r0, #0x100      /* clear the A bit */
169         msr spsr, r0            /* update spsr */
170         add lr, pc, #0x8        /* update lr */
171         movs pc, lr             /* update cpsr */
172         nop
173         nop
174         nop
175         nop
176         msr spsr, r1            /* restore old spsr */
177 #endif
178
179         /* ARM errata ID #468414 */
180         mrc 15, 0, r1, c1, c0, 1
181         orr r1, r1, #(1 << 5)    /* enable L1NEON bit */
182         mcr 15, 0, r1, c1, c0, 1
183
184         init_l2cc
185
186         init_aips
187
188         init_clock /* not finished */
189
190         mov pc, lr
191
192 /* Board level setting value */
193 CCM_BASE_ADDR_W:        .word CCM_BASE_ADDR
194 W_DP_OP_800:            .word DP_OP_800
195 W_DP_MFD_800:           .word DP_MFD_800
196 W_DP_MFN_800:           .word DP_MFN_800
197 W_DP_OP_600:            .word DP_OP_600
198 W_DP_MFD_600:           .word DP_MFD_600
199 W_DP_MFN_600:           .word DP_MFN_600
200 W_DP_OP_400:            .word DP_OP_400
201 W_DP_MFD_400:           .word DP_MFD_400
202 W_DP_MFN_400:           .word DP_MFN_400
203 W_DP_OP_216:            .word DP_OP_216
204 W_DP_MFD_216:           .word DP_MFD_216
205 W_DP_MFN_216:           .word DP_MFN_216
206 PLATFORM_BASE_ADDR_W:   .word ARM_BASE_ADDR
207 PLATFORM_CLOCK_DIV_W:   .word 0x00000124