summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authoraugustss <augustss@NetBSD.org>1999-08-01 17:53:39 +0000
committeraugustss <augustss@NetBSD.org>1999-08-01 17:53:39 +0000
commit0c0dc211d49f657f2cfac0590ce6cf5fb2b28120 (patch)
tree05eea72de226ba04d16fd9e08066b56793c08c1c /sys/dev
parent34fba9bc343e66cf9d97f1f7b7f954ad29e8ee6c (diff)
Make an MPU attachment to ISA. Used for old Roland cards. Written
by me and gson@araneus.fi (Andreas Gustafsson).
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/isa/files.isa5
-rw-r--r--sys/dev/isa/mpu.c15
-rw-r--r--sys/dev/isa/mpu_isa.c111
-rw-r--r--sys/dev/isa/mpuvar.h11
4 files changed, 128 insertions, 14 deletions
diff --git a/sys/dev/isa/files.isa b/sys/dev/isa/files.isa
index 27df742cd31..a17d7b0f25a 100644
--- a/sys/dev/isa/files.isa
+++ b/sys/dev/isa/files.isa
@@ -1,4 +1,4 @@
-# $NetBSD: files.isa,v 1.84 1999/06/06 17:30:37 dante Exp $
+# $NetBSD: files.isa,v 1.85 1999/08/01 17:53:39 augustss Exp $
#
# Config file and device description for machine-independent ISA code.
# Included by ports that need it. Requires that the SCSI files be
@@ -263,6 +263,9 @@ file dev/isa/if_trtcm_isa.c tr_isa
device mpu: midibus
file dev/isa/mpu.c (mpu | sb) needs-flag
+attach mpu at isa with mpu_isa
+file dev/isa/mpu_isa.c mpu_isa needs-flag
+
# the SoundBlaster DSP, or close likenesses; used by other drivers
define sbdsp { }
file dev/isa/sbdsp.c sbdsp
diff --git a/sys/dev/isa/mpu.c b/sys/dev/isa/mpu.c
index 35a94e0d8b2..009b962de38 100644
--- a/sys/dev/isa/mpu.c
+++ b/sys/dev/isa/mpu.c
@@ -1,4 +1,4 @@
-/* $NetBSD: mpu.c,v 1.2 1999/03/24 20:59:21 augustss Exp $ */
+/* $NetBSD: mpu.c,v 1.3 1999/08/01 17:53:39 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -52,21 +52,17 @@
#include <dev/midi_if.h>
-#include <dev/isa/isavar.h>
-#include <dev/isa/isadmavar.h>
-
#include <dev/isa/mpuvar.h>
#ifdef AUDIO_DEBUG
#define DPRINTF(x) if (mpudebug) printf x
#define DPRINTFN(n,x) if (mpudebug >= (n)) printf x
-int mpudebug = 100;
+int mpudebug = 0;
#else
#define DPRINTF(x)
#define DPRINTFN(n,x)
#endif
-#define MPU401_NPORT 2
#define MPU_DATA 0
#define MPU_COMMAND 1
#define MPU_RESET 0xff
@@ -84,6 +80,13 @@ int mpu_reset(struct mpu_softc *);
static __inline int mpu_waitready(struct mpu_softc *);
void mpu_readinput(struct mpu_softc *);
+int mpu_open __P((void *, int,
+ void (*iintr)__P((void *, int)),
+ void (*ointr)__P((void *)), void *arg));
+void mpu_close __P((void *));
+int mpu_output __P((void *, int));
+void mpu_getinfo __P((void *, struct midi_info *));
+
struct midi_hw_if mpu_midi_hw_if = {
mpu_open,
mpu_close,
diff --git a/sys/dev/isa/mpu_isa.c b/sys/dev/isa/mpu_isa.c
new file mode 100644
index 00000000000..f92b9d69136
--- /dev/null
+++ b/sys/dev/isa/mpu_isa.c
@@ -0,0 +1,111 @@
+/* $NetBSD: mpu_isa.c,v 1.1 1999/08/01 17:53:39 augustss Exp $ */
+
+/*-
+ * Copyright (c) 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Lennart Augustsson.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION 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/kernel.h>
+#include <sys/errno.h>
+#include <sys/device.h>
+#include <sys/proc.h>
+#include <sys/conf.h>
+#include <sys/midiio.h>
+
+#include <machine/bus.h>
+
+#include <dev/midi_if.h>
+
+#include <dev/isa/isavar.h>
+#include <dev/isa/mpuvar.h>
+
+struct mpu_isa_softc {
+ struct mpu_softc sc_mpu; /* generic part */
+ void *sc_ih; /* ISA interrupt handler */
+};
+
+int mpu_isa_match __P((struct device *, struct cfdata *, void *));
+void mpu_isa_attach __P((struct device *, struct device *, void *));
+
+struct cfattach mpu_isa_ca = {
+ sizeof (struct mpu_isa_softc), mpu_isa_match, mpu_isa_attach
+};
+
+int
+mpu_isa_match(parent, match, aux)
+ struct device *parent;
+ struct cfdata *match;
+ void *aux;
+{
+ struct isa_attach_args *ia = aux;
+ struct mpu_isa_softc sc;
+ int r;
+
+ memset(&sc, 0, sizeof sc);
+ sc.sc_mpu.iot = ia->ia_iot;
+ if (bus_space_map(sc.sc_mpu.iot, ia->ia_iobase, MPU401_NPORT, 0, &sc.sc_mpu.ioh))
+ return (0);
+ r = mpu_find(&sc.sc_mpu);
+ bus_space_unmap(sc.sc_mpu.iot, sc.sc_mpu.ioh, MPU401_NPORT);
+ if (r) {
+ ia->ia_iosize = MPU401_NPORT;
+ ia->ia_msize = 0;
+ }
+ return (r);
+}
+
+void
+mpu_isa_attach(parent, self, aux)
+ struct device *parent;
+ struct device *self;
+ void *aux;
+{
+ struct mpu_isa_softc *sc = (struct mpu_isa_softc *)self;
+ struct isa_attach_args *ia = aux;
+
+ printf("\n");
+
+ if (bus_space_map(sc->sc_mpu.iot, ia->ia_iobase, MPU401_NPORT, 0, &sc->sc_mpu.ioh)) {
+ printf("mpu_isa_attach: bus_space_map failed\n");
+ return;
+ }
+
+ sc->sc_ih = isa_intr_establish(ia->ia_ic, ia->ia_irq, IST_EDGE, IPL_AUDIO,
+ mpu_intr, sc);
+
+ midi_attach_mi(&mpu_midi_hw_if, &sc->sc_mpu, &sc->sc_mpu.sc_dev);
+}
+
diff --git a/sys/dev/isa/mpuvar.h b/sys/dev/isa/mpuvar.h
index fd59eb968d6..56fa9099cc6 100644
--- a/sys/dev/isa/mpuvar.h
+++ b/sys/dev/isa/mpuvar.h
@@ -1,4 +1,4 @@
-/* $NetBSD: mpuvar.h,v 1.1 1999/03/22 07:37:35 mycroft Exp $ */
+/* $NetBSD: mpuvar.h,v 1.2 1999/08/01 17:53:40 augustss Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -37,6 +37,7 @@
*/
struct mpu_softc {
+ struct device sc_dev; /* base device */
bus_space_tag_t iot; /* tag */
bus_space_handle_t ioh; /* handle */
int open;
@@ -47,10 +48,6 @@ struct mpu_softc {
struct midi_hw_if mpu_midi_hw_if;
int mpu_find __P((struct mpu_softc *));
-int mpu_open __P((void *, int,
- void (*iintr)__P((void *, int)),
- void (*ointr)__P((void *)), void *arg));
-void mpu_close __P((void *));
-int mpu_output __P((void *, int));
-void mpu_getinfo __P((void *, struct midi_info *));
int mpu_intr __P((void *));
+
+#define MPU401_NPORT 2