v2.4.10.4 -> v2.4.10.5
[linux-flexiantxendom0-3.2.10.git] / arch / mips / dec / wbflush.c
1 /*
2  * Setup the right wbflush routine for the different DECstations.
3  *
4  * Created with information from:
5  *      DECstation 3100 Desktop Workstation Functional Specification
6  *      DECstation 5000/200 KN02 System Module Functional Specification
7  *      mipsel-linux-objdump --disassemble vmunix | grep "wbflush" :-)
8  *
9  * This file is subject to the terms and conditions of the GNU General Public
10  * License.  See the file "COPYING" in the main directory of this archive
11  * for more details.
12  *
13  * Copyright (C) 1998 Harald Koerfgen
14  */
15
16 #include <asm/bootinfo.h>
17 #include <linux/init.h>
18
19 static void wbflush_kn01(void);
20 static void wbflush_kn210(void);
21 static void wbflush_kn02ba(void);
22 static void wbflush_kn03(void);
23
24 void (*__wbflush) (void);
25
26 void __init wbflush_setup(void)
27 {
28         switch (mips_machtype) {
29         case MACH_DS23100:
30             __wbflush = wbflush_kn01;
31             break;
32         case MACH_DS5100:       /*  DS5100 MIPSMATE */
33             __wbflush = wbflush_kn210;
34             break;
35         case MACH_DS5000_200:   /* DS5000 3max */
36             __wbflush = wbflush_kn01;
37             break;
38         case MACH_DS5000_1XX:   /* DS5000/100 3min */
39             __wbflush = wbflush_kn02ba;
40             break;
41         case MACH_DS5000_2X0:   /* DS5000/240 3max+ */
42             __wbflush = wbflush_kn03;
43             break;
44         case MACH_DS5000_XX:    /* Personal DS5000/2x */
45             __wbflush = wbflush_kn02ba;
46             break;
47         }
48 }
49
50 /*
51  * For the DS3100 and DS5000/200 the writeback buffer functions
52  * as part of Coprocessor 0.
53  */
54 static void wbflush_kn01(void)
55 {
56     asm(".set\tpush\n\t"
57         ".set\tnoreorder\n\t"
58         "1:\tbc0f\t1b\n\t"
59         "nop\n\t"
60         ".set\tpop");
61 }
62
63 /*
64  * For the DS5100 the writeback buffer seems to be a part of Coprocessor 3.
65  * But CP3 has to enabled first.
66  */
67 static void wbflush_kn210(void)
68 {
69     asm(".set\tpush\n\t"
70         ".set\tnoreorder\n\t"
71         "mfc0\t$2,$12\n\t"
72         "lui\t$3,0x8000\n\t"
73         "or\t$3,$2,$3\n\t"
74         "mtc0\t$3,$12\n\t"
75         "nop\n"
76         "1:\tbc3f\t1b\n\t"
77         "nop\n\t"
78         "mtc0\t$2,$12\n\t"
79         "nop\n\t"
80         ".set\tpop"
81   : : :"$2", "$3");
82 }
83
84 /*
85  * Looks like some magic with the System Interrupt Mask Register
86  * in the famous IOASIC for kmins and maxines.
87  */
88 static void wbflush_kn02ba(void)
89 {
90     asm(".set\tpush\n\t"
91         ".set\tnoreorder\n\t"
92         "lui\t$2,0xbc04\n\t"
93         "lw\t$3,0x120($2)\n\t"
94         "lw\t$3,0x120($2)\n\t"
95         ".set\tpop"
96   : : :"$2", "$3");
97 }
98
99 /*
100  * The DS500/2x0 doesnt need to write back the WB.
101  */
102 static void wbflush_kn03(void)
103 {
104 }
105
106 #include <linux/module.h>
107
108 EXPORT_SYMBOL(__wbflush);