2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2003-12-08 01:34:36 +00:00
|
|
|
/*
|
2004-02-12 00:47:09 +00:00
|
|
|
* (C) Copyright 2002
|
2003-12-08 01:34:36 +00:00
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*/
|
|
|
|
|
2023-10-12 23:03:56 +00:00
|
|
|
#include <config.h>
|
2019-11-14 19:57:37 +00:00
|
|
|
#include <cpu_func.h>
|
2010-03-12 04:12:53 +00:00
|
|
|
#include <asm/immap.h>
|
|
|
|
#include <asm/cache.h>
|
2003-12-08 01:34:36 +00:00
|
|
|
|
2010-03-12 04:12:53 +00:00
|
|
|
volatile int *cf_icache_status = (int *)ICACHE_STATUS;
|
|
|
|
volatile int *cf_dcache_status = (int *)DCACHE_STATUS;
|
|
|
|
|
|
|
|
void flush_cache(ulong start_addr, ulong size)
|
2003-12-08 01:34:36 +00:00
|
|
|
{
|
2004-02-12 00:47:09 +00:00
|
|
|
/* Must be implemented for all M68k processors with copy-back data cache */
|
2003-12-08 01:34:36 +00:00
|
|
|
}
|
2010-03-12 04:12:53 +00:00
|
|
|
|
|
|
|
int icache_status(void)
|
|
|
|
{
|
|
|
|
return *cf_icache_status;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dcache_status(void)
|
|
|
|
{
|
|
|
|
return *cf_dcache_status;
|
|
|
|
}
|
|
|
|
|
|
|
|
void icache_enable(void)
|
|
|
|
{
|
|
|
|
icache_invalid();
|
|
|
|
|
|
|
|
*cf_icache_status = 1;
|
|
|
|
|
2023-01-10 16:19:45 +00:00
|
|
|
#if defined(CONFIG_CF_V4) || defined(CFG_CF_V4E)
|
2022-11-16 18:10:41 +00:00
|
|
|
__asm__ __volatile__("movec %0, %%acr2"::"r"(CFG_SYS_CACHE_ACR2));
|
2023-01-10 16:19:45 +00:00
|
|
|
__asm__ __volatile__("movec %0, %%acr3"::"r"(CFG_SYS_CACHE_ACR3));
|
|
|
|
#if defined(CFG_CF_V4E)
|
|
|
|
__asm__ __volatile__("movec %0, %%acr6"::"r"(CFG_SYS_CACHE_ACR6));
|
|
|
|
__asm__ __volatile__("movec %0, %%acr7"::"r"(CFG_SYS_CACHE_ACR7));
|
2017-05-31 19:32:48 +00:00
|
|
|
#endif
|
2010-03-12 04:12:53 +00:00
|
|
|
#else
|
2022-11-16 18:10:41 +00:00
|
|
|
__asm__ __volatile__("movec %0, %%acr0"::"r"(CFG_SYS_CACHE_ACR0));
|
|
|
|
__asm__ __volatile__("movec %0, %%acr1"::"r"(CFG_SYS_CACHE_ACR1));
|
2010-03-12 04:12:53 +00:00
|
|
|
#endif
|
|
|
|
|
2022-11-16 18:10:41 +00:00
|
|
|
__asm__ __volatile__("movec %0, %%cacr"::"r"(CFG_SYS_CACHE_ICACR));
|
2010-03-12 04:12:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void icache_disable(void)
|
|
|
|
{
|
|
|
|
u32 temp = 0;
|
|
|
|
|
|
|
|
*cf_icache_status = 0;
|
|
|
|
icache_invalid();
|
|
|
|
|
2023-01-10 16:19:45 +00:00
|
|
|
#if defined(CONFIG_CF_V4) || defined(CFG_CF_V4E)
|
2010-03-12 04:12:53 +00:00
|
|
|
__asm__ __volatile__("movec %0, %%acr2"::"r"(temp));
|
|
|
|
__asm__ __volatile__("movec %0, %%acr3"::"r"(temp));
|
2023-01-10 16:19:45 +00:00
|
|
|
#if defined(CFG_CF_V4E)
|
2010-03-12 04:12:53 +00:00
|
|
|
__asm__ __volatile__("movec %0, %%acr6"::"r"(temp));
|
|
|
|
__asm__ __volatile__("movec %0, %%acr7"::"r"(temp));
|
2017-05-31 19:32:48 +00:00
|
|
|
#endif
|
2010-03-12 04:12:53 +00:00
|
|
|
#else
|
|
|
|
__asm__ __volatile__("movec %0, %%acr0"::"r"(temp));
|
|
|
|
__asm__ __volatile__("movec %0, %%acr1"::"r"(temp));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void icache_invalid(void)
|
|
|
|
{
|
|
|
|
u32 temp;
|
|
|
|
|
2022-11-16 18:10:41 +00:00
|
|
|
temp = CFG_SYS_ICACHE_INV;
|
2010-03-12 04:12:53 +00:00
|
|
|
if (*cf_icache_status)
|
2022-11-16 18:10:41 +00:00
|
|
|
temp |= CFG_SYS_CACHE_ICACR;
|
2010-03-12 04:12:53 +00:00
|
|
|
|
|
|
|
__asm__ __volatile__("movec %0, %%cacr"::"r"(temp));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2021-05-15 01:34:10 +00:00
|
|
|
* data cache only for ColdFire V4 such as MCF5445x
|
2010-03-12 04:12:53 +00:00
|
|
|
* the dcache will be dummy in ColdFire V2 and V3
|
|
|
|
*/
|
|
|
|
void dcache_enable(void)
|
|
|
|
{
|
|
|
|
dcache_invalid();
|
|
|
|
*cf_dcache_status = 1;
|
|
|
|
|
2023-01-10 16:19:45 +00:00
|
|
|
#if defined(CONFIG_CF_V4) || defined(CFG_CF_V4E)
|
2022-11-16 18:10:41 +00:00
|
|
|
__asm__ __volatile__("movec %0, %%acr0"::"r"(CFG_SYS_CACHE_ACR0));
|
|
|
|
__asm__ __volatile__("movec %0, %%acr1"::"r"(CFG_SYS_CACHE_ACR1));
|
2023-01-10 16:19:45 +00:00
|
|
|
#if defined(CFG_CF_V4E)
|
|
|
|
__asm__ __volatile__("movec %0, %%acr4"::"r"(CFG_SYS_CACHE_ACR4));
|
|
|
|
__asm__ __volatile__("movec %0, %%acr5"::"r"(CFG_SYS_CACHE_ACR5));
|
2017-05-31 19:32:48 +00:00
|
|
|
#endif
|
2010-03-12 04:12:53 +00:00
|
|
|
#endif
|
|
|
|
|
2022-11-16 18:10:41 +00:00
|
|
|
__asm__ __volatile__("movec %0, %%cacr"::"r"(CFG_SYS_CACHE_DCACR));
|
2010-03-12 04:12:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void dcache_disable(void)
|
|
|
|
{
|
|
|
|
u32 temp = 0;
|
|
|
|
|
|
|
|
*cf_dcache_status = 0;
|
|
|
|
dcache_invalid();
|
|
|
|
|
|
|
|
__asm__ __volatile__("movec %0, %%cacr"::"r"(temp));
|
|
|
|
|
2023-01-10 16:19:45 +00:00
|
|
|
#if defined(CONFIG_CF_V4) || defined(CFG_CF_V4E)
|
2010-03-12 04:12:53 +00:00
|
|
|
__asm__ __volatile__("movec %0, %%acr0"::"r"(temp));
|
|
|
|
__asm__ __volatile__("movec %0, %%acr1"::"r"(temp));
|
2023-01-10 16:19:45 +00:00
|
|
|
#if defined(CFG_CF_V4E)
|
2010-03-12 04:12:53 +00:00
|
|
|
__asm__ __volatile__("movec %0, %%acr4"::"r"(temp));
|
|
|
|
__asm__ __volatile__("movec %0, %%acr5"::"r"(temp));
|
2017-05-31 19:32:48 +00:00
|
|
|
#endif
|
2010-03-12 04:12:53 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void dcache_invalid(void)
|
|
|
|
{
|
2023-01-10 16:19:45 +00:00
|
|
|
#if defined(CONFIG_CF_V4) || defined(CFG_CF_V4E)
|
2010-03-12 04:12:53 +00:00
|
|
|
u32 temp;
|
|
|
|
|
2022-11-16 18:10:41 +00:00
|
|
|
temp = CFG_SYS_DCACHE_INV;
|
2010-03-12 04:12:53 +00:00
|
|
|
if (*cf_dcache_status)
|
2022-11-16 18:10:41 +00:00
|
|
|
temp |= CFG_SYS_CACHE_DCACR;
|
2010-03-12 04:12:53 +00:00
|
|
|
if (*cf_icache_status)
|
2022-11-16 18:10:41 +00:00
|
|
|
temp |= CFG_SYS_CACHE_ICACR;
|
2010-03-12 04:12:53 +00:00
|
|
|
|
|
|
|
__asm__ __volatile__("movec %0, %%cacr"::"r"(temp));
|
|
|
|
#endif
|
|
|
|
}
|
2015-07-27 03:40:15 +00:00
|
|
|
|
|
|
|
__weak void invalidate_dcache_range(unsigned long start, unsigned long stop)
|
|
|
|
{
|
|
|
|
/* An empty stub, real implementation should be in platform code */
|
|
|
|
}
|
|
|
|
__weak void flush_dcache_range(unsigned long start, unsigned long stop)
|
|
|
|
{
|
|
|
|
/* An empty stub, real implementation should be in platform code */
|
|
|
|
}
|