9
0
Fork 0
barebox/arch/blackfin/lib/cpu.c

133 lines
3.0 KiB
C
Raw Normal View History

2006-03-12 01:12:27 +00:00
/*
* barebox - cpu.c CPU specific functions
2006-03-12 01:12:27 +00:00
*
* Copyright (c) 2005 blackfin.uclinux.org
*
* (C) Copyright 2000-2004
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#include <common.h>
#include <asm/blackfin.h>
#include <command.h>
#include <asm/entry.h>
2007-09-16 09:24:28 +00:00
#include <asm/cpu.h>
#include <init.h>
void reset_cpu(ulong ignored)
2006-03-12 01:12:27 +00:00
{
2007-09-16 09:24:28 +00:00
icache_disable();
2006-03-12 01:12:27 +00:00
__asm__ __volatile__
("cli r3;"
"P0 = %0;"
"JUMP (P0);"
:
: "r" (L1_ISRAM)
);
}
2007-09-16 09:24:28 +00:00
void icache_disable(void)
2006-03-12 01:12:27 +00:00
{
2007-09-16 09:24:28 +00:00
#ifdef __ADSPBF537__
if ((*pCHIPID >> 28) < 2)
return;
#endif
__builtin_bfin_ssync();
asm(" .align 8; ");
*(unsigned int *)IMEM_CONTROL &= ~(IMC | ENICPLB);
__builtin_bfin_ssync();
2006-03-12 01:12:27 +00:00
}
void icache_enable(void)
{
2007-09-16 09:24:28 +00:00
unsigned int *I0, *I1;
int j = 0;
#ifdef __ADSPBF537__
if ((*pCHIPID >> 28) < 2)
return;
#endif
/* Before enable icache, disable it first */
icache_disable();
2006-03-12 01:12:27 +00:00
I0 = (unsigned int *)ICPLB_ADDR0;
I1 = (unsigned int *)ICPLB_DATA0;
2006-03-12 01:55:22 +00:00
/* We only setup instruction caching for barebox itself.
2007-09-16 09:24:28 +00:00
* This has the nice side effect that we trigger an
* exception when barebox goes crazy.
2007-09-16 09:24:28 +00:00
*/
*I0++ = TEXT_BASE & ~((1 << 20) - 1);
*I1++ = PAGE_SIZE_1MB | CPLB_L1_CHBL | CPLB_USER_RD | CPLB_VALID | CPLB_LOCK;
j++;
/* Fill the rest with invalid entry */
for ( ; j < 16 ; j++) {
debug("filling %i with 0\n",j);
*I1++ = 0x0;
}
__builtin_bfin_ssync();
asm(" .align 8; ");
2006-03-12 01:12:27 +00:00
*(unsigned int *)IMEM_CONTROL = IMC | ENICPLB;
2007-09-16 09:24:28 +00:00
__builtin_bfin_ssync();
2006-03-12 01:12:27 +00:00
}
int icache_status(void)
{
unsigned int value;
value = *(unsigned int *)IMEM_CONTROL;
2007-09-16 09:24:28 +00:00
if (value & (IMC | ENICPLB))
return 1;
2006-03-12 01:12:27 +00:00
else
2007-09-16 09:24:28 +00:00
return 0;
2006-03-12 01:12:27 +00:00
}
2007-09-16 09:24:28 +00:00
static void blackfin_init_exceptions(void)
2006-03-12 01:12:27 +00:00
{
2007-09-16 09:24:28 +00:00
*(unsigned volatile long *) (SIC_IMASK) = SIC_UNMASK_ALL;
#ifndef CONFIG_KGDB
*(unsigned volatile long *) (EVT_EMULATION_ADDR) = 0x0;
#endif
*(unsigned volatile long *) (EVT_NMI_ADDR) =
(unsigned volatile long) evt_nmi;
*(unsigned volatile long *) (EVT_EXCEPTION_ADDR) =
(unsigned volatile long) trap;
*(unsigned volatile long *) (EVT_HARDWARE_ERROR_ADDR) =
(unsigned volatile long) evt_ivhw;
*(volatile unsigned long *) ILAT = 0;
asm("csync;");
*(volatile unsigned long *) IMASK = 0x3f;
asm("csync;");
2006-03-12 01:12:27 +00:00
}
2007-09-16 09:24:28 +00:00
static int blackfin_init_core(void)
2006-03-12 01:12:27 +00:00
{
2007-09-16 09:24:28 +00:00
blackfin_init_exceptions();
icache_enable();
2006-03-12 01:12:27 +00:00
2007-09-16 09:24:28 +00:00
return 0;
2006-03-12 01:12:27 +00:00
}
2007-09-16 09:24:28 +00:00
core_initcall(blackfin_init_core);