ym_isapnp.c revision 1.2 1 1.2 augustss /* $NetBSD: ym_isapnp.c,v 1.2 1998/05/21 19:07:10 augustss 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.1 augustss #include <sys/errno.h>
48 1.1 augustss #include <sys/ioctl.h>
49 1.1 augustss #include <sys/syslog.h>
50 1.1 augustss #include <sys/device.h>
51 1.1 augustss #include <sys/proc.h>
52 1.1 augustss
53 1.1 augustss #include <sys/audioio.h>
54 1.1 augustss #include <dev/audio_if.h>
55 1.1 augustss
56 1.1 augustss #include <dev/isa/isavar.h>
57 1.1 augustss #include <dev/isa/isadmavar.h>
58 1.1 augustss
59 1.1 augustss #include <dev/isapnp/isapnpreg.h>
60 1.1 augustss #include <dev/isapnp/isapnpvar.h>
61 1.1 augustss
62 1.1 augustss #include <dev/ic/ad1848reg.h>
63 1.1 augustss #include <dev/isa/ad1848var.h>
64 1.1 augustss
65 1.1 augustss #include <dev/ic/cs4231reg.h>
66 1.1 augustss #include <dev/isa/cs4231var.h>
67 1.1 augustss
68 1.1 augustss #include <dev/isa/wssreg.h>
69 1.1 augustss #include <dev/isa/ymvar.h>
70 1.1 augustss
71 1.1 augustss int ym_isapnp_match __P((struct device *, struct cfdata *, void *));
72 1.1 augustss void ym_isapnp_attach __P((struct device *, struct device *, void *));
73 1.1 augustss
74 1.1 augustss struct cfattach ym_isapnp_ca = {
75 1.1 augustss sizeof(struct ym_softc), ym_isapnp_match, ym_isapnp_attach
76 1.1 augustss };
77 1.1 augustss
78 1.1 augustss
79 1.1 augustss /*
80 1.1 augustss * Probe / attach routines.
81 1.1 augustss */
82 1.1 augustss
83 1.1 augustss /*
84 1.1 augustss * Probe for the Yamaha hardware.
85 1.1 augustss */
86 1.1 augustss int
87 1.1 augustss ym_isapnp_match(parent, match, aux)
88 1.1 augustss struct device *parent;
89 1.1 augustss struct cfdata *match;
90 1.1 augustss void *aux;
91 1.1 augustss {
92 1.1 augustss struct isapnp_attach_args *ipa = aux;
93 1.1 augustss
94 1.1 augustss if (strcmp(ipa->ipa_devlogic, "YMH0021")) /* OPL3-SA3 */
95 1.1 augustss return 0;
96 1.1 augustss
97 1.1 augustss return 1;
98 1.1 augustss }
99 1.1 augustss
100 1.1 augustss /*
101 1.1 augustss * Attach hardware to driver, attach hardware driver to audio
102 1.1 augustss * pseudo-device driver.
103 1.1 augustss */
104 1.1 augustss void
105 1.1 augustss ym_isapnp_attach(parent, self, aux)
106 1.1 augustss struct device *parent, *self;
107 1.1 augustss void *aux;
108 1.1 augustss {
109 1.2 augustss struct ym_softc *sc = (struct ym_softc *)self;
110 1.2 augustss struct isapnp_attach_args *ipa = aux;
111 1.2 augustss
112 1.2 augustss printf("\n");
113 1.2 augustss
114 1.2 augustss if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
115 1.2 augustss printf("%s: error in region allocation\n",
116 1.2 augustss sc->sc_dev.dv_xname);
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.2 augustss sc->ym_drq = ipa->ipa_drq[0].num;
126 1.2 augustss sc->ym_recdrq = ipa->ipa_drq[1].num;
127 1.2 augustss
128 1.2 augustss sc->sc_controlioh = ipa->ipa_io[4].h;
129 1.2 augustss
130 1.2 augustss sc->sc_ad1848.sc_iot = sc->sc_iot;
131 1.2 augustss sc->sc_ad1848.sc_ioh = sc->sc_ioh;
132 1.2 augustss sc->sc_ad1848.sc_isa = parent->dv_parent;
133 1.2 augustss sc->sc_ad1848.sc_iooffs = WSS_CODEC;
134 1.2 augustss sc->sc_ad1848.mode = 2;
135 1.2 augustss sc->sc_ad1848.MCE_bit = MODE_CHANGE_ENABLE;
136 1.2 augustss sc->sc_ad1848.chip_name = "OPL3-SA3";
137 1.1 augustss
138 1.2 augustss printf("%s: %s %s", sc->sc_dev.dv_xname, ipa->ipa_devident,
139 1.2 augustss ipa->ipa_devclass);
140 1.1 augustss
141 1.2 augustss ym_attach(sc);
142 1.1 augustss }
143 1.1 augustss
144