]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/blackfin/mach-bf533/head.S
Blackfin arch: remove support for Anomaly 05000125 as it doesnt exist on any supporte...
[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 ENTRY(_real_start)
232         [ -- sp ] = reti;
233         p0.l = lo(WDOG_CTL);
234         p0.h = hi(WDOG_CTL);
235         r0 = 0xAD6(z);
236         w[p0] = r0;     /* watchdog off for now */
237         ssync;
238
239         /* Code update for BSS size == 0
240          * Zero out the bss region.
241          */
242
243         p1.l = ___bss_start;
244         p1.h = ___bss_start;
245         p2.l = ___bss_stop;
246         p2.h = ___bss_stop;
247         r0 = 0;
248         p2 -= p1;
249         lsetup (.L_clear_bss, .L_clear_bss) lc0 = p2;
250 .L_clear_bss:
251         B[p1++] = r0;
252
253         /* In case there is a NULL pointer reference
254          * Zero out region before stext
255          */
256
257         p1.l = 0x0;
258         p1.h = 0x0;
259         r0.l = __stext;
260         r0.h = __stext;
261         r0 = r0 >> 1;
262         p2 = r0;
263         r0 = 0;
264         lsetup (.L_clear_zero, .L_clear_zero) lc0 = p2;
265 .L_clear_zero:
266         W[p1++] = r0;
267
268         /* pass the uboot arguments to the global value command line */
269         R0 = R7;
270         call _cmdline_init;
271
272         p1.l = __rambase;
273         p1.h = __rambase;
274         r0.l = __sdata;
275         r0.h = __sdata;
276         [p1] = r0;
277
278         p1.l = __ramstart;
279         p1.h = __ramstart;
280         p3.l = ___bss_stop;
281         p3.h = ___bss_stop;
282
283         r1 = p3;
284         [p1] = r1;
285
286         /*
287          * load the current thread pointer and stack
288          */
289         r1.l = _init_thread_union;
290         r1.h = _init_thread_union;
291
292         r2.l = 0x2000;
293         r2.h = 0x0000;
294         r1 = r1 + r2;
295         sp = r1;
296         usp = sp;
297         fp = sp;
298         jump.l _start_kernel;
299 ENDPROC(_real_start)
300
301 __FINIT
302
303 .section .l1.text
304 #ifdef CONFIG_BFIN_KERNEL_CLOCK
305 ENTRY(_start_dma_code)
306         p0.h = hi(SIC_IWR);
307         p0.l = lo(SIC_IWR);
308         r0.l = 0x1;
309         r0.h = 0x0;
310         [p0] = r0;
311         SSYNC;
312
313         /*
314          *  Set PLL_CTL
315          *   - [14:09] = MSEL[5:0] : CLKIN / VCO multiplication factors
316          *   - [8]     = BYPASS    : BYPASS the PLL, run CLKIN into CCLK/SCLK
317          *   - [7]     = output delay (add 200ps of delay to mem signals)
318          *   - [6]     = input delay (add 200ps of input delay to mem signals)
319          *   - [5]     = PDWN      : 1=All Clocks off
320          *   - [3]     = STOPCK    : 1=Core Clock off
321          *   - [1]     = PLL_OFF   : 1=Disable Power to PLL
322          *   - [0]     = DF        : 1=Pass CLKIN/2 to PLL / 0=Pass CLKIN to PLL
323          *   all other bits set to zero
324          */
325
326         p0.h = hi(PLL_LOCKCNT);
327         p0.l = lo(PLL_LOCKCNT);
328         r0 = 0x300(Z);
329         w[p0] = r0.l;
330         ssync;
331
332         P2.H = hi(EBIU_SDGCTL);
333         P2.L = lo(EBIU_SDGCTL);
334         R0 = [P2];
335         BITSET (R0, 24);
336         [P2] = R0;
337         SSYNC;
338
339         r0 = CONFIG_VCO_MULT & 63;       /* Load the VCO multiplier         */
340         r0 = r0 << 9;                    /* Shift it over,                  */
341         r1 = CLKIN_HALF;                 /* Do we need to divide CLKIN by 2?*/
342         r0 = r1 | r0;
343         r1 = PLL_BYPASS;                 /* Bypass the PLL?                 */
344         r1 = r1 << 8;                    /* Shift it over                   */
345         r0 = r1 | r0;                    /* add them all together           */
346
347         p0.h = hi(PLL_CTL);
348         p0.l = lo(PLL_CTL);              /* Load the address                */
349         cli r2;                          /* Disable interrupts              */
350         ssync;
351         w[p0] = r0.l;                    /* Set the value                   */
352         idle;                            /* Wait for the PLL to stablize    */
353         sti r2;                          /* Enable interrupts               */
354
355 .Lcheck_again:
356         p0.h = hi(PLL_STAT);
357         p0.l = lo(PLL_STAT);
358         R0 = W[P0](Z);
359         CC = BITTST(R0,5);
360         if ! CC jump .Lcheck_again;
361
362         /* Configure SCLK & CCLK Dividers */
363         r0 = (CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV);
364         p0.h = hi(PLL_DIV);
365         p0.l = lo(PLL_DIV);
366         w[p0] = r0.l;
367         ssync;
368
369         p0.l = lo(EBIU_SDRRC);
370         p0.h = hi(EBIU_SDRRC);
371         r0 = mem_SDRRC;
372         w[p0] = r0.l;
373         ssync;
374
375         P2.H = hi(EBIU_SDGCTL);
376         P2.L = lo(EBIU_SDGCTL);
377         R0 = [P2];
378         BITCLR (R0, 24);
379         p0.h = hi(EBIU_SDSTAT);
380         p0.l = lo(EBIU_SDSTAT);
381         r2.l = w[p0];
382         cc = bittst(r2,3);
383         if !cc jump .Lskip;
384         NOP;
385         BITSET (R0, 23);
386 .Lskip:
387         [P2] = R0;
388         SSYNC;
389
390         R0.L = lo(mem_SDGCTL);
391         R0.H = hi(mem_SDGCTL);
392         R1 = [p2];
393         R1 = R1 | R0;
394         [P2] = R1;
395         SSYNC;
396
397         p0.h = hi(SIC_IWR);
398         p0.l = lo(SIC_IWR);
399         r0.l = lo(IWR_ENABLE_ALL);
400         r0.h = hi(IWR_ENABLE_ALL);
401         [p0] = r0;
402         SSYNC;
403
404         RTS;
405 ENDPROC(_start_dma_code)
406 #endif /* CONFIG_BFIN_KERNEL_CLOCK */