2 * Common Blackfin startup code
4 * Copyright 2004-2008 Analog Devices Inc.
6 * Enter bugs at http://blackfin.uclinux.org/
8 * Licensed under the GPL-2 or later.
11 #include <linux/linkage.h>
12 #include <linux/init.h>
13 #include <asm/blackfin.h>
14 #include <asm/thread_info.h>
15 #include <asm/trace.h>
19 #define INITIAL_STACK (L1_SCRATCH_START + L1_SCRATCH_LENGTH - 12)
22 /* R0: argument of command line string, passed from uboot, save it */
24 /* Enable Cycle Counter and Nesting Of Interrupts */
25 #ifdef CONFIG_BFIN_SCRATCH_REG_CYCLES
28 R0 = SYSCFG_SNEN | SYSCFG_CCEN;
33 /* Clear Out All the data and pointer Registers */
55 /* Clear Out All the DAG Registers */
72 * Clear ITEST_COMMAND and DTEST_COMMAND registers,
73 * Leaving these as non-zero can confuse the emulator
75 p0.L = LO(DTEST_COMMAND);
76 p0.H = HI(DTEST_COMMAND);
78 [p0 + (ITEST_COMMAND - DTEST_COMMAND)] = R0;
81 trace_buffer_init(p0,r0);
85 /* Turn off the icache */
86 p0.l = LO(IMEM_CONTROL);
87 p0.h = HI(IMEM_CONTROL);
94 /* Turn off the dcache */
95 p0.l = LO(DMEM_CONTROL);
96 p0.h = HI(DMEM_CONTROL);
103 /* in case of double faults, save a few things */
109 #ifdef CONFIG_DEBUG_DOUBLEFAULT
110 /* Only save these if we are storing them,
111 * This happens here, since L1 gets clobbered
116 p1.l = _init_saved_retx;
117 p1.h = _init_saved_retx;
121 p0.l = _saved_dcplb_fault_addr;
122 p0.h = _saved_dcplb_fault_addr;
123 p1.l = _init_saved_dcplb_fault_addr;
124 p1.h = _init_saved_dcplb_fault_addr;
128 p0.l = _saved_icplb_fault_addr;
129 p0.h = _saved_icplb_fault_addr;
130 p1.l = _init_saved_icplb_fault_addr;
131 p1.h = _init_saved_icplb_fault_addr;
135 p0.l = _saved_seqstat;
136 p0.h = _saved_seqstat;
137 p1.l = _init_saved_seqstat;
138 p1.h = _init_saved_seqstat;
143 /* Initialize stack pointer */
144 sp.l = lo(INITIAL_STACK);
145 sp.h = hi(INITIAL_STACK);
149 #ifdef CONFIG_EARLY_PRINTK
150 call _init_early_exception_vectors;
153 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
154 call _bfin_relocate_l1_mem;
155 #ifdef CONFIG_BFIN_KERNEL_CLOCK
156 call _start_dma_code;
159 /* This section keeps the processor in supervisor mode
160 * during kernel boot. Switches to user mode at end of boot.
161 * See page 3-9 of Hardware Reference manual for documentation.
164 /* EVT15 = _real_start */
193 /* A little BF561 glue ... */
195 # define WDOG_CTL WDOGA_CTL
199 /* Enable nested interrupts */
202 /* watchdog off for now */
209 #if L1_DATA_A_LENGTH > 0
217 if cc jump .L_a_l1_done;
221 lsetup (.L_clear_a_l1, .L_clear_a_l1 ) lc0 = p2;
227 #if L1_DATA_B_LENGTH > 0
235 if cc jump .L_b_l1_done;
239 lsetup (.L_clear_b_l1, .L_clear_b_l1 ) lc0 = p2;
253 if cc jump .L_l2_done;
257 lsetup (.L_clear_l2, .L_clear_l2 ) lc0 = p2;
263 /* Zero out the bss region
264 * Note: this will fail if bss is 0 bytes ...
275 lsetup (.L_clear_bss, .L_clear_bss) lc0 = p2;
279 /* In case there is a NULL pointer reference,
280 * zero out region before stext
287 lsetup (.L_clear_zero, .L_clear_zero) lc0 = p2;
291 /* Pass the u-boot arguments to the global value command line */
295 /* Load the current thread pointer and stack */
296 sp.l = _init_thread_union;
297 sp.h = _init_thread_union;
298 p1 = THREAD_SIZE (z);
302 jump.l _start_kernel;