Home | History | Annotate | Line # | Download | only in dev
ioblix_zbus.c revision 1.6.8.1
      1  1.6.8.1  gehenna /*	$NetBSD: ioblix_zbus.c,v 1.6.8.1 2002/05/16 16:58:58 gehenna Exp $ */
      2      1.2       is 
      3      1.1       is /*-
      4      1.1       is  * Copyright (c) 2000 The NetBSD Foundation, Inc.
      5      1.1       is  * All rights reserved.
      6      1.1       is  *
      7      1.1       is  * This code is derived from software contributed to The NetBSD Foundation
      8      1.1       is  * by Ignatios Souvatzis.
      9      1.1       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.1       is  *        This product includes software developed by the NetBSD
     21      1.1       is  *        Foundation, Inc. and its contributors.
     22      1.1       is  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23      1.1       is  *    contributors may be used to endorse or promote products derived
     24      1.1       is  *    from this software without specific prior written permission.
     25      1.1       is  *
     26      1.1       is  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27      1.1       is  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28      1.1       is  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29      1.1       is  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30      1.1       is  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31      1.1       is  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32      1.1       is  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33      1.1       is  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34      1.1       is  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35      1.1       is  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36      1.1       is  * POSSIBILITY OF SUCH DAMAGE.
     37      1.1       is  */
     38      1.6  aymeric 
     39      1.6  aymeric #include <sys/cdefs.h>
     40  1.6.8.1  gehenna __KERNEL_RCSID(0, "$NetBSD: ioblix_zbus.c,v 1.6.8.1 2002/05/16 16:58:58 gehenna Exp $");
     41      1.1       is 
     42      1.1       is /* IOBlix Zorro driver */
     43      1.1       is /* XXX to be done: we need to probe the com clock speed! */
     44      1.1       is 
     45      1.1       is #include <sys/types.h>
     46      1.1       is 
     47      1.1       is #include <sys/conf.h>
     48      1.1       is #include <sys/device.h>
     49      1.1       is #include <sys/systm.h>
     50      1.1       is #include <sys/param.h>
     51      1.1       is 
     52      1.1       is #include <machine/bus.h>
     53      1.1       is 
     54      1.1       is #include <amiga/include/cpu.h>
     55      1.1       is 
     56      1.1       is #include <amiga/amiga/device.h>
     57      1.1       is #include <amiga/amiga/drcustom.h>
     58      1.1       is 
     59      1.1       is #include <amiga/dev/supio.h>
     60      1.1       is #include <amiga/dev/zbusvar.h>
     61      1.1       is 
     62      1.1       is 
     63      1.1       is struct iobz_softc {
     64      1.1       is 	struct device sc_dev;
     65      1.1       is 	struct bus_space_tag sc_bst;
     66      1.1       is };
     67      1.1       is 
     68      1.4  aymeric int iobzmatch(struct device *, struct cfdata *, void *);
     69      1.4  aymeric void iobzattach(struct device *, struct device *, void *);
     70      1.4  aymeric int iobzprint(void *auxp, const char *);
     71      1.5       is void iobz_shutdown(void *);
     72      1.1       is 
     73      1.1       is struct cfattach iobl_zbus_ca = {
     74      1.1       is 	sizeof(struct iobz_softc), iobzmatch, iobzattach
     75      1.1       is };
     76      1.1       is 
     77      1.1       is int
     78      1.4  aymeric iobzmatch(struct device *parent, struct cfdata *cfp, void *auxp)
     79      1.1       is {
     80      1.1       is 
     81      1.1       is 	struct zbus_args *zap;
     82      1.1       is 
     83      1.1       is 	zap = auxp;
     84      1.1       is 
     85      1.1       is 	if (zap->manid != 4711)
     86      1.1       is 		return (0);
     87      1.1       is 
     88      1.1       is 	if (zap->prodid != 1)
     89      1.1       is 		return (0);
     90      1.1       is 
     91      1.1       is 	return (1);
     92      1.1       is }
     93      1.1       is 
     94      1.1       is struct iobz_devs {
     95      1.1       is 	char *name;
     96      1.1       is 	unsigned off;
     97      1.1       is 	int arg;
     98      1.1       is } iobzdevices[] = {
     99      1.3       is 	{ "com", 0x100, 24000000 },	/* XXX see below */
    100      1.1       is 	{ "com", 0x108, 24000000 },
    101      1.1       is 	{ "com", 0x110, 24000000 },
    102      1.1       is 	{ "com", 0x118, 24000000 },
    103      1.1       is 	{ "lpt", 0x200, 0 },
    104      1.1       is 	{ "lpt", 0x300, 0 },
    105      1.1       is 	{ 0, 0, 0}
    106      1.1       is };
    107      1.1       is 
    108      1.3       is #ifndef IOBZCLOCK
    109      1.3       is #define IOBZCLOCK 22118400;
    110      1.3       is #endif
    111      1.3       is int iobzclock = IOBZCLOCK;		/* patchable! */
    112      1.1       is 
    113      1.1       is void
    114      1.4  aymeric iobzattach(struct device *parent, struct device *self, void *auxp)
    115      1.1       is {
    116      1.1       is 	struct iobz_softc *iobzsc;
    117      1.1       is 	struct iobz_devs  *iobzd;
    118      1.1       is 	struct zbus_args *zap;
    119      1.1       is 	struct supio_attach_args supa;
    120      1.1       is 	extern const struct amiga_bus_space_methods amiga_bus_stride_16;
    121      1.1       is 	volatile u_int8_t *p;
    122      1.1       is 
    123      1.1       is 
    124      1.1       is 	iobzsc = (struct iobz_softc *)self;
    125      1.1       is 	zap = auxp;
    126      1.1       is 
    127      1.1       is 	if (parent)
    128      1.1       is 		printf("\n");
    129      1.1       is 
    130      1.1       is 	iobzsc->sc_bst.base = (u_long)zap->va;
    131      1.1       is 	iobzsc->sc_bst.absm = &amiga_bus_stride_16;
    132      1.1       is 
    133      1.1       is 	supa.supio_iot = &iobzsc->sc_bst;
    134      1.1       is 	supa.supio_ipl = 6;
    135      1.1       is 
    136      1.1       is 	iobzd = iobzdevices;
    137      1.1       is 
    138      1.1       is 	while (iobzd->name) {
    139      1.1       is 		supa.supio_name = iobzd->name;
    140      1.1       is 		supa.supio_iobase = iobzd->off;
    141      1.3       is 		supa.supio_arg = iobzclock /* XXX iobzd->arg */;
    142      1.1       is 		config_found(self, &supa, iobzprint); /* XXX */
    143      1.1       is 		++iobzd;
    144      1.1       is 	}
    145      1.1       is 
    146      1.1       is 	p = (volatile u_int8_t *)zap->va + 2;
    147      1.5       is 	(void)shutdownhook_establish(iobz_shutdown, (void *)p);
    148      1.1       is 	*p = ((*p) & 0x1F) | 0x80;
    149      1.1       is }
    150      1.1       is 
    151      1.1       is int
    152      1.4  aymeric iobzprint(void *auxp, const char *pnp)
    153      1.1       is {
    154      1.1       is 	struct supio_attach_args *supa;
    155      1.1       is 	supa = auxp;
    156      1.1       is 
    157      1.1       is 	if (pnp == NULL)
    158      1.1       is 		return(QUIET);
    159      1.1       is 
    160      1.1       is 	printf("%s at %s port 0x%02x",
    161      1.1       is 	    supa->supio_name, pnp, supa->supio_iobase);
    162      1.1       is 
    163      1.1       is 	return(UNCONF);
    164      1.5       is }
    165      1.5       is 
    166      1.5       is /*
    167      1.5       is  * Disable board interupts at shutdown time.
    168      1.5       is  */
    169      1.5       is 
    170      1.5       is void
    171      1.5       is iobz_shutdown(void *p) {
    172      1.5       is 	volatile int8_t *q;
    173      1.5       is 
    174      1.5       is 	q = p;
    175      1.5       is 
    176      1.5       is 	*q &= 0x1F;
    177      1.1       is }
    178