MOXA linux-2.6.x / linux-2.6.9-uc0 from sdlinux-moxaart.tgz
[linux-2.6.9-moxart.git] / arch / m32r / mm / cache.c
blobe2dd92d693808a9f9a6817a170cde7eefb22b6b1
1 /*
2 * linux/arch/m32r/mm/cache.c
4 * Copyright (C) 2002 Hirokazu Takata
5 */
7 /* $Id$ */
9 #include <linux/config.h>
10 #include <asm/pgtable.h>
12 #undef MCCR
14 #if defined(CONFIG_CHIP_XNUX2) || defined(CONFIG_CHIP_M32700) || defined(CONFIG_CHIP_VDEC2) || defined(CONFIG_CHIP_OPSP)
15 /* Cache Control Register */
16 #define MCCR ((volatile unsigned long*)0xfffffffc)
17 #define MCCR_CC (1UL << 7) /* Cache mode modify bit */
18 #define MCCR_IIV (1UL << 6) /* I-cache invalidate */
19 #define MCCR_DIV (1UL << 5) /* D-cache invalidate */
20 #define MCCR_DCB (1UL << 4) /* D-cache copy back */
21 #define MCCR_ICM (1UL << 1) /* I-cache mode [0:off,1:on] */
22 #define MCCR_DCM (1UL << 0) /* D-cache mode [0:off,1:on] */
23 #define MCCR_ICACHE_INV (MCCR_CC|MCCR_IIV)
24 #define MCCR_DCACHE_CB (MCCR_CC|MCCR_DCB)
25 #define MCCR_DCACHE_CBINV (MCCR_CC|MCCR_DIV|MCCR_DCB)
26 #define CHECK_MCCR(mccr) (mccr = *MCCR)
27 #elif defined(CONFIG_CHIP_M32102)
28 #define MCCR ((volatile unsigned long*)0xfffffffc)
29 #define MCCR_IIV (1UL << 8) /* I-cache invalidate */
30 #define MCCR_ICACHE_INV MCCR_IIV
31 #endif /* CONFIG_CHIP_XNUX2 || CONFIG_CHIP_M32700 */
33 #ifndef MCCR
34 #error Unknown cache type.
35 #endif
38 /* Copy back and invalidate D-cache and invalidate I-cache all */
39 void _flush_cache_all(void)
41 #if defined(CONFIG_CHIP_M32102)
42 *MCCR = MCCR_ICACHE_INV;
43 #else
44 unsigned long mccr;
46 /* Copyback and invalidate D-cache */
47 /* Invalidate I-cache */
48 *MCCR = MCCR_ICACHE_INV | MCCR_DCACHE_CBINV;
49 while ((mccr = *MCCR) & MCCR_IIV); /* loop while invalidating... */
50 #endif
53 /* Copy back D-cache and invalidate I-cache all */
54 void _flush_cache_copyback_all(void)
56 #if defined(CONFIG_CHIP_M32102)
57 *MCCR = MCCR_ICACHE_INV;
58 #else
59 unsigned long mccr;
61 /* Copyback D-cache */
62 /* Invalidate I-cache */
63 *MCCR = MCCR_ICACHE_INV | MCCR_DCACHE_CB;
64 while ((mccr = *MCCR) & MCCR_IIV); /* loop while invalidating... */
66 #endif