2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2002-08-17 09:36:01 +00:00
|
|
|
/*
|
|
|
|
* (C) Copyright 2002
|
|
|
|
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
2019-11-14 19:57:39 +00:00
|
|
|
#include <cpu_func.h>
|
2007-10-31 16:55:58 +00:00
|
|
|
#include <asm/cache.h>
|
2008-04-29 11:32:45 +00:00
|
|
|
#include <watchdog.h>
|
2003-03-31 17:27:09 +00:00
|
|
|
|
2008-12-05 07:36:14 +00:00
|
|
|
void flush_cache(ulong start_addr, ulong size)
|
2002-08-17 09:36:01 +00:00
|
|
|
{
|
2003-03-31 17:27:09 +00:00
|
|
|
#ifndef CONFIG_5xx
|
2008-12-05 07:36:14 +00:00
|
|
|
ulong addr, start, end;
|
2002-08-17 09:36:01 +00:00
|
|
|
|
2008-12-05 07:36:14 +00:00
|
|
|
start = start_addr & ~(CONFIG_SYS_CACHELINE_SIZE - 1);
|
|
|
|
end = start_addr + size - 1;
|
2002-08-17 09:36:01 +00:00
|
|
|
|
2009-02-06 14:08:06 +00:00
|
|
|
for (addr = start; (addr <= end) && (addr >= start);
|
|
|
|
addr += CONFIG_SYS_CACHELINE_SIZE) {
|
2008-12-05 07:36:14 +00:00
|
|
|
asm volatile("dcbst 0,%0" : : "r" (addr) : "memory");
|
|
|
|
WATCHDOG_RESET();
|
2002-08-17 09:36:01 +00:00
|
|
|
}
|
2008-12-05 07:36:14 +00:00
|
|
|
/* wait for all dcbst to complete on bus */
|
|
|
|
asm volatile("sync" : : : "memory");
|
|
|
|
|
2009-02-06 14:08:06 +00:00
|
|
|
for (addr = start; (addr <= end) && (addr >= start);
|
|
|
|
addr += CONFIG_SYS_CACHELINE_SIZE) {
|
2008-12-05 07:36:14 +00:00
|
|
|
asm volatile("icbi 0,%0" : : "r" (addr) : "memory");
|
|
|
|
WATCHDOG_RESET();
|
|
|
|
}
|
|
|
|
asm volatile("sync" : : : "memory");
|
|
|
|
/* flush prefetch queue */
|
|
|
|
asm volatile("isync" : : : "memory");
|
2003-03-31 17:27:09 +00:00
|
|
|
#endif
|
2002-08-17 09:36:01 +00:00
|
|
|
}
|