Home | History | Annotate | Line # | Download | only in dev
hyper.c revision 1.7
      1 /*	$NetBSD: hyper.c,v 1.7 1999/02/16 22:46:57 is Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 1999 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 #ifdef notyet
    132 	{ "lpt", 0x0800, 0, HYPERPROD3PLUS | HYPERPROD4PLUS },
    133 	{ "lpt", 0x1400, 0, HYPERPROD4PLUS },
    134 #endif
    135 };
    136 
    137 void
    138 hyperattach(parent, self, auxp)
    139 	struct device *parent, *self;
    140 	void *auxp;
    141 {
    142 	struct hyper_softc *hprsc;
    143 	struct hyper_devs  *hprsd;
    144 	struct zbus_args *zap;
    145 	struct supio_attach_args supa;
    146 	struct hyper_prods *hprpp;
    147 
    148 	hprsc = (struct hyper_softc *)self;
    149 	zap = auxp;
    150 	hprpp = &hyperproducts[zap->prodid];
    151 
    152 	if (parent)
    153 		printf(": Hypercom %s\n", hprpp->name);
    154 
    155 	hprsc->sc_bst.base = (u_long)zap->va + hprpp->baseoff;
    156 	hprsc->sc_bst.stride = 2;
    157 
    158 	supa.supio_iot = &hprsc->sc_bst;
    159 	supa.supio_ipl = 6;
    160 
    161 	hprsd = hyperdevices;
    162 
    163 	while (hprsd->name) {
    164 		if (hprsd->productmask & (1 << zap->prodid)) {
    165 			supa.supio_name = hprsd->name;
    166 			supa.supio_iobase = hprsd->off;
    167 			supa.supio_arg = hprsd->arg;
    168 			config_found(self, &supa, hyperprint); /* XXX */
    169 		}
    170 		++hprsd;
    171 	}
    172 }
    173 
    174 int
    175 hyperprint(auxp, pnp)
    176 	void *auxp;
    177 	const char *pnp;
    178 {
    179 	struct supio_attach_args *supa;
    180 	supa = auxp;
    181 
    182 	if (pnp == NULL)
    183 		return(QUIET);
    184 
    185 	printf("%s at %s port 0x%02x",
    186 	    supa->supio_name, pnp, supa->supio_iobase);
    187 
    188 	return(UNCONF);
    189 }
    190