/* Released under the terms of the GNU GPL v2.0.  */
static void sh2__flush_wback_region(void *start, int size)
/* Released under the terms of the GNU GPL v2.0.  */
static void sh2__flush_wback_region(void *start, int size)
{
	unsigned long v;
	unsigned long begin, end;
	begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
	end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
		& ~(L1_CACHE_BYTES-1);
	for (v = begin; v < end; v+=L1_CACHE_BYTES) {
		unsigned long addr = CACHE_OC_ADDRESS_ARRAY | (v & 0x00000ff0);
		int way;
		for (way = 0; way < 4; way++) {
			unsigned long data =  ctrl_inl(addr | (way << 12));
			if ((data & CACHE_PHYSADDR_MASK) == (v & CACHE_PHYSADDR_MASK)) {
				data &= ~SH_CACHE_UPDATED;
				ctrl_outl(data, addr | (way << 12));
			}
		}
	}
}