1 /* $NetBSD: ess_pnpbios.c,v 1.19 2009/06/23 15:00:18 christos Exp $ */
4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Nathan J. Williams.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: ess_pnpbios.c,v 1.19 2009/06/23 15:00:18 christos Exp $");
35 #include <sys/param.h>
36 #include <sys/systm.h>
37 #include <sys/errno.h>
38 #include <sys/ioctl.h>
39 #include <sys/syslog.h>
40 #include <sys/device.h>
43 #include <machine/bus.h>
45 #include <sys/audioio.h>
46 #include <dev/audio_if.h>
47 #include <dev/midi_if.h>
48 #include <dev/mulaw.h>
50 #include <dev/isa/isavar.h>
51 #include <dev/isa/isadmavar.h>
53 #include <i386/pnpbios/pnpbiosvar.h>
55 #include <dev/isa/essreg.h>
56 #include <dev/isa/essvar.h>
58 int ess_pnpbios_match(device_t
, cfdata_t
, void *);
59 void ess_pnpbios_attach(device_t
, device_t
, void *);
61 CFATTACH_DECL(ess_pnpbios
, sizeof(struct ess_softc
),
62 ess_pnpbios_match
, ess_pnpbios_attach
, NULL
, NULL
);
65 ess_pnpbios_match(device_t parent
, cfdata_t match
, void *aux
)
67 struct pnpbiosdev_attach_args
*aa
= aux
;
69 if (strcmp(aa
->idstr
, "ESS0104") && /* 1788 */
70 strcmp(aa
->idstr
, "ESS0114") && /* 1788 */
71 strcmp(aa
->idstr
, "CPQAE27") && /* 1788 */
72 strcmp(aa
->idstr
, "ESS1869") && /* 1869 */
73 strcmp(aa
->idstr
, "CPQB0AB") && /* 1869 */
74 strcmp(aa
->idstr
, "CPQB0AC") && /* 1869 */
75 strcmp(aa
->idstr
, "CPQB0AD") && /* 1869 */
76 strcmp(aa
->idstr
, "CPQB0F1") && /* 1869 */
77 strcmp(aa
->idstr
, "ESS1878") && /* 1878 */
78 strcmp(aa
->idstr
, "ESS1879")) /* 1879 */
85 ess_pnpbios_attach(device_t parent
, device_t self
, void *aux
)
87 struct ess_softc
*sc
= device_private(self
);
88 struct pnpbiosdev_attach_args
*aa
= aux
;
90 if (pnpbios_io_map(aa
->pbt
, aa
->resc
, 0, &sc
->sc_iot
, &sc
->sc_ioh
)) {
91 aprint_error(": can't map i/o space\n");
97 /* XXX These are only for setting chip configuration registers. */
98 pnpbios_getiobase(aa
->pbt
, aa
->resc
, 0, 0, &sc
->sc_iobase
);
100 sc
->sc_audio1
.ist
= IST_EDGE
;
101 sc
->sc_audio2
.ist
= IST_EDGE
;
103 if (pnpbios_getirqnum(aa
->pbt
, aa
->resc
, 0, &sc
->sc_audio1
.irq
,
105 aprint_error(": can't get IRQ\n");
109 if (pnpbios_getirqnum(aa
->pbt
, aa
->resc
, 1, &sc
->sc_audio2
.irq
,
111 sc
->sc_audio2
.irq
= -1;
113 if (pnpbios_getdmachan(aa
->pbt
, aa
->resc
, 0, &sc
->sc_audio1
.drq
)) {
114 aprint_error(": can't get DMA channel\n");
118 if (pnpbios_getdmachan(aa
->pbt
, aa
->resc
, 1, &sc
->sc_audio2
.drq
))
119 sc
->sc_audio2
.drq
= -1;
123 pnpbios_print_devres(self
, aa
);
125 aprint_normal_dev(self
, "");
128 aprint_error_dev(self
, "essmatch failed\n");
129 pnpbios_io_unmap(aa
->pbt
, aa
->resc
, 0, sc
->sc_iot
, sc
->sc_ioh
);