ess_pnpbios.c revision 1.16 1 /* $NetBSD: ess_pnpbios.c,v 1.16 2008/04/04 22:18:05 cegger 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/cdefs.h>
40 __KERNEL_RCSID(0, "$NetBSD: ess_pnpbios.c,v 1.16 2008/04/04 22:18:05 cegger Exp $");
41
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/errno.h>
45 #include <sys/ioctl.h>
46 #include <sys/syslog.h>
47 #include <sys/device.h>
48 #include <sys/proc.h>
49
50 #include <machine/bus.h>
51
52 #include <sys/audioio.h>
53 #include <dev/audio_if.h>
54 #include <dev/midi_if.h>
55 #include <dev/mulaw.h>
56
57 #include <dev/isa/isavar.h>
58 #include <dev/isa/isadmavar.h>
59
60 #include <i386/pnpbios/pnpbiosvar.h>
61
62 #include <dev/isa/essreg.h>
63 #include <dev/isa/essvar.h>
64
65 int ess_pnpbios_match(struct device *, struct cfdata *, void *);
66 void ess_pnpbios_attach(struct device *, struct device *, void *);
67
68 CFATTACH_DECL(ess_pnpbios, sizeof(struct ess_softc),
69 ess_pnpbios_match, ess_pnpbios_attach, NULL, NULL);
70
71 int
72 ess_pnpbios_match(struct device *parent, struct cfdata *match,
73 void *aux)
74 {
75 struct pnpbiosdev_attach_args *aa = aux;
76
77 if (strcmp(aa->idstr, "ESS0104") && /* 1788 */
78 strcmp(aa->idstr, "ESS0114") && /* 1788 */
79 strcmp(aa->idstr, "CPQAE27") && /* 1788 */
80 strcmp(aa->idstr, "ESS1869") && /* 1869 */
81 strcmp(aa->idstr, "CPQB0AB") && /* 1869 */
82 strcmp(aa->idstr, "CPQB0AC") && /* 1869 */
83 strcmp(aa->idstr, "CPQB0AD") && /* 1869 */
84 strcmp(aa->idstr, "CPQB0F1") && /* 1869 */
85 strcmp(aa->idstr, "ESS1879")) /* 1879 */
86 return (0);
87
88 return (1);
89 }
90
91 void
92 ess_pnpbios_attach(struct device *parent, struct device *self,
93 void *aux)
94 {
95 struct ess_softc *sc = (void *)self;
96 struct pnpbiosdev_attach_args *aa = aux;
97
98 if (pnpbios_io_map(aa->pbt, aa->resc, 0, &sc->sc_iot, &sc->sc_ioh)) {
99 printf(": can't map i/o space\n");
100 return;
101 }
102
103 sc->sc_ic = aa->ic;
104
105 /* XXX These are only for setting chip configuration registers. */
106 pnpbios_getiobase(aa->pbt, aa->resc, 0, 0, &sc->sc_iobase);
107
108 sc->sc_audio1.ist = IST_EDGE;
109 sc->sc_audio2.ist = IST_EDGE;
110
111 if (pnpbios_getirqnum(aa->pbt, aa->resc, 0, &sc->sc_audio1.irq,
112 NULL)) {
113 printf(": can't get IRQ\n");
114 return;
115 }
116
117 if (pnpbios_getirqnum(aa->pbt, aa->resc, 1, &sc->sc_audio2.irq,
118 NULL))
119 sc->sc_audio2.irq = -1;
120
121 if (pnpbios_getdmachan(aa->pbt, aa->resc, 0, &sc->sc_audio1.drq)) {
122 printf(": can't get DMA channel\n");
123 return;
124 }
125
126 if (pnpbios_getdmachan(aa->pbt, aa->resc, 1, &sc->sc_audio2.drq))
127 sc->sc_audio2.drq = -1;
128
129 printf("\n");
130 pnpbios_print_devres(self, aa);
131
132 printf("%s", device_xname(self));
133
134 if (!essmatch(sc)) {
135 aprint_error_dev(&sc->sc_dev, "essmatch failed\n");
136 pnpbios_io_unmap(aa->pbt, aa->resc, 0, sc->sc_iot, sc->sc_ioh);
137 return;
138 }
139
140 essattach(sc, 0);
141 }
142