2 * This file contains miscellaneous low-level functions.
3 * Copyright (C) 1995-1996 Gary Thomas (gdt@linuxppc.org)
5 * Largely rewritten by Cort Dougan (cort@cs.nmt.edu)
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version
11 * 2 of the License, or (at your option) any later version.
18 #include <ppc_asm.tmpl>
20 #include <asm/cache.h>
24 * Flush instruction cache.
26 _GLOBAL(invalidate_icache)
32 * Write any modified data cache blocks out to memory
33 * and invalidate the corresponding instruction cache blocks.
35 * flush_icache_range(unsigned long start, unsigned long stop)
37 _GLOBAL(flush_icache_range)
38 li r5,L1_CACHE_BYTES-1
42 srwi. r4,r4,L1_CACHE_SHIFT
47 addi r3,r3,L1_CACHE_BYTES
49 sync /* wait for dcbst's to get to ram */
52 addi r6,r6,L1_CACHE_BYTES
54 sync /* additional sync needed on g4 */
59 * Write any modified data cache blocks out to memory.
60 * Does not invalidate the corresponding cache lines (especially for
61 * any corresponding instruction cache).
63 * clean_dcache_range(unsigned long start, unsigned long stop)
65 _GLOBAL(clean_dcache_range)
66 li r5,L1_CACHE_BYTES-1
70 srwi. r4,r4,L1_CACHE_SHIFT
75 addi r3,r3,L1_CACHE_BYTES
77 sync /* wait for dcbst's to get to ram */
81 * Write any modified data cache blocks out to memory and invalidate them.
82 * Does not invalidate the corresponding instruction cache blocks.
84 * flush_dcache_range(unsigned long start, unsigned long stop)
86 _GLOBAL(flush_dcache_range)
87 li r5,L1_CACHE_BYTES-1
91 srwi. r4,r4,L1_CACHE_SHIFT
96 addi r3,r3,L1_CACHE_BYTES
98 sync /* wait for dcbst's to get to ram */
102 * Like above, but invalidate the D-cache. This is used by the 8xx
103 * to invalidate the cache so the PPC core doesn't get stale data
104 * from the CPM (no cache snooping here :-).
106 * invalidate_dcache_range(unsigned long start, unsigned long stop)
108 _GLOBAL(invalidate_dcache_range)
109 li r5,L1_CACHE_BYTES-1
113 srwi. r4,r4,L1_CACHE_SHIFT
118 addi r3,r3,L1_CACHE_BYTES
120 sync /* wait for dcbi's to get to ram */
124 * 40x cores have 8K or 16K dcache and 32 byte line size.
125 * 44x has a 32K dcache and 32 byte line size.
126 * 8xx has 1, 2, 4, 8K variants.
127 * For now, cover the worst case of the 44x.
128 * Must be called with external interrupts disabled.
130 #define CACHE_NWAYS 64
131 #define CACHE_NLINES 32
133 _GLOBAL(flush_dcache)
134 li r4,(2 * CACHE_NWAYS * CACHE_NLINES)
137 1: lwz r3,0(r5) /* Load one word from every line */
138 addi r5,r5,L1_CACHE_BYTES
143 _GLOBAL(invalidate_dcache)
144 addi r6,0,0x0000 /* clear GPR 6 */
145 /* Do loop for # of dcache congruence classes. */
146 lis r7,(CONFIG_SYS_DCACHE_SIZE / L1_CACHE_BYTES / 2)@ha /* TBS for large sized cache */
147 ori r7,r7,(CONFIG_SYS_DCACHE_SIZE / L1_CACHE_BYTES / 2)@l
148 /* NOTE: dccci invalidates both */
149 mtctr r7 /* ways in the D cache */
151 dccci 0,r6 /* invalidate line */
152 addi r6,r6,L1_CACHE_BYTES /* bump to next line */
160 * NOTE: currently the 440s run with dcache _disabled_ once relocated to DRAM,
161 * although for some cache-ralated calls stubs have to be provided to satisfy
162 * symbols resolution.
163 * Icache-related functions are used in POST framework.
168 .globl dcache_disable
170 .globl icache_disable
185 #else /* CONFIG_440 */
193 addis r3,r0, 0xc000 /* set bit 0 */
197 .globl icache_disable
199 addis r3,r0, 0x0000 /* clear bit 0 */
207 srwi r3, r3, 31 /* >>31 => select bit 0 */
216 addis r3,r0, 0x8000 /* set bit 0 */
220 .globl dcache_disable
225 addis r3,r0, 0x0000 /* clear bit 0 */
232 srwi r3, r3, 31 /* >>31 => select bit 0 */
235 #endif /* CONFIG_440 */