1 /* $NetBSD: cmi.c,v 1.3 2000/06/04 18:02:35 ragge Exp $ */ 2 /* 3 * Copyright (c) 1999 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/device.h> 35 #include <sys/systm.h> 36 37 #include <machine/bus.h> 38 #include <machine/nexus.h> 39 #include <machine/cpu.h> 40 #include <machine/sid.h> 41 #include <machine/ka750.h> 42 43 static int cmi_print(void *, const char *); 44 static int cmi_match(struct device *, struct cfdata *, void *); 45 static void cmi_attach(struct device *, struct device *, void*); 46 47 struct cfattach cmi_ca = { 48 sizeof(struct device), cmi_match, cmi_attach 49 }; 50 51 int 52 cmi_print(void *aux, const char *name) 53 { 54 struct sbi_attach_args *sa = (struct sbi_attach_args *)aux; 55 56 if (name) 57 printf("unknown device 0x%x at %s", sa->sa_type, name); 58 59 printf(" tr%d", sa->sa_nexnum); 60 return (UNCONF); 61 } 62 63 64 int 65 cmi_match(struct device *parent, struct cfdata *cf, void *aux) 66 { 67 if (vax_bustype == VAX_CMIBUS) 68 return 1; 69 return 0; 70 } 71 72 void 73 cmi_attach(struct device *parent, struct device *self, void *aux) 74 { 75 struct sbi_attach_args sa; 76 77 printf("\n"); 78 /* 79 * Probe for memory, can be in the first 4 slots. 80 */ 81 #define NEXPAGES (sizeof(struct nexus) / VAX_NBPG) 82 for (sa.sa_nexnum = 0; sa.sa_nexnum < 4; sa.sa_nexnum++) { 83 sa.sa_ioh = vax_map_physmem(NEX750 + 84 sizeof(struct nexus) * sa.sa_nexnum, NEXPAGES); 85 if (badaddr((caddr_t)sa.sa_ioh, 4)) { 86 vax_unmap_physmem((vaddr_t)sa.sa_ioh, NEXPAGES); 87 } else { 88 sa.sa_type = NEX_MEM16; 89 config_found(self, (void*)&sa, cmi_print); 90 } 91 } 92 93 /* 94 * Probe for mba's, can be in slot 4 - 7. 95 */ 96 for (sa.sa_nexnum = 4; sa.sa_nexnum < 7; sa.sa_nexnum++) { 97 sa.sa_ioh = vax_map_physmem(NEX750 + 98 sizeof(struct nexus) * sa.sa_nexnum, NEXPAGES); 99 if (badaddr((caddr_t)sa.sa_ioh, 4)) { 100 vax_unmap_physmem((vaddr_t)sa.sa_ioh, NEXPAGES); 101 } else { 102 sa.sa_type = NEX_MBA; 103 config_found(self, (void*)&sa, cmi_print); 104 } 105 } 106 107 /* 108 * There are always one generic UBA, and maybe an optional. 109 */ 110 sa.sa_nexnum = 8; 111 sa.sa_ioh = vax_map_physmem(NEX750 + 112 sizeof(struct nexus) * sa.sa_nexnum, NEXPAGES); 113 sa.sa_type = NEX_UBA0; 114 config_found(self, (void*)&sa, cmi_print); 115 116 sa.sa_nexnum = 9; 117 sa.sa_ioh = vax_map_physmem(NEX750 + 118 sizeof(struct nexus) * sa.sa_nexnum, NEXPAGES); 119 sa.sa_type = NEX_UBA1; 120 if (badaddr((caddr_t)sa.sa_ioh, 4)) 121 vax_unmap_physmem((vaddr_t)sa.sa_ioh, NEXPAGES); 122 else 123 config_found(self, (void*)&sa, cmi_print); 124 } 125