1 /* $NetBSD: hyper.c,v 1.14 2002/09/27 20:30:05 thorpej Exp $ */ 2 3 /*- 4 * Copyright (c) 1997,1998 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Ignatios Souvatzis. 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 #include <sys/cdefs.h> 40 __KERNEL_RCSID(0, "$NetBSD: hyper.c,v 1.14 2002/09/27 20:30:05 thorpej Exp $"); 41 42 /* 43 * zbus HyperCom driver 44 */ 45 46 #include <sys/types.h> 47 48 #include <sys/conf.h> 49 #include <sys/device.h> 50 #include <sys/systm.h> 51 #include <sys/param.h> 52 53 #include <machine/bus.h> 54 55 #include <amiga/include/cpu.h> 56 57 #include <amiga/amiga/device.h> 58 #include <amiga/amiga/drcustom.h> 59 60 #include <amiga/dev/supio.h> 61 #include <amiga/dev/zbusvar.h> 62 63 64 struct hyper_softc { 65 struct device sc_dev; 66 struct bus_space_tag sc_bst; 67 }; 68 69 int hypermatch(struct device *, struct cfdata *, void *); 70 void hyperattach(struct device *, struct device *, void *); 71 int hyperprint(void *auxp, const char *); 72 73 const struct cfattach hyper_ca = { 74 sizeof(struct hyper_softc), hypermatch, hyperattach 75 }; 76 77 struct hyper_prods { 78 char *name; 79 unsigned baseoff; 80 } hyperproducts [] = { 81 {0, 0}, /* 0: not used */ 82 {0, 0}, /* 1: handled by aster driver */ 83 {"4", 1}, /* 2 */ 84 {"Z3", 0}, /* 3 */ 85 {0, 0}, /* 4: not used */ 86 {0, 0}, /* 5: not used */ 87 {"4+", 0x8000}, /* 6 */ 88 {"3+", 0x8000} /* 7 */ 89 }; 90 91 int 92 hypermatch(struct device *parent, struct cfdata *cfp, void *auxp) 93 { 94 95 struct zbus_args *zap; 96 97 zap = auxp; 98 99 if (zap->manid != 5001) 100 return (0); 101 102 if (zap->prodid < sizeof(hyperproducts)/sizeof(*hyperproducts) && 103 hyperproducts[zap->prodid].name) 104 105 return (1); 106 107 return (0); 108 } 109 110 #define HYPERPROD3 (1<<3) 111 #define HYPERPROD4 (1<<2) 112 #define HYPERPROD4PLUS (1<<6) 113 #define HYPERPROD3PLUS (1<<7) 114 115 struct hyper_devs { 116 char *name; 117 unsigned off; 118 int arg; 119 u_int32_t productmask; /* XXX only prodid 0..31 */ 120 } hyperdevices[] = { 121 { "com", 0x00, 115200 * 16 * 4, HYPERPROD3 | HYPERPROD4 }, 122 { "com", 0x08, 115200 * 16 * 4, HYPERPROD3 | HYPERPROD4 }, 123 { "com", 0x10, 115200 * 16 * 4, HYPERPROD4 }, 124 { "com", 0x18, 115200 * 16 * 4, HYPERPROD4 }, 125 /* not yet { "lpt", 0x40, 0, HYPERPROD3 }, */ 126 { "com", 0x0400, 115200 * 16 * 4, HYPERPROD3PLUS | HYPERPROD4PLUS }, 127 { "com", 0x0000, 115200 * 16 * 4, HYPERPROD3PLUS | HYPERPROD4PLUS }, 128 { "com", 0x0c00, 115200 * 16 * 4, HYPERPROD4PLUS }, 129 { "com", 0x1000, 115200 * 16 * 4, HYPERPROD4PLUS }, 130 { "lpt", 0x0800, 0, HYPERPROD3PLUS | HYPERPROD4PLUS }, 131 { "lpt", 0x1400, 0, HYPERPROD4PLUS }, 132 }; 133 134 void 135 hyperattach(struct device *parent, struct device *self, void *auxp) 136 { 137 struct hyper_softc *hprsc; 138 struct hyper_devs *hprsd; 139 struct zbus_args *zap; 140 struct supio_attach_args supa; 141 struct hyper_prods *hprpp; 142 143 hprsc = (struct hyper_softc *)self; 144 zap = auxp; 145 hprpp = &hyperproducts[zap->prodid]; 146 147 if (parent) 148 printf(": Hypercom %s\n", hprpp->name); 149 150 hprsc->sc_bst.base = (u_long)zap->va + hprpp->baseoff; 151 hprsc->sc_bst.absm = &amiga_bus_stride_4; 152 153 supa.supio_iot = &hprsc->sc_bst; 154 supa.supio_ipl = 6; 155 156 hprsd = hyperdevices; 157 158 while (hprsd->name) { 159 if (hprsd->productmask & (1 << zap->prodid)) { 160 supa.supio_name = hprsd->name; 161 supa.supio_iobase = hprsd->off; 162 supa.supio_arg = hprsd->arg; 163 config_found(self, &supa, hyperprint); /* XXX */ 164 } 165 ++hprsd; 166 } 167 } 168 169 int 170 hyperprint(void *auxp, const char *pnp) 171 { 172 struct supio_attach_args *supa; 173 supa = auxp; 174 175 if (pnp == NULL) 176 return(QUIET); 177 178 printf("%s at %s port 0x%02x", 179 supa->supio_name, pnp, supa->supio_iobase); 180 181 return(UNCONF); 182 } 183