1 /* $NetBSD: ka660.c,v 1.4 2002/09/28 09:53:08 ragge 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_cache_enable(void); 66 67 struct vs_cpu *ka660_cpu; 68 69 /* 70 * Declaration of 660-specific calls. 71 */ 72 struct cpu_dep ka660_calls = { 73 ka660_cache_enable, 74 ka660_mchk, 75 ka660_memerr, 76 ka660_conf, 77 generic_clkread, 78 generic_clkwrite, 79 6, /* ~VUPS */ 80 2, /* SCB pages */ 81 generic_halt, 82 generic_reboot, 83 }; 84 85 86 void 87 ka660_conf() 88 { 89 printf("cpu0: KA660, microcode Rev. %d\n", vax_cpudata & 0377); 90 91 cpmbx = (struct cpmbx *)vax_map_physmem(0x20140400, 1); 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