wss_isapnp.c revision 1.5 1 /* $NetBSD: wss_isapnp.c,v 1.5 1998/11/25 22:17:07 augustss Exp $ */
2
3 /*
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson (augustss (at) netbsd.org).
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/device.h>
42 #include <sys/errno.h>
43
44 #include <machine/bus.h>
45
46 #include <sys/audioio.h>
47 #include <dev/audio_if.h>
48
49 #include <dev/isa/isavar.h>
50 #include <dev/isa/isadmavar.h>
51
52 #include <dev/isapnp/isapnpreg.h>
53 #include <dev/isapnp/isapnpvar.h>
54 #include <dev/isapnp/isapnpdevs.h>
55
56 #include <dev/isa/ad1848var.h>
57 #include <dev/isa/madreg.h>
58 #include <dev/isa/wssreg.h>
59 #include <dev/isa/wssvar.h>
60
61 int wss_isapnp_match __P((struct device *, struct cfdata *, void *));
62 void wss_isapnp_attach __P((struct device *, struct device *, void *));
63
64 struct cfattach wss_isapnp_ca = {
65 sizeof(struct wss_softc), wss_isapnp_match, wss_isapnp_attach
66 };
67
68
69 /*
70 * Probe / attach routines.
71 */
72
73 /*
74 * Probe for the WSS hardware.
75 */
76 int
77 wss_isapnp_match(parent, match, aux)
78 struct device *parent;
79 struct cfdata *match;
80 void *aux;
81 {
82 return isapnp_devmatch(aux, &isapnp_wss_devinfo);
83 }
84
85
86
87 /*
88 * Attach hardware to driver, attach hardware driver to audio
89 * pseudo-device driver.
90 */
91 void
92 wss_isapnp_attach(parent, self, aux)
93 struct device *parent, *self;
94 void *aux;
95 {
96 struct wss_softc *sc = (struct wss_softc *)self;
97 struct ad1848_softc *ac = &sc->sc_ad1848.sc_ad1848;
98 struct isapnp_attach_args *ipa = aux;
99
100 printf("\n");
101
102 if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
103 printf("%s: error in region allocation\n",
104 ac->sc_dev.dv_xname);
105 return;
106 }
107
108 sc->sc_iot = ipa->ipa_iot;
109 sc->sc_ioh = ipa->ipa_io[0].h;
110
111 sc->mad_chip_type = MAD_NONE;
112
113 /* Set up AD1848 I/O handle. */
114 ac->sc_iot = ipa->ipa_iot;
115 ac->sc_ioh = sc->sc_ioh;
116 ac->mode = 2;
117
118 sc->sc_ad1848.sc_ic = ipa->ipa_ic;
119 sc->sc_ad1848.sc_iooffs = 0;
120
121 sc->wss_ic = ipa->ipa_ic;
122 sc->wss_irq = ipa->ipa_irq[0].num;
123 sc->wss_drq = ipa->ipa_drq[0].num;
124 sc->wss_recdrq =
125 ipa->ipa_ndrq > 1 ? ipa->ipa_drq[1].num : ipa->ipa_drq[0].num;
126
127 if (!ad1848_isa_probe(&sc->sc_ad1848)) {
128 printf("%s: ad1848_probe failed\n", ac->sc_dev.dv_xname);
129 return;
130 }
131
132 printf("%s: %s %s", ac->sc_dev.dv_xname, ipa->ipa_devident,
133 ipa->ipa_devclass);
134
135 wssattach(sc);
136 }
137