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_DF_RETX];
128 p1.l = _init_saved_retx;
129 p1.h = _init_saved_retx;
132 r6 = [p0 + PDA_DF_DCPLB];
133 p1.l = _init_saved_dcplb_fault_addr;
134 p1.h = _init_saved_dcplb_fault_addr;
137 r6 = [p0 + PDA_DF_ICPLB];
138 p1.l = _init_saved_icplb_fault_addr;
139 p1.h = _init_saved_icplb_fault_addr;
142 r6 = [p0 + PDA_DF_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;
156 r0 = (EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
161 /* Zero out all of the fun bss regions */
162 #if L1_DATA_A_LENGTH > 0
167 call __init_clear_bss
169 #if L1_DATA_B_LENGTH > 0
174 call __init_clear_bss
181 call __init_clear_bss
187 call __init_clear_bss
189 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
190 call _bfin_relocate_l1_mem;
191 #ifdef CONFIG_BFIN_KERNEL_CLOCK
192 /* Only use on-chip scratch space for stack when absolutely required
193 * to avoid Anomaly 05000227 ... we know the init_clocks() func only
194 * uses L1 text and stack space and no other memory region.
196 # define KERNEL_CLOCK_STACK (L1_SCRATCH_START + L1_SCRATCH_LENGTH - 12)
197 sp.l = lo(KERNEL_CLOCK_STACK);
198 sp.h = hi(KERNEL_CLOCK_STACK);
200 sp = usp; /* usp hasnt been touched, so restore from there */
203 /* This section keeps the processor in supervisor mode
204 * during kernel boot. Switches to user mode at end of boot.
205 * See page 3-9 of Hardware Reference manual for documentation.
208 /* EVT15 = _real_start */
217 #ifdef CONFIG_EARLY_PRINTK
218 r0 = (EVT_IVG15 | EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU) (z);
225 #ifdef CONFIG_EARLY_PRINTK
242 /* A little BF561 glue ... */
244 # define WDOG_CTL WDOGA_CTL
248 /* Enable nested interrupts */
251 /* watchdog off for now */
258 /* Pass the u-boot arguments to the global value command line */
262 /* Load the current thread pointer and stack */
263 p1 = THREAD_SIZE + 4 (z); /* +4 is for reti loading */
270 jump.l _start_kernel;