ym_pnpbios.c revision 1.4.2.2 1 1.4.2.2 bouyer /* $NetBSD: ym_pnpbios.c,v 1.4.2.2 2000/11/20 20:09:37 bouyer Exp $ */
2 1.4.2.2 bouyer /*
3 1.4.2.2 bouyer * Copyright (c) 1999
4 1.4.2.2 bouyer * Matthias Drochner. All rights reserved.
5 1.4.2.2 bouyer * Soren S. Jorvang. All rights reserved.
6 1.4.2.2 bouyer *
7 1.4.2.2 bouyer * Redistribution and use in source and binary forms, with or without
8 1.4.2.2 bouyer * modification, are permitted provided that the following conditions
9 1.4.2.2 bouyer * are met:
10 1.4.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
11 1.4.2.2 bouyer * notice, this list of conditions, and the following disclaimer.
12 1.4.2.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
13 1.4.2.2 bouyer * notice, this list of conditions and the following disclaimer in the
14 1.4.2.2 bouyer * documentation and/or other materials provided with the distribution.
15 1.4.2.2 bouyer *
16 1.4.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 1.4.2.2 bouyer * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 1.4.2.2 bouyer * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 1.4.2.2 bouyer * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 1.4.2.2 bouyer * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.4.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 1.4.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.4.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 1.4.2.2 bouyer * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.4.2.2 bouyer * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.4.2.2 bouyer * SUCH DAMAGE.
27 1.4.2.2 bouyer */
28 1.4.2.2 bouyer
29 1.4.2.2 bouyer #include "mpu_ym.h"
30 1.4.2.2 bouyer
31 1.4.2.2 bouyer #include <sys/param.h>
32 1.4.2.2 bouyer #include <sys/systm.h>
33 1.4.2.2 bouyer #include <sys/errno.h>
34 1.4.2.2 bouyer #include <sys/ioctl.h>
35 1.4.2.2 bouyer #include <sys/syslog.h>
36 1.4.2.2 bouyer #include <sys/device.h>
37 1.4.2.2 bouyer #include <sys/proc.h>
38 1.4.2.2 bouyer
39 1.4.2.2 bouyer #include <machine/bus.h>
40 1.4.2.2 bouyer
41 1.4.2.2 bouyer #include <sys/audioio.h>
42 1.4.2.2 bouyer #include <dev/audio_if.h>
43 1.4.2.2 bouyer #include <dev/midi_if.h>
44 1.4.2.2 bouyer #include <dev/mulaw.h>
45 1.4.2.2 bouyer
46 1.4.2.2 bouyer #include <dev/isa/isavar.h>
47 1.4.2.2 bouyer #include <dev/isa/isadmavar.h>
48 1.4.2.2 bouyer
49 1.4.2.2 bouyer #include <i386/pnpbios/pnpbiosvar.h>
50 1.4.2.2 bouyer
51 1.4.2.2 bouyer #include <dev/ic/ad1848reg.h>
52 1.4.2.2 bouyer #include <dev/isa/ad1848var.h>
53 1.4.2.2 bouyer
54 1.4.2.2 bouyer #include <dev/ic/cs4231reg.h>
55 1.4.2.2 bouyer #include <dev/isa/cs4231var.h>
56 1.4.2.2 bouyer
57 1.4.2.2 bouyer #include <dev/ic/opl3sa3reg.h>
58 1.4.2.2 bouyer #include <dev/isa/wssreg.h>
59 1.4.2.2 bouyer #include <dev/isa/ymvar.h>
60 1.4.2.2 bouyer
61 1.4.2.2 bouyer int ym_pnpbios_match __P((struct device *, struct cfdata *, void *));
62 1.4.2.2 bouyer void ym_pnpbios_attach __P((struct device *, struct device *, void *));
63 1.4.2.2 bouyer
64 1.4.2.2 bouyer struct cfattach ym_pnpbios_ca = {
65 1.4.2.2 bouyer sizeof(struct ym_softc), ym_pnpbios_match, ym_pnpbios_attach
66 1.4.2.2 bouyer };
67 1.4.2.2 bouyer
68 1.4.2.2 bouyer int
69 1.4.2.2 bouyer ym_pnpbios_match(parent, match, aux)
70 1.4.2.2 bouyer struct device *parent;
71 1.4.2.2 bouyer struct cfdata *match;
72 1.4.2.2 bouyer void *aux;
73 1.4.2.2 bouyer {
74 1.4.2.2 bouyer struct pnpbiosdev_attach_args *aa = aux;
75 1.4.2.2 bouyer
76 1.4.2.2 bouyer if (strcmp(aa->idstr, "YMH0021"))
77 1.4.2.2 bouyer return 0;
78 1.4.2.2 bouyer
79 1.4.2.2 bouyer return 1;
80 1.4.2.2 bouyer }
81 1.4.2.2 bouyer
82 1.4.2.2 bouyer void
83 1.4.2.2 bouyer ym_pnpbios_attach(parent, self, aux)
84 1.4.2.2 bouyer struct device *parent, *self;
85 1.4.2.2 bouyer void *aux;
86 1.4.2.2 bouyer {
87 1.4.2.2 bouyer struct ym_softc *sc = (void *)self;
88 1.4.2.2 bouyer struct ad1848_softc *ac = &sc->sc_ad1848.sc_ad1848;
89 1.4.2.2 bouyer struct pnpbiosdev_attach_args *aa = aux;
90 1.4.2.2 bouyer
91 1.4.2.2 bouyer if (pnpbios_io_map(aa->pbt, aa->resc, 0,
92 1.4.2.2 bouyer &sc->sc_iot, &sc->sc_sb_ioh) != 0) {
93 1.4.2.2 bouyer printf(": can't map sb i/o space\n");
94 1.4.2.2 bouyer return;
95 1.4.2.2 bouyer }
96 1.4.2.2 bouyer if (pnpbios_io_map(aa->pbt, aa->resc, 1,
97 1.4.2.2 bouyer &sc->sc_iot, &sc->sc_ioh) != 0) {
98 1.4.2.2 bouyer printf(": can't map sb i/o space\n");
99 1.4.2.2 bouyer return;
100 1.4.2.2 bouyer }
101 1.4.2.2 bouyer if (pnpbios_io_map(aa->pbt, aa->resc, 2,
102 1.4.2.2 bouyer &sc->sc_iot, &sc->sc_opl_ioh) != 0) {
103 1.4.2.2 bouyer printf(": can't map opl i/o space\n");
104 1.4.2.2 bouyer return;
105 1.4.2.2 bouyer }
106 1.4.2.2 bouyer #if NMPU_YM > 0
107 1.4.2.2 bouyer if (pnpbios_io_map(aa->pbt, aa->resc, 3,
108 1.4.2.2 bouyer &sc->sc_iot, &sc->sc_mpu_ioh) != 0) {
109 1.4.2.2 bouyer printf(": can't map mpu i/o space\n");
110 1.4.2.2 bouyer return;
111 1.4.2.2 bouyer }
112 1.4.2.2 bouyer #endif
113 1.4.2.2 bouyer if (pnpbios_io_map(aa->pbt, aa->resc, 4,
114 1.4.2.2 bouyer &sc->sc_iot, &sc->sc_controlioh) != 0) {
115 1.4.2.2 bouyer printf(": can't map control i/o space\n");
116 1.4.2.2 bouyer return;
117 1.4.2.2 bouyer }
118 1.4.2.2 bouyer
119 1.4.2.2 bouyer sc->sc_ic = aa->ic;
120 1.4.2.2 bouyer
121 1.4.2.2 bouyer if (pnpbios_getirqnum(aa->pbt, aa->resc, 0, &sc->ym_irq, NULL)) {
122 1.4.2.2 bouyer printf(": can't get IRQ\n");
123 1.4.2.2 bouyer return;
124 1.4.2.2 bouyer }
125 1.4.2.2 bouyer
126 1.4.2.2 bouyer if (pnpbios_getdmachan(aa->pbt, aa->resc, 0, &sc->ym_playdrq)) {
127 1.4.2.2 bouyer printf(": can't get DMA channel\n");
128 1.4.2.2 bouyer return;
129 1.4.2.2 bouyer }
130 1.4.2.2 bouyer if (pnpbios_getdmachan(aa->pbt, aa->resc, 1, &sc->ym_recdrq))
131 1.4.2.2 bouyer sc->ym_recdrq = sc->ym_playdrq; /* half-duplex mode */
132 1.4.2.2 bouyer
133 1.4.2.2 bouyer printf("\n");
134 1.4.2.2 bouyer pnpbios_print_devres(self, aa);
135 1.4.2.2 bouyer
136 1.4.2.2 bouyer printf("%s", self->dv_xname);
137 1.4.2.2 bouyer
138 1.4.2.2 bouyer ac->sc_iot = sc->sc_iot;
139 1.4.2.2 bouyer if (bus_space_subregion(sc->sc_iot, sc->sc_ioh, WSS_CODEC, AD1848_NPORT,
140 1.4.2.2 bouyer &ac->sc_ioh)) {
141 1.4.2.2 bouyer printf("%s: bus_space_subregion failed\n", self->dv_xname);
142 1.4.2.2 bouyer return;
143 1.4.2.2 bouyer }
144 1.4.2.2 bouyer ac->mode = 2;
145 1.4.2.2 bouyer ac->MCE_bit = MODE_CHANGE_ENABLE;
146 1.4.2.2 bouyer ac->chip_name = "OPL3-SA3";
147 1.4.2.2 bouyer
148 1.4.2.2 bouyer sc->sc_ad1848.sc_ic = sc->sc_ic;
149 1.4.2.2 bouyer
150 1.4.2.2 bouyer ym_attach(sc);
151 1.4.2.2 bouyer }
152