Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / isapnp / ym_isapnp.c
blobe31a0522dbb162f67f8943873103bbd8ae598550
1 /* $NetBSD: ym_isapnp.c,v 1.23 2009/05/12 10:07:55 cegger Exp $ */
3 /*
4 * Copyright (c) 1991-1993 Regents of the University of California.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the Computer Systems
18 * Engineering Group at Lawrence Berkeley Laboratory.
19 * 4. Neither the name of the University nor of the Laboratory may be used
20 * to endorse or promote products derived from this software without
21 * specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
38 * Driver for the Yamaha OPL3-SA3 chipset. This is found on many laptops
39 * and Pentium (II) motherboards.
41 * Original code from OpenBSD.
44 #include <sys/cdefs.h>
45 __KERNEL_RCSID(0, "$NetBSD: ym_isapnp.c,v 1.23 2009/05/12 10:07:55 cegger Exp $");
47 #include "mpu_ym.h"
49 #include <sys/param.h>
50 #include <sys/systm.h>
51 #include <sys/device.h>
52 #include <sys/errno.h>
54 #include <sys/audioio.h>
55 #include <dev/audio_if.h>
57 #include <dev/isa/isavar.h>
58 #include <dev/isa/isadmavar.h>
60 #include <dev/isapnp/isapnpreg.h>
61 #include <dev/isapnp/isapnpvar.h>
62 #include <dev/isapnp/isapnpdevs.h>
64 #include <dev/ic/ad1848reg.h>
65 #include <dev/isa/ad1848var.h>
67 #include <dev/ic/cs4231reg.h>
68 #include <dev/isa/cs4231var.h>
70 #include <dev/ic/opl3sa3reg.h>
71 #include <dev/isa/wssreg.h>
72 #include <dev/isa/ymvar.h>
74 int ym_isapnp_match(device_t, cfdata_t, void *);
75 void ym_isapnp_attach(device_t, device_t, void *);
77 CFATTACH_DECL(ym_isapnp, sizeof(struct ym_softc),
78 ym_isapnp_match, ym_isapnp_attach, NULL, NULL);
81 * Probe / attach routines.
85 * Probe for the Yamaha hardware.
87 int
88 ym_isapnp_match(device_t parent, cfdata_t match, void *aux)
90 int pri, variant;
92 pri = isapnp_devmatch(aux, &isapnp_ym_devinfo, &variant);
93 if (pri && variant > 0)
94 pri = 0;
95 return pri;
99 * Attach hardware to driver, attach hardware driver to audio
100 * pseudo-device driver.
102 void
103 ym_isapnp_attach(device_t parent, device_t self, void *aux)
105 struct ym_softc *sc;
106 struct ad1848_softc *ac;
107 struct isapnp_attach_args *ipa;
109 sc = device_private(self);
110 ac = &sc->sc_ad1848.sc_ad1848;
111 ipa = aux;
112 printf("\n");
114 if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
115 aprint_error_dev(self, "error in region allocation\n");
116 return;
119 sc->sc_iot = ipa->ipa_iot;
120 sc->sc_ic = ipa->ipa_ic;
121 sc->sc_ioh = ipa->ipa_io[1].h;
123 sc->ym_irq = ipa->ipa_irq[0].num;
124 sc->ym_playdrq = ipa->ipa_drq[0].num;
125 sc->ym_recdrq = ipa->ipa_drq[1].num;
127 sc->sc_sb_ioh = ipa->ipa_io[0].h;
128 sc->sc_opl_ioh = ipa->ipa_io[2].h;
129 #if NMPU_YM > 0
130 sc->sc_mpu_ioh = ipa->ipa_io[3].h;
131 #endif
132 sc->sc_controlioh = ipa->ipa_io[4].h;
134 ac->sc_iot = sc->sc_iot;
135 if (bus_space_subregion(sc->sc_iot, sc->sc_ioh, WSS_CODEC, AD1848_NPORT,
136 &ac->sc_ioh)) {
137 aprint_error_dev(self, "bus_space_subregion failed\n");
138 return;
140 ac->mode = 2;
141 ac->MCE_bit = MODE_CHANGE_ENABLE;
143 sc->sc_ad1848.sc_ic = sc->sc_ic;
145 printf("%s: %s %s", device_xname(self), ipa->ipa_devident,
146 ipa->ipa_devclass);
148 ym_attach(sc);