1 /* $NetBSD: intio.c,v 1.7 2001/11/17 23:33:22 gmcgarry Exp $ */ 2 3 /*- 4 * Copyright (c) 1996, 1998, 2001 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Jason R. Thorpe. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 /* 40 * Autoconfiguration support for hp300 internal i/o space. 41 */ 42 43 #include <sys/param.h> 44 #include <sys/systm.h> 45 #include <sys/device.h> 46 47 #include <machine/hp300spu.h> 48 49 #include <hp300/dev/intioreg.h> 50 #include <hp300/dev/intiovar.h> 51 52 int intiomatch(struct device *, struct cfdata *, void *); 53 void intioattach(struct device *, struct device *, void *); 54 int intioprint(void *, const char *); 55 56 const struct cfattach intio_ca = { 57 sizeof(struct device), intiomatch, intioattach 58 }; 59 60 #if defined(HP320) || defined(HP330) || defined(HP340) || defined(HP345) || \ 61 defined(HP350) || defined(HP360) || defined(HP370) || defined(HP375) || \ 62 defined(HP380) || defined(HP385) 63 const struct intio_builtins intio_3xx_builtins[] = { 64 { "rtc ", 0x020000, -1}, 65 { "hil ", 0x028000, 1}, 66 { "fb ", 0x160000, -1}, 67 }; 68 #define nintio_3xx_builtins \ 69 (sizeof(intio_3xx_builtins) / sizeof(intio_3xx_builtins[0])) 70 #endif 71 72 #if defined(HP400) || defined(HP425) || defined(HP433) 73 const struct intio_builtins intio_4xx_builtins[] = { 74 { "rtc ", 0x020000, -1}, 75 { "frodo ", 0x01c000, 5}, 76 { "hil ", 0x028000, 1}, 77 { "fb ", 0x160000, -1}, 78 }; 79 #define nintio_4xx_builtins \ 80 (sizeof(intio_4xx_builtins) / sizeof(intio_4xx_builtins[0])) 81 #endif 82 83 static int intio_matched = 0; 84 85 int 86 intiomatch(parent, match, aux) 87 struct device *parent; 88 struct cfdata *match; 89 void *aux; 90 { 91 /* Allow only one instance. */ 92 if (intio_matched) 93 return (0); 94 95 intio_matched = 1; 96 return (1); 97 } 98 99 void 100 intioattach(parent, self, aux) 101 struct device *parent, *self; 102 void *aux; 103 { 104 struct intio_attach_args ia; 105 const struct intio_builtins *ib; 106 int ndevs; 107 int i; 108 109 printf("\n"); 110 111 switch (machineid) { 112 #if defined(HP320) || defined(HP330) || defined(HP340) || defined(HP345) || \ 113 defined(HP350) || defined(HP360) || defined(HP370) || defined(HP375) || \ 114 defined(HP380) || defined(HP385) 115 case HP_320: 116 case HP_330: 117 case HP_340: 118 case HP_345: 119 case HP_350: 120 case HP_360: 121 case HP_370: 122 case HP_375: 123 case HP_380: 124 case HP_385: 125 ib = intio_3xx_builtins; 126 ndevs = nintio_3xx_builtins; 127 break; 128 #endif 129 #if defined(HP400) || defined(HP425) || defined(HP433) 130 case HP_400: 131 case HP_425: 132 case HP_433: 133 ib = intio_4xx_builtins; 134 ndevs = nintio_4xx_builtins; 135 break; 136 #endif 137 default: 138 return; 139 } 140 141 memset(&ia, 0, sizeof(ia)); 142 143 for (i=0; i<ndevs; i++) { 144 strncpy(ia.ia_modname, ib[i].ib_modname, INTIO_MOD_LEN); 145 ia.ia_modname[INTIO_MOD_LEN] = '\0'; 146 ia.ia_bst = HP300_BUS_SPACE_INTIO; 147 ia.ia_iobase = ib[i].ib_offset; 148 ia.ia_addr = (bus_addr_t)(intiobase + ib[i].ib_offset); 149 ia.ia_ipl = ib[i].ib_ipl; 150 config_found(self, &ia, intioprint); 151 } 152 } 153 154 int 155 intioprint(aux, pnp) 156 void *aux; 157 const char *pnp; 158 { 159 struct intio_attach_args *ia = aux; 160 161 if (pnp) 162 printf("%s at %s", ia->ia_modname, pnp); 163 if (ia->ia_addr != 0) { 164 printf(" addr 0x%lx", INTIOBASE + ia->ia_iobase); 165 if (ia->ia_ipl != -1) 166 printf(" ipl %d", ia->ia_ipl); 167 } 168 return (UNCONF); 169 } 170