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