diff options
author | 2002-11-28 22:37:20 +0000 | |
---|---|---|
committer | 2002-11-28 22:37:20 +0000 | |
commit | 2f103064b9cc969a219da614d5539dce364d500c (patch) | |
tree | baf9f5aed25ec332642f020e0a73b2cb2342ed6f | |
parent | fd sharing was re-enabled quite awhile ago. (diff) | |
download | wireguard-openbsd-2f103064b9cc969a219da614d5539dce364d500c.tar.xz wireguard-openbsd-2f103064b9cc969a219da614d5539dce364d500c.zip |
generic isa mpu, from Sergey A. Smitienko w/ fixes from me
-rw-r--r-- | sys/arch/i386/conf/GENERIC | 4 | ||||
-rw-r--r-- | sys/dev/ic/mpuvar.h | 15 | ||||
-rw-r--r-- | sys/dev/isa/files.isa | 19 | ||||
-rw-r--r-- | sys/dev/isa/mpu401.c | 14 | ||||
-rw-r--r-- | sys/dev/isa/ympu_isa.c | 158 |
5 files changed, 187 insertions, 23 deletions
diff --git a/sys/arch/i386/conf/GENERIC b/sys/arch/i386/conf/GENERIC index d9043b4d763..87b320421c4 100644 --- a/sys/arch/i386/conf/GENERIC +++ b/sys/arch/i386/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.321 2002/10/13 20:59:34 pvalchev Exp $ +# $OpenBSD: GENERIC,v 1.322 2002/11/28 22:37:20 mickey Exp $ # $NetBSD: GENERIC,v 1.48 1996/05/20 18:17:23 mrg Exp $ # # GENERIC -- everything that's currently supported @@ -413,6 +413,7 @@ pas0 at isa? port 0x220 irq 7 drq 1 # ProAudio Spectrum gus0 at isa? disable port 0x220 irq 7 drq 1 drq2 6 # Gravis (drq2 is record drq) ym* at isapnp? mpu* at isapnp? +ympu* at isa? port 0x300 # generic MPU, Yamaha SW60XG #aria0 at isa? port 0x280 irq 10 drq 0 flags 0x1 # Prometheus Aria 16 # OPL[23] FM syntheziers @@ -429,6 +430,7 @@ midi* at opl? # OPL FM synth midi* at ym? midi* at mpu? midi* at autri? +midi* at ympu? # The spkr driver provides a simple tone interface to the built in speaker. #spkr0 at pcppi? # PC speaker diff --git a/sys/dev/ic/mpuvar.h b/sys/dev/ic/mpuvar.h index e3ebcc12cac..d0166020292 100644 --- a/sys/dev/ic/mpuvar.h +++ b/sys/dev/ic/mpuvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mpuvar.h,v 1.3 2002/03/14 03:16:05 millert Exp $ */ +/* $OpenBSD: mpuvar.h,v 1.4 2002/11/28 22:37:20 mickey Exp $ */ /* $NetBSD: mpu401var.h,v 1.3 1998/11/25 22:17:06 augustss Exp $ */ /* @@ -50,10 +50,21 @@ struct midi_hw_if mpu_midi_hw_if; int mpu_intr(void *); int mpu_find(void *); -int mpu_open(void *, int, +int mpu_open(void *, int, void (*iintr)(void *, int), void (*ointr)(void *), void *arg); void mpu_close(void *); int mpu_output(void *, int); void mpu_getinfo(void *addr, struct midi_info *mi); +#define MPU401_NPORT 2 +#define MPU_DATA 0 +#define MPU_COMMAND 1 +#define MPU_RESET 0xff +#define MPU_UART_MODE 0x3f +#define MPU_ACK 0xfe +#define MPU_STATUS 1 +#define MPU_OUTPUT_BUSY 0x40 +#define MPU_INPUT_EMPTY 0x80 + +#define MPU_MAXWAIT 10000 /* usec/10 to wait */ diff --git a/sys/dev/isa/files.isa b/sys/dev/isa/files.isa index d3ba40aa1e8..53bb36f8cac 100644 --- a/sys/dev/isa/files.isa +++ b/sys/dev/isa/files.isa @@ -1,4 +1,4 @@ -# $OpenBSD: files.isa,v 1.79 2002/10/15 15:00:11 mickey Exp $ +# $OpenBSD: files.isa,v 1.80 2002/11/28 22:37:20 mickey Exp $ # $NetBSD: files.isa,v 1.21 1996/05/16 03:45:55 mycroft Exp $ # # Config file and device description for machine-independent ISA code. @@ -221,7 +221,7 @@ file dev/isa/if_ie.c ie_isa # Intel i82595-based boards. # (Intel EtherExpress PRO/100) -device iy: ether, ifnet +device iy: ether, ifnet attach iy at isa file dev/isa/if_iy.c iy @@ -243,7 +243,7 @@ attach le at isa with le_isa file dev/isa/if_le.c le_isa | le_pci file dev/isa/if_le_isa.c le_isa -# SMC91Cxx Ethernet Controllers +# SMC91Cxx Ethernet Controllers attach sm at isa with sm_isa file dev/isa/if_sm_isa.c sm_isa @@ -266,6 +266,11 @@ file dev/isa/if_trtcm_isa.c tr_isa define mpu file dev/isa/mpu401.c mpu | midi +# MPU401 generic MIDI UART for dump MPUs like Yamaha SW60XG +device ympu: midibus +attach ympu at isa with ympu_isa +file dev/isa/ympu_isa.c ympu & midi + # the SoundBlaster DSP, or close likenesses; used by other drivers define sbdsp { } file dev/isa/sbdsp.c sbdsp @@ -326,7 +331,7 @@ file dev/isa/opl_ess.c opl_ess # Gravis UltraSound & UltraSound MAX. # Use the "flags" keyword in a config file to specify an extra DMA -# channel for full-duplex operation. +# channel for full-duplex operation. device gus: audio, isa_dma, ics2101, ad1848, mulaw, auconv file dev/isa/gus.c gus needs-flag @@ -369,10 +374,10 @@ file dev/isa/radiotrack2.c rtii device pcppi {} attach pcppi at isa file dev/isa/pcppi.c pcppi needs-flag -device spkr -attach spkr at pcppi +device spkr +attach spkr at pcppi file dev/isa/spkr.c spkr needs-flag -attach midi at pcppi with midi_pcppi: midisyn +attach midi at pcppi with midi_pcppi: midisyn file dev/isa/midi_pcppi.c midi_pcppi # 8255A-based PC parallel ports diff --git a/sys/dev/isa/mpu401.c b/sys/dev/isa/mpu401.c index 3c72e004bb2..5c18301722d 100644 --- a/sys/dev/isa/mpu401.c +++ b/sys/dev/isa/mpu401.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpu401.c,v 1.6 2002/03/14 01:26:56 millert Exp $ */ +/* $OpenBSD: mpu401.c,v 1.7 2002/11/28 22:37:20 mickey Exp $ */ /* $NetBSD: mpu401.c,v 1.3 1998/11/25 22:17:06 augustss Exp $ */ /* @@ -71,18 +71,6 @@ int mpu401debug = 0; #define DPRINTFN(n,x) #endif -#define MPU401_NPORT 2 -#define MPU_DATA 0 -#define MPU_COMMAND 1 -#define MPU_RESET 0xff -#define MPU_UART_MODE 0x3f -#define MPU_ACK 0xfe -#define MPU_STATUS 1 -#define MPU_OUTPUT_BUSY 0x40 -#define MPU_INPUT_EMPTY 0x80 - -#define MPU_MAXWAIT 10000 /* usec/10 to wait */ - #define MPU_GETSTATUS(iot, ioh) (bus_space_read_1(iot, ioh, MPU_STATUS)) int mpu_reset(struct mpu_softc *); diff --git a/sys/dev/isa/ympu_isa.c b/sys/dev/isa/ympu_isa.c new file mode 100644 index 00000000000..1848db40b3d --- /dev/null +++ b/sys/dev/isa/ympu_isa.c @@ -0,0 +1,158 @@ +/* $Id: ympu_isa.c,v 1.1 2002/11/28 22:37:20 mickey Exp $ */ + +/* + * Copyright (c) 2002 Sergey Smitienko. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/errno.h> +#include <sys/ioctl.h> +#include <sys/syslog.h> +#include <sys/device.h> +#include <sys/proc.h> + +#include <machine/bus.h> + +#include <sys/audioio.h> +#include <dev/audio_if.h> +#include <dev/midi_if.h> + +#include <dev/isa/isavar.h> +#include <dev/isa/isadmavar.h> + +#include <dev/ic/mpuvar.h> + +int ympu_isa_match(struct device *, void *, void *); +void ympu_isa_attach(struct device *, struct device *, void *); +int ympu_test(bus_space_tag_t, int); + +#ifdef AUDIO_DEBUG +#define DPRINTF(x) if (ympu_debug) printf x +int ympu_debug = 0; +#else +#define DPRINTF(x) +#endif + +#define MPU_GETSTATUS(iot, ioh) (bus_space_read_1(iot, ioh, MPU_STATUS)) + +struct ympu_isa_softc { + struct device sc_dev; + + struct mpu_softc sc_mpu; +}; + +struct cfdriver ympu_cd = { + NULL, "ympu", DV_DULL +}; + +struct cfattach ympu_isa_ca = { + sizeof(struct ympu_isa_softc), ympu_isa_match, ympu_isa_attach +}; + +int +ympu_test (iot, iobase) + bus_space_tag_t iot; + int iobase; /* base port number to try */ +{ + bus_space_handle_t ioh; + int i, rc; + + rc = 0; + if (bus_space_map(iot, iobase, MPU401_NPORT, 0, &ioh)) { + DPRINTF(("ympu_test: can`t map: %x/2\n", iobase)); + return (0); + } + + DPRINTF(("ympu_test: trying: %x\n", iobase)); + + /* + * The following code is a shameless copy of mpu401.c + * it is here until a redesign of mpu_find() interface + */ + + if (MPU_GETSTATUS(iot, ioh) == 0xff) + goto done; + + for (i = 0; i < MPU_MAXWAIT; i++) { + if (!(MPU_GETSTATUS(iot, ioh) & MPU_OUTPUT_BUSY)) + goto done; + delay (10); + } + bus_space_write_1(iot, ioh, MPU_COMMAND, MPU_RESET); + + for (i = 0; i < 2 * MPU_MAXWAIT; i++) + if (!(MPU_GETSTATUS(iot, ioh) & MPU_INPUT_EMPTY) && + bus_space_read_1(iot, ioh, MPU_DATA) == MPU_ACK) { + rc = 1; + break; + } +done: + bus_space_unmap(iot, ioh, MPU401_NPORT); + + return (rc); +} + +int +ympu_isa_match(parent, match, aux) + struct device *parent; + void *match, *aux; +{ + struct isa_attach_args *ia = aux; + + if (ympu_test(ia->ia_iot, ia->ia_iobase)) { + ia->ia_iosize = MPU401_NPORT; + return (1); + } + + return (0); +} + +void +ympu_isa_attach(parent, self, aux) + struct device *parent, *self; + void *aux; +{ + struct ympu_isa_softc *sc = (struct ympu_isa_softc *)self; + struct isa_attach_args *ia = aux; + + sc->sc_mpu.iot = ia->ia_iot; + + if (bus_space_map (ia->ia_iot, ia->ia_iobase, MPU401_NPORT, + 0, &sc->sc_mpu.ioh)) { + printf(": can`t map i/o space\n"); + return; + } + + if (!mpu_find(&sc->sc_mpu)) { + printf(": find failed\n"); + return; + } + + printf(": generic MPU-401 compatible\n"); + + midi_attach_mi(&mpu_midi_hw_if, &sc->sc_mpu, &sc->sc_dev); +} |