Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / dev / isapnp / mpu_isapnp.c
blobe0916ff30b506a6b4521816a46dba59b648f0ac2
1 /* $NetBSD: mpu_isapnp.c,v 1.16 2007/10/19 12:00:33 ad Exp $ */
3 #include <sys/cdefs.h>
4 __KERNEL_RCSID(0, "$NetBSD: mpu_isapnp.c,v 1.16 2007/10/19 12:00:33 ad Exp $");
6 #include "midi.h"
8 #include <sys/param.h>
9 #include <sys/systm.h>
10 #include <sys/errno.h>
11 #include <sys/ioctl.h>
12 #include <sys/syslog.h>
13 #include <sys/device.h>
14 #include <sys/proc.h>
16 #include <sys/bus.h>
18 #include <sys/audioio.h>
19 #include <dev/audio_if.h>
20 #include <dev/midi_if.h>
21 #include <dev/mulaw.h>
23 #include <dev/isa/isavar.h>
24 #include <dev/isa/isadmavar.h>
26 #include <dev/isapnp/isapnpreg.h>
27 #include <dev/isapnp/isapnpvar.h>
28 #include <dev/isapnp/isapnpdevs.h>
30 #include <dev/ic/mpuvar.h>
32 static int mpu_isapnp_match(device_t, cfdata_t, void *);
33 static void mpu_isapnp_attach(device_t, device_t, void *);
35 struct mpu_isapnp_softc {
36 void *sc_ih;
38 struct mpu_softc sc_mpu;
41 CFATTACH_DECL_NEW(mpu_isapnp, sizeof(struct mpu_isapnp_softc),
42 mpu_isapnp_match, mpu_isapnp_attach, NULL, NULL);
44 static int
45 mpu_isapnp_match(device_t parent, cfdata_t match, void *aux)
47 int pri, variant;
49 pri = isapnp_devmatch(aux, &isapnp_mpu_devinfo, &variant);
50 if (pri && variant > 0)
51 pri = 0;
52 return pri;
55 static void
56 mpu_isapnp_attach(device_t parent, device_t self, void *aux)
58 struct mpu_isapnp_softc *sc = device_private(self);
59 struct isapnp_attach_args *ipa = aux;
61 aprint_normal("\n");
63 if (isapnp_config(ipa->ipa_iot, ipa->ipa_memt, ipa)) {
64 aprint_error_dev(self, "error in region allocation\n");
65 return;
68 sc->sc_mpu.iot = ipa->ipa_iot;
69 sc->sc_mpu.ioh = ipa->ipa_io[0].h;
71 if (!mpu_find(&sc->sc_mpu)) {
72 aprint_error_dev(self, "find failed\n");
73 return;
76 aprint_normal_dev(self, "%s %s\n", ipa->ipa_devident,
77 ipa->ipa_devclass);
79 sc->sc_mpu.model = "Roland MPU-401 MIDI UART";
81 midi_attach_mi(&mpu_midi_hw_if, &sc->sc_mpu, self);
83 sc->sc_ih = isa_intr_establish(ipa->ipa_ic, ipa->ipa_irq[0].num,
84 ipa->ipa_irq[0].type, IPL_AUDIO, mpu_intr, &sc->sc_mpu);