Home | History | Annotate | Line # | Download | only in isa
ess_isa.c revision 1.5
      1 /*	$NetBSD: ess_isa.c,v 1.5 1999/06/18 20:25:23 augustss 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 Nathan J. Williams.
      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 #include <sys/param.h>
     41 #include <sys/systm.h>
     42 #include <sys/device.h>
     43 
     44 #include <machine/cpu.h>
     45 #include <machine/bus.h>
     46 
     47 #include <dev/isa/isavar.h>
     48 
     49 #include <dev/isa/essreg.h>
     50 #include <dev/isa/essvar.h>
     51 
     52 #ifdef ESS_ISA_DEBUG
     53 #define DPRINTF(x)	printf x
     54 #else
     55 #define DPRINTF(x)
     56 #endif
     57 
     58 int ess_isa_probe __P((struct device *, struct cfdata *, void *));
     59 void ess_isa_attach __P((struct device *, struct device *, void *));
     60 
     61 struct cfattach ess_isa_ca = {
     62 	sizeof(struct ess_softc), ess_isa_probe, ess_isa_attach
     63 };
     64 
     65 int
     66 ess_isa_probe(parent, match, aux)
     67 	struct device *parent;
     68 	struct cfdata *match;
     69 	void *aux;
     70 {
     71   	int ret;
     72 	struct isa_attach_args *ia = aux;
     73 	struct ess_softc probesc, *sc= &probesc;
     74 
     75 	memset(sc, 0, sizeof *sc);
     76 
     77 	sc->sc_ic = ia->ia_ic;
     78 	sc->sc_iot = ia->ia_iot;
     79 	sc->sc_iobase = ia->ia_iobase;
     80 	if (bus_space_map(sc->sc_iot, sc->sc_iobase, ESS_NPORT, 0, &sc->sc_ioh)) {
     81 	  DPRINTF(("ess_isa_probe: Couldn't map I/O region at %x, size %x\n",
     82 			   sc->sc_iobase, ESS_NPORT));
     83 	  return 0;
     84 	}
     85 
     86 	sc->sc_audio1.irq = ia->ia_irq;
     87 	sc->sc_audio1.ist = IST_EDGE;
     88 	sc->sc_audio1.drq = ia->ia_drq;
     89 	sc->sc_audio2.irq = -1;
     90 	sc->sc_audio2.drq = ia->ia_drq2;
     91 
     92 	ret = essmatch(sc);
     93 
     94 	bus_space_unmap(sc->sc_iot, sc->sc_ioh, ESS_NPORT);
     95 
     96 	if (ret) {
     97 		DPRINTF(("ess_isa_probe succeeded (score %d)\n", ret));
     98 		ia->ia_iosize = ESS_NPORT;
     99 	} else
    100 		DPRINTF(("ess_isa_probe failed\n"));
    101 
    102 	return ret;
    103 }
    104 
    105 void ess_isa_attach(parent, self, aux)
    106 	 struct device *parent, *self;
    107 	 void *aux;
    108 {
    109 	struct ess_softc *sc = (void *)self;
    110 	struct isa_attach_args *ia = aux;
    111 
    112 	printf("\n");
    113 
    114 	sc->sc_ic = ia->ia_ic;
    115 	sc->sc_iot = ia->ia_iot;
    116 	sc->sc_iobase = ia->ia_iobase;
    117 	if (bus_space_map(sc->sc_iot, sc->sc_iobase, ESS_NPORT, 0, &sc->sc_ioh)) {
    118 	  DPRINTF(("ess_isa_attach: Couldn't map I/O region at %x, size %x\n",
    119 			   sc->sc_iobase, ESS_NPORT));
    120 	  return;
    121 	}
    122 
    123 	sc->sc_audio1.irq = ia->ia_irq;
    124 	sc->sc_audio1.ist = IST_EDGE;
    125 	sc->sc_audio1.drq = ia->ia_drq;
    126 	sc->sc_audio2.irq = -1;
    127 	sc->sc_audio2.drq = ia->ia_drq2;
    128 
    129 	printf("%s", sc->sc_dev.dv_xname);
    130 
    131 	essattach(sc);
    132 }
    133