2 * File: arch/blackfin/mach-bf537/head.S
3 * Based on: arch/blackfin/mach-bf533/head.S
4 * Author: Jeff Dionne <jeff@uclinux.org> COPYRIGHT 1998 D. Jeff Dionne
7 * Description: Startup code for Blackfin BF537
10 * Copyright 2004-2006 Analog Devices Inc.
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 #include <linux/linkage.h>
31 #include <linux/init.h>
32 #include <asm/blackfin.h>
33 #include <asm/trace.h>
35 #if CONFIG_BFIN_KERNEL_CLOCK
36 #include <asm/mach-common/clocks.h>
37 #include <asm/mach/mem_init.h>
45 .extern _bf53x_relocate_l1_mem
47 #define INITIAL_STACK 0xFFB01000
52 /* R0: argument of command line string, passed from uboot, save it */
54 /* Set the SYSCFG register:
55 * Enable Cycle Counter and Nesting Of Interrupts (3rd Bit)
61 /* Clear Out All the data and pointer Registers */
83 /* Clear Out All the DAG Registers */
99 trace_buffer_init(p0,r0);
103 /* Turn off the icache */
104 p0.l = LO(IMEM_CONTROL);
105 p0.h = HI(IMEM_CONTROL);
110 /* Anomaly 05000125 */
121 /* Turn off the dcache */
122 p0.l = LO(DMEM_CONTROL);
123 p0.h = HI(DMEM_CONTROL);
128 /* Anomaly 05000125 */
139 /* Initialise General-Purpose I/O Modules on BF537 */
140 /* Rev 0.0 Anomaly 05000212 - PORTx_FER,
141 * PORT_MUX Registers Do Not accept "writes" correctly:
143 p0.h = hi(BFIN_PORT_MUX);
144 p0.l = lo(BFIN_PORT_MUX);
146 R0.L = W[P0]; /* Read */
149 R0 = (PGDE_UART | PFTE_UART)(Z);
151 W[P0] = R0.L; /* Write */
154 W[P0] = R0.L; /* Enable both UARTS */
157 p0.h = hi(PORTF_FER);
158 p0.l = lo(PORTF_FER);
160 R0.L = W[P0]; /* Read */
165 W[P0] = R0.L; /* Write */
168 /* Enable peripheral function of PORTF for UART0 and UART1 */
172 #if !defined(CONFIG_BF534)
173 p0.h = hi(EMAC_SYSTAT);
174 p0.l = lo(EMAC_SYSTAT);
175 R0.h = 0xFFFF; /* Clear EMAC Interrupt Status bits */
181 #ifdef CONFIG_BF537_PORT_H
182 p0.h = hi(PORTH_FER);
183 p0.l = lo(PORTH_FER);
184 R0.L = W[P0]; /* Read */
187 W[P0] = R0.L; /* Write */
189 W[P0] = R0.L; /* Disable peripheral function of PORTH */
193 /* Initialise UART - when booting from u-boot, the UART is not disabled
194 * so if we dont initalize here, our serial console gets hosed */
198 w[p0] = r0.L; /* To enable DLL writes */
213 p0.h = hi(UART_GCTL);
214 p0.l = lo(UART_GCTL);
216 w[p0] = r0.L; /* To enable UART clock */
219 /* Initialize stack pointer */
220 sp.l = lo(INITIAL_STACK);
221 sp.h = hi(INITIAL_STACK);
225 /* Put The Code for PLL Programming and SDRAM Programming in L1 ISRAM */
226 call _bf53x_relocate_l1_mem;
227 #if CONFIG_BFIN_KERNEL_CLOCK
228 call _start_dma_code;
231 /* Code for initializing Async memory banks */
233 p2.h = hi(EBIU_AMBCTL1);
234 p2.l = lo(EBIU_AMBCTL1);
235 r0.h = hi(AMBCTL1VAL);
236 r0.l = lo(AMBCTL1VAL);
240 p2.h = hi(EBIU_AMBCTL0);
241 p2.l = lo(EBIU_AMBCTL0);
242 r0.h = hi(AMBCTL0VAL);
243 r0.l = lo(AMBCTL0VAL);
247 p2.h = hi(EBIU_AMGCTL);
248 p2.l = lo(EBIU_AMGCTL);
253 /* This section keeps the processor in supervisor mode
254 * during kernel boot. Switches to user mode at end of boot.
255 * See page 3-9 of Hardware Reference manual for documentation.
258 /* EVT15 = _real_start */
292 w[p0] = r0; /* watchdog off for now */
295 /* Code update for BSS size == 0
296 * Zero out the bss region.
305 lsetup (.L_clear_bss, .L_clear_bss) lc0 = p2;
309 /* In case there is a NULL pointer reference
310 * Zero out region before stext
320 lsetup (.L_clear_zero, .L_clear_zero) lc0 = p2;
324 /* pass the uboot arguments to the global value command line */
343 * load the current thread pointer and stack
345 r1.l = _init_thread_union;
346 r1.h = _init_thread_union;
354 jump.l _start_kernel;
360 #if CONFIG_BFIN_KERNEL_CLOCK
361 ENTRY(_start_dma_code)
363 /* Enable PHY CLK buffer output */
380 * - [14:09] = MSEL[5:0] : CLKIN / VCO multiplication factors
381 * - [8] = BYPASS : BYPASS the PLL, run CLKIN into CCLK/SCLK
382 * - [7] = output delay (add 200ps of delay to mem signals)
383 * - [6] = input delay (add 200ps of input delay to mem signals)
384 * - [5] = PDWN : 1=All Clocks off
385 * - [3] = STOPCK : 1=Core Clock off
386 * - [1] = PLL_OFF : 1=Disable Power to PLL
387 * - [0] = DF : 1=Pass CLKIN/2 to PLL / 0=Pass CLKIN to PLL
388 * all other bits set to zero
391 p0.h = hi(PLL_LOCKCNT);
392 p0.l = lo(PLL_LOCKCNT);
397 P2.H = hi(EBIU_SDGCTL);
398 P2.L = lo(EBIU_SDGCTL);
404 r0 = CONFIG_VCO_MULT & 63; /* Load the VCO multiplier */
405 r0 = r0 << 9; /* Shift it over, */
406 r1 = CLKIN_HALF; /* Do we need to divide CLKIN by 2?*/
408 r1 = PLL_BYPASS; /* Bypass the PLL? */
409 r1 = r1 << 8; /* Shift it over */
410 r0 = r1 | r0; /* add them all together */
413 p0.l = lo(PLL_CTL); /* Load the address */
414 cli r2; /* Disable interrupts */
416 w[p0] = r0.l; /* Set the value */
417 idle; /* Wait for the PLL to stablize */
418 sti r2; /* Enable interrupts */
425 if ! CC jump .Lcheck_again;
427 /* Configure SCLK & CCLK Dividers */
428 r0 = (CONFIG_CCLK_ACT_DIV | CONFIG_SCLK_DIV);
434 p0.l = lo(EBIU_SDRRC);
435 p0.h = hi(EBIU_SDRRC);
440 p0.l = LO(EBIU_SDBCTL);
441 p0.h = HI(EBIU_SDBCTL); /* SDRAM Memory Bank Control Register */
446 P2.H = hi(EBIU_SDGCTL);
447 P2.L = lo(EBIU_SDGCTL);
450 p0.h = hi(EBIU_SDSTAT);
451 p0.l = lo(EBIU_SDSTAT);
461 R0.L = lo(mem_SDGCTL);
462 R0.H = hi(mem_SDGCTL);
470 r0.l = lo(IWR_ENABLE_ALL);
471 r0.h = hi(IWR_ENABLE_ALL);
476 ENDPROC(_start_dma_code)
477 #endif /* CONFIG_BFIN_KERNEL_CLOCK */
480 /* No more interrupts to be handled*/
484 #if defined(CONFIG_MTD_M25P80)
486 * The following code fix the SPI flash reboot issue,
487 * /CS signal of the chip which is using PF10 return to GPIO mode
489 p0.h = hi(PORTF_FER);
490 p0.l = lo(PORTF_FER);
495 /* /CS return to high */
502 /* Delay some time, This is necessary */
506 lsetup (.L_delay_lab1, .L_delay_lab1_end) lc1 = p1;
511 lsetup (.L_delay_lab0, .L_delay_lab0_end) lc0 = p0;
520 /* Clear the IMASK register */
526 /* Clear the ILAT register */
533 /* make sure SYSCR is set to use BMODE */
540 /* issue a system soft reset */
547 /* clear system soft reset */
552 /* issue core reset */
561 * Set up the usable of RAM stuff. Size of RAM is determined then
562 * an initial stack set up at the end.