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