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