]> git.karo-electronics.de Git - karo-tx-uboot.git/blob - cpu/bf533/start.S
scrub unused symbols
[karo-tx-uboot.git] / cpu / bf533 / start.S
1 /*
2  * U-boot - start.S Startup file of u-boot for BF533/BF561
3  *
4  * Copyright (c) 2005-2007 Analog Devices Inc.
5  *
6  * This file is based on head.S
7  * Copyright (c) 2003  Metrowerks/Motorola
8  * Copyright (C) 1998  D. Jeff Dionne <jeff@ryeham.ee.ryerson.ca>,
9  *                     Kenneth Albanowski <kjahds@kjahds.com>,
10  *                     The Silver Hammer Group, Ltd.
11  * (c) 1995, Dionne & Associates
12  * (c) 1995, DKG Display Tech.
13  *
14  * See file CREDITS for list of people who contributed to this
15  * project.
16  *
17  * This program is free software; you can redistribute it and/or
18  * modify it under the terms of the GNU General Public License as
19  * published by the Free Software Foundation; either version 2 of
20  * the License, or (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU General Public License for more details.
26  *
27  * You should have received a copy of the GNU General Public License
28  * along with this program; if not, write to the Free Software
29  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
30  * MA 02110-1301 USA
31  */
32
33 /*
34  * Note: A change in this file subsequently requires a change in
35  *       board/$(board_name)/config.mk for a valid u-boot.bin
36  */
37
38 #define ASSEMBLY
39
40 #include <linux/config.h>
41 #include <config.h>
42 #include <asm/blackfin.h>
43
44 #include <asm/mach-common/bits/core.h>
45 #include <asm/mach-common/bits/dma.h>
46 #include <asm/mach-common/bits/pll.h>
47
48 .global _stext;
49 .global __bss_start;
50 .global start;
51 .global _start;
52 .global edata;
53 .global _exit;
54 .global init_sdram;
55
56 #if (CONFIG_CCLK_DIV == 1)
57 #define CONFIG_CCLK_ACT_DIV   CCLK_DIV1
58 #endif
59 #if (CONFIG_CCLK_DIV == 2)
60 #define CONFIG_CCLK_ACT_DIV   CCLK_DIV2
61 #endif
62 #if (CONFIG_CCLK_DIV == 4)
63 #define CONFIG_CCLK_ACT_DIV   CCLK_DIV4
64 #endif
65 #if (CONFIG_CCLK_DIV == 8)
66 #define CONFIG_CCLK_ACT_DIV   CCLK_DIV8
67 #endif
68 #ifndef CONFIG_CCLK_ACT_DIV
69 #define CONFIG_CCLK_ACT_DIV   CONFIG_CCLK_DIV_not_defined_properly
70 #endif
71
72 .text
73 _start:
74 start:
75 _stext:
76
77         R0 = 0x32;
78         SYSCFG = R0;
79         SSYNC;
80
81         /* As per HW reference manual DAG registers,
82          * DATA and Address resgister shall be zero'd
83          * in initialization, after a reset state
84          */
85         r1 = 0; /* Data registers zero'd */
86         r2 = 0;
87         r3 = 0;
88         r4 = 0;
89         r5 = 0;
90         r6 = 0;
91         r7 = 0;
92
93         p0 = 0; /* Address registers zero'd */
94         p1 = 0;
95         p2 = 0;
96         p3 = 0;
97         p4 = 0;
98         p5 = 0;
99
100         i0 = 0; /* DAG Registers zero'd */
101         i1 = 0;
102         i2 = 0;
103         i3 = 0;
104         m0 = 0;
105         m1 = 0;
106         m3 = 0;
107         m3 = 0;
108         l0 = 0;
109         l1 = 0;
110         l2 = 0;
111         l3 = 0;
112         b0 = 0;
113         b1 = 0;
114         b2 = 0;
115         b3 = 0;
116
117         /* Set loop counters to zero, to make sure that
118          * hw loops are disabled.
119          */
120         r0  = 0;
121         lc0 = r0;
122         lc1 = r0;
123
124         SSYNC;
125
126         /* Check soft reset status */
127         p0.h = SWRST >> 16;
128         p0.l = SWRST & 0xFFFF;
129         r0.l = w[p0];
130
131         cc = bittst(r0, 15);
132         if !cc jump no_soft_reset;
133
134         /* Clear Soft reset */
135         r0 = 0x0000;
136         w[p0] = r0;
137         ssync;
138
139 no_soft_reset:
140         nop;
141
142         /* Clear EVT registers */
143         p0.h = (EVT0 >> 16);
144         p0.l = (EVT0 & 0xFFFF);
145         p0 += 8;
146         p1 = 14;
147         r1 = 0;
148         LSETUP(4,4) lc0 = p1;
149         [ p0 ++ ] = r1;
150
151         p0.h = hi(SIC_IWR);
152         p0.l = lo(SIC_IWR);
153         r0.l = 0x1;
154         w[p0] = r0.l;
155         SSYNC;
156
157         sp.l = (0xffb01000 & 0xFFFF);
158         sp.h = (0xffb01000 >> 16);
159
160         call init_sdram;
161
162         /* relocate into to RAM */
163         call get_pc;
164 offset:
165         r2.l = offset;
166         r2.h = offset;
167         r3.l = start;
168         r3.h = start;
169         r1 = r2 - r3;
170
171         r0 = r0 - r1;
172         p1 = r0;
173
174         p2.l = (CFG_MONITOR_BASE & 0xffff);
175         p2.h = (CFG_MONITOR_BASE >> 16);
176
177         p3 = 0x04;
178         p4.l = ((CFG_MONITOR_BASE + CFG_MONITOR_LEN) & 0xffff);
179         p4.h = ((CFG_MONITOR_BASE + CFG_MONITOR_LEN) >> 16);
180 loop1:
181         r1 = [p1 ++ p3];
182         [p2 ++ p3] = r1;
183         cc=p2==p4;
184         if !cc jump loop1;
185         /*
186          * configure STACK
187          */
188         r0.h = (CONFIG_STACKBASE >> 16);
189         r0.l = (CONFIG_STACKBASE & 0xFFFF);
190         sp = r0;
191         fp = sp;
192
193         /*
194          * This next section keeps the processor in supervisor mode
195          * during kernel boot.  Switches to user mode at end of boot.
196          * See page 3-9 of Hardware Reference manual for documentation.
197          */
198
199         /* To keep ourselves in the supervisor mode */
200         p0.l = (EVT15 & 0xFFFF);
201         p0.h = (EVT15 >> 16);
202
203         p1.l = _real_start;
204         p1.h = _real_start;
205         [p0] = p1;
206
207         p0.l = (IMASK & 0xFFFF);
208         p0.h = (IMASK >> 16);
209         r0.l = LO(EVT_IVG15);
210         r0.h = HI(EVT_IVG15);
211         [p0] = r0;
212         raise 15;
213         p0.l = WAIT_HERE;
214         p0.h = WAIT_HERE;
215         reti = p0;
216         rti;
217
218 WAIT_HERE:
219         jump WAIT_HERE;
220
221 .global _real_start;
222 _real_start:
223         [ -- sp ] = reti;
224
225         /* DMA reset code to Hi of L1 SRAM */
226 copy:
227         /* P1 Points to the beginning of SYSTEM MMR Space */
228         P1.H = hi(SYSMMR_BASE);
229         P1.L = lo(SYSMMR_BASE);
230
231         R0.H = reset_start;     /* Source Address (high) */
232         R0.L = reset_start;     /* Source Address (low) */
233         R1.H = reset_end;
234         R1.L = reset_end;
235         R2 = R1 - R0;           /* Count */
236         R1.H = hi(L1_INST_SRAM);        /* Destination Address (high) */
237         R1.L = lo(L1_INST_SRAM);        /* Destination Address (low) */
238         R3.L = DMAEN;           /* Source DMAConfig Value (8-bit words) */
239         /* Destination DMAConfig Value (8-bit words) */
240         R4.L = (DI_EN | WNR | DMAEN);
241
242 DMA:
243         R6 = 0x1 (Z);
244         W[P1+OFFSET_(MDMA_S0_X_MODIFY)] = R6;   /* Source Modify = 1 */
245         W[P1+OFFSET_(MDMA_D0_X_MODIFY)] = R6;   /* Destination Modify = 1 */
246
247         [P1+OFFSET_(MDMA_S0_START_ADDR)] = R0;  /* Set Source Base Address */
248         W[P1+OFFSET_(MDMA_S0_X_COUNT)] = R2;    /* Set Source Count */
249         /* Set Source  DMAConfig = DMA Enable,
250         Memory Read,  8-Bit Transfers, 1-D DMA, Flow - Stop */
251         W[P1+OFFSET_(MDMA_S0_CONFIG)] = R3;
252
253         /* Set Destination Base Address */
254         [P1+OFFSET_(MDMA_D0_START_ADDR)] = R1;
255         W[P1+OFFSET_(MDMA_D0_X_COUNT)] = R2;    /* Set Destination Count */
256         /* Set Destination DMAConfig = DMA Enable,
257         Memory Write, 8-Bit Transfers, 1-D DMA, Flow - Stop, IOC */
258         W[P1+OFFSET_(MDMA_D0_CONFIG)] = R4;
259
260 WAIT_DMA_DONE:
261         p0.h = hi(MDMA_D0_IRQ_STATUS);
262         p0.l = lo(MDMA_D0_IRQ_STATUS);
263         R0 = W[P0](Z);
264         CC = BITTST(R0, 0);
265         if ! CC jump WAIT_DMA_DONE
266
267         R0 = 0x1;
268
269         /* Write 1 to clear DMA interrupt */
270         W[P1+OFFSET_(MDMA_D0_IRQ_STATUS)] = R0;
271
272         /* Initialize BSS Section with 0 s */
273         p1.l = __bss_start;
274         p1.h = __bss_start;
275         p2.l = _end;
276         p2.h = _end;
277         r1 = p1;
278         r2 = p2;
279         r3 = r2 - r1;
280         r3 = r3 >> 2;
281         p3 = r3;
282         lsetup (_clear_bss, _clear_bss_end ) lc1 = p3;
283         CC = p2<=p1;
284         if CC jump _clear_bss_skip;
285         r0 = 0;
286 _clear_bss:
287 _clear_bss_end:
288         [p1++] = r0;
289 _clear_bss_skip:
290
291         p0.l = _start1;
292         p0.h = _start1;
293         jump (p0);
294
295 reset_start:
296         p0.h = WDOG_CNT >> 16;
297         p0.l = WDOG_CNT & 0xffff;
298         r0 = 0x0010;
299         w[p0] = r0;
300         p0.h = WDOG_CTL >> 16;
301         p0.l = WDOG_CTL & 0xffff;
302         r0 = 0x0000;
303         w[p0] = r0;
304 reset_wait:
305         jump reset_wait;
306
307 reset_end: nop;
308
309 _exit:
310         jump.s  _exit;
311 get_pc:
312         r0 = rets;
313         rts;