blob: c32fef616351ea0abb8b5d043622e7c7f60a5156 [file] [log] [blame]
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01001/*
Aubrey.Li3f0606a2007-03-09 13:38:44 +08002 * U-boot - start.S Startup file of u-boot for BF533/BF561
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01003 *
Aubrey Li155fd762007-04-05 18:31:18 +08004 * Copyright (c) 2005-2007 Analog Devices Inc.
Wolfgang Denk6cb142f2006-03-12 02:12:27 +01005 *
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
Aubrey Li155fd762007-04-05 18:31:18 +080029 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
30 * MA 02110-1301 USA
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010031 */
32
33/*
34 * Note: A change in this file subsequently requires a change in
Aubrey Li8db13d62007-03-10 23:49:29 +080035 * board/$(board_name)/config.mk for a valid u-boot.bin
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010036 */
37
38#define ASSEMBLY
39
40#include <linux/config.h>
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010041#include <config.h>
Aubrey.Li3f0606a2007-03-09 13:38:44 +080042#include <asm/blackfin.h>
43
Mike Frysingerd4d77302008-02-04 19:26:55 -050044#include <asm/mach-common/bits/core.h>
45#include <asm/mach-common/bits/dma.h>
46#include <asm/mach-common/bits/pll.h>
47
Aubrey.Li3f0606a2007-03-09 13:38:44 +080048.global _stext;
49.global __bss_start;
50.global start;
51.global _start;
Aubrey.Li3f0606a2007-03-09 13:38:44 +080052.global edata;
Aubrey.Li3f0606a2007-03-09 13:38:44 +080053.global _exit;
Aubrey.Li3f0606a2007-03-09 13:38:44 +080054.global init_sdram;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010055
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
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010072.text
73_start:
74start:
75_stext:
76
Aubrey.Li3f0606a2007-03-09 13:38:44 +080077 R0 = 0x32;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010078 SYSCFG = R0;
79 SSYNC;
80
81 /* As per HW reference manual DAG registers,
Aubrey Li0d93de12007-03-12 12:11:55 +080082 * DATA and Address resgister shall be zero'd
Wolfgang Denk6cb142f2006-03-12 02:12:27 +010083 * 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;
Aubrey Li0d93de12007-03-12 12:11:55 +080099
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100100 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 */
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800120 r0 = 0;
121 lc0 = r0;
122 lc1 = r0;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100123
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
139no_soft_reset:
140 nop;
141
142 /* Clear EVT registers */
Mike Frysingerd4d77302008-02-04 19:26:55 -0500143 p0.h = (EVT0 >> 16);
144 p0.l = (EVT0 & 0xFFFF);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100145 p0 += 8;
146 p1 = 14;
147 r1 = 0;
148 LSETUP(4,4) lc0 = p1;
149 [ p0 ++ ] = r1;
Aubrey Li0d93de12007-03-12 12:11:55 +0800150
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800151 p0.h = hi(SIC_IWR);
Aubrey Li8db13d62007-03-10 23:49:29 +0800152 p0.l = lo(SIC_IWR);
153 r0.l = 0x1;
154 w[p0] = r0.l;
155 SSYNC;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100156
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800157 sp.l = (0xffb01000 & 0xFFFF);
158 sp.h = (0xffb01000 >> 16);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100159
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800160 call init_sdram;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100161
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100162 /* relocate into to RAM */
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800163 call get_pc;
164offset:
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
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100174 p2.l = (CFG_MONITOR_BASE & 0xffff);
175 p2.h = (CFG_MONITOR_BASE >> 16);
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800176
177 p3 = 0x04;
178 p4.l = ((CFG_MONITOR_BASE + CFG_MONITOR_LEN) & 0xffff);
179 p4.h = ((CFG_MONITOR_BASE + CFG_MONITOR_LEN) >> 16);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100180loop1:
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800181 r1 = [p1 ++ p3];
182 [p2 ++ p3] = r1;
183 cc=p2==p4;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100184 if !cc jump loop1;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100185 /*
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 */
Mike Frysingerd4d77302008-02-04 19:26:55 -0500200 p0.l = (EVT15 & 0xFFFF);
201 p0.h = (EVT15 >> 16);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100202
203 p1.l = _real_start;
204 p1.h = _real_start;
205 [p0] = p1;
206
207 p0.l = (IMASK & 0xFFFF);
208 p0.h = (IMASK >> 16);
Mike Frysingerd4d77302008-02-04 19:26:55 -0500209 r0.l = LO(EVT_IVG15);
210 r0.h = HI(EVT_IVG15);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100211 [p0] = r0;
212 raise 15;
213 p0.l = WAIT_HERE;
214 p0.h = WAIT_HERE;
215 reti = p0;
216 rti;
217
218WAIT_HERE:
219 jump WAIT_HERE;
220
221.global _real_start;
222_real_start:
223 [ -- sp ] = reti;
224
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100225 /* DMA reset code to Hi of L1 SRAM */
226copy:
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800227 /* P1 Points to the beginning of SYSTEM MMR Space */
228 P1.H = hi(SYSMMR_BASE);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100229 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 */
Mike Frysingerd4d77302008-02-04 19:26:55 -0500236 R1.H = hi(L1_INST_SRAM); /* Destination Address (high) */
237 R1.L = lo(L1_INST_SRAM); /* Destination Address (low) */
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100238 R3.L = DMAEN; /* Source DMAConfig Value (8-bit words) */
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800239 /* Destination DMAConfig Value (8-bit words) */
240 R4.L = (DI_EN | WNR | DMAEN);
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100241
242DMA:
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
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800253 /* Set Destination Base Address */
254 [P1+OFFSET_(MDMA_D0_START_ADDR)] = R1;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100255 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;
Aubrey Li0d93de12007-03-12 12:11:55 +0800259
260WAIT_DMA_DONE:
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800261 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
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100266
267 R0 = 0x1;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100268
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800269 /* Write 1 to clear DMA interrupt */
270 W[P1+OFFSET_(MDMA_D0_IRQ_STATUS)] = R0;
Wolfgang Denk6cb142f2006-03-12 02:12:27 +0100271
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
295reset_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;
304reset_wait:
305 jump reset_wait;
306
307reset_end: nop;
308
309_exit:
310 jump.s _exit;
Aubrey.Li3f0606a2007-03-09 13:38:44 +0800311get_pc:
312 r0 = rets;
313 rts;