Home | History | Annotate | Line # | Download | only in isapnp
ess_isapnp.c revision 1.6.16.1
      1  1.6.16.1   thorpej /*	$NetBSD: ess_isapnp.c,v 1.6.16.1 2002/01/10 19:55:50 thorpej Exp $	*/
      2       1.1      matt 
      3       1.1      matt /*
      4       1.1      matt  * Copyright (c) 1991-1993 Regents of the University of California.
      5       1.1      matt  * All rights reserved.
      6       1.1      matt  *
      7       1.1      matt  * Redistribution and use in source and binary forms, with or without
      8       1.1      matt  * modification, are permitted provided that the following conditions
      9       1.1      matt  * are met:
     10       1.1      matt  * 1. Redistributions of source code must retain the above copyright
     11       1.1      matt  *    notice, this list of conditions and the following disclaimer.
     12       1.1      matt  * 2. Redistributions in binary form must reproduce the above copyright
     13       1.1      matt  *    notice, this list of conditions and the following disclaimer in the
     14       1.1      matt  *    documentation and/or other materials provided with the distribution.
     15       1.1      matt  * 3. All advertising materials mentioning features or use of this software
     16       1.1      matt  *    must display the following acknowledgement:
     17       1.1      matt  *	This product includes software developed by the Computer Systems
     18       1.1      matt  *	Engineering Group at Lawrence Berkeley Laboratory.
     19       1.1      matt  * 4. Neither the name of the University nor of the Laboratory may be used
     20       1.1      matt  *    to endorse or promote products derived from this software without
     21       1.1      matt  *    specific prior written permission.
     22       1.1      matt  *
     23       1.1      matt  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24       1.1      matt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25       1.1      matt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26       1.1      matt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27       1.1      matt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28       1.1      matt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29       1.1      matt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30       1.1      matt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31       1.1      matt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32       1.1      matt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33       1.1      matt  * SUCH DAMAGE.
     34       1.1      matt  *
     35       1.1      matt  */
     36  1.6.16.1   thorpej 
     37  1.6.16.1   thorpej #include <sys/cdefs.h>
     38  1.6.16.1   thorpej __KERNEL_RCSID(0, "$NetBSD: ess_isapnp.c,v 1.6.16.1 2002/01/10 19:55:50 thorpej Exp $");
     39       1.1      matt 
     40       1.1      matt #include <sys/param.h>
     41       1.1      matt #include <sys/systm.h>
     42       1.1      matt #include <sys/errno.h>
     43       1.1      matt #include <sys/ioctl.h>
     44       1.1      matt #include <sys/syslog.h>
     45       1.1      matt #include <sys/device.h>
     46       1.1      matt #include <sys/proc.h>
     47       1.1      matt 
     48       1.1      matt #include <machine/bus.h>
     49       1.1      matt 
     50       1.1      matt #include <sys/audioio.h>
     51       1.1      matt #include <dev/audio_if.h>
     52       1.1      matt #include <dev/mulaw.h>
     53       1.1      matt 
     54       1.1      matt #include <dev/isa/isavar.h>
     55       1.1      matt #include <dev/isa/isadmavar.h>
     56       1.1      matt 
     57       1.1      matt #include <dev/isapnp/isapnpreg.h>
     58       1.1      matt #include <dev/isapnp/isapnpvar.h>
     59       1.1      matt #include <dev/isapnp/isapnpdevs.h>
     60       1.1      matt 
     61       1.1      matt #include <dev/isa/essreg.h>
     62       1.1      matt #include <dev/isa/essvar.h>
     63       1.1      matt 
     64       1.1      matt int	ess_isapnp_match __P((struct device *, struct cfdata *, void *));
     65       1.1      matt void	ess_isapnp_attach __P((struct device *, struct device *, void *));
     66       1.1      matt 
     67       1.1      matt struct cfattach ess_isapnp_ca = {
     68       1.1      matt 	sizeof(struct ess_softc), ess_isapnp_match, ess_isapnp_attach
     69       1.1      matt };
     70       1.1      matt 
     71       1.1      matt 
     72       1.1      matt /*
     73       1.1      matt  * Probe / attach routines.
     74       1.1      matt  */
     75       1.1      matt 
     76       1.1      matt /*
     77       1.6  augustss  * Probe for the ess hardware.
     78       1.1      matt  */
     79       1.1      matt int
     80       1.1      matt ess_isapnp_match(parent, match, aux)
     81       1.1      matt 	struct device *parent;
     82       1.1      matt 	struct cfdata *match;
     83       1.1      matt 	void *aux;
     84       1.1      matt {
     85       1.5   mycroft 	int pri, variant;
     86       1.4   mycroft 
     87       1.5   mycroft 	pri = isapnp_devmatch(aux, &isapnp_ess_devinfo, &variant);
     88       1.5   mycroft 	if (pri && variant > 0)
     89       1.5   mycroft 		pri = 0;
     90       1.5   mycroft 	return (pri);
     91       1.1      matt }
     92       1.1      matt 
     93       1.1      matt 
     94       1.1      matt /*
     95       1.1      matt  * Attach hardware to driver, attach hardware driver to audio
     96       1.1      matt  * pseudo-device driver.
     97       1.1      matt  */
     98       1.1      matt void
     99       1.1      matt ess_isapnp_attach(parent, self, aux)
    100       1.1      matt 	struct device *parent, *self;
    101       1.1      matt 	void *aux;
    102       1.1      matt {
    103       1.1      matt 	struct ess_softc *sc = (struct ess_softc *)self;
    104       1.1      matt 	struct isapnp_attach_args *ipa = aux;
    105       1.1      matt 
    106       1.1      matt 	printf("\n");
    107       1.1      matt 
    108       1.1      matt 	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
    109       1.1      matt 		printf("%s: error in region allocation\n", sc->sc_dev.dv_xname);
    110       1.1      matt 		return;
    111       1.1      matt 	}
    112       1.1      matt 
    113       1.1      matt 	sc->sc_ic = ipa->ipa_ic;
    114       1.1      matt 
    115       1.1      matt 	sc->sc_iot = ipa->ipa_iot;
    116       1.1      matt 	sc->sc_iobase = ipa->ipa_io[0].base;
    117       1.1      matt 	sc->sc_ioh = ipa->ipa_io[0].h;
    118       1.1      matt 
    119       1.2   mycroft 	sc->sc_audio1.irq = ipa->ipa_irq[0].num;
    120       1.2   mycroft 	sc->sc_audio1.ist = ipa->ipa_irq[0].type;
    121       1.2   mycroft 	sc->sc_audio1.drq = ipa->ipa_drq[0].num;
    122       1.3   mycroft 	sc->sc_audio2.irq = -1;
    123       1.2   mycroft 	sc->sc_audio2.drq = ipa->ipa_drq[1].num;
    124       1.1      matt 
    125       1.1      matt 	if (!essmatch(sc)) {
    126       1.1      matt 		printf("%s: essmatch failed\n", sc->sc_dev.dv_xname);
    127       1.1      matt 		return;
    128       1.1      matt 	}
    129       1.1      matt 
    130       1.1      matt 	printf("%s:", sc->sc_dev.dv_xname);
    131       1.1      matt 
    132       1.1      matt 	essattach(sc);
    133       1.1      matt }
    134