Home | History | Annotate | Line # | Download | only in isapnp
ym_isapnp.c revision 1.16
      1  1.16   thorpej /*	$NetBSD: ym_isapnp.c,v 1.16 2002/10/02 16:34:05 thorpej 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.12     lukem 
     45  1.12     lukem #include <sys/cdefs.h>
     46  1.16   thorpej __KERNEL_RCSID(0, "$NetBSD: ym_isapnp.c,v 1.16 2002/10/02 16:34:05 thorpej Exp $");
     47   1.1  augustss 
     48  1.11     itohy #include "mpu_ym.h"
     49  1.11     itohy 
     50   1.1  augustss #include <sys/param.h>
     51   1.1  augustss #include <sys/systm.h>
     52   1.5        pk #include <sys/device.h>
     53   1.1  augustss #include <sys/errno.h>
     54   1.1  augustss 
     55   1.1  augustss #include <sys/audioio.h>
     56   1.1  augustss #include <dev/audio_if.h>
     57   1.1  augustss 
     58   1.1  augustss #include <dev/isa/isavar.h>
     59   1.1  augustss #include <dev/isa/isadmavar.h>
     60   1.1  augustss 
     61   1.1  augustss #include <dev/isapnp/isapnpreg.h>
     62   1.1  augustss #include <dev/isapnp/isapnpvar.h>
     63   1.4  christos #include <dev/isapnp/isapnpdevs.h>
     64   1.1  augustss 
     65   1.1  augustss #include <dev/ic/ad1848reg.h>
     66   1.1  augustss #include <dev/isa/ad1848var.h>
     67   1.1  augustss 
     68   1.1  augustss #include <dev/ic/cs4231reg.h>
     69   1.1  augustss #include <dev/isa/cs4231var.h>
     70   1.1  augustss 
     71  1.11     itohy #include <dev/ic/opl3sa3reg.h>
     72   1.1  augustss #include <dev/isa/wssreg.h>
     73   1.1  augustss #include <dev/isa/ymvar.h>
     74   1.1  augustss 
     75   1.1  augustss int	ym_isapnp_match __P((struct device *, struct cfdata *, void *));
     76   1.1  augustss void	ym_isapnp_attach __P((struct device *, struct device *, void *));
     77   1.1  augustss 
     78  1.15   thorpej CFATTACH_DECL(ym_isapnp, sizeof(struct ym_softc),
     79  1.16   thorpej     ym_isapnp_match, ym_isapnp_attach, NULL, NULL);
     80   1.1  augustss 
     81   1.1  augustss /*
     82   1.1  augustss  * Probe / attach routines.
     83   1.1  augustss  */
     84   1.1  augustss 
     85   1.1  augustss /*
     86   1.1  augustss  * Probe for the Yamaha hardware.
     87   1.1  augustss  */
     88   1.1  augustss int
     89   1.1  augustss ym_isapnp_match(parent, match, aux)
     90   1.1  augustss 	struct device *parent;
     91   1.1  augustss 	struct cfdata *match;
     92   1.1  augustss 	void *aux;
     93   1.1  augustss {
     94   1.8   mycroft 	int pri, variant;
     95   1.7   mycroft 
     96   1.8   mycroft 	pri = isapnp_devmatch(aux, &isapnp_ym_devinfo, &variant);
     97   1.8   mycroft 	if (pri && variant > 0)
     98   1.8   mycroft 		pri = 0;
     99   1.8   mycroft 	return (pri);
    100   1.1  augustss }
    101   1.1  augustss 
    102   1.1  augustss /*
    103   1.1  augustss  * Attach hardware to driver, attach hardware driver to audio
    104   1.1  augustss  * pseudo-device driver.
    105   1.1  augustss  */
    106   1.1  augustss void
    107   1.1  augustss ym_isapnp_attach(parent, self, aux)
    108   1.1  augustss 	struct device *parent, *self;
    109   1.1  augustss 	void *aux;
    110   1.1  augustss {
    111   1.2  augustss 	struct ym_softc *sc = (struct ym_softc *)self;
    112   1.5        pk 	struct ad1848_softc *ac = &sc->sc_ad1848.sc_ad1848;
    113   1.2  augustss 	struct isapnp_attach_args *ipa = aux;
    114   1.2  augustss 
    115   1.2  augustss 	printf("\n");
    116   1.2  augustss 
    117   1.2  augustss 	if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
    118   1.9   mycroft 		printf("%s: error in region allocation\n", self->dv_xname);
    119   1.2  augustss 		return;
    120   1.2  augustss 	}
    121   1.2  augustss 
    122   1.2  augustss 	sc->sc_iot = ipa->ipa_iot;
    123   1.2  augustss 	sc->sc_ic = ipa->ipa_ic;
    124   1.2  augustss 	sc->sc_ioh = ipa->ipa_io[1].h;
    125   1.2  augustss 
    126   1.2  augustss 	sc->ym_irq = ipa->ipa_irq[0].num;
    127   1.6   nathanw 	sc->ym_playdrq = ipa->ipa_drq[0].num;
    128   1.2  augustss 	sc->ym_recdrq = ipa->ipa_drq[1].num;
    129  1.11     itohy 
    130  1.11     itohy 	sc->sc_sb_ioh = ipa->ipa_io[0].h;
    131  1.11     itohy 	sc->sc_opl_ioh = ipa->ipa_io[2].h;
    132  1.11     itohy #if NMPU_YM > 0
    133  1.11     itohy 	sc->sc_mpu_ioh = ipa->ipa_io[3].h;
    134  1.11     itohy #endif
    135  1.11     itohy 	sc->sc_controlioh = ipa->ipa_io[4].h;
    136  1.11     itohy 
    137   1.5        pk 	ac->sc_iot = sc->sc_iot;
    138  1.10   mycroft 	if (bus_space_subregion(sc->sc_iot, sc->sc_ioh, WSS_CODEC, AD1848_NPORT,
    139   1.9   mycroft 	    &ac->sc_ioh)) {
    140   1.9   mycroft 		printf("%s: bus_space_subregion failed\n", self->dv_xname);
    141   1.9   mycroft 		return;
    142   1.9   mycroft 	}
    143   1.5        pk 	ac->mode = 2;
    144   1.5        pk 	ac->MCE_bit = MODE_CHANGE_ENABLE;
    145   1.5        pk 
    146   1.3   thorpej 	sc->sc_ad1848.sc_ic  = sc->sc_ic;
    147   1.1  augustss 
    148   1.9   mycroft 	printf("%s: %s %s", self->dv_xname, ipa->ipa_devident,
    149   1.9   mycroft 	    ipa->ipa_devclass);
    150   1.1  augustss 
    151   1.2  augustss 	ym_attach(sc);
    152   1.1  augustss }
    153