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