xref: /openbmc/linux/arch/mips/dec/wbflush.c (revision 93d90ad7)
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  * Copyright (C) 2002 Maciej W. Rozycki
15  */
16 
17 #include <linux/init.h>
18 
19 #include <asm/bootinfo.h>
20 #include <asm/wbflush.h>
21 #include <asm/barrier.h>
22 
23 static void wbflush_kn01(void);
24 static void wbflush_kn210(void);
25 static void wbflush_mips(void);
26 
27 void (*__wbflush) (void);
28 
29 void __init wbflush_setup(void)
30 {
31 	switch (mips_machtype) {
32 	case MACH_DS23100:
33 	case MACH_DS5000_200:	/* DS5000 3max */
34 		__wbflush = wbflush_kn01;
35 		break;
36 	case MACH_DS5100:	/* DS5100 MIPSMATE */
37 		__wbflush = wbflush_kn210;
38 		break;
39 	case MACH_DS5000_1XX:	/* DS5000/100 3min */
40 	case MACH_DS5000_XX:	/* Personal DS5000/2x */
41 	case MACH_DS5000_2X0:	/* DS5000/240 3max+ */
42 	case MACH_DS5900:	/* DS5900 bigmax */
43 	default:
44 		__wbflush = wbflush_mips;
45 		break;
46 	}
47 }
48 
49 /*
50  * For the DS3100 and DS5000/200 the R2020/R3220 writeback buffer functions
51  * as part of Coprocessor 0.
52  */
53 static void wbflush_kn01(void)
54 {
55     asm(".set\tpush\n\t"
56 	".set\tnoreorder\n\t"
57 	"1:\tbc0f\t1b\n\t"
58 	"nop\n\t"
59 	".set\tpop");
60 }
61 
62 /*
63  * For the DS5100 the writeback buffer seems to be a part of Coprocessor 3.
64  * But CP3 has to enabled first.
65  */
66 static void wbflush_kn210(void)
67 {
68     asm(".set\tpush\n\t"
69 	".set\tnoreorder\n\t"
70 	"mfc0\t$2,$12\n\t"
71 	"lui\t$3,0x8000\n\t"
72 	"or\t$3,$2,$3\n\t"
73 	"mtc0\t$3,$12\n\t"
74 	"nop\n"
75 	"1:\tbc3f\t1b\n\t"
76 	"nop\n\t"
77 	"mtc0\t$2,$12\n\t"
78 	"nop\n\t"
79 	".set\tpop"
80 	: : : "$2", "$3");
81 }
82 
83 /*
84  * I/O ASIC systems use a standard writeback buffer that gets flushed
85  * upon an uncached read.
86  */
87 static void wbflush_mips(void)
88 {
89 	__fast_iob();
90 }
91 
92 #include <linux/module.h>
93 
94 EXPORT_SYMBOL(__wbflush);
95