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