2 * Common Blackfin startup code
4 * Copyright 2004-2008 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
9 #include <linux/linkage.h>
10 #include <linux/init.h>
11 #include <asm/blackfin.h>
12 #include <asm/thread_info.h>
13 #include <asm/trace.h>
14 #include <asm/asm-offsets.h>
18 ENTRY(__init_clear_bss)
21 if cc jump .L_bss_done;
25 lsetup (1f, 1f) lc0 = p2;
29 ENDPROC(__init_clear_bss)
32 /* R0: argument of command line string, passed from uboot, save it */
34 /* Enable Cycle Counter and Nesting Of Interrupts */
35 #ifdef CONFIG_BFIN_SCRATCH_REG_CYCLES
38 R0 = SYSCFG_SNEN | SYSCFG_CCEN;
43 /* Clear Out All the data and pointer Registers */
65 /* Clear Out All the DAG Registers */
82 * Clear ITEST_COMMAND and DTEST_COMMAND registers,
83 * Leaving these as non-zero can confuse the emulator
85 p0.L = LO(DTEST_COMMAND);
86 p0.H = HI(DTEST_COMMAND);
88 [p0 + (ITEST_COMMAND - DTEST_COMMAND)] = R0;
91 trace_buffer_init(p0,r0);
95 /* Turn off the icache */
96 p0.l = LO(IMEM_CONTROL);
97 p0.h = HI(IMEM_CONTROL);
104 /* Turn off the dcache */
105 p0.l = LO(DMEM_CONTROL);
106 p0.h = HI(DMEM_CONTROL);
113 /* in case of double faults, save a few things */
119 #ifdef CONFIG_DEBUG_DOUBLEFAULT
120 /* Only save these if we are storing them,
121 * This happens here, since L1 gets clobbered
125 r6 = [p0 + PDA_DF_RETX];
126 p1.l = _init_saved_retx;
127 p1.h = _init_saved_retx;
130 r6 = [p0 + PDA_DF_DCPLB];
131 p1.l = _init_saved_dcplb_fault_addr;
132 p1.h = _init_saved_dcplb_fault_addr;
135 r6 = [p0 + PDA_DF_ICPLB];
136 p1.l = _init_saved_icplb_fault_addr;
137 p1.h = _init_saved_icplb_fault_addr;
140 r6 = [p0 + PDA_DF_SEQSTAT];
141 p1.l = _init_saved_seqstat;
142 p1.h = _init_saved_seqstat;
146 /* Initialize stack pointer */
147 sp.l = _init_thread_union;
148 sp.h = _init_thread_union;
152 #ifdef CONFIG_EARLY_PRINTK
153 call _init_early_exception_vectors;
154 r0 = (EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
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 */
215 #ifdef CONFIG_EARLY_PRINTK
216 r0 = (EVT_IVG15 | EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU) (z);
223 #ifdef CONFIG_EARLY_PRINTK
240 /* A little BF561 glue ... */
242 # define WDOG_CTL WDOGA_CTL
246 /* Enable nested interrupts */
249 /* watchdog off for now */
256 /* Pass the u-boot arguments to the global value command line */
260 /* Load the current thread pointer and stack */
261 p1 = THREAD_SIZE + 4 (z); /* +4 is for reti loading */
268 jump.l _start_kernel;