Home | History | Annotate | Line # | Download | only in dev
hyper.c revision 1.4
      1 /*	$NetBSD: hyper.c,v 1.4 1998/12/14 20:33:45 is Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1997 Ignatios Souvatzis
      5  * All rights reserved.
      6  *
      7  * Redistribution and use in source and binary forms, with or without
      8  * modification, are permitted provided that the following conditions
      9  * are met:
     10  * 1. Redistributions of source code must retain the above copyright
     11  *    notice, this list of conditions and the following disclaimer.
     12  * 2. Redistributions in binary form must reproduce the above copyright
     13  *    notice, this list of conditions and the following disclaimer in the
     14  *    documentation and/or other materials provided with the distribution.
     15  * 3. All advertising materials mentioning features or use of this software
     16  *    must display the following acknowledgement:
     17  *      This product includes software developed by Ignatios Souvatzis
     18  *      for the NetBSD Project.
     19  * 4. The name of the author may not be used to endorse or promote products
     20  *    derived from this software without specific prior written permission
     21  *
     22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     32  */
     33 
     34 /*
     35  * zbus HyperCom driver
     36  */
     37 
     38 #include <sys/types.h>
     39 
     40 #include <sys/conf.h>
     41 #include <sys/device.h>
     42 #include <sys/systm.h>
     43 #include <sys/param.h>
     44 
     45 #include <machine/bus.h>
     46 #include <machine/conf.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 __P((struct device *, struct cfdata *, void *));
     63 void hyperattach __P((struct device *, struct device *, void *));
     64 int hyperprint __P((void *auxp, const char *));
     65 
     66 struct cfattach hyper_ca = {
     67 	sizeof(struct hyper_softc), hypermatch, hyperattach
     68 };
     69 
     70 int
     71 hypermatch(parent, cfp, auxp)
     72 	struct device *parent;
     73 	struct cfdata *cfp;
     74 	void *auxp;
     75 {
     76 
     77 	struct zbus_args *zap;
     78 
     79 	zap = auxp;
     80 
     81 	if (zap->manid != 5001)
     82 		return (0);
     83 
     84 	if (zap->prodid != 2 && zap->prodid != 3  &&
     85 	    zap->prodid != 6 && zap->prodid != 7)
     86 		return (0);
     87 
     88 	return (1);
     89 }
     90 
     91 struct hyper_devs {
     92 	char *name;
     93 	unsigned off;
     94 	int arg;
     95 };
     96 
     97 struct hyper_devs hyper3devs[] = {
     98 	{ "com", 0x00, 115200 * 16 * 4 },
     99 	{ "com", 0x08, 115200 * 16 * 4 },
    100 	/* not yet { "lpt", 0x40, 0 }, */
    101 	{ 0 }
    102 };
    103 
    104 struct hyper_devs hyper4devs[] = {
    105 	{ "com", 0x00, 115200 * 16 * 4 },
    106 	{ "com", 0x08, 115200 * 16 * 4 },
    107 	{ "com", 0x10, 115200 * 16 * 4 },
    108 	{ "com", 0x18, 115200 * 16 * 4 },
    109 	{ 0 }
    110 };
    111 
    112 struct hyper_devs hyper3Pdevs[] = {
    113 	{ "com", 0x0400, 115200 * 16 * 4 },
    114 	{ "com", 0x0000, 115200 * 16 * 4 },
    115 #ifdef notyet
    116 	{ "lpt", 0x0800, 0 },
    117 #endif
    118 	{ 0 }
    119 };
    120 
    121 struct hyper_devs hyper4Pdevs[] = {
    122 	{ "com", 0x0400, 115200 * 16 * 4 },
    123 	{ "com", 0x0000, 115200 * 16 * 4 },
    124 	{ "com", 0x0c00, 115200 * 16 * 4 },
    125 	{ "com", 0x1000, 115200 * 16 * 4 },
    126 #ifdef notyet
    127 	{ "lpt", 0x0800, 0 },
    128 	{ "lpt", 0x1400, 0 },
    129 #endif
    130 	{ 0 }
    131 };
    132 
    133 void
    134 hyperattach(parent, self, auxp)
    135 	struct device *parent, *self;
    136 	void *auxp;
    137 {
    138 	struct hyper_softc *hprsc;
    139 	struct hyper_devs  *hprsd;
    140 	struct zbus_args *zap;
    141 	struct supio_attach_args supa;
    142 
    143 	hprsc = (struct hyper_softc *)self;
    144 	zap = auxp;
    145 
    146 	if (zap->prodid == 2) {
    147 		if (parent)
    148 			printf(": HyperCom 4\n");
    149 		hprsc->sc_bst.base = (u_long)zap->va + 1;
    150 		hprsc->sc_bst.stride = 2;
    151 		hprsd = hyper4devs;
    152 	} else if (zap->prodid == 3) {
    153 		if (parent)
    154 			printf(": HyperCom 3Z\n");
    155 		hprsc->sc_bst.base = (u_long)zap->va + 0;
    156 		hprsc->sc_bst.stride = 2;
    157 		hprsd = hyper3devs;
    158 	} else if (zap->prodid == 6) {
    159 		if (parent)
    160 			printf(": HyperCom 4+\n");
    161 		hprsc->sc_bst.base = (u_long)zap->va + 0x8000;
    162 		hprsc->sc_bst.stride = 2;
    163 		hprsd = hyper4Pdevs;
    164 	} else /* if (zap->prodid == 7) */ {
    165 		if (parent)
    166 			printf(": HyperCom 3+\n");
    167 		hprsc->sc_bst.base = (u_long)zap->va + 0x8000;
    168 		hprsc->sc_bst.stride = 2;
    169 		hprsd = hyper3Pdevs;
    170 	}
    171 
    172 	supa.supio_iot = &hprsc->sc_bst;
    173 	supa.supio_ipl = 6;
    174 
    175 	while (hprsd->name) {
    176 		supa.supio_name = hprsd->name;
    177 		supa.supio_iobase = hprsd->off;
    178 		supa.supio_arg = hprsd->arg;
    179 		config_found(self, &supa, hyperprint); /* XXX */
    180 		++hprsd;
    181 	}
    182 }
    183 
    184 int
    185 hyperprint(auxp, pnp)
    186 	void *auxp;
    187 	const char *pnp;
    188 {
    189 	struct supio_attach_args *supa;
    190 	supa = auxp;
    191 
    192 	if (pnp == NULL)
    193 		return(QUIET);
    194 
    195 	printf("%s at %s port 0x%02x",
    196 	    supa->supio_name, pnp, supa->supio_iobase);
    197 
    198 	return(UNCONF);
    199 }
    200