2 * Copyright (c) 1999 Doug Rabson
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * $FreeBSD: src/sys/dev/sound/isa/es1888.c,v 1.5.2.5 2002/04/22 15:49:30 cg Exp $
27 * $DragonFly: src/sys/dev/sound/isa/Attic/es1888.c,v 1.2 2003/06/17 04:28:30 dillon Exp $
30 #include <dev/sound/pcm/sound.h>
31 #include <dev/sound/isa/sb.h>
33 SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/isa/Attic/es1888.c,v 1.2 2003/06/17 04:28:30 dillon Exp $");
37 es1888_dspready(u_int32_t port)
39 return ((inb(port + SBDSP_STATUS) & 0x80) == 0);
43 es1888_dspwr(u_int32_t port, u_char val)
47 for (i = 0; i < 1000; i++) {
48 if (es1888_dspready(port)) {
49 outb(port + SBDSP_CMD, val);
52 if (i > 10) DELAY((i > 100)? 1000 : 10);
58 es1888_get_byte(u_int32_t port)
62 for (i = 1000; i > 0; i--) {
63 if (inb(port + DSP_DATA_AVAIL) & 0x80)
64 return inb(port + DSP_READ);
72 es1888_reset(u_int32_t port)
74 outb(port + SBDSP_RST, 3);
76 outb(port + SBDSP_RST, 0);
77 if (es1888_get_byte(port) != 0xAA) {
78 return ENXIO; /* Sorry */
84 es1888_configuration_mode(void)
87 * Emit the Read-Sequence-Key to enter configuration
88 * mode. Note this only works after a reset (or after bit 2 of
89 * mixer register 0x40 is set).
91 * 3 reads from 0x229 in a row guarantees reset of key
92 * sequence to beginning.
98 inb(0x22b); /* state 1 */
99 inb(0x229); /* state 2 */
100 inb(0x22b); /* state 3 */
101 inb(0x229); /* state 4 */
102 inb(0x229); /* state 5 */
103 inb(0x22b); /* state 6 */
104 inb(0x229); /* state 7 */
108 es1888_set_port(u_int32_t port)
110 es1888_configuration_mode();
116 es1888_identify(driver_t *driver, device_t parent)
119 * Only use this on alpha since PNPBIOS is a better solution on x86.
125 es1888_set_port(0x220);
126 if (es1888_reset(0x220))
130 * Check identification bytes for es1888.
132 if (es1888_dspwr(0x220, 0xe7))
134 hi = es1888_get_byte(0x220);
135 lo = es1888_get_byte(0x220);
136 if (hi != 0x68 || (lo & 0xf0) != 0x80)
140 * Program irq and drq.
142 if (es1888_dspwr(0x220, 0xc6) /* enter extended mode */
143 || es1888_dspwr(0x220, 0xb1) /* write register b1 */
144 || es1888_dspwr(0x220, 0x14) /* enable irq 5 */
145 || es1888_dspwr(0x220, 0xb2) /* write register b1 */
146 || es1888_dspwr(0x220, 0x18)) /* enable drq 1 */
150 * Create the device and program its resources.
152 dev = BUS_ADD_CHILD(parent, ISA_ORDER_PNP, NULL, -1);
153 bus_set_resource(dev, SYS_RES_IOPORT, 0, 0x220, 0x10);
154 bus_set_resource(dev, SYS_RES_IRQ, 0, 5, 1);
155 bus_set_resource(dev, SYS_RES_DRQ, 0, 1, 1);
156 isa_set_vendorid(dev, PNP_EISAID("ESS1888"));
157 isa_set_logicalid(dev, PNP_EISAID("ESS1888"));
161 static device_method_t es1888_methods[] = {
162 /* Device interface */
163 DEVMETHOD(device_identify, es1888_identify),
168 static driver_t es1888_driver = {
174 DRIVER_MODULE(snd_es1888, isa, es1888_driver, pcm_devclass, 0, 0);
175 MODULE_DEPEND(snd_es1888, snd_pcm, PCM_MINVER, PCM_PREFVER, PCM_MAXVER);
176 MODULE_VERSION(snd_es1888, 1);