Home | History | Annotate | Line # | Download | only in dev
hyper.c revision 1.5
      1 /*	$NetBSD: hyper.c,v 1.5 1998/12/26 22:22:58 is Exp $ */
      2 
      3 /*
      4  * Copyright (c) 1997, 1998 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 struct hyper_prods {
     71 	char *name;
     72 	unsigned baseoff;
     73 } hyperproducts [] = {
     74 	{0, 0},			/* 0: not used */
     75 	{0, 0},			/* 1: handled by aster driver */
     76 	{"4", 1},		/* 2 */
     77 	{"Z3", 0},		/* 3 */
     78 	{0, 0},			/* 4: not used */
     79 	{0, 0},			/* 5: not used */
     80 	{"4+", 0x8000},		/* 6 */
     81 	{"3+", 0x8000}		/* 7 */
     82 };
     83 
     84 #define HYPERPROD3	(1<<3)
     85 #define HYPERPROD4	(1<<2)
     86 #define HYPERPROD4PLUS	(1<<6)
     87 #define HYPERPROD3PLUS	(1<<7)
     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 (prodid < sizeof(hyperproducts)/sizeof(*hyperproducts) &&
    104 	    hyperproducts[prodid].name)
    105 
    106 		return (1);
    107 
    108 	return (0);
    109 }
    110 
    111 struct hyper_devs {
    112 	char *name;
    113 	unsigned off;
    114 	int arg;
    115 	u_int32_t productmask;	/* XXX only prodid 0..31 */
    116 } hyperdevices[] = {
    117 	{ "com", 0x00, 115200 * 16 * 4, HYPERPROD3 | HYPERPROD4 },
    118 	{ "com", 0x08, 115200 * 16 * 4, HYPERPROD3 | HYPERPROD4 },
    119 	{ "com", 0x10, 115200 * 16 * 4, HYPERPROD4 },
    120 	{ "com", 0x18, 115200 * 16 * 4, HYPERPROD4 },
    121 	/* not yet { "lpt", 0x40, 0, HYPERPROD3 }, */
    122 	{ "com", 0x0400, 115200 * 16 * 4, HYPERPROD3PLUS | HYPERPROD4PLUS },
    123 	{ "com", 0x0000, 115200 * 16 * 4, HYPERPROD3PLUS | HYPERPROD4PLUS },
    124 	{ "com", 0x0c00, 115200 * 16 * 4, HYPERPROD4PLUS },
    125 	{ "com", 0x1000, 115200 * 16 * 4, HYPERPROD4PLUS },
    126 #ifdef notyet
    127 	{ "lpt", 0x0800, 0, HYPERPROD3PLUS | HYPERPROD4PLUS },
    128 	{ "lpt", 0x1400, 0, HYPERPROD4PLUS },
    129 #endif
    130 };
    131 
    132 void
    133 hyperattach(parent, self, auxp)
    134 	struct device *parent, *self;
    135 	void *auxp;
    136 {
    137 	struct hyper_softc *hprsc;
    138 	struct hyper_devs  *hprsd;
    139 	struct zbus_args *zap;
    140 	struct supio_attach_args supa;
    141 	struct hyper_products *hprpp;
    142 
    143 	hprsc = (struct hyper_softc *)self;
    144 	zap = auxp;
    145 	hprpp = &hyper_products[zap->prodid];
    146 
    147 	if (parent)
    148 		printf(": Hypercom %s\n", hprpp->name);
    149 
    150 	hprsc->sc_bst.base = (u_long)zap->va + hprpp->baseoff;
    151 	hprsc->sc_bst.stride = 2;
    152 
    153 	supa.supio_iot = &hprsc->sc_bst;
    154 	supa.supio_ipl = 6;
    155 
    156 	while (hprsd->name) {
    157 		if (hprsd->productmask && (1 << zap->prodid)) {
    158 			supa.supio_name = hprsd->name;
    159 			supa.supio_iobase = hprsd->off;
    160 			supa.supio_arg = hprsd->arg;
    161 			config_found(self, &supa, hyperprint); /* XXX */
    162 		}
    163 		++hprsd;
    164 	}
    165 }
    166 
    167 int
    168 hyperprint(auxp, pnp)
    169 	void *auxp;
    170 	const char *pnp;
    171 {
    172 	struct supio_attach_args *supa;
    173 	supa = auxp;
    174 
    175 	if (pnp == NULL)
    176 		return(QUIET);
    177 
    178 	printf("%s at %s port 0x%02x",
    179 	    supa->supio_name, pnp, supa->supio_iobase);
    180 
    181 	return(UNCONF);
    182 }
    183