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 */
35 /* Enable Cycle Counter and Nesting Of Interrupts */
36 #ifdef CONFIG_BFIN_SCRATCH_REG_CYCLES
39 R0 = SYSCFG_SNEN | SYSCFG_CCEN;
43 /* Optimization register tricks: keep a base value in the
44 * reserved P registers so we use the load/store with an
45 * offset syntax. R0 = [P5 + <constant>];
51 p5.h = hi(COREMMR_BASE);
53 /* Zero out registers required by Blackfin ABI */
55 /* Disable circular buffers */
61 /* Disable hardware loops in case we were started by 'go' */
66 * Clear ITEST_COMMAND and DTEST_COMMAND registers,
67 * Leaving these as non-zero can confuse the emulator
69 [p5 + (DTEST_COMMAND - COREMMR_BASE)] = r6;
70 [p5 + (ITEST_COMMAND - COREMMR_BASE)] = r6;
73 trace_buffer_init(p0,r0);
75 /* Turn off the icache */
76 r1 = [p5 + (IMEM_CONTROL - COREMMR_BASE)];
77 BITCLR (r1, ENICPLB_P);
78 [p5 + (IMEM_CONTROL - COREMMR_BASE)] = r1;
81 /* Turn off the dcache */
82 r1 = [p5 + (DMEM_CONTROL - COREMMR_BASE)];
83 BITCLR (r1, ENDCPLB_P);
84 [p5 + (DMEM_CONTROL - COREMMR_BASE)] = r1;
87 /* in case of double faults, save a few things */
93 #ifdef CONFIG_DEBUG_DOUBLEFAULT
94 /* Only save these if we are storing them,
95 * This happens here, since L1 gets clobbered
99 r5 = [p0 + PDA_DF_RETX];
100 p1.l = _init_saved_retx;
101 p1.h = _init_saved_retx;
104 r5 = [p0 + PDA_DF_DCPLB];
105 p1.l = _init_saved_dcplb_fault_addr;
106 p1.h = _init_saved_dcplb_fault_addr;
109 r5 = [p0 + PDA_DF_ICPLB];
110 p1.l = _init_saved_icplb_fault_addr;
111 p1.h = _init_saved_icplb_fault_addr;
114 r5 = [p0 + PDA_DF_SEQSTAT];
115 p1.l = _init_saved_seqstat;
116 p1.h = _init_saved_seqstat;
120 /* Initialize stack pointer */
121 sp.l = _init_thread_union + THREAD_SIZE;
122 sp.h = _init_thread_union + THREAD_SIZE;
126 #ifdef CONFIG_EARLY_PRINTK
127 call _init_early_exception_vectors;
128 r0 = (EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU);
133 /* Zero out all of the fun bss regions */
134 #if L1_DATA_A_LENGTH > 0
139 call __init_clear_bss
141 #if L1_DATA_B_LENGTH > 0
146 call __init_clear_bss
153 call __init_clear_bss
159 call __init_clear_bss
161 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
162 call _bfin_relocate_l1_mem;
164 #ifdef CONFIG_ROMKERNEL
165 call _bfin_relocate_xip_data;
168 #ifdef CONFIG_BFIN_KERNEL_CLOCK
169 /* Only use on-chip scratch space for stack when absolutely required
170 * to avoid Anomaly 05000227 ... we know the init_clocks() func only
171 * uses L1 text and stack space and no other memory region.
173 # define KERNEL_CLOCK_STACK (L1_SCRATCH_START + L1_SCRATCH_LENGTH - 12)
174 sp.l = lo(KERNEL_CLOCK_STACK);
175 sp.h = hi(KERNEL_CLOCK_STACK);
177 sp = usp; /* usp hasn't been touched, so restore from there */
180 /* This section keeps the processor in supervisor mode
181 * during kernel boot. Switches to user mode at end of boot.
182 * See page 3-9 of Hardware Reference manual for documentation.
185 /* EVT15 = _real_start */
189 [p5 + (EVT15 - COREMMR_BASE)] = p1;
192 #ifdef CONFIG_EARLY_PRINTK
193 r0 = (EVT_IVG15 | EVT_IVHW | EVT_IRPTEN | EVT_EVX | EVT_NMI | EVT_RST | EVT_EMU) (z);
200 #ifdef CONFIG_EARLY_PRINTK
217 /* A little BF561 glue ... */
219 # define WDOG_CTL WDOGA_CTL
223 /* Enable nested interrupts */
226 /* watchdog off for now */
233 /* Pass the u-boot arguments to the global value command line */
237 sp += -12 + 4; /* +4 is for reti loading above */
240 jump.l _start_kernel;