]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/blackfin/mach-bf533/head.S
7f0a7a0c6fd6fde6204a8e9329e7f0bacd6be4ea
[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         /* This section keeps the processor in supervisor mode
176          * during kernel boot.  Switches to user mode at end of boot.
177          * See page 3-9 of Hardware Reference manual for documentation.
178          */
179
180         /* EVT15 = _real_start */
181
182         p0.l = lo(EVT15);
183         p0.h = hi(EVT15);
184         p1.l = _real_start;
185         p1.h = _real_start;
186         [p0] = p1;
187         csync;
188
189         p0.l = lo(IMASK);
190         p0.h = hi(IMASK);
191         p1.l = IMASK_IVG15;
192         p1.h = 0x0;
193         [p0] = p1;
194         csync;
195
196         raise 15;
197         p0.l = .LWAIT_HERE;
198         p0.h = .LWAIT_HERE;
199         reti = p0;
200 #if ANOMALY_05000281
201         nop; nop; nop;
202 #endif
203         rti;
204
205 .LWAIT_HERE:
206         jump .LWAIT_HERE;
207 ENDPROC(__start)
208
209 __FINIT
210
211 .section .l1.text
212 #ifdef CONFIG_BFIN_KERNEL_CLOCK
213 ENTRY(_start_dma_code)
214         p0.h = hi(SIC_IWR);
215         p0.l = lo(SIC_IWR);
216         r0.l = 0x1;
217         r0.h = 0x0;
218         [p0] = r0;
219         SSYNC;
220
221         /*
222          *  Set PLL_CTL
223          *   - [14:09] = MSEL[5:0] : CLKIN / VCO multiplication factors
224          *   - [8]     = BYPASS    : BYPASS the PLL, run CLKIN into CCLK/SCLK
225          *   - [7]     = output delay (add 200ps of delay to mem signals)
226          *   - [6]     = input delay (add 200ps of input delay to mem signals)
227          *   - [5]     = PDWN      : 1=All Clocks off
228          *   - [3]     = STOPCK    : 1=Core Clock off
229          *   - [1]     = PLL_OFF   : 1=Disable Power to PLL
230          *   - [0]     = DF        : 1=Pass CLKIN/2 to PLL / 0=Pass CLKIN to PLL
231          *   all other bits set to zero
232          */
233
234         p0.h = hi(PLL_LOCKCNT);
235         p0.l = lo(PLL_LOCKCNT);
236         r0 = 0x300(Z);
237         w[p0] = r0.l;
238         ssync;
239
240         P2.H = hi(EBIU_SDGCTL);
241         P2.L = lo(EBIU_SDGCTL);
242         R0 = [P2];
243         BITSET (R0, 24);
244         [P2] = R0;
245         SSYNC;
246
247         r0 = CONFIG_VCO_MULT & 63;       /* Load the VCO multiplier         */
248         r0 = r0 << 9;                    /* Shift it over,                  */
249         r1 = CLKIN_HALF;                 /* Do we need to divide CLKIN by 2?*/
250         r0 = r1 | r0;
251         r1 = PLL_BYPASS;                 /* Bypass the PLL?                 */
252         r1 = r1 << 8;                    /* Shift it over                   */
253         r0 = r1 | r0;                    /* add them all together           */
254
255         p0.h = hi(PLL_CTL);
256         p0.l = lo(PLL_CTL);              /* Load the address                */
257         cli r2;                          /* Disable interrupts              */
258         ssync;
259         w[p0] = r0.l;                    /* Set the value                   */
260         idle;                            /* Wait for the PLL to stablize    */
261         sti r2;                          /* Enable interrupts               */
262
263 .Lcheck_again:
264         p0.h = hi(PLL_STAT);
265         p0.l = lo(PLL_STAT);
266         R0 = W[P0](Z);
267         CC = BITTST(R0,5);
268         if ! CC jump .Lcheck_again;
269
270         /* Configure SCLK & CCLK Dividers */
271         r0 = (CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV);
272         p0.h = hi(PLL_DIV);
273         p0.l = lo(PLL_DIV);
274         w[p0] = r0.l;
275         ssync;
276
277         p0.l = lo(EBIU_SDRRC);
278         p0.h = hi(EBIU_SDRRC);
279         r0 = mem_SDRRC;
280         w[p0] = r0.l;
281         ssync;
282
283         P2.H = hi(EBIU_SDGCTL);
284         P2.L = lo(EBIU_SDGCTL);
285         R0 = [P2];
286         BITCLR (R0, 24);
287         p0.h = hi(EBIU_SDSTAT);
288         p0.l = lo(EBIU_SDSTAT);
289         r2.l = w[p0];
290         cc = bittst(r2,3);
291         if !cc jump .Lskip;
292         NOP;
293         BITSET (R0, 23);
294 .Lskip:
295         [P2] = R0;
296         SSYNC;
297
298         R0.L = lo(mem_SDGCTL);
299         R0.H = hi(mem_SDGCTL);
300         R1 = [p2];
301         R1 = R1 | R0;
302         [P2] = R1;
303         SSYNC;
304
305         p0.h = hi(SIC_IWR);
306         p0.l = lo(SIC_IWR);
307         r0.l = lo(IWR_ENABLE_ALL);
308         r0.h = hi(IWR_ENABLE_ALL);
309         [p0] = r0;
310         SSYNC;
311
312         RTS;
313 ENDPROC(_start_dma_code)
314 #endif /* CONFIG_BFIN_KERNEL_CLOCK */