2012-02-03 06:08:17 -05:00
|
|
|
#include <irq.h>
|
|
|
|
#include <uart.h>
|
2014-05-14 04:24:56 -04:00
|
|
|
#ifdef __or1k__
|
|
|
|
#include <spr-defs.h>
|
|
|
|
#endif
|
2012-02-03 06:08:17 -05:00
|
|
|
|
|
|
|
#include <system.h>
|
2014-02-21 11:55:05 -05:00
|
|
|
#include <generated/mem.h>
|
2013-11-24 13:50:17 -05:00
|
|
|
#include <generated/csr.h>
|
2012-02-03 06:08:17 -05:00
|
|
|
|
|
|
|
void flush_cpu_icache(void)
|
|
|
|
{
|
2014-05-14 04:24:56 -04:00
|
|
|
#if defined (__lm32__)
|
2012-02-03 06:08:17 -05:00
|
|
|
asm volatile(
|
|
|
|
"wcsr ICC, r0\n"
|
|
|
|
"nop\n"
|
|
|
|
"nop\n"
|
|
|
|
"nop\n"
|
|
|
|
"nop\n"
|
|
|
|
);
|
2014-05-14 04:24:56 -04:00
|
|
|
#elif defined (__or1k__)
|
|
|
|
unsigned long iccfgr;
|
|
|
|
unsigned long cache_set_size;
|
|
|
|
unsigned long cache_ways;
|
|
|
|
unsigned long cache_block_size;
|
|
|
|
unsigned long cache_size;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
iccfgr = mfspr(SPR_ICCFGR);
|
|
|
|
cache_ways = 1 << (iccfgr & SPR_ICCFGR_NCW);
|
|
|
|
cache_set_size = 1 << ((iccfgr & SPR_ICCFGR_NCS) >> 3);
|
|
|
|
cache_block_size = (iccfgr & SPR_ICCFGR_CBS) ? 32 : 16;
|
|
|
|
cache_size = cache_set_size * cache_ways * cache_block_size;
|
|
|
|
|
|
|
|
for (i = 0; i < cache_size; i += cache_block_size)
|
|
|
|
mtspr(SPR_ICBIR, i);
|
|
|
|
#else
|
|
|
|
#error Unsupported architecture
|
|
|
|
#endif
|
2012-02-03 06:08:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void flush_cpu_dcache(void)
|
|
|
|
{
|
2014-05-14 04:24:56 -04:00
|
|
|
#if defined (__lm32__)
|
2012-02-03 06:08:17 -05:00
|
|
|
asm volatile(
|
|
|
|
"wcsr DCC, r0\n"
|
|
|
|
"nop\n"
|
|
|
|
);
|
2014-05-14 04:24:56 -04:00
|
|
|
#elif defined (__or1k__)
|
|
|
|
unsigned long dccfgr;
|
|
|
|
unsigned long cache_set_size;
|
|
|
|
unsigned long cache_ways;
|
|
|
|
unsigned long cache_block_size;
|
|
|
|
unsigned long cache_size;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
dccfgr = mfspr(SPR_DCCFGR);
|
|
|
|
cache_ways = 1 << (dccfgr & SPR_ICCFGR_NCW);
|
|
|
|
cache_set_size = 1 << ((dccfgr & SPR_DCCFGR_NCS) >> 3);
|
|
|
|
cache_block_size = (dccfgr & SPR_DCCFGR_CBS) ? 32 : 16;
|
|
|
|
cache_size = cache_set_size * cache_ways * cache_block_size;
|
|
|
|
|
|
|
|
for (i = 0; i < cache_size; i += cache_block_size)
|
|
|
|
mtspr(SPR_DCBIR, i);
|
|
|
|
#else
|
|
|
|
#error Unsupported architecture
|
|
|
|
#endif
|
2012-02-03 06:08:17 -05:00
|
|
|
}
|
2013-11-16 10:27:21 -05:00
|
|
|
|
2015-03-02 06:25:59 -05:00
|
|
|
#ifdef CSR_WISHBONE2LASMI_BASE
|
2013-11-16 10:27:21 -05:00
|
|
|
void flush_l2_cache(void)
|
|
|
|
{
|
|
|
|
unsigned int l2_nwords;
|
|
|
|
unsigned int i;
|
|
|
|
register unsigned int addr;
|
|
|
|
register unsigned int dummy;
|
|
|
|
|
2015-02-27 08:13:38 -05:00
|
|
|
l2_nwords = 1 << wishbone2lasmi_cachesize_read();
|
2013-11-16 10:27:21 -05:00
|
|
|
for(i=0;i<2*l2_nwords;i++) {
|
|
|
|
addr = SDRAM_BASE + i*4;
|
2014-05-14 04:24:56 -04:00
|
|
|
#ifdef __lm32__
|
2013-11-16 10:27:21 -05:00
|
|
|
__asm__ volatile("lw %0, (%1+0)\n":"=r"(dummy):"r"(addr));
|
2014-05-14 04:24:56 -04:00
|
|
|
#else
|
|
|
|
#warning TODO
|
|
|
|
#endif
|
2013-11-16 10:27:21 -05:00
|
|
|
}
|
|
|
|
}
|
2015-02-27 09:28:37 -05:00
|
|
|
#else
|
|
|
|
void flush_l2_cache(void)
|
|
|
|
{
|
|
|
|
}
|
2015-02-27 08:13:38 -05:00
|
|
|
#endif
|