ess_pnpbios.c revision 1.1 1 /* $NetBSD: ess_pnpbios.c,v 1.1 2000/02/15 17:12:54 nathanw Exp $ */
2
3 /*-
4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Nathan J. Williams.
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/errno.h>
42 #include <sys/ioctl.h>
43 #include <sys/syslog.h>
44 #include <sys/device.h>
45 #include <sys/proc.h>
46
47 #include <machine/bus.h>
48
49 #include <sys/audioio.h>
50 #include <dev/audio_if.h>
51 #include <dev/midi_if.h>
52 #include <dev/mulaw.h>
53
54 #include <dev/isa/isavar.h>
55 #include <dev/isa/isadmavar.h>
56
57 #include <i386/pnpbios/pnpbiosvar.h>
58
59 #include <dev/isa/essreg.h>
60 #include <dev/isa/essvar.h>
61
62 int ess_pnpbios_match __P((struct device *, struct cfdata *, void *));
63 void ess_pnpbios_attach __P((struct device *, struct device *, void *));
64
65 struct cfattach ess_pnpbios_ca = {
66 sizeof(struct ess_softc), ess_pnpbios_match, ess_pnpbios_attach
67 };
68
69 int
70 ess_pnpbios_match(parent, match, aux)
71 struct device *parent;
72 struct cfdata *match;
73 void *aux;
74 {
75 struct pnpbiosdev_attach_args *aa = aux;
76
77 if (strcmp(aa->idstr, "ESS0104"))
78 return (0);
79
80 return (1);
81 }
82
83 void
84 ess_pnpbios_attach(parent, self, aux)
85 struct device *parent, *self;
86 void *aux;
87 {
88 struct ess_softc *sc = (void *)self;
89 struct pnpbiosdev_attach_args *aa = aux;
90
91 if (pnpbios_io_map(aa->pbt, aa->resc, 0, &sc->sc_iot, &sc->sc_ioh)) {
92 printf(": can't map i/o space\n");
93 return;
94 }
95
96 sc->sc_ic = aa->ic;
97
98 /* XXX These are only for setting chip configuration registers. */
99 pnpbios_getiobase(aa->pbt, aa->resc, 0, 0, &sc->sc_iobase);
100
101 sc->sc_audio1.ist = IST_EDGE;
102 sc->sc_audio2.ist = IST_EDGE;
103
104 if (pnpbios_getirqnum(aa->pbt, aa->resc, 0, &sc->sc_audio1.irq)) {
105 printf(": can't get IRQ\n");
106 return;
107 }
108
109 if (pnpbios_getirqnum(aa->pbt, aa->resc, 1, &sc->sc_audio2.irq))
110 sc->sc_audio2.irq = -1;
111
112 if (pnpbios_getdmachan(aa->pbt, aa->resc, 0, &sc->sc_audio1.drq)) {
113 printf(": can't get DMA channel\n");
114 return;
115 }
116
117 if (pnpbios_getdmachan(aa->pbt, aa->resc, 1, &sc->sc_audio2.drq))
118 sc->sc_audio2.drq = -1;
119
120 printf("\n");
121 pnpbios_print_devres(self, aa);
122
123 printf("%s", self->dv_xname);
124
125 if (!essmatch(sc)) {
126 printf("%s: essmatch failed\n", sc->sc_dev.dv_xname);
127 /* XXX should probably use "pnpbios_io_unmap", but it doesn't exist. */
128 bus_space_unmap(sc->sc_iot, sc->sc_ioh, ESS_NPORT);
129 return;
130 }
131
132 essattach(sc);
133 }
134
135