2008-03-30 19:46:13 +00:00
|
|
|
/*
|
|
|
|
* U-boot - cpu.c CPU specific functions
|
|
|
|
*
|
|
|
|
* Copyright (c) 2005-2008 Analog Devices Inc.
|
|
|
|
*
|
|
|
|
* (C) Copyright 2000-2004
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*
|
|
|
|
* Licensed under the GPL-2 or later.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <asm/blackfin.h>
|
|
|
|
#include <asm/cplb.h>
|
|
|
|
#include <asm/mach-common/bits/core.h>
|
2008-10-12 01:44:00 +00:00
|
|
|
#include <asm/mach-common/bits/ebiu.h>
|
2008-03-30 19:46:13 +00:00
|
|
|
#include <asm/mach-common/bits/trace.h>
|
|
|
|
|
|
|
|
#include "cpu.h"
|
|
|
|
#include "serial.h"
|
2011-05-30 17:47:38 +00:00
|
|
|
#include "initcode.h"
|
2008-03-30 19:46:13 +00:00
|
|
|
|
2008-10-12 01:44:00 +00:00
|
|
|
ulong bfin_poweron_retx;
|
|
|
|
|
2008-03-30 19:46:13 +00:00
|
|
|
__attribute__ ((__noreturn__))
|
|
|
|
void cpu_init_f(ulong bootflag, ulong loaded_from_ldr)
|
|
|
|
{
|
2009-04-25 03:39:41 +00:00
|
|
|
#ifndef CONFIG_BFIN_BOOTROM_USES_EVT1
|
|
|
|
/* Build a NOP slide over the LDR jump block. Whee! */
|
|
|
|
char nops[0xC];
|
|
|
|
serial_early_puts("NOP Slide\n");
|
|
|
|
memset(nops, 0x00, sizeof(nops));
|
2009-11-03 11:11:31 +00:00
|
|
|
memcpy((void *)L1_INST_SRAM, nops, sizeof(nops));
|
2009-04-25 03:39:41 +00:00
|
|
|
#endif
|
|
|
|
|
2008-03-30 19:46:13 +00:00
|
|
|
if (!loaded_from_ldr) {
|
|
|
|
/* Relocate sections into L1 if the LDR didn't do it -- don't
|
|
|
|
* check length because the linker script does the size
|
|
|
|
* checking at build time.
|
|
|
|
*/
|
|
|
|
serial_early_puts("L1 Relocate\n");
|
2009-11-03 11:11:31 +00:00
|
|
|
extern char _stext_l1[], _text_l1_lma[], _text_l1_len[];
|
|
|
|
memcpy(&_stext_l1, &_text_l1_lma, (unsigned long)_text_l1_len);
|
|
|
|
extern char _sdata_l1[], _data_l1_lma[], _data_l1_len[];
|
|
|
|
memcpy(&_sdata_l1, &_data_l1_lma, (unsigned long)_data_l1_len);
|
2008-03-30 19:46:13 +00:00
|
|
|
}
|
2011-05-30 17:47:38 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure our async settings are committed. Some bootroms
|
|
|
|
* (like the BF537) will reset some registers on us after it
|
|
|
|
* has finished loading the LDR. Or if we're booting over
|
|
|
|
* JTAG, the initcode never got a chance to run. Or if we
|
|
|
|
* aren't booting from parallel flash, the initcode skipped
|
|
|
|
* this step completely.
|
2008-03-30 19:46:13 +00:00
|
|
|
*/
|
2011-05-30 17:47:38 +00:00
|
|
|
program_async_controller(NULL);
|
2008-03-30 19:46:13 +00:00
|
|
|
|
2008-10-12 01:44:00 +00:00
|
|
|
/* Save RETX so we can pass it while booting Linux */
|
|
|
|
bfin_poweron_retx = bootflag;
|
|
|
|
|
2008-03-30 19:46:13 +00:00
|
|
|
#ifdef CONFIG_DEBUG_DUMP
|
|
|
|
/* Turn on hardware trace buffer */
|
|
|
|
bfin_write_TBUFCTL(TBUFPWR | TBUFEN);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_PANIC_HANG
|
|
|
|
/* Reset upon a double exception rather than just hanging.
|
|
|
|
* Do not do bfin_read on SWRST as that will reset status bits.
|
|
|
|
*/
|
|
|
|
bfin_write_SWRST(DOUBLE_FAULT);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
serial_early_puts("Board init flash\n");
|
|
|
|
board_init_f(bootflag);
|
|
|
|
}
|
|
|
|
|
|
|
|
int exception_init(void)
|
|
|
|
{
|
|
|
|
bfin_write_EVT3(trap);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int irq_init(void)
|
|
|
|
{
|
|
|
|
#ifdef SIC_IMASK0
|
|
|
|
bfin_write_SIC_IMASK0(0);
|
|
|
|
bfin_write_SIC_IMASK1(0);
|
|
|
|
# ifdef SIC_IMASK2
|
|
|
|
bfin_write_SIC_IMASK2(0);
|
|
|
|
# endif
|
|
|
|
#elif defined(SICA_IMASK0)
|
|
|
|
bfin_write_SICA_IMASK0(0);
|
|
|
|
bfin_write_SICA_IMASK1(0);
|
|
|
|
#else
|
|
|
|
bfin_write_SIC_IMASK(0);
|
|
|
|
#endif
|
2010-05-05 06:07:44 +00:00
|
|
|
/* Set up a dummy NMI handler if needed. */
|
|
|
|
if (CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_BYPASS || ANOMALY_05000219)
|
|
|
|
bfin_write_EVT2(evt_nmi); /* NMI */
|
2008-03-30 19:46:13 +00:00
|
|
|
bfin_write_EVT5(evt_default); /* hardware error */
|
|
|
|
bfin_write_EVT6(evt_default); /* core timer */
|
|
|
|
bfin_write_EVT7(evt_default);
|
|
|
|
bfin_write_EVT8(evt_default);
|
|
|
|
bfin_write_EVT9(evt_default);
|
|
|
|
bfin_write_EVT10(evt_default);
|
|
|
|
bfin_write_EVT11(evt_default);
|
|
|
|
bfin_write_EVT12(evt_default);
|
|
|
|
bfin_write_EVT13(evt_default);
|
|
|
|
bfin_write_EVT14(evt_default);
|
|
|
|
bfin_write_EVT15(evt_default);
|
|
|
|
bfin_write_ILAT(0);
|
|
|
|
CSYNC();
|
2008-08-07 19:16:56 +00:00
|
|
|
/* enable hardware error irq */
|
|
|
|
irq_flags = 0x3f;
|
2008-03-30 19:46:13 +00:00
|
|
|
local_irq_enable();
|
|
|
|
return 0;
|
|
|
|
}
|