1 /* $NetBSD: hyper.c,v 1.20 2010/02/02 19:03:31 phx 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 * 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29 * POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32 #include <sys/cdefs.h> 33 __KERNEL_RCSID(0, "$NetBSD: hyper.c,v 1.20 2010/02/02 19:03:31 phx Exp $"); 34 35 /* 36 * zbus HyperCom driver 37 */ 38 39 #include <sys/types.h> 40 41 #include <sys/device.h> 42 #include <sys/conf.h> 43 #include <sys/systm.h> 44 #include <sys/param.h> 45 46 #include <machine/bus.h> 47 48 #include <amiga/include/cpu.h> 49 50 #include <amiga/amiga/device.h> 51 #include <amiga/amiga/drcustom.h> 52 53 #include <amiga/dev/supio.h> 54 #include <amiga/dev/zbusvar.h> 55 56 57 struct hyper_softc { 58 struct device sc_dev; 59 struct bus_space_tag sc_bst; 60 }; 61 62 int hypermatch(struct device *, struct cfdata *, void *); 63 void hyperattach(struct device *, struct device *, void *); 64 int hyperprint(void *auxp, const char *); 65 66 CFATTACH_DECL(hyper, sizeof(struct hyper_softc), 67 hypermatch, hyperattach, NULL, NULL); 68 69 struct hyper_prods { 70 const char *name; 71 unsigned baseoff; 72 } hyperproducts [] = { 73 {0, 0}, /* 0: not used */ 74 {0, 0}, /* 1: handled by aster driver */ 75 {"4", 1}, /* 2 */ 76 {"Z3", 0}, /* 3 */ 77 {0, 0}, /* 4: not used */ 78 {0, 0}, /* 5: not used */ 79 {"4+", 0x8000}, /* 6 */ 80 {"3+", 0x8000} /* 7 */ 81 }; 82 83 int 84 hypermatch(struct device *parent, struct cfdata *cfp, void *auxp) 85 { 86 87 struct zbus_args *zap; 88 89 zap = auxp; 90 91 if (zap->manid != 5001) 92 return (0); 93 94 if (zap->prodid < sizeof(hyperproducts)/sizeof(*hyperproducts) && 95 hyperproducts[zap->prodid].name) 96 97 return (1); 98 99 return (0); 100 } 101 102 #define HYPERPROD3 (1<<3) 103 #define HYPERPROD4 (1<<2) 104 #define HYPERPROD4PLUS (1<<6) 105 #define HYPERPROD3PLUS (1<<7) 106 107 struct hyper_devs { 108 const char *name; 109 unsigned off; 110 int arg; 111 u_int32_t productmask; /* XXX only prodid 0..31 */ 112 } hyperdevices[] = { 113 { "com", 0x00, 115200 * 16 * 4, HYPERPROD3 | HYPERPROD4 }, 114 { "com", 0x08, 115200 * 16 * 4, HYPERPROD3 | HYPERPROD4 }, 115 { "com", 0x10, 115200 * 16 * 4, HYPERPROD4 }, 116 { "com", 0x18, 115200 * 16 * 4, HYPERPROD4 }, 117 /* not yet { "lpt", 0x40, 0, HYPERPROD3 }, */ 118 { "com", 0x0400, 115200 * 16 * 4, HYPERPROD3PLUS | HYPERPROD4PLUS }, 119 { "com", 0x0000, 115200 * 16 * 4, HYPERPROD3PLUS | HYPERPROD4PLUS }, 120 { "com", 0x0c00, 115200 * 16 * 4, HYPERPROD4PLUS }, 121 { "com", 0x1000, 115200 * 16 * 4, HYPERPROD4PLUS }, 122 { "lpt", 0x0800, 0, HYPERPROD3PLUS | HYPERPROD4PLUS }, 123 { "lpt", 0x1400, 0, HYPERPROD4PLUS }, 124 }; 125 126 void 127 hyperattach(struct device *parent, struct device *self, void *auxp) 128 { 129 struct hyper_softc *hprsc; 130 struct hyper_devs *hprsd; 131 struct zbus_args *zap; 132 struct supio_attach_args supa; 133 struct hyper_prods *hprpp; 134 135 hprsc = (struct hyper_softc *)self; 136 zap = auxp; 137 hprpp = &hyperproducts[zap->prodid]; 138 139 if (parent) 140 printf(": Hypercom %s\n", hprpp->name); 141 142 hprsc->sc_bst.base = (u_long)zap->va + hprpp->baseoff; 143 hprsc->sc_bst.absm = &amiga_bus_stride_4; 144 145 supa.supio_iot = &hprsc->sc_bst; 146 supa.supio_ipl = 6; 147 148 hprsd = hyperdevices; 149 150 while (hprsd->name) { 151 if (hprsd->productmask & (1 << zap->prodid)) { 152 supa.supio_name = hprsd->name; 153 supa.supio_iobase = hprsd->off; 154 supa.supio_arg = hprsd->arg; 155 config_found(self, &supa, hyperprint); /* XXX */ 156 } 157 ++hprsd; 158 } 159 } 160 161 int 162 hyperprint(void *auxp, const char *pnp) 163 { 164 struct supio_attach_args *supa; 165 supa = auxp; 166 167 if (pnp == NULL) 168 return(QUIET); 169 170 aprint_normal("%s at %s port 0x%02x", 171 supa->supio_name, pnp, supa->supio_iobase); 172 173 return(UNCONF); 174 } 175