2 * File: arch/blackfin/mach-bf533/head.S
4 * Author: Jeff Dionne <jeff@uclinux.org> COPYRIGHT 1998 D. Jeff Dionne
7 * Description: bf533 startup file
10 * Copyright 2004-2006 Analog Devices Inc.
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
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.
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.
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
30 #include <linux/linkage.h>
31 #include <linux/init.h>
32 #include <asm/blackfin.h>
33 #include <asm/trace.h>
34 #if CONFIG_BFIN_KERNEL_CLOCK
35 #include <asm/mach/mem_init.h>
37 #if CONFIG_DEBUG_KERNEL_START
38 #include <asm/mach-common/def_LPBlackfin.h>
46 .extern _bf53x_relocate_l1_mem
48 #define INITIAL_STACK 0xFFB01000
53 /* R0: argument of command line string, passed from uboot, save it */
55 /* Set the SYSCFG register:
56 * Enable Cycle Counter and Nesting Of Interrupts (3rd Bit)
62 /* Clear Out All the data and pointer Registers */
84 /* Clear Out All the DAG Registers */
100 trace_buffer_start(p0,r0);
104 #if CONFIG_DEBUG_KERNEL_START
107 * Set up a temporary Event Vector Table, so if something bad happens before
108 * the kernel is fully started, it doesn't vector off into the bootloaders
115 P2.l = debug_kernel_start_trap;
116 P2.h = debug_kernel_start_trap;
124 .Lfill_temp_vector_table:
125 [P0++] = P2; /* Core Event Vector Table */
127 if !CC JUMP .Lfill_temp_vector_table
134 p0.h = hi(FIO_MASKA_C);
135 p0.l = lo(FIO_MASKA_C);
137 w[p0] = r0.L; /* Disable all interrupts */
140 p0.h = hi(FIO_MASKB_C);
141 p0.l = lo(FIO_MASKB_C);
143 w[p0] = r0.L; /* Disable all interrupts */
146 /* Turn off the icache */
147 p0.l = (IMEM_CONTROL & 0xFFFF);
148 p0.h = (IMEM_CONTROL >> 16);
153 /* Anomaly 05000125 */
154 #ifdef ANOMALY_05000125
160 #ifdef ANOMALY_05000125
164 /* Turn off the dcache */
165 p0.l = (DMEM_CONTROL & 0xFFFF);
166 p0.h = (DMEM_CONTROL >> 16);
171 /* Anomaly 05000125 */
172 #ifdef ANOMALY_05000125
178 #ifdef ANOMALY_05000125
182 /* Initialise UART - when booting from u-boot, the UART is not disabled
183 * so if we dont initalize here, our serial console gets hosed */
187 w[p0] = r0.L; /* To enable DLL writes */
202 p0.h = hi(UART_GCTL);
203 p0.l = lo(UART_GCTL);
205 w[p0] = r0.L; /* To enable UART clock */
208 /* Initialize stack pointer */
209 sp.l = lo(INITIAL_STACK);
210 sp.h = hi(INITIAL_STACK);
214 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
215 call _bf53x_relocate_l1_mem;
216 #if CONFIG_BFIN_KERNEL_CLOCK
217 call _start_dma_code;
220 /* Code for initializing Async memory banks */
222 p2.h = hi(EBIU_AMBCTL1);
223 p2.l = lo(EBIU_AMBCTL1);
224 r0.h = hi(AMBCTL1VAL);
225 r0.l = lo(AMBCTL1VAL);
229 p2.h = hi(EBIU_AMBCTL0);
230 p2.l = lo(EBIU_AMBCTL0);
231 r0.h = hi(AMBCTL0VAL);
232 r0.l = lo(AMBCTL0VAL);
236 p2.h = hi(EBIU_AMGCTL);
237 p2.l = lo(EBIU_AMGCTL);
242 /* This section keeps the processor in supervisor mode
243 * during kernel boot. Switches to user mode at end of boot.
244 * See page 3-9 of Hardware Reference manual for documentation.
247 /* EVT15 = _real_start */
267 #if defined(ANOMALY_05000281)
281 w[p0] = r0; /* watchdog off for now */
284 /* Code update for BSS size == 0
285 * Zero out the bss region.
294 lsetup (.L_clear_bss, .L_clear_bss) lc0 = p2;
298 /* In case there is a NULL pointer reference
299 * Zero out region before stext
309 lsetup (.L_clear_zero, .L_clear_zero) lc0 = p2;
313 /* pass the uboot arguments to the global value command line */
332 * load the current thread pointer and stack
334 r1.l = _init_thread_union;
335 r1.h = _init_thread_union;
343 jump.l _start_kernel;
349 #if CONFIG_BFIN_KERNEL_CLOCK
350 ENTRY(_start_dma_code)
360 * - [14:09] = MSEL[5:0] : CLKIN / VCO multiplication factors
361 * - [8] = BYPASS : BYPASS the PLL, run CLKIN into CCLK/SCLK
362 * - [7] = output delay (add 200ps of delay to mem signals)
363 * - [6] = input delay (add 200ps of input delay to mem signals)
364 * - [5] = PDWN : 1=All Clocks off
365 * - [3] = STOPCK : 1=Core Clock off
366 * - [1] = PLL_OFF : 1=Disable Power to PLL
367 * - [0] = DF : 1=Pass CLKIN/2 to PLL / 0=Pass CLKIN to PLL
368 * all other bits set to zero
371 p0.h = hi(PLL_LOCKCNT);
372 p0.l = lo(PLL_LOCKCNT);
377 P2.H = hi(EBIU_SDGCTL);
378 P2.L = lo(EBIU_SDGCTL);
384 r0 = CONFIG_VCO_MULT & 63; /* Load the VCO multiplier */
385 r0 = r0 << 9; /* Shift it over, */
386 r1 = CLKIN_HALF; /* Do we need to divide CLKIN by 2?*/
388 r1 = PLL_BYPASS; /* Bypass the PLL? */
389 r1 = r1 << 8; /* Shift it over */
390 r0 = r1 | r0; /* add them all together */
393 p0.l = lo(PLL_CTL); /* Load the address */
394 cli r2; /* Disable interrupts */
396 w[p0] = r0.l; /* Set the value */
397 idle; /* Wait for the PLL to stablize */
398 sti r2; /* Enable interrupts */
405 if ! CC jump .Lcheck_again;
407 /* Configure SCLK & CCLK Dividers */
408 r0 = (CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV);
414 p0.l = lo(EBIU_SDRRC);
415 p0.h = hi(EBIU_SDRRC);
420 p0.l = (EBIU_SDBCTL & 0xFFFF);
421 p0.h = (EBIU_SDBCTL >> 16); /* SDRAM Memory Bank Control Register */
426 P2.H = hi(EBIU_SDGCTL);
427 P2.L = lo(EBIU_SDGCTL);
430 p0.h = hi(EBIU_SDSTAT);
431 p0.l = lo(EBIU_SDSTAT);
441 R0.L = lo(mem_SDGCTL);
442 R0.H = hi(mem_SDGCTL);
450 r0.l = lo(IWR_ENABLE_ALL);
451 r0.h = hi(IWR_ENABLE_ALL);
456 ENDPROC(_start_dma_code)
457 #endif /* CONFIG_BFIN_KERNEL_CLOCK */
460 /* No more interrupts to be handled*/
464 #if defined(CONFIG_BFIN_SHARED_FLASH_ENET)
467 r0.l = ~(1 << CONFIG_ENET_FLASH_PIN);
472 r0.l = (1 << CONFIG_ENET_FLASH_PIN);
475 p0.h = hi(FIO_FLAG_C);
476 p0.l = lo(FIO_FLAG_C);
477 r0.l = (1 << CONFIG_ENET_FLASH_PIN);
481 /* Clear the IMASK register */
487 /* Clear the ILAT register */
494 /* make sure SYSCR is set to use BMODE */
501 /* issue a system soft reset */
508 /* clear system soft reset */
513 /* issue core reset */
519 #if CONFIG_DEBUG_KERNEL_START
520 debug_kernel_start_trap:
521 /* Set up a temp stack in L1 - SDRAM might not be working */
522 P0.L = lo(L1_DATA_A_START + 0x100);
523 P0.H = hi(L1_DATA_A_START + 0x100);
526 /* Make sure the Clocks are the way I think they should be */
527 r0 = CONFIG_VCO_MULT & 63; /* Load the VCO multiplier */
528 r0 = r0 << 9; /* Shift it over, */
529 r1 = CLKIN_HALF; /* Do we need to divide CLKIN by 2?*/
531 r1 = PLL_BYPASS; /* Bypass the PLL? */
532 r1 = r1 << 8; /* Shift it over */
533 r0 = r1 | r0; /* add them all together */
536 p0.l = lo(PLL_CTL); /* Load the address */
537 cli r2; /* Disable interrupts */
539 w[p0] = r0.l; /* Set the value */
540 idle; /* Wait for the PLL to stablize */
541 sti r2; /* Enable interrupts */
548 if ! CC jump .Lcheck_again1;
550 /* Configure SCLK & CCLK Dividers */
551 r0 = (CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV);
557 /* Make sure UART is enabled - you can never be sure */
560 * Setup for console. Argument comes from the menuconfig
563 #ifdef CONFIG_BAUD_9600
564 #define CONSOLE_BAUD_RATE 9600
565 #elif CONFIG_BAUD_19200
566 #define CONSOLE_BAUD_RATE 19200
567 #elif CONFIG_BAUD_38400
568 #define CONSOLE_BAUD_RATE 38400
569 #elif CONFIG_BAUD_57600
570 #define CONSOLE_BAUD_RATE 57600
571 #elif CONFIG_BAUD_115200
572 #define CONSOLE_BAUD_RATE 115200
575 p0.h = hi(UART_GCTL);
576 p0.l = lo(UART_GCTL);
578 w[p0] = r0.L; /* To Turn off UART clocks */
584 w[p0] = r0.L; /* To enable DLL writes */
587 R1 = (((CONFIG_CLKIN_HZ * CONFIG_VCO_MULT) / CONFIG_SCLK_DIV) / (CONSOLE_BAUD_RATE * 16));
602 p0.h = hi(UART_GCTL);
603 p0.l = lo(UART_GCTL);
605 w[p0] = r0.L; /* To enable UART clock */
611 w[p0] = r0.L; /* To Turn on UART */
614 p0.h = hi(UART_GCTL);
615 p0.l = lo(UART_GCTL);
617 w[p0] = r0.L; /* To Turn on UART Clocks */
693 .Ldebug_kernel_start_trap_done:
694 JUMP .Ldebug_kernel_start_trap_done;
698 R5 = ':'; /* one past 9 */
707 if CC JUMP .Ldump_reg1;
713 if !CC JUMP .Ldump_reg1;
717 if !CC JUMP .Ldump_reg2
723 if !CC JUMP .Lwait_char;
727 #endif /* CONFIG_DEBUG_KERNEL_START */
732 * Set up the usable of RAM stuff. Size of RAM is determined then
733 * an initial stack set up at the end.