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 * SPDX-License-Identifier: GPL-2.0+
13 #include <asm/ppc4xx.h>
14 #include <ppc_asm.tmpl>
16 #include <asm/cache.h>
20 * Flush instruction cache.
22 _GLOBAL(invalidate_icache)
28 * Write any modified data cache blocks out to memory
29 * and invalidate the corresponding instruction cache blocks.
31 * flush_icache_range(unsigned long start, unsigned long stop)
33 _GLOBAL(flush_icache_range)
34 li r5,L1_CACHE_BYTES-1
38 srwi. r4,r4,L1_CACHE_SHIFT
43 addi r3,r3,L1_CACHE_BYTES
45 sync /* wait for dcbst's to get to ram */
48 addi r6,r6,L1_CACHE_BYTES
50 sync /* additional sync needed on g4 */
55 * Write any modified data cache blocks out to memory.
56 * Does not invalidate the corresponding cache lines (especially for
57 * any corresponding instruction cache).
59 * clean_dcache_range(unsigned long start, unsigned long stop)
61 _GLOBAL(clean_dcache_range)
62 li r5,L1_CACHE_BYTES-1
66 srwi. r4,r4,L1_CACHE_SHIFT
71 addi r3,r3,L1_CACHE_BYTES
73 sync /* wait for dcbst's to get to ram */
77 * 40x cores have 8K or 16K dcache and 32 byte line size.
78 * 44x has a 32K dcache and 32 byte line size.
79 * 8xx has 1, 2, 4, 8K variants.
80 * For now, cover the worst case of the 44x.
81 * Must be called with external interrupts disabled.
83 #define CACHE_NWAYS 64
84 #define CACHE_NLINES 32
87 li r4,(2 * CACHE_NWAYS * CACHE_NLINES)
90 1: lwz r3,0(r5) /* Load one word from every line */
91 addi r5,r5,L1_CACHE_BYTES
96 _GLOBAL(invalidate_dcache)
97 addi r6,0,0x0000 /* clear GPR 6 */
98 /* Do loop for # of dcache congruence classes. */
99 lis r7,(CONFIG_SYS_DCACHE_SIZE / L1_CACHE_BYTES / 2)@ha /* TBS for large sized cache */
100 ori r7,r7,(CONFIG_SYS_DCACHE_SIZE / L1_CACHE_BYTES / 2)@l
101 /* NOTE: dccci invalidates both */
102 mtctr r7 /* ways in the D cache */
104 dccci 0,r6 /* invalidate line */
105 addi r6,r6,L1_CACHE_BYTES /* bump to next line */
113 * NOTE: currently the 440s run with dcache _disabled_ once relocated to DRAM,
114 * although for some cache-ralated calls stubs have to be provided to satisfy
115 * symbols resolution.
116 * Icache-related functions are used in POST framework.
121 .globl dcache_disable
123 .globl icache_disable
138 #else /* CONFIG_440 */
146 addis r3,r0, 0xc000 /* set bit 0 */
150 .globl icache_disable
152 addis r3,r0, 0x0000 /* clear bit 0 */
160 srwi r3, r3, 31 /* >>31 => select bit 0 */
169 addis r3,r0, 0x8000 /* set bit 0 */
173 .globl dcache_disable
178 addis r3,r0, 0x0000 /* clear bit 0 */
185 srwi r3, r3, 31 /* >>31 => select bit 0 */
188 #endif /* CONFIG_440 */