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