Home | History | Annotate | Line # | Download | only in isapnp
ym_isapnp.c revision 1.10
      1  1.10   mycroft /*	$NetBSD: ym_isapnp.c,v 1.10 1999/03/22 14:32:59 mycroft 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.8   mycroft 	int pri, variant;
     91   1.7   mycroft 
     92   1.8   mycroft 	pri = isapnp_devmatch(aux, &isapnp_ym_devinfo, &variant);
     93   1.8   mycroft 	if (pri && variant > 0)
     94   1.8   mycroft 		pri = 0;
     95   1.8   mycroft 	return (pri);
     96   1.1  augustss }
     97   1.1  augustss 
     98   1.1  augustss /*
     99   1.1  augustss  * Attach hardware to driver, attach hardware driver to audio
    100   1.1  augustss  * pseudo-device driver.
    101   1.1  augustss  */
    102   1.1  augustss void
    103   1.1  augustss ym_isapnp_attach(parent, self, aux)
    104   1.1  augustss 	struct device *parent, *self;
    105   1.1  augustss 	void *aux;
    106   1.1  augustss {
    107   1.2  augustss 	struct ym_softc *sc = (struct ym_softc *)self;
    108   1.5        pk 	struct ad1848_softc *ac = &sc->sc_ad1848.sc_ad1848;
    109   1.2  augustss 	struct isapnp_attach_args *ipa = aux;
    110   1.2  augustss 
    111   1.2  augustss 	printf("\n");
    112   1.2  augustss 
    113   1.2  augustss 	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
    114   1.9   mycroft 		printf("%s: error in region allocation\n", self->dv_xname);
    115   1.2  augustss 		return;
    116   1.2  augustss 	}
    117   1.2  augustss 
    118   1.2  augustss 	sc->sc_iot = ipa->ipa_iot;
    119   1.2  augustss 	sc->sc_ic = ipa->ipa_ic;
    120   1.2  augustss 	sc->sc_ioh = ipa->ipa_io[1].h;
    121   1.2  augustss 
    122   1.2  augustss 	sc->ym_irq = ipa->ipa_irq[0].num;
    123   1.6   nathanw 	sc->ym_playdrq = ipa->ipa_drq[0].num;
    124   1.2  augustss 	sc->ym_recdrq = ipa->ipa_drq[1].num;
    125   1.2  augustss 
    126   1.2  augustss 	sc->sc_controlioh = ipa->ipa_io[4].h;
    127   1.2  augustss 
    128   1.5        pk 	ac->sc_iot = sc->sc_iot;
    129  1.10   mycroft 	if (bus_space_subregion(sc->sc_iot, sc->sc_ioh, WSS_CODEC, AD1848_NPORT,
    130   1.9   mycroft 	    &ac->sc_ioh)) {
    131   1.9   mycroft 		printf("%s: bus_space_subregion failed\n", self->dv_xname);
    132   1.9   mycroft 		return;
    133   1.9   mycroft 	}
    134   1.5        pk 	ac->mode = 2;
    135   1.5        pk 	ac->MCE_bit = MODE_CHANGE_ENABLE;
    136   1.5        pk 	ac->chip_name = "OPL3-SA3";
    137   1.5        pk 
    138   1.3   thorpej 	sc->sc_ad1848.sc_ic  = sc->sc_ic;
    139   1.1  augustss 
    140   1.9   mycroft 	printf("%s: %s %s", self->dv_xname, ipa->ipa_devident,
    141   1.9   mycroft 	    ipa->ipa_devclass);
    142   1.1  augustss 
    143   1.2  augustss 	ym_attach(sc);
    144   1.1  augustss }
    145   1.1  augustss 
    146