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