arc: disable i-cache in early init because ARC CPUs start with it on

The ARC CPU comes up from reset with i-cache enabled.
It can have garbage in it from a previous run.
The fix is to check the build register for the i-cache, and if its
present, invalidate it fully, and then disable it.
_icache_setup() is called later to turn it on.

Change-Id: I26fae915153841c61e9530d5af2ddb9d0553275b
Signed-off-by: Chuck Jordan <cjordan@synopsys.com>
This commit is contained in:
Chuck Jordan 2016-05-23 13:30:55 -07:00 committed by Anas Nashif
commit bc04903bdd

View file

@ -77,6 +77,30 @@ static void dataCopy(void)
#endif #endif
/**
*
* @brief Disable the i-cache if present
*
* For those ARC CPUs that have a i-cache present,
* invalidate the i-cache and then disable it.
*
* @return N/A
*/
static void disable_icache(void)
{
unsigned int val;
val = _arc_v2_aux_reg_read(_ARC_V2_I_CACHE_BUILD);
val &= 0xff; /* version field */
if (val == 0) {
return; /* skip if i-cache is not present */
}
_arc_v2_aux_reg_write(_ARC_V2_IC_IVIC, 0);
__asm__ __volatile__ ("nop");
_arc_v2_aux_reg_write(_ARC_V2_IC_CTRL, 1);
}
/** /**
* *
* @brief Invalidate the data cache if present * @brief Invalidate the data cache if present
@ -140,8 +164,9 @@ extern FUNC_NORETURN void _Cstart(void);
void _PrepC(void) void _PrepC(void)
{ {
adjust_vector_table_base(); disable_icache();
invalidate_dcache(); invalidate_dcache();
adjust_vector_table_base();
bssZero(); bssZero();
dataCopy(); dataCopy();
_Cstart(); _Cstart();