xref: /netbsd/sys/arch/vax/vax/ka660.c (revision bf9ec67e)
1 /*	$NetBSD: ka660.c,v 1.3 2000/06/29 07:14:27 mrg Exp $	*/
2 /*
3  * Copyright (c) 2000 Ludd, University of Lule}, Sweden.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *     This product includes software developed at Ludd, University of
17  *     Lule}, Sweden and its contributors.
18  * 4. The name of the author may not be used to endorse or promote products
19  *    derived from this software without specific prior written permission
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #include <sys/param.h>
34 #include <sys/types.h>
35 #include <sys/device.h>
36 #include <sys/kernel.h>
37 #include <sys/systm.h>
38 
39 #include <uvm/uvm_extern.h>
40 
41 #include <machine/pte.h>
42 #include <machine/cpu.h>
43 #include <machine/mtpr.h>
44 #include <machine/sid.h>
45 #include <machine/pmap.h>
46 #include <machine/nexus.h>
47 #include <machine/uvax.h>
48 #include <machine/ka410.h>
49 #include <machine/ka420.h>
50 #include <machine/clock.h>
51 #include <machine/vsbus.h>
52 
53 #define KA660_CCR	37	/* Cache Control Register */
54 #define KA660_CTAG	0x20150000	/* Cache Tags */
55 #define KA660_CDATA	0x20150400	/* Cache Data */
56 #define KA660_BEHR	0x20150800	/* Bank Enable/Hit Register */
57 #define CCR_WWP 8	/* Write Wrong Parity */
58 #define CCR_ENA 4	/* Cache Enable */
59 #define CCR_FLU 2	/* Cache Flush */
60 #define CCR_DIA 1	/* Diagnostic mode */
61 
62 static void    ka660_conf(void);
63 static void    ka660_memerr(void);
64 static int     ka660_mchk(caddr_t);
65 static void    ka660_halt(void);
66 static void    ka660_reboot(int);
67 static void    ka660_cache_enable(void);
68 
69 struct vs_cpu *ka660_cpu;
70 
71 /*
72  * Declaration of 660-specific calls.
73  */
74 struct cpu_dep ka660_calls = {
75 	ka660_cache_enable,
76 	ka660_mchk,
77 	ka660_memerr,
78 	ka660_conf,
79 	generic_clkread,
80 	generic_clkwrite,
81 	6,	/* ~VUPS */
82 	2,	/* SCB pages */
83 	ka660_halt,
84 	ka660_reboot,
85 };
86 
87 
88 void
89 ka660_conf()
90 {
91 	printf("cpu0: KA660, microcode Rev. %d\n", vax_cpudata & 0377);
92 }
93 
94 void
95 ka660_cache_enable()
96 {
97 	unsigned int *p;
98 	int cnt, bnk, behrtmp;
99 
100 	mtpr(0, KA660_CCR);	/* Disable cache */
101 	mtpr(CCR_DIA, KA660_CCR);	/* Switch to diag mode */
102 	bnk = 1;
103 	behrtmp = 0;
104 	while(bnk <= 0x80)
105 	{
106 		*(int *)KA660_BEHR = bnk;
107 		p = (int *)KA660_CDATA;
108 		*p = 0x55aaff00L;
109 		if(*p == 0x55aaff00L) behrtmp |= bnk;
110 		*p = 0xffaa0055L;
111 		if(*p != 0xffaa0055L) behrtmp &= ~bnk;
112 		cnt = 256;
113 		while(cnt--) *p++ = 0L;
114 		p = (int *) KA660_CTAG;
115 		cnt =128;
116 		while(cnt--) { *p++ = 0x80000000L; p++; }
117 		bnk <<= 1;
118 	}
119 	*(int *)KA660_BEHR = behrtmp;
120 
121 	mtpr(CCR_DIA|CCR_FLU, KA660_CCR);	/* Flush tags */
122 	mtpr(CCR_ENA, KA660_CCR);	/* Enable cache */
123 }
124 
125 void
126 ka660_memerr()
127 {
128 	printf("Memory err!\n");
129 }
130 
131 int
132 ka660_mchk(addr)
133 	caddr_t addr;
134 {
135 	panic("Machine check");
136 	return 0;
137 }
138 
139 static void
140 ka660_halt()
141 {
142 	asm("halt");
143 }
144 
145 static void
146 ka660_reboot(int arg)
147 {
148 	asm("halt");
149 }
150 
151