1 /* MN10300 CPU cache invalidation routines, using automatic purge registers
3 * Copyright (C) 2011 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public Licence
8 * as published by the Free Software Foundation; either version
9 * 2 of the Licence, or (at your option) any later version.
11 #include <linux/sys.h>
12 #include <linux/linkage.h>
15 #include <asm/cache.h>
16 #include <asm/irqflags.h>
17 #include <asm/cacheflush.h>
22 ###############################################################################
24 # void debugger_local_cache_flushinv(void)
25 # Flush the entire data cache back to RAM and invalidate the icache
27 ###############################################################################
29 .globl debugger_local_cache_flushinv
30 .type debugger_local_cache_flushinv,@function
31 debugger_local_cache_flushinv:
33 # firstly flush the dcache
36 btst CHCTR_DCEN|CHCTR_ICEN,d0
37 beq debugger_local_cache_flushinv_end
47 beq debugger_local_cache_flushinv_no_dcache
49 # wait for busy bit of area purge
52 btst DCPGCR_DCPGBSY,d0
66 # wait for busy bit of area purge
69 btst DCPGCR_DCPGBSY,d0
72 debugger_local_cache_flushinv_no_dcache:
74 # secondly, invalidate the icache if it is enabled
79 beq debugger_local_cache_flushinv_done
83 debugger_local_cache_flushinv_done:
86 debugger_local_cache_flushinv_end:
88 .size debugger_local_cache_flushinv,.-debugger_local_cache_flushinv
90 ###############################################################################
92 # void debugger_local_cache_flushinv_one(u8 *addr)
94 # Invalidate one particular cacheline if it's in the icache
96 ###############################################################################
98 .globl debugger_local_cache_flushinv_one
99 .type debugger_local_cache_flushinv_one,@function
100 debugger_local_cache_flushinv_one:
102 btst CHCTR_DCEN|CHCTR_ICEN,d1
103 beq debugger_local_cache_flushinv_one_end
105 beq debugger_local_cache_flushinv_one_no_dcache
107 # round cacheline addr down
108 and L1_CACHE_TAG_MASK,d0
112 # determine the dcache purge control reg address
113 mov DCACHE_PURGE(0,0),a0
114 and L1_CACHE_TAG_ENTRY,d0
117 # retain valid entries in the cache
118 or L1_CACHE_TAG_VALID,d1
120 # conditionally purge this line in all ways
121 mov d1,(L1_CACHE_WAYDISP*0,a0)
123 debugger_local_cache_flushinv_one_no_dcache:
125 # now try to flush the icache
130 beq debugger_local_cache_flushinv_one_end
136 # wait for the invalidator to quiesce
139 btst ICIVCR_ICIVBSY,d0
143 mov L1_CACHE_TAG_MASK,d0
146 # invalidate the cache line at the given address
150 # wait for the invalidator to quiesce again
153 btst ICIVCR_ICIVBSY,d0
156 LOCAL_IRQ_RESTORE(d1)
158 debugger_local_cache_flushinv_one_end:
160 .size debugger_local_cache_flushinv_one,.-debugger_local_cache_flushinv_one