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>
16 #include <asm/asm-offsets.h>
20 ENTRY(__init_clear_bss)
23 if cc jump .L_bss_done;
27 lsetup (1f, 1f) lc0 = p2;
31 ENDPROC(__init_clear_bss)
34 /* R0: argument of command line string, passed from uboot, save it */
36 /* Enable Cycle Counter and Nesting Of Interrupts */
37 #ifdef CONFIG_BFIN_SCRATCH_REG_CYCLES
40 R0 = SYSCFG_SNEN | SYSCFG_CCEN;
45 /* Clear Out All the data and pointer Registers */
67 /* Clear Out All the DAG Registers */
84 * Clear ITEST_COMMAND and DTEST_COMMAND registers,
85 * Leaving these as non-zero can confuse the emulator
87 p0.L = LO(DTEST_COMMAND);
88 p0.H = HI(DTEST_COMMAND);
90 [p0 + (ITEST_COMMAND - DTEST_COMMAND)] = R0;
93 trace_buffer_init(p0,r0);
97 /* Turn off the icache */
98 p0.l = LO(IMEM_CONTROL);
99 p0.h = HI(IMEM_CONTROL);
106 /* Turn off the dcache */
107 p0.l = LO(DMEM_CONTROL);
108 p0.h = HI(DMEM_CONTROL);
115 /* in case of double faults, save a few things */
121 #ifdef CONFIG_DEBUG_DOUBLEFAULT
122 /* Only save these if we are storing them,
123 * This happens here, since L1 gets clobbered
127 r6 = [p0 + PDA_RETX];
128 p1.l = _init_saved_retx;
129 p1.h = _init_saved_retx;
132 r6 = [p0 + PDA_DCPLB];
133 p1.l = _init_saved_dcplb_fault_addr;
134 p1.h = _init_saved_dcplb_fault_addr;
137 r6 = [p0 + PDA_ICPLB];
138 p1.l = _init_saved_icplb_fault_addr;
139 p1.h = _init_saved_icplb_fault_addr;
142 r6 = [p0 + PDA_SEQSTAT];
143 p1.l = _init_saved_seqstat;
144 p1.h = _init_saved_seqstat;
148 /* Initialize stack pointer */
149 sp.l = _init_thread_union;
150 sp.h = _init_thread_union;
154 #ifdef CONFIG_EARLY_PRINTK
155 call _init_early_exception_vectors;
159 /* Zero out all of the fun bss regions */
160 #if L1_DATA_A_LENGTH > 0
165 call __init_clear_bss
167 #if L1_DATA_B_LENGTH > 0
172 call __init_clear_bss
179 call __init_clear_bss
185 call __init_clear_bss
187 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
188 call _bfin_relocate_l1_mem;
189 #ifdef CONFIG_BFIN_KERNEL_CLOCK
190 /* Only use on-chip scratch space for stack when absolutely required
191 * to avoid Anomaly 05000227 ... we know the init_clocks() func only
192 * uses L1 text and stack space and no other memory region.
194 # define KERNEL_CLOCK_STACK (L1_SCRATCH_START + L1_SCRATCH_LENGTH - 12)
195 sp.l = lo(KERNEL_CLOCK_STACK);
196 sp.h = hi(KERNEL_CLOCK_STACK);
198 sp = usp; /* usp hasnt been touched, so restore from there */
201 /* This section keeps the processor in supervisor mode
202 * during kernel boot. Switches to user mode at end of boot.
203 * See page 3-9 of Hardware Reference manual for documentation.
206 /* EVT15 = _real_start */
231 /* A little BF561 glue ... */
233 # define WDOG_CTL WDOGA_CTL
237 /* Enable nested interrupts */
240 /* watchdog off for now */
247 /* Pass the u-boot arguments to the global value command line */
251 /* Load the current thread pointer and stack */
252 p1 = THREAD_SIZE + 4 (z); /* +4 is for reti loading */
259 jump.l _start_kernel;