2 * U-boot - start.S Startup file of u-boot for BF533
4 * Copyright (c) 2005 blackfin.uclinux.org
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.
14 * See file CREDITS for list of people who contributed to this
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.
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.
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., 59 Temple Place, Suite 330, Boston,
34 * Note: A change in this file subsequently requires a change in
35 * board/$(board_name)/config.mk for a valid u-boot.bin
40 #include <linux/config.h>
41 #include <asm/blackfin.h>
43 #include <asm/mem_init.h>
45 #if (CONFIG_CCLK_DIV == 1)
46 #define CONFIG_CCLK_ACT_DIV CCLK_DIV1
48 #if (CONFIG_CCLK_DIV == 2)
49 #define CONFIG_CCLK_ACT_DIV CCLK_DIV2
51 #if (CONFIG_CCLK_DIV == 4)
52 #define CONFIG_CCLK_ACT_DIV CCLK_DIV4
54 #if (CONFIG_CCLK_DIV == 8)
55 #define CONFIG_CCLK_ACT_DIV CCLK_DIV8
57 #ifndef CONFIG_CCLK_ACT_DIV
58 #define CONFIG_CCLK_ACT_DIV CONFIG_CCLK_DIV_not_defined_properly
68 .global _bf533_data_dest;
69 .global _bf533_data_size;
84 /* As per HW reference manual DAG registers,
85 * DATA and Address resgister shall be zero'd
86 * in initialization, after a reset state
88 r1 = 0; /* Data registers zero'd */
96 p0 = 0; /* Address registers zero'd */
103 i0 = 0; /* DAG Registers zero'd */
120 /* Set loop counters to zero, to make sure that
121 * hw loops are disabled.
128 /* Check soft reset status */
130 p0.l = SWRST & 0xFFFF;
134 if !cc jump no_soft_reset;
136 /* Clear Soft reset */
144 /* Clear EVT registers */
145 p0.h = (EVT_EMULATION_ADDR >> 16);
146 p0.l = (EVT_EMULATION_ADDR & 0xFFFF);
150 LSETUP(4,4) lc0 = p1;
155 * - [14:09] = MSEL[5:0] : CLKIN / VCO multiplication factors
156 * - [8] = BYPASS : BYPASS the PLL, run CLKIN into CCLK/SCLK
157 * - [7] = output delay (add 200ps of delay to mem signals)
158 * - [6] = input delay (add 200ps of input delay to mem signals)
159 * - [5] = PDWN : 1=All Clocks off
160 * - [3] = STOPCK : 1=Core Clock off
161 * - [1] = PLL_OFF : 1=Disable Power to PLL
162 * - [0] = DF : 1=Pass CLKIN/2 to PLL / 0=Pass CLKIN to PLL
163 * all other bits set to zero
166 r0 = CONFIG_VCO_MULT; /* Load the VCO multiplier */
167 r0 = r0 << 9; /* Shift it over */
168 r1 = CONFIG_CLKIN_HALF; /* Do we need to divide CLKIN by 2? */
170 r1 = CONFIG_PLL_BYPASS; /* Bypass the PLL? */
171 r1 = r1 << 8; /* Shift it over */
172 r0 = r1 | r0; /* add them all together */
174 p0.h = (PLL_CTL >> 16);
175 p0.l = (PLL_CTL & 0xFFFF); /* Load the address */
176 cli r2; /* Disable interrupts */
177 w[p0] = r0; /* Set the value */
178 idle; /* Wait for the PLL to stablize */
179 sti r2; /* Enable interrupts */
183 * Turn on the CYCLES COUNTER
189 /* Configure SCLK & CCLK Dividers */
190 r0 = CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV;
191 p0.h = (PLL_DIV >> 16);
192 p0.l = (PLL_DIV & 0xFFFF);
197 p0.h = (PLL_STAT >> 16);
198 p0.l = (PLL_STAT & 0xFFFF);
201 if !cc jump wait_for_pll_stab;
203 /* Configure SDRAM if SDRAM is already not enabled */
204 p0.l = (EBIU_SDSTAT & 0xFFFF);
205 p0.h = (EBIU_SDSTAT >> 16);
208 if !cc jump skip_sdram_enable;
210 /* SDRAM initialization */
211 p0.l = (EBIU_SDGCTL & 0xFFFF);
212 p0.h = (EBIU_SDGCTL >> 16); /* SDRAM Memory Global Control Register */
213 r0.h = (mem_SDGCTL >> 16);
214 r0.l = (mem_SDGCTL & 0xFFFF);
218 p0.l = (EBIU_SDBCTL & 0xFFFF);
219 p0.h = (EBIU_SDBCTL >> 16); /* SDRAM Memory Bank Control Register */
224 p0.l = (EBIU_SDRRC & 0xFFFF);
225 p0.h = (EBIU_SDRRC >> 16); /* SDRAM Refresh Rate Control Register */
234 /* relocate into to RAM */
235 p1.l = (CFG_FLASH_BASE & 0xffff);
236 p1.h = (CFG_FLASH_BASE >> 16);
237 p2.l = (CFG_MONITOR_BASE & 0xffff);
238 p2.h = (CFG_MONITOR_BASE >> 16);
239 r0.l = (CFG_MONITOR_LEN & 0xffff);
240 r0.h = (CFG_MONITOR_LEN >> 16);
255 r0.h = (CONFIG_STACKBASE >> 16);
256 r0.l = (CONFIG_STACKBASE & 0xFFFF);
261 * This next section keeps the processor in supervisor mode
262 * during kernel boot. Switches to user mode at end of boot.
263 * See page 3-9 of Hardware Reference manual for documentation.
266 /* To keep ourselves in the supervisor mode */
267 p0.l = (EVT_IVG15_ADDR & 0xFFFF);
268 p0.h = (EVT_IVG15_ADDR >> 16);
274 p0.l = (IMASK & 0xFFFF);
275 p0.h = (IMASK >> 16);
291 #ifdef CONFIG_EZKIT533
292 p0.l = (WDOG_CTL & 0xFFFF);
293 p0.h = (WDOG_CTL >> 16);
294 r0 = WATCHDOG_DISABLE(z);
298 /* Code for initializing Async mem banks */
299 p2.h = (EBIU_AMBCTL1 >> 16);
300 p2.l = (EBIU_AMBCTL1 & 0xFFFF);
301 r0.h = (AMBCTL1VAL >> 16);
302 r0.l = (AMBCTL1VAL & 0xFFFF);
306 p2.h = (EBIU_AMBCTL0 >> 16);
307 p2.l = (EBIU_AMBCTL0 & 0xFFFF);
308 r0.h = (AMBCTL0VAL >> 16);
309 r0.l = (AMBCTL0VAL & 0xFFFF);
313 p2.h = (EBIU_AMGCTL >> 16);
314 p2.l = (EBIU_AMGCTL & 0xffff);
319 /* DMA reset code to Hi of L1 SRAM */
321 P1.H = hi(SYSMMR_BASE); /* P1 Points to the beginning of SYSTEM MMR Space */
322 P1.L = lo(SYSMMR_BASE);
324 R0.H = reset_start; /* Source Address (high) */
325 R0.L = reset_start; /* Source Address (low) */
328 R2 = R1 - R0; /* Count */
329 R1.H = hi(L1_ISRAM); /* Destination Address (high) */
330 R1.L = lo(L1_ISRAM); /* Destination Address (low) */
331 R3.L = DMAEN; /* Source DMAConfig Value (8-bit words) */
332 R4.L = (DI_EN | WNR | DMAEN); /* Destination DMAConfig Value (8-bit words) */
336 W[P1+OFFSET_(MDMA_S0_X_MODIFY)] = R6; /* Source Modify = 1 */
337 W[P1+OFFSET_(MDMA_D0_X_MODIFY)] = R6; /* Destination Modify = 1 */
339 [P1+OFFSET_(MDMA_S0_START_ADDR)] = R0; /* Set Source Base Address */
340 W[P1+OFFSET_(MDMA_S0_X_COUNT)] = R2; /* Set Source Count */
341 /* Set Source DMAConfig = DMA Enable,
342 Memory Read, 8-Bit Transfers, 1-D DMA, Flow - Stop */
343 W[P1+OFFSET_(MDMA_S0_CONFIG)] = R3;
345 [P1+OFFSET_(MDMA_D0_START_ADDR)] = R1; /* Set Destination Base Address */
346 W[P1+OFFSET_(MDMA_D0_X_COUNT)] = R2; /* Set Destination Count */
347 /* Set Destination DMAConfig = DMA Enable,
348 Memory Write, 8-Bit Transfers, 1-D DMA, Flow - Stop, IOC */
349 W[P1+OFFSET_(MDMA_D0_CONFIG)] = R4;
351 IDLE; /* Wait for DMA to Complete */
354 W[P1+OFFSET_(MDMA_D0_IRQ_STATUS)] = R0; /* Write 1 to clear DMA interrupt */
356 /* DMA reset code to DATA BANK A which uses this port
357 * to avoid following problem
358 * " Data from a Data Cache fill can be corrupoted after or during
359 * instruction DMA if certain core stalls exist"
363 R0.H = reset_start; /* Source Address (high) */
364 R0.L = reset_start; /* Source Address (low) */
367 R2 = R1 - R0; /* Count */
368 R1.H = hi(DATA_BANKA_SRAM); /* Destination Address (high) */
369 R1.L = lo(DATA_BANKA_SRAM); /* Destination Address (low) */
370 R3.L = DMAEN; /* Source DMAConfig Value (8-bit words) */
371 R4.L = (DI_EN | WNR | DMAEN); /* Destination DMAConfig Value (8-bit words) */
375 W[P1+OFFSET_(MDMA_S0_X_MODIFY)] = R6; /* Source Modify = 1 */
376 W[P1+OFFSET_(MDMA_D0_X_MODIFY)] = R6; /* Destination Modify = 1 */
378 [P1+OFFSET_(MDMA_S0_START_ADDR)] = R0; /* Set Source Base Address */
379 W[P1+OFFSET_(MDMA_S0_X_COUNT)] = R2; /* Set Source Count */
380 /* Set Source DMAConfig = DMA Enable,
381 Memory Read, 8-Bit Transfers, 1-D DMA, Flow - Stop */
382 W[P1+OFFSET_(MDMA_S0_CONFIG)] = R3;
384 [P1+OFFSET_(MDMA_D0_START_ADDR)] = R1; /* Set Destination Base Address */
385 W[P1+OFFSET_(MDMA_D0_X_COUNT)] = R2; /* Set Destination Count */
386 /* Set Destination DMAConfig = DMA Enable,
387 Memory Write, 8-Bit Transfers, 1-D DMA, Flow - Stop, IOC */
388 W[P1+OFFSET_(MDMA_D0_CONFIG)] = R4;
390 IDLE; /* Wait for DMA to Complete */
393 W[P1+OFFSET_(MDMA_D0_IRQ_STATUS)] = R0; /* Write 1 to clear DMA interrupt */
397 /* Initialize BSS Section with 0 s */
407 lsetup (_clear_bss, _clear_bss_end ) lc1 = p3;
409 if CC jump _clear_bss_skip;
421 p0.h = WDOG_CNT >> 16;
422 p0.l = WDOG_CNT & 0xffff;
425 p0.h = WDOG_CTL >> 16;
426 p0.l = WDOG_CTL & 0xffff;