]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/blackfin/mach-bf533/head.S
Blackfin arch: unify the duplicated _real_start functions
[linux-2.6-omap-h63xx.git] / arch / blackfin / mach-bf533 / head.S
1 /*
2  * File:         arch/blackfin/mach-bf533/head.S
3  * Based on:
4  * Author:       Jeff Dionne <jeff@uclinux.org> COPYRIGHT 1998 D. Jeff Dionne
5  *
6  * Created:      1998
7  * Description:  bf533 startup file
8  *
9  * Modified:
10  *               Copyright 2004-2006 Analog Devices Inc.
11  *
12  * Bugs:         Enter bugs at http://blackfin.uclinux.org/
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program; if not, see the file COPYING, or write
26  * to the Free Software Foundation, Inc.,
27  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28  */
29
30 #include <linux/linkage.h>
31 #include <linux/init.h>
32 #include <asm/blackfin.h>
33 #include <asm/trace.h>
34 #ifdef CONFIG_BFIN_KERNEL_CLOCK
35 #include <asm/mach-common/clocks.h>
36 #include <asm/mach/mem_init.h>
37 #endif
38
39 .extern ___bss_stop
40 .extern ___bss_start
41 .extern _bf53x_relocate_l1_mem
42
43 #define INITIAL_STACK   0xFFB01000
44
45 __INIT
46
47 ENTRY(__start)
48         /* R0: argument of command line string, passed from uboot, save it */
49         R7 = R0;
50         /* Enable Cycle Counter and Nesting Of Interrupts */
51 #ifdef CONFIG_BFIN_SCRATCH_REG_CYCLES
52         R0 = SYSCFG_SNEN;
53 #else
54         R0 = SYSCFG_SNEN | SYSCFG_CCEN;
55 #endif
56         SYSCFG = R0;
57         R0 = 0;
58
59         /* Clear Out All the data and pointer Registers */
60         R1 = R0;
61         R2 = R0;
62         R3 = R0;
63         R4 = R0;
64         R5 = R0;
65         R6 = R0;
66
67         P0 = R0;
68         P1 = R0;
69         P2 = R0;
70         P3 = R0;
71         P4 = R0;
72         P5 = R0;
73
74         LC0 = r0;
75         LC1 = r0;
76         L0 = r0;
77         L1 = r0;
78         L2 = r0;
79         L3 = r0;
80
81         /* Clear Out All the DAG Registers */
82         B0 = r0;
83         B1 = r0;
84         B2 = r0;
85         B3 = r0;
86
87         I0 = r0;
88         I1 = r0;
89         I2 = r0;
90         I3 = r0;
91
92         M0 = r0;
93         M1 = r0;
94         M2 = r0;
95         M3 = r0;
96
97         trace_buffer_init(p0,r0);
98         P0 = R1;
99         R0 = R1;
100
101         p0.h = hi(FIO_MASKA_C);
102         p0.l = lo(FIO_MASKA_C);
103         r0 = 0xFFFF(Z);
104         w[p0] = r0.L;   /* Disable all interrupts */
105         ssync;
106
107         p0.h = hi(FIO_MASKB_C);
108         p0.l = lo(FIO_MASKB_C);
109         r0 = 0xFFFF(Z);
110         w[p0] = r0.L;   /* Disable all interrupts */
111         ssync;
112
113         /* Turn off the icache */
114         p0.l = LO(IMEM_CONTROL);
115         p0.h = HI(IMEM_CONTROL);
116         R1 = [p0];
117         R0 = ~ENICPLB;
118         R0 = R0 & R1;
119         [p0] = R0;
120         SSYNC;
121
122         /* Turn off the dcache */
123         p0.l = LO(DMEM_CONTROL);
124         p0.h = HI(DMEM_CONTROL);
125         R1 = [p0];
126         R0 = ~ENDCPLB;
127         R0 = R0 & R1;
128         [p0] = R0;
129         SSYNC;
130
131         /* Initialise UART - when booting from u-boot, the UART is not disabled
132          * so if we dont initalize here, our serial console gets hosed */
133         p0.h = hi(BFIN_UART_LCR);
134         p0.l = lo(BFIN_UART_LCR);
135         r0 = 0x0(Z);
136         w[p0] = r0.L;   /* To enable DLL writes */
137         ssync;
138
139         p0.h = hi(BFIN_UART_DLL);
140         p0.l = lo(BFIN_UART_DLL);
141         r0 = 0x0(Z);
142         w[p0] = r0.L;
143         ssync;
144
145         p0.h = hi(BFIN_UART_DLH);
146         p0.l = lo(BFIN_UART_DLH);
147         r0 = 0x00(Z);
148         w[p0] = r0.L;
149         ssync;
150
151         p0.h = hi(BFIN_UART_GCTL);
152         p0.l = lo(BFIN_UART_GCTL);
153         r0 = 0x0(Z);
154         w[p0] = r0.L;   /* To enable UART clock */
155         ssync;
156
157         /* Initialize stack pointer */
158         sp.l = lo(INITIAL_STACK);
159         sp.h = hi(INITIAL_STACK);
160         fp = sp;
161         usp = sp;
162
163 #ifdef CONFIG_EARLY_PRINTK
164         SP += -12;
165         call _init_early_exception_vectors;
166         SP += 12;
167 #endif
168
169         /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
170         call _bf53x_relocate_l1_mem;
171 #ifdef CONFIG_BFIN_KERNEL_CLOCK
172         call _start_dma_code;
173 #endif
174
175         /* Code for initializing Async memory banks */
176
177         p2.h = hi(EBIU_AMBCTL1);
178         p2.l = lo(EBIU_AMBCTL1);
179         r0.h = hi(AMBCTL1VAL);
180         r0.l = lo(AMBCTL1VAL);
181         [p2] = r0;
182         ssync;
183
184         p2.h = hi(EBIU_AMBCTL0);
185         p2.l = lo(EBIU_AMBCTL0);
186         r0.h = hi(AMBCTL0VAL);
187         r0.l = lo(AMBCTL0VAL);
188         [p2] = r0;
189         ssync;
190
191         p2.h = hi(EBIU_AMGCTL);
192         p2.l = lo(EBIU_AMGCTL);
193         r0 = AMGCTLVAL;
194         w[p2] = r0;
195         ssync;
196
197         /* This section keeps the processor in supervisor mode
198          * during kernel boot.  Switches to user mode at end of boot.
199          * See page 3-9 of Hardware Reference manual for documentation.
200          */
201
202         /* EVT15 = _real_start */
203
204         p0.l = lo(EVT15);
205         p0.h = hi(EVT15);
206         p1.l = _real_start;
207         p1.h = _real_start;
208         [p0] = p1;
209         csync;
210
211         p0.l = lo(IMASK);
212         p0.h = hi(IMASK);
213         p1.l = IMASK_IVG15;
214         p1.h = 0x0;
215         [p0] = p1;
216         csync;
217
218         raise 15;
219         p0.l = .LWAIT_HERE;
220         p0.h = .LWAIT_HERE;
221         reti = p0;
222 #if ANOMALY_05000281
223         nop; nop; nop;
224 #endif
225         rti;
226
227 .LWAIT_HERE:
228         jump .LWAIT_HERE;
229 ENDPROC(__start)
230
231 __FINIT
232
233 .section .l1.text
234 #ifdef CONFIG_BFIN_KERNEL_CLOCK
235 ENTRY(_start_dma_code)
236         p0.h = hi(SIC_IWR);
237         p0.l = lo(SIC_IWR);
238         r0.l = 0x1;
239         r0.h = 0x0;
240         [p0] = r0;
241         SSYNC;
242
243         /*
244          *  Set PLL_CTL
245          *   - [14:09] = MSEL[5:0] : CLKIN / VCO multiplication factors
246          *   - [8]     = BYPASS    : BYPASS the PLL, run CLKIN into CCLK/SCLK
247          *   - [7]     = output delay (add 200ps of delay to mem signals)
248          *   - [6]     = input delay (add 200ps of input delay to mem signals)
249          *   - [5]     = PDWN      : 1=All Clocks off
250          *   - [3]     = STOPCK    : 1=Core Clock off
251          *   - [1]     = PLL_OFF   : 1=Disable Power to PLL
252          *   - [0]     = DF        : 1=Pass CLKIN/2 to PLL / 0=Pass CLKIN to PLL
253          *   all other bits set to zero
254          */
255
256         p0.h = hi(PLL_LOCKCNT);
257         p0.l = lo(PLL_LOCKCNT);
258         r0 = 0x300(Z);
259         w[p0] = r0.l;
260         ssync;
261
262         P2.H = hi(EBIU_SDGCTL);
263         P2.L = lo(EBIU_SDGCTL);
264         R0 = [P2];
265         BITSET (R0, 24);
266         [P2] = R0;
267         SSYNC;
268
269         r0 = CONFIG_VCO_MULT & 63;       /* Load the VCO multiplier         */
270         r0 = r0 << 9;                    /* Shift it over,                  */
271         r1 = CLKIN_HALF;                 /* Do we need to divide CLKIN by 2?*/
272         r0 = r1 | r0;
273         r1 = PLL_BYPASS;                 /* Bypass the PLL?                 */
274         r1 = r1 << 8;                    /* Shift it over                   */
275         r0 = r1 | r0;                    /* add them all together           */
276
277         p0.h = hi(PLL_CTL);
278         p0.l = lo(PLL_CTL);              /* Load the address                */
279         cli r2;                          /* Disable interrupts              */
280         ssync;
281         w[p0] = r0.l;                    /* Set the value                   */
282         idle;                            /* Wait for the PLL to stablize    */
283         sti r2;                          /* Enable interrupts               */
284
285 .Lcheck_again:
286         p0.h = hi(PLL_STAT);
287         p0.l = lo(PLL_STAT);
288         R0 = W[P0](Z);
289         CC = BITTST(R0,5);
290         if ! CC jump .Lcheck_again;
291
292         /* Configure SCLK & CCLK Dividers */
293         r0 = (CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV);
294         p0.h = hi(PLL_DIV);
295         p0.l = lo(PLL_DIV);
296         w[p0] = r0.l;
297         ssync;
298
299         p0.l = lo(EBIU_SDRRC);
300         p0.h = hi(EBIU_SDRRC);
301         r0 = mem_SDRRC;
302         w[p0] = r0.l;
303         ssync;
304
305         P2.H = hi(EBIU_SDGCTL);
306         P2.L = lo(EBIU_SDGCTL);
307         R0 = [P2];
308         BITCLR (R0, 24);
309         p0.h = hi(EBIU_SDSTAT);
310         p0.l = lo(EBIU_SDSTAT);
311         r2.l = w[p0];
312         cc = bittst(r2,3);
313         if !cc jump .Lskip;
314         NOP;
315         BITSET (R0, 23);
316 .Lskip:
317         [P2] = R0;
318         SSYNC;
319
320         R0.L = lo(mem_SDGCTL);
321         R0.H = hi(mem_SDGCTL);
322         R1 = [p2];
323         R1 = R1 | R0;
324         [P2] = R1;
325         SSYNC;
326
327         p0.h = hi(SIC_IWR);
328         p0.l = lo(SIC_IWR);
329         r0.l = lo(IWR_ENABLE_ALL);
330         r0.h = hi(IWR_ENABLE_ALL);
331         [p0] = r0;
332         SSYNC;
333
334         RTS;
335 ENDPROC(_start_dma_code)
336 #endif /* CONFIG_BFIN_KERNEL_CLOCK */