1 /* $NetBSD: hyper.c,v 1.15 2002/10/02 04:55:51 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.15 2002/10/02 04:55:51 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 CFATTACH_DECL(hyper, sizeof(struct hyper_softc), 74 hypermatch, hyperattach, NULL, NULL); 75 76 struct hyper_prods { 77 char *name; 78 unsigned baseoff; 79 } hyperproducts [] = { 80 {0, 0}, /* 0: not used */ 81 {0, 0}, /* 1: handled by aster driver */ 82 {"4", 1}, /* 2 */ 83 {"Z3", 0}, /* 3 */ 84 {0, 0}, /* 4: not used */ 85 {0, 0}, /* 5: not used */ 86 {"4+", 0x8000}, /* 6 */ 87 {"3+", 0x8000} /* 7 */ 88 }; 89 90 int 91 hypermatch(struct device *parent, struct cfdata *cfp, void *auxp) 92 { 93 94 struct zbus_args *zap; 95 96 zap = auxp; 97 98 if (zap->manid != 5001) 99 return (0); 100 101 if (zap->prodid < sizeof(hyperproducts)/sizeof(*hyperproducts) && 102 hyperproducts[zap->prodid].name) 103 104 return (1); 105 106 return (0); 107 } 108 109 #define HYPERPROD3 (1<<3) 110 #define HYPERPROD4 (1<<2) 111 #define HYPERPROD4PLUS (1<<6) 112 #define HYPERPROD3PLUS (1<<7) 113 114 struct hyper_devs { 115 char *name; 116 unsigned off; 117 int arg; 118 u_int32_t productmask; /* XXX only prodid 0..31 */ 119 } hyperdevices[] = { 120 { "com", 0x00, 115200 * 16 * 4, HYPERPROD3 | HYPERPROD4 }, 121 { "com", 0x08, 115200 * 16 * 4, HYPERPROD3 | HYPERPROD4 }, 122 { "com", 0x10, 115200 * 16 * 4, HYPERPROD4 }, 123 { "com", 0x18, 115200 * 16 * 4, HYPERPROD4 }, 124 /* not yet { "lpt", 0x40, 0, HYPERPROD3 }, */ 125 { "com", 0x0400, 115200 * 16 * 4, HYPERPROD3PLUS | HYPERPROD4PLUS }, 126 { "com", 0x0000, 115200 * 16 * 4, HYPERPROD3PLUS | HYPERPROD4PLUS }, 127 { "com", 0x0c00, 115200 * 16 * 4, HYPERPROD4PLUS }, 128 { "com", 0x1000, 115200 * 16 * 4, HYPERPROD4PLUS }, 129 { "lpt", 0x0800, 0, HYPERPROD3PLUS | HYPERPROD4PLUS }, 130 { "lpt", 0x1400, 0, HYPERPROD4PLUS }, 131 }; 132 133 void 134 hyperattach(struct device *parent, struct device *self, void *auxp) 135 { 136 struct hyper_softc *hprsc; 137 struct hyper_devs *hprsd; 138 struct zbus_args *zap; 139 struct supio_attach_args supa; 140 struct hyper_prods *hprpp; 141 142 hprsc = (struct hyper_softc *)self; 143 zap = auxp; 144 hprpp = &hyperproducts[zap->prodid]; 145 146 if (parent) 147 printf(": Hypercom %s\n", hprpp->name); 148 149 hprsc->sc_bst.base = (u_long)zap->va + hprpp->baseoff; 150 hprsc->sc_bst.absm = &amiga_bus_stride_4; 151 152 supa.supio_iot = &hprsc->sc_bst; 153 supa.supio_ipl = 6; 154 155 hprsd = hyperdevices; 156 157 while (hprsd->name) { 158 if (hprsd->productmask & (1 << zap->prodid)) { 159 supa.supio_name = hprsd->name; 160 supa.supio_iobase = hprsd->off; 161 supa.supio_arg = hprsd->arg; 162 config_found(self, &supa, hyperprint); /* XXX */ 163 } 164 ++hprsd; 165 } 166 } 167 168 int 169 hyperprint(void *auxp, const char *pnp) 170 { 171 struct supio_attach_args *supa; 172 supa = auxp; 173 174 if (pnp == NULL) 175 return(QUIET); 176 177 printf("%s at %s port 0x%02x", 178 supa->supio_name, pnp, supa->supio_iobase); 179 180 return(UNCONF); 181 } 182