Home | History | Annotate | Line # | Download | only in dev
drsupio.c revision 1.10
      1  1.10  aymeric /*	$NetBSD: drsupio.c,v 1.10 2002/01/28 09:56:54 aymeric Exp $ */
      2   1.1       is 
      3   1.5       is /*-
      4   1.6       is  * Copyright (c) 1997 The NetBSD Foundation, Inc.
      5   1.1       is  * All rights reserved.
      6   1.1       is  *
      7   1.5       is  * This code is derived from software contributed to The NetBSD Foundation
      8   1.5       is  * by Ignatios Souvatzis.
      9   1.5       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.5       is  *        This product includes software developed by the NetBSD
     21   1.5       is  *        Foundation, Inc. and its contributors.
     22   1.5       is  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23   1.5       is  *    contributors may be used to endorse or promote products derived
     24   1.5       is  *    from this software without specific prior written permission.
     25   1.1       is  *
     26   1.5       is  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27   1.5       is  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28   1.5       is  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29   1.5       is  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30   1.5       is  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31   1.5       is  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32   1.5       is  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33   1.5       is  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34   1.5       is  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35   1.5       is  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36   1.5       is  * POSSIBILITY OF SUCH DAMAGE.
     37   1.1       is  */
     38  1.10  aymeric 
     39  1.10  aymeric #include <sys/cdefs.h>
     40  1.10  aymeric __KERNEL_RCSID(0, "$NetBSD: drsupio.c,v 1.10 2002/01/28 09:56:54 aymeric Exp $");
     41   1.1       is 
     42   1.1       is /*
     43   1.1       is  * DraCo multi-io chip bus space stuff
     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 #include <machine/conf.h>
     55   1.1       is 
     56   1.1       is #include <amiga/include/cpu.h>
     57   1.1       is 
     58   1.1       is #include <amiga/amiga/device.h>
     59   1.1       is #include <amiga/amiga/drcustom.h>
     60   1.1       is 
     61   1.1       is #include <amiga/dev/supio.h>
     62   1.1       is 
     63   1.1       is struct drsupio_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.9  aymeric int drsupiomatch(struct device *, struct cfdata *, void *);
     69   1.9  aymeric void drsupioattach(struct device *, struct device *, void *);
     70   1.9  aymeric int drsupprint(void *auxp, const char *);
     71   1.9  aymeric void drlptintack(void *);
     72   1.1       is 
     73   1.1       is struct cfattach drsupio_ca = {
     74   1.1       is 	sizeof(struct drsupio_softc), drsupiomatch, drsupioattach
     75   1.1       is };
     76   1.1       is 
     77   1.1       is int
     78   1.9  aymeric drsupiomatch(struct device *parent, struct cfdata *cfp, void *auxp)
     79   1.1       is {
     80   1.8   kleink 	static int drsupio_matched = 0;
     81   1.1       is 
     82   1.1       is 	/* Exactly one of us lives on the DraCo */
     83   1.8   kleink 	if (!is_draco() || !matchname(auxp, "drsupio") || drsupio_matched)
     84   1.8   kleink 		return 0;
     85   1.1       is 
     86   1.8   kleink 	drsupio_matched = 1;
     87   1.8   kleink 	return 1;
     88   1.1       is }
     89   1.1       is 
     90   1.1       is struct drsupio_devs {
     91   1.1       is 	char *name;
     92   1.1       is 	int off;
     93   1.2       is 	int arg;
     94   1.1       is } drsupiodevs[] = {
     95   1.2       is 	{ "com", 0x3f8, 115200 * 16 },
     96   1.2       is 	{ "com", 0x2f8, 115200 * 16 },
     97   1.3       is 	{ "lpt", 0x278, (int)drlptintack },
     98   1.2       is 	{ "fdc", 0x3f0, 0 },
     99   1.1       is 	/* WD port? */
    100   1.1       is 	{ 0 }
    101   1.1       is };
    102   1.1       is 
    103   1.1       is void
    104   1.9  aymeric drsupioattach(struct device *parent, struct device *self, void *auxp)
    105   1.1       is {
    106   1.1       is 	struct drsupio_softc *drsc;
    107   1.1       is 	struct drsupio_devs  *drsd;
    108   1.3       is 	struct drioct *ioct;
    109   1.1       is 	struct supio_attach_args supa;
    110   1.1       is 
    111   1.1       is 	drsc = (struct drsupio_softc *)self;
    112   1.1       is 	drsd = drsupiodevs;
    113   1.1       is 
    114   1.1       is 	if (parent)
    115   1.1       is 		printf("\n");
    116   1.1       is 
    117   1.1       is 	drsc->sc_bst.base = DRCCADDR + NBPG * DRSUPIOPG + 1;
    118   1.7       is 	drsc->sc_bst.absm = &amiga_bus_stride_4;
    119   1.9  aymeric 
    120   1.1       is 	supa.supio_iot = &drsc->sc_bst;
    121   1.2       is 	supa.supio_ipl = 5;
    122   1.1       is 
    123   1.1       is 	while (drsd->name) {
    124   1.1       is 		supa.supio_name = drsd->name;
    125   1.1       is 		supa.supio_iobase = drsd->off;
    126   1.2       is 		supa.supio_arg = drsd->arg;
    127   1.1       is 		config_found(self, &supa, drsupprint); /* XXX */
    128   1.1       is 		++drsd;
    129   1.1       is 	}
    130   1.3       is 
    131   1.3       is 	drlptintack(0);
    132   1.3       is 	ioct = (struct drioct *)(DRCCADDR + NBPG * DRIOCTLPG);
    133   1.3       is 	ioct->io_status2 |= DRSTAT2_PARIRQENA;
    134   1.3       is }
    135   1.3       is 
    136   1.3       is void
    137   1.9  aymeric drlptintack(void *p)
    138   1.3       is {
    139   1.3       is 	struct drioct *ioct;
    140   1.3       is 
    141   1.3       is 	(void)p;
    142   1.3       is 	ioct = (struct drioct *)(DRCCADDR + NBPG * DRIOCTLPG);
    143   1.3       is 
    144   1.3       is 	ioct->io_parrst = 0;	/* any value works */
    145   1.1       is }
    146   1.1       is 
    147   1.1       is int
    148   1.9  aymeric drsupprint(void *auxp, const char *pnp)
    149   1.1       is {
    150   1.1       is 	struct supio_attach_args *supa;
    151   1.1       is 	supa = auxp;
    152   1.1       is 
    153   1.1       is 	if (pnp == NULL)
    154   1.1       is 		return(QUIET);
    155   1.1       is 
    156   1.1       is 	printf("%s at %s port 0x%02x",
    157   1.1       is 	    supa->supio_name, pnp, supa->supio_iobase);
    158   1.1       is 
    159   1.1       is 	return(UNCONF);
    160   1.1       is }
    161